… | |
… | |
175 | arch_ptr ACC (RW, arch); /* Pointer to archetype */ |
175 | arch_ptr ACC (RW, arch); /* Pointer to archetype */ |
176 | arch_ptr ACC (RW, other_arch);/* Pointer used for various things - mostly used for what */ |
176 | arch_ptr ACC (RW, other_arch);/* Pointer used for various things - mostly used for what */ |
177 | |
177 | |
178 | float ACC (RW, speed); /* The overall speed of this object */ |
178 | float ACC (RW, speed); /* The overall speed of this object */ |
179 | float ACC (RW, speed_left); /* How much speed is left to spend this round */ |
179 | float ACC (RW, speed_left); /* How much speed is left to spend this round */ |
180 | uint32 ACC (RW, nrof); /* How many of the objects */ |
180 | sint32 ACC (RW, nrof); /* How many of the objects */ |
181 | |
181 | |
182 | /* This next big block is basically used for monsters and equipment */ |
182 | /* This next big block is basically used for monsters and equipment */ |
183 | uint16 ACC (RW, client_type); /* Public type information. see doc/Developers/objects */ |
183 | uint16 ACC (RW, client_type); /* Public type information. see doc/Developers/objects */ |
184 | |
184 | |
185 | sint16 ACC (RW, resist[NROFATTACKS]); /* Resistance adjustments for attacks */ |
185 | sint16 ACC (RW, resist[NROFATTACKS]); /* Resistance adjustments for attacks */ |
… | |
… | |
260 | bool ACC (RW, flag[NUM_FLAGS]); |
260 | bool ACC (RW, flag[NUM_FLAGS]); |
261 | #endif |
261 | #endif |
262 | uint16 ACC (RW, animation_id);/* An index into the animation array */ |
262 | uint16 ACC (RW, animation_id);/* An index into the animation array */ |
263 | uint8 ACC (RW, anim_speed); /* ticks between animation-frames */ |
263 | uint8 ACC (RW, anim_speed); /* ticks between animation-frames */ |
264 | uint8 ACC (RW, last_anim); /* last sequence used to draw face */ |
264 | uint8 ACC (RW, last_anim); /* last sequence used to draw face */ |
265 | sint16 ACC (RW, elevation); /* elevation of this terrain - not currently used */ |
|
|
266 | uint8 ACC (RW, smoothlevel); /* how to smooth this square around */ |
265 | uint8 ACC (RW, smoothlevel); /* how to smooth this square around */ |
267 | uint8 ACC (RW, will_apply); /* See crossfire.doc */ |
266 | uint8 ACC (RW, will_apply); /* See crossfire.doc */ |
|
|
267 | uint16 ACC (RW, cached_sp); /* cached spell points used for a spell, used by esrv_update_spells */ |
|
|
268 | uint16 ACC (RW, cached_grace);/* cached grace points used for a spell, used by esrv_update_spells */ |
|
|
269 | uint16 ACC (RW, cached_eat); /* cached food, used by esrv_update_spells */ |
268 | }; |
270 | }; |
269 | |
271 | |
270 | struct object : zero_initialised, object_copy |
272 | struct object : zero_initialised, object_copy |
271 | { |
273 | { |
272 | // These variables are not changed by ->copy_to |
274 | // These variables are not changed by ->copy_to |
273 | maptile_ptr ACC (RW, map); /* Pointer to the map in which this object is present */ |
275 | maptile *ACC (RW, map); /* Pointer to the map in which this object is present */ |
274 | |
276 | |
275 | UUID ACC (RW, uuid); // Unique Identifier, survives saves etc. |
277 | UUID ACC (RW, uuid); // Unique Identifier, survives saves etc. |
276 | int ACC (RO, count); |
278 | int ACC (RO, count); |
277 | object_vector_index ACC (RO, index); // index into objects |
279 | object_vector_index ACC (RO, index); // index into objects |
278 | object_vector_index ACC (RO, active); // index into actives |
280 | object_vector_index ACC (RO, active); // index into actives |
… | |
… | |
338 | |
340 | |
339 | MTH int slottype () const; |
341 | MTH int slottype () const; |
340 | MTH static object *create (); |
342 | MTH static object *create (); |
341 | const mapxy &operator =(const mapxy &pos); |
343 | const mapxy &operator =(const mapxy &pos); |
342 | MTH void copy_to (object *dst); |
344 | MTH void copy_to (object *dst); |
343 | MTH object *clone (); // create + copy_to |
345 | MTH object *clone (); // create + copy_to a single object |
|
|
346 | MTH object *deep_clone (); // copy whole more chain and inventory |
344 | void do_destroy (); |
347 | void do_destroy (); |
345 | void gather_callbacks (AV *&callbacks, event_type event) const; |
348 | void gather_callbacks (AV *&callbacks, event_type event) const; |
346 | MTH void destroy (bool destroy_inventory = false); |
349 | MTH void destroy (bool destroy_inventory = false); |
347 | |
350 | |
348 | // recursively destroy all objects in inventory, optionally dropping them to the ground instead |
351 | // recursively destroy all objects in inventory, optionally dropping them to the ground instead |
… | |
… | |
438 | * 1000 |
441 | * 1000 |
439 | * (type == CONTAINER ? 1000 : 1) |
442 | * (type == CONTAINER ? 1000 : 1) |
440 | / dominant_material ()->density; |
443 | / dominant_material ()->density; |
441 | } |
444 | } |
442 | |
445 | |
|
|
446 | MTH bool is_wiz () const { return flag [FLAG_WIZ]; } |
443 | MTH bool is_weapon () const { return type == ARROW || type == BOW || type == WEAPON; } |
447 | MTH bool is_weapon () const { return type == ARROW || type == BOW || type == WEAPON; } |
444 | MTH bool is_armor () const { return type == ARMOUR || type == SHIELD || type == HELMET |
448 | MTH bool is_armor () const { return type == ARMOUR || type == SHIELD || type == HELMET |
445 | || type == CLOAK || type == BOOTS || type == GLOVES |
449 | || type == CLOAK || type == BOOTS || type == GLOVES |
446 | || type == BRACERS || type == GIRDLE; } |
450 | || type == BRACERS || type == GIRDLE; } |
447 | MTH bool is_alive () const { return (type == PLAYER |
451 | MTH bool is_alive () const { return (type == PLAYER |
… | |
… | |
464 | /* This return true if object has still randomitems which |
468 | /* This return true if object has still randomitems which |
465 | * could be expanded. |
469 | * could be expanded. |
466 | */ |
470 | */ |
467 | MTH bool has_random_items () const { return randomitems && !flag [FLAG_IS_A_TEMPLATE]; } |
471 | MTH bool has_random_items () const { return randomitems && !flag [FLAG_IS_A_TEMPLATE]; } |
468 | |
472 | |
|
|
473 | MTH bool has_dialogue () const { return *&msg == '@'; } |
|
|
474 | |
469 | // returns the outermost owner, never returns 0 |
475 | // returns the outermost owner, never returns 0 |
470 | MTH object *outer_owner () |
476 | MTH object *outer_owner () |
471 | { |
477 | { |
|
|
478 | object *op; |
|
|
479 | |
472 | for (object *op = this; ; op = op->owner) |
480 | for (op = this; op->owner; op = op->owner) |
473 | if (!op->owner) |
481 | ; |
|
|
482 | |
474 | return op; |
483 | return op; |
475 | } |
484 | } |
476 | |
485 | |
477 | // returns the outermost environment, never returns 0 |
486 | // returns the outermost environment, never returns 0 |
478 | MTH object *outer_env () |
487 | MTH object *outer_env () |
479 | { |
488 | { |
|
|
489 | object *op; |
|
|
490 | |
480 | for (object *op = this; ; op = op->env) |
491 | for (op = this; op->env; op = op->env) |
481 | if (!op->env) |
492 | ; |
|
|
493 | |
482 | return op; |
494 | return op; |
483 | } |
495 | } |
484 | |
496 | |
485 | // returns the player that has this object in his inventory, or 0 |
497 | // returns the player that has this object in his inventory, or 0 |
486 | // we assume the player is always the outer env |
498 | // we assume the player is always the outer env |
487 | MTH object *in_player () |
499 | MTH object *in_player () |
… | |
… | |
536 | // set the given flag on all objects in the inventory recursively |
548 | // set the given flag on all objects in the inventory recursively |
537 | MTH void set_flag_inv (int flag, int value = 1); |
549 | MTH void set_flag_inv (int flag, int value = 1); |
538 | |
550 | |
539 | void enter_exit (object *exit);//Perl |
551 | void enter_exit (object *exit);//Perl |
540 | MTH void enter_map (maptile *newmap, int x, int y); |
552 | MTH void enter_map (maptile *newmap, int x, int y); |
|
|
553 | void player_goto (const char *path, int x, int y); // only for players |
541 | |
554 | |
542 | // returns the mapspace this object is in |
555 | // returns the mapspace this object is in |
543 | mapspace &ms () const; |
556 | mapspace &ms () const; |
544 | |
557 | |
545 | // fully recursive iterator |
558 | // fully recursive iterator |
… | |
… | |
676 | MTH static archetype *find (const_utf8_string name); |
689 | MTH static archetype *find (const_utf8_string name); |
677 | |
690 | |
678 | MTH void link (); |
691 | MTH void link (); |
679 | MTH void unlink (); |
692 | MTH void unlink (); |
680 | |
693 | |
681 | MTH static object *get (const char *name); // find()->instance() |
694 | MTH static object *get (const char *name); // (find() || singularity)->instance() |
682 | MTH object *instance (); |
695 | MTH object *instance (); |
683 | |
696 | |
684 | object_vector_index ACC (RW, archid); // index in archvector |
697 | object_vector_index ACC (RW, archid); // index in archvector |
685 | shstr ACC (RW, archname); /* More definite name, like "generate_kobold" */ |
698 | shstr ACC (RW, archname); /* More definite name, like "generate_kobold" */ |
686 | |
699 | |
… | |
… | |
691 | static archetype *read (object_thawer &f); |
704 | static archetype *read (object_thawer &f); |
692 | MTH static void commit_load (); // commit any objects loaded, resolves cyclic dependencies and more |
705 | MTH static void commit_load (); // commit any objects loaded, resolves cyclic dependencies and more |
693 | static void postpone_arch_ref (arch_ptr &ref, const_utf8_string other_arch); /* postpone other_arch reference */ |
706 | static void postpone_arch_ref (arch_ptr &ref, const_utf8_string other_arch); /* postpone other_arch reference */ |
694 | }; |
707 | }; |
695 | |
708 | |
|
|
709 | // compatbiility, remove once replaced by ->instance |
|
|
710 | inline object * |
|
|
711 | arch_to_object (archetype *at) |
|
|
712 | { |
|
|
713 | return at->instance (); |
|
|
714 | } |
|
|
715 | |
696 | inline void |
716 | inline void |
697 | object_freezer::put (keyword k, archetype *v) |
717 | object_freezer::put (keyword k, archetype *v) |
698 | { |
718 | { |
699 | put (k, v ? &v->archname : (const char *)0); |
719 | put (k, v ? &v->archname : (const char *)0); |
700 | } |
720 | } |
… | |
… | |
705 | |
725 | |
706 | extern objectvec objects; |
726 | extern objectvec objects; |
707 | extern activevec actives; |
727 | extern activevec actives; |
708 | extern archvec archetypes; |
728 | extern archvec archetypes; |
709 | |
729 | |
|
|
730 | // "safely" iterate over inv in a way such that the current item is removable |
|
|
731 | // quite horrible, thats why its hidden in some macro |
|
|
732 | #define for_inv_removable(op,var) \ |
|
|
733 | for (object *var, *next_ = (op)->inv; (var = next_), var && (next_ = var->below), var; ) |
|
|
734 | |
710 | #define for_all_objects(var) \ |
735 | #define for_all_objects(var) \ |
711 | for (unsigned _i = 0; _i < objects.size (); ++_i) \ |
736 | for (unsigned _i = 0; _i < objects.size (); ++_i) \ |
712 | statementvar (object *, var, objects [_i]) |
737 | statementvar (object *, var, objects [_i]) |
713 | |
738 | |
714 | #define for_all_actives(var) \ |
739 | #define for_all_actives(var) \ |
715 | for (unsigned _i = 0; _i < actives.size (); ++_i) \ |
740 | for (unsigned _i = 0; _i < actives.size (); ++_i) \ |
716 | statementvar (object *, var, actives [_i]) |
741 | statementvar (object *, var, actives [_i]) |
717 | |
742 | |
718 | #define for_all_archetypes(var) \ |
743 | #define for_all_archetypes(var) \ |
719 | for (unsigned _i = 0; _i < archetypes.size (); ++_i) \ |
744 | for (unsigned _i = 0; _i < archetypes.size (); ++_i) \ |
720 | statementvar (archetype *, var, archetypes [_i]) |
745 | statementvar (archetype *, var, archetypes [_i]) |
721 | |
746 | |
722 | /* Used by update_object to know if the object being passed is |
747 | /* Used by update_object to know if the object being passed is |
723 | * being added or removed. |
748 | * being added or removed. |