… | |
… | |
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 |
… | |
… | |
342 | MTH void copy_to (object *dst); |
344 | MTH void copy_to (object *dst); |
343 | MTH object *clone (); // create + copy_to a single object |
345 | MTH object *clone (); // create + copy_to a single object |
344 | MTH object *deep_clone (); // copy whole more chain and inventory |
346 | MTH object *deep_clone (); // copy whole more chain and inventory |
345 | void do_destroy (); |
347 | void do_destroy (); |
346 | void gather_callbacks (AV *&callbacks, event_type event) const; |
348 | void gather_callbacks (AV *&callbacks, event_type event) const; |
347 | MTH void destroy (bool destroy_inventory = false); |
349 | MTH void destroy (); |
|
|
350 | MTH void drop_and_destroy () |
|
|
351 | { |
|
|
352 | destroy_inv (true); |
|
|
353 | destroy (); |
|
|
354 | } |
348 | |
355 | |
349 | // recursively destroy all objects in inventory, optionally dropping them to the ground instead |
356 | // recursively destroy all objects in inventory, optionally dropping them to the ground instead |
350 | MTH void destroy_inv (bool drop_to_ground = false); |
357 | MTH void destroy_inv (bool drop_to_ground = false); |
351 | MTH object *insert (object *item); // insert into inventory |
358 | MTH object *insert (object *item); // insert into inventory |
352 | MTH void play_sound (faceidx sound); |
359 | MTH void play_sound (faceidx sound); |
… | |
… | |
439 | * 1000 |
446 | * 1000 |
440 | * (type == CONTAINER ? 1000 : 1) |
447 | * (type == CONTAINER ? 1000 : 1) |
441 | / dominant_material ()->density; |
448 | / dominant_material ()->density; |
442 | } |
449 | } |
443 | |
450 | |
|
|
451 | MTH bool is_wiz () const { return flag [FLAG_WIZ]; } |
444 | MTH bool is_weapon () const { return type == ARROW || type == BOW || type == WEAPON; } |
452 | MTH bool is_weapon () const { return type == ARROW || type == BOW || type == WEAPON; } |
445 | MTH bool is_armor () const { return type == ARMOUR || type == SHIELD || type == HELMET |
453 | MTH bool is_armor () const { return type == ARMOUR || type == SHIELD || type == HELMET |
446 | || type == CLOAK || type == BOOTS || type == GLOVES |
454 | || type == CLOAK || type == BOOTS || type == GLOVES |
447 | || type == BRACERS || type == GIRDLE; } |
455 | || type == BRACERS || type == GIRDLE; } |
448 | MTH bool is_alive () const { return (type == PLAYER |
456 | MTH bool is_alive () const { return (type == PLAYER |
… | |
… | |
465 | /* This return true if object has still randomitems which |
473 | /* This return true if object has still randomitems which |
466 | * could be expanded. |
474 | * could be expanded. |
467 | */ |
475 | */ |
468 | MTH bool has_random_items () const { return randomitems && !flag [FLAG_IS_A_TEMPLATE]; } |
476 | MTH bool has_random_items () const { return randomitems && !flag [FLAG_IS_A_TEMPLATE]; } |
469 | |
477 | |
|
|
478 | MTH bool has_dialogue () const { return *&msg == '@'; } |
|
|
479 | |
470 | // returns the outermost owner, never returns 0 |
480 | // returns the outermost owner, never returns 0 |
471 | MTH object *outer_owner () |
481 | MTH object *outer_owner () |
472 | { |
482 | { |
|
|
483 | object *op; |
|
|
484 | |
473 | for (object *op = this; ; op = op->owner) |
485 | for (op = this; op->owner; op = op->owner) |
474 | if (!op->owner) |
486 | ; |
|
|
487 | |
475 | return op; |
488 | return op; |
476 | } |
489 | } |
477 | |
490 | |
478 | // returns the outermost environment, never returns 0 |
491 | // returns the outermost environment, never returns 0 |
479 | MTH object *outer_env () |
492 | MTH object *outer_env () |
480 | { |
493 | { |
|
|
494 | object *op; |
|
|
495 | |
481 | for (object *op = this; ; op = op->env) |
496 | for (op = this; op->env; op = op->env) |
482 | if (!op->env) |
497 | ; |
|
|
498 | |
483 | return op; |
499 | return op; |
484 | } |
500 | } |
485 | |
501 | |
486 | // returns the player that has this object in his inventory, or 0 |
502 | // returns the player that has this object in his inventory, or 0 |
487 | // we assume the player is always the outer env |
503 | // we assume the player is always the outer env |
488 | MTH object *in_player () |
504 | MTH object *in_player () |
… | |
… | |
504 | } |
520 | } |
505 | |
521 | |
506 | MTH bool is_on_map () const |
522 | MTH bool is_on_map () const |
507 | { |
523 | { |
508 | return !env && !flag [FLAG_REMOVED]; |
524 | return !env && !flag [FLAG_REMOVED]; |
|
|
525 | } |
|
|
526 | |
|
|
527 | MTH bool is_inserted () const |
|
|
528 | { |
|
|
529 | return !flag [FLAG_REMOVED]; |
509 | } |
530 | } |
510 | |
531 | |
511 | // returns the player that cna see this object, if any |
532 | // returns the player that cna see this object, if any |
512 | MTH object *visible_to () const; |
533 | MTH object *visible_to () const; |
513 | |
534 | |
… | |
… | |
537 | // set the given flag on all objects in the inventory recursively |
558 | // set the given flag on all objects in the inventory recursively |
538 | MTH void set_flag_inv (int flag, int value = 1); |
559 | MTH void set_flag_inv (int flag, int value = 1); |
539 | |
560 | |
540 | void enter_exit (object *exit);//Perl |
561 | void enter_exit (object *exit);//Perl |
541 | MTH void enter_map (maptile *newmap, int x, int y); |
562 | MTH void enter_map (maptile *newmap, int x, int y); |
|
|
563 | void player_goto (const char *path, int x, int y); // only for players |
542 | |
564 | |
543 | // returns the mapspace this object is in |
565 | // returns the mapspace this object is in |
544 | mapspace &ms () const; |
566 | mapspace &ms () const; |
545 | |
567 | |
546 | // fully recursive iterator |
568 | // fully recursive iterator |
… | |
… | |
677 | MTH static archetype *find (const_utf8_string name); |
699 | MTH static archetype *find (const_utf8_string name); |
678 | |
700 | |
679 | MTH void link (); |
701 | MTH void link (); |
680 | MTH void unlink (); |
702 | MTH void unlink (); |
681 | |
703 | |
682 | MTH static object *get (const char *name); // find()->instance() |
704 | MTH static object *get (const char *name); // (find() || singularity)->instance() |
683 | MTH object *instance (); |
705 | MTH object *instance (); |
684 | |
706 | |
685 | object_vector_index ACC (RW, archid); // index in archvector |
707 | object_vector_index ACC (RW, archid); // index in archvector |
686 | shstr ACC (RW, archname); /* More definite name, like "generate_kobold" */ |
708 | shstr ACC (RW, archname); /* More definite name, like "generate_kobold" */ |
687 | |
709 | |
… | |
… | |
692 | static archetype *read (object_thawer &f); |
714 | static archetype *read (object_thawer &f); |
693 | MTH static void commit_load (); // commit any objects loaded, resolves cyclic dependencies and more |
715 | MTH static void commit_load (); // commit any objects loaded, resolves cyclic dependencies and more |
694 | static void postpone_arch_ref (arch_ptr &ref, const_utf8_string other_arch); /* postpone other_arch reference */ |
716 | static void postpone_arch_ref (arch_ptr &ref, const_utf8_string other_arch); /* postpone other_arch reference */ |
695 | }; |
717 | }; |
696 | |
718 | |
|
|
719 | // compatbiility, remove once replaced by ->instance |
|
|
720 | inline object * |
|
|
721 | arch_to_object (archetype *at) |
|
|
722 | { |
|
|
723 | return at->instance (); |
|
|
724 | } |
|
|
725 | |
697 | inline void |
726 | inline void |
698 | object_freezer::put (keyword k, archetype *v) |
727 | object_freezer::put (keyword k, archetype *v) |
699 | { |
728 | { |
700 | put (k, v ? &v->archname : (const char *)0); |
729 | put (k, v ? &v->archname : (const char *)0); |
701 | } |
730 | } |
… | |
… | |
706 | |
735 | |
707 | extern objectvec objects; |
736 | extern objectvec objects; |
708 | extern activevec actives; |
737 | extern activevec actives; |
709 | extern archvec archetypes; |
738 | extern archvec archetypes; |
710 | |
739 | |
|
|
740 | // "safely" iterate over inv in a way such that the current item is removable |
|
|
741 | // quite horrible, thats why its hidden in some macro |
|
|
742 | #define for_inv_removable(op,var) \ |
|
|
743 | for (object *var, *next_ = (op)->inv; (var = next_), var && (next_ = var->below), var; ) |
|
|
744 | |
711 | #define for_all_objects(var) \ |
745 | #define for_all_objects(var) \ |
712 | for (unsigned _i = 0; _i < objects.size (); ++_i) \ |
746 | for (unsigned _i = 0; _i < objects.size (); ++_i) \ |
713 | statementvar (object *, var, objects [_i]) |
747 | statementvar (object *, var, objects [_i]) |
714 | |
748 | |
715 | #define for_all_actives(var) \ |
749 | #define for_all_actives(var) \ |
716 | for (unsigned _i = 0; _i < actives.size (); ++_i) \ |
750 | for (unsigned _i = 0; _i < actives.size (); ++_i) \ |
717 | statementvar (object *, var, actives [_i]) |
751 | statementvar (object *, var, actives [_i]) |
718 | |
752 | |
719 | #define for_all_archetypes(var) \ |
753 | #define for_all_archetypes(var) \ |
720 | for (unsigned _i = 0; _i < archetypes.size (); ++_i) \ |
754 | for (unsigned _i = 0; _i < archetypes.size (); ++_i) \ |
721 | statementvar (archetype *, var, archetypes [_i]) |
755 | statementvar (archetype *, var, archetypes [_i]) |
722 | |
756 | |
723 | /* Used by update_object to know if the object being passed is |
757 | /* Used by update_object to know if the object being passed is |
724 | * being added or removed. |
758 | * being added or removed. |