1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2001 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
… | |
… | |
32 | |
32 | |
33 | //+GPL |
33 | //+GPL |
34 | |
34 | |
35 | typedef int tag_t; |
35 | typedef int tag_t; |
36 | |
36 | |
|
|
37 | // also see common/item.C |
37 | enum { |
38 | enum { |
38 | body_skill, |
39 | body_skill, |
39 | body_combat, |
40 | body_combat, |
40 | body_range, |
41 | body_range, |
41 | body_shield, |
42 | body_shield, |
… | |
… | |
50 | body_wrist, |
51 | body_wrist, |
51 | body_waist, |
52 | body_waist, |
52 | NUM_BODY_LOCATIONS |
53 | NUM_BODY_LOCATIONS |
53 | }; |
54 | }; |
54 | |
55 | |
55 | enum slottype_t |
|
|
56 | { |
|
|
57 | slot_none, |
|
|
58 | slot_combat, |
|
|
59 | slot_ranged, |
|
|
60 | }; |
|
|
61 | |
|
|
62 | /* See common/item.c */ |
56 | /* See common/item.c */ |
63 | |
57 | |
64 | typedef struct Body_Locations |
58 | typedef struct Body_Locations |
65 | { |
59 | { |
66 | keyword save_name; /* Name used to load/save it to disk */ |
60 | keyword save_name; /* Name used to load/save it to disk */ |
… | |
… | |
360 | bool parse_kv (object_thawer &f); // parse kv pairs, (ab-)used by archetypes, which should not exist at all |
354 | bool parse_kv (object_thawer &f); // parse kv pairs, (ab-)used by archetypes, which should not exist at all |
361 | MTH void post_load_check (); // do some adjustments after parsing |
355 | MTH void post_load_check (); // do some adjustments after parsing |
362 | static object *read (object_thawer &f, maptile *map = 0); // map argument due to toal design bogosity, must go. |
356 | static object *read (object_thawer &f, maptile *map = 0); // map argument due to toal design bogosity, must go. |
363 | bool write (object_freezer &f); |
357 | bool write (object_freezer &f); |
364 | |
358 | |
365 | MTH int slottype () const; |
|
|
366 | MTH static object *create (); |
359 | MTH static object *create (); |
367 | const mapxy &operator =(const mapxy &pos); |
360 | const mapxy &operator =(const mapxy &pos); |
368 | MTH void copy_to (object *dst); |
361 | MTH void copy_to (object *dst); |
369 | MTH object *clone (); // create + copy_to a single object |
362 | MTH object *clone (); // create + copy_to a single object |
370 | MTH object *deep_clone (); // copy whole more chain and inventory |
363 | MTH object *deep_clone (); // copy whole more chain and inventory |
… | |
… | |
397 | remove (); |
390 | remove (); |
398 | *this = pos; |
391 | *this = pos; |
399 | insert_at (this, this); |
392 | insert_at (this, this); |
400 | } |
393 | } |
401 | |
394 | |
402 | // high-level move functions, return true if successful |
395 | // high-level move method. |
|
|
396 | // object op is trying to move in direction dir. |
|
|
397 | // originator is typically the same as op, but |
|
|
398 | // can be different if originator is causing op to |
|
|
399 | // move (originator is pushing op) |
|
|
400 | // returns 0 if the object is not able to move to the |
|
|
401 | // desired space, 1 otherwise (in which case we also |
|
|
402 | // move the object accordingly. This function is |
|
|
403 | // very similiar to move_object. |
403 | int move (int dir, object *originator); |
404 | int move (int dir, object *originator); |
404 | |
405 | |
405 | int move (int dir) |
406 | int move (int dir) |
406 | { |
407 | { |
407 | return move (dir, this); |
408 | return move (dir, this); |
408 | } |
409 | } |
|
|
410 | |
|
|
411 | // changes move_type to a new value - handles move_on/move_off effects |
|
|
412 | MTH void change_move_type (MoveType mt); |
409 | |
413 | |
410 | static bool can_merge_slow (object *op1, object *op2); |
414 | static bool can_merge_slow (object *op1, object *op2); |
411 | |
415 | |
412 | // this is often used in time-critical code, so optimise |
416 | // this is often used in time-critical code, so optimise |
413 | MTH static bool can_merge (object *op1, object *op2) |
417 | MTH static bool can_merge (object *op1, object *op2) |
… | |
… | |
418 | } |
422 | } |
419 | |
423 | |
420 | MTH void set_owner (object *owner); |
424 | MTH void set_owner (object *owner); |
421 | MTH void set_speed (float speed); |
425 | MTH void set_speed (float speed); |
422 | MTH void set_glow_radius (sint8 rad); |
426 | MTH void set_glow_radius (sint8 rad); |
423 | MTH bool change_weapon (object *ob); |
|
|
424 | MTH bool change_skill (object *ob); |
427 | MTH bool change_skill (object *ob); // deprecated? |
425 | |
428 | |
426 | MTH void open_container (object *new_container); |
429 | MTH void open_container (object *new_container); |
427 | MTH void close_container () |
430 | MTH void close_container () |
428 | { |
431 | { |
429 | open_container (0); |
432 | open_container (0); |
… | |
… | |
649 | MTH void set_flag_inv (int flag, int value = 1); |
652 | MTH void set_flag_inv (int flag, int value = 1); |
650 | |
653 | |
651 | void enter_exit (object *exit);//Perl |
654 | void enter_exit (object *exit);//Perl |
652 | MTH void enter_map (maptile *newmap, int x, int y); |
655 | MTH void enter_map (maptile *newmap, int x, int y); |
653 | void player_goto (const_utf8_string path, int x, int y); // only for players |
656 | void player_goto (const_utf8_string path, int x, int y); // only for players |
|
|
657 | MTH bool apply (object *ob, int aflags = AP_APPLY); // ob may be 0 |
654 | |
658 | |
655 | // returns the mapspace this object is in |
659 | // returns the mapspace this object is in |
656 | mapspace &ms () const; |
660 | mapspace &ms () const; |
657 | |
661 | |
658 | // fully recursive iterator |
662 | // fully recursive iterator |