… | |
… | |
29 | |
29 | |
30 | #include "cfperl.h" |
30 | #include "cfperl.h" |
31 | #include "shstr.h" |
31 | #include "shstr.h" |
32 | |
32 | |
33 | typedef int tag_t; |
33 | typedef int tag_t; |
|
|
34 | |
34 | #define NUM_BODY_LOCATIONS 12 |
35 | #define NUM_BODY_LOCATIONS 14 |
35 | #define BODY_ARMS 1 |
36 | #define BODY_ARMS 1 |
36 | |
37 | |
37 | /* See common/item.c */ |
38 | /* See common/item.c */ |
38 | |
39 | |
39 | typedef struct Body_Locations |
40 | typedef struct Body_Locations |
… | |
… | |
88 | |
89 | |
89 | /* However, if you're keeping a pointer of some sort, you probably |
90 | /* However, if you're keeping a pointer of some sort, you probably |
90 | * don't just want it copied, so you'll need to add to common/object.C, |
91 | * don't just want it copied, so you'll need to add to common/object.C, |
91 | * e.g. ->copy_to () |
92 | * e.g. ->copy_to () |
92 | */ |
93 | */ |
|
|
94 | |
|
|
95 | struct body_slot |
|
|
96 | { |
|
|
97 | sint8 info:4; /* body info as loaded from the file */ |
|
|
98 | sint8 used:4; /* Calculated value based on items equipped */ |
|
|
99 | }; |
93 | |
100 | |
94 | INTERFACE_CLASS (object) |
101 | INTERFACE_CLASS (object) |
95 | // these are being copied |
102 | // these are being copied |
96 | struct object_copy : attachable |
103 | struct object_copy : attachable |
97 | { |
104 | { |
… | |
… | |
121 | object_ptr ACC (RW, spell); /* Spell that was being cast */ |
128 | object_ptr ACC (RW, spell); /* Spell that was being cast */ |
122 | object_ptr ACC (RW, current_weapon); /* Pointer to the weapon currently used */ |
129 | object_ptr ACC (RW, current_weapon); /* Pointer to the weapon currently used */ |
123 | arch_ptr ACC (RW, arch); /* Pointer to archetype */ |
130 | arch_ptr ACC (RW, arch); /* Pointer to archetype */ |
124 | arch_ptr ACC (RW, other_arch);/* Pointer used for various things - mostly used for what */ |
131 | arch_ptr ACC (RW, other_arch);/* Pointer used for various things - mostly used for what */ |
125 | |
132 | |
126 | facetile *ACC (RW, face); /* Face with colors */ |
|
|
127 | float ACC (RW, speed); /* The overall speed of this object */ |
133 | float ACC (RW, speed); /* The overall speed of this object */ |
128 | float ACC (RW, speed_left); /* How much speed is left to spend this round */ |
134 | float ACC (RW, speed_left); /* How much speed is left to spend this round */ |
129 | uint32 ACC (RW, nrof); /* How many of the objects */ |
135 | uint32 ACC (RW, nrof); /* How many of the objects */ |
130 | |
136 | |
131 | /* This next big block are basically used for monsters and equipment */ |
137 | /* This next big block are basically used for monsters and equipment */ |
… | |
… | |
158 | sint32 ACC (RW, weight_limit);/* Weight-limit of object */ |
164 | sint32 ACC (RW, weight_limit);/* Weight-limit of object */ |
159 | sint32 ACC (RW, carrying); /* How much weight this object contains */ |
165 | sint32 ACC (RW, carrying); /* How much weight this object contains */ |
160 | sint64 ACC (RW, perm_exp); /* Permanent exp */ |
166 | sint64 ACC (RW, perm_exp); /* Permanent exp */ |
161 | uint32 ACC (RW, weapontype); /* type of weapon */ |
167 | uint32 ACC (RW, weapontype); /* type of weapon */ |
162 | uint32 ACC (RW, tooltype); /* type of tool or build facility */ |
168 | uint32 ACC (RW, tooltype); /* type of tool or build facility */ |
163 | sint8 ACC (RW, body_info[NUM_BODY_LOCATIONS]); /* body info as loaded from the file */ |
169 | body_slot slot [NUM_BODY_LOCATIONS]; |
164 | sint8 ACC (RW, body_used[NUM_BODY_LOCATIONS]); /* Calculated value based on items equipped */ |
170 | faceidx ACC (RW, face); /* Face with colors */ |
165 | living ACC (RO, stats); /* Str, Con, Dex, etc */ |
171 | living ACC (RO, stats); /* Str, Con, Dex, etc */ |
166 | /* See the pod/objects.pod for more info about body locations */ |
172 | /* See the pod/objects.pod for more info about body locations */ |
167 | |
173 | |
168 | /* Following mostly refers to fields only used for monsters */ |
174 | /* Following mostly refers to fields only used for monsters */ |
169 | uint32 ACC (RW, hide); /* The object is hidden, not invisible */ |
175 | uint32 ACC (RW, hide); /* The object is hidden, not invisible */ |
… | |
… | |
198 | char *ACC (RW, spellarg); |
204 | char *ACC (RW, spellarg); |
199 | |
205 | |
200 | /* Following are values used by any object */ |
206 | /* Following are values used by any object */ |
201 | /* this objects turns into or what this object creates */ |
207 | /* this objects turns into or what this object creates */ |
202 | treasurelist *ACC (RW, randomitems); /* Items to be generated */ |
208 | treasurelist *ACC (RW, randomitems); /* Items to be generated */ |
203 | key_value *key_values; /* Fields not explictly known by the loader. */ |
|
|
204 | flags_t flag; /* various flags */ |
209 | flags_t flag; /* various flags */ |
205 | #if FOR_PERL |
210 | #if FOR_PERL |
206 | bool ACC (RW, flag[NUM_FLAGS]); |
211 | bool ACC (RW, flag[NUM_FLAGS]); |
207 | #endif |
212 | #endif |
208 | uint16 ACC (RW, animation_id);/* An index into the animation array */ |
213 | uint16 ACC (RW, animation_id);/* An index into the animation array */ |
… | |
… | |
238 | * This is typically the container that the object is in. |
243 | * This is typically the container that the object is in. |
239 | */ |
244 | */ |
240 | object *ACC (RW, more); /* Pointer to the rest of a large body of objects */ |
245 | object *ACC (RW, more); /* Pointer to the rest of a large body of objects */ |
241 | object *head; /* Points to the main object of a large body */ // NO ACC, perl semantics are different |
246 | object *head; /* Points to the main object of a large body */ // NO ACC, perl semantics are different |
242 | client_container *seen_by; // seen by which player/container currently? |
247 | client_container *seen_by; // seen by which player/container currently? |
|
|
248 | key_value *key_values; /* Fields not explictly known by the loader. */ |
|
|
249 | |
|
|
250 | bool parse_kv (object_thawer &f); // parse kv pairs, (ab-)used by archetypes, which should not exist at all |
|
|
251 | static object *read (object_thawer &f, maptile *map = 0); // map argument due to toal design bogosity, must go. |
|
|
252 | bool write (object_freezer &f); |
243 | |
253 | |
244 | MTH static object *create (); |
254 | MTH static object *create (); |
|
|
255 | object &operator =(const object &src); |
245 | MTH void copy_to (object *dst); |
256 | MTH void copy_to (object *dst); |
246 | MTH object *clone (); // create + copy_to |
257 | MTH object *clone (); // create + copy_to |
247 | void do_destroy (); |
258 | void do_destroy (); |
248 | void gather_callbacks (AV *&callbacks, event_type event) const; |
259 | void gather_callbacks (AV *&callbacks, event_type event) const; |
249 | MTH void destroy (bool destroy_inventory = false); |
260 | MTH void destroy (bool destroy_inventory = false); |
… | |
… | |
268 | && can_merge_slow (op1, op2); |
279 | && can_merge_slow (op1, op2); |
269 | } |
280 | } |
270 | |
281 | |
271 | MTH void set_owner (object *owner); |
282 | MTH void set_owner (object *owner); |
272 | MTH void set_speed (float speed); |
283 | MTH void set_speed (float speed); |
|
|
284 | MTH void set_weapon (object *ob); |
273 | |
285 | |
274 | MTH void open_container (object *new_container); |
286 | MTH void open_container (object *new_container); |
275 | MTH void close_container () |
287 | MTH void close_container () |
276 | { |
288 | { |
277 | open_container (0); |
289 | open_container (0); |
278 | } |
290 | } |
279 | |
291 | |
280 | MTH void instantiate () |
292 | MTH void instantiate (); |
281 | { |
|
|
282 | if (!uuid.seq) // HACK |
|
|
283 | uuid = gen_uuid (); |
|
|
284 | |
|
|
285 | attachable::instantiate (); |
|
|
286 | } |
|
|
287 | |
293 | |
288 | // recalculate all stats |
294 | // recalculate all stats |
289 | MTH void update_stats (); |
295 | MTH void update_stats (); |
290 | MTH void roll_stats (); |
296 | MTH void roll_stats (); |
291 | MTH void swap_stats (int a, int b); |
297 | MTH void swap_stats (int a, int b); |
… | |
… | |
295 | MTH void drain_specific_stat (int deplete_stats); |
301 | MTH void drain_specific_stat (int deplete_stats); |
296 | MTH void change_luck (int value); |
302 | MTH void change_luck (int value); |
297 | |
303 | |
298 | // info must hold 256 * 3 bytes currently |
304 | // info must hold 256 * 3 bytes currently |
299 | const char *debug_desc (char *info) const; |
305 | const char *debug_desc (char *info) const; |
300 | MTH const char *debug_desc () const; |
306 | MTH const char *debug_desc () const; // uses at least 3 round-robin buffers |
301 | const char *debug_desc2 () const; // another debug_desc, pure convinience function |
|
|
302 | const char *flag_desc (char *desc, int len) const; |
307 | const char *flag_desc (char *desc, int len) const; |
303 | |
308 | |
304 | int number_of () const |
309 | int number_of () const |
305 | { |
310 | { |
306 | return nrof ? nrof : 1; |
311 | return nrof ? nrof : 1; |
… | |
… | |
332 | || (flag [FLAG_ALIVE] && !flag [FLAG_GENERATOR] && type != DOOR)) |
337 | || (flag [FLAG_ALIVE] && !flag [FLAG_GENERATOR] && type != DOOR)) |
333 | && !flag [FLAG_IS_A_TEMPLATE]; } |
338 | && !flag [FLAG_IS_A_TEMPLATE]; } |
334 | MTH bool is_arrow () const { return type == ARROW |
339 | MTH bool is_arrow () const { return type == ARROW |
335 | || (type == SPELL_EFFECT |
340 | || (type == SPELL_EFFECT |
336 | && (subtype == SP_BULLET || subtype == SP_MAGIC_MISSILE)); } |
341 | && (subtype == SP_BULLET || subtype == SP_MAGIC_MISSILE)); } |
|
|
342 | MTH bool is_range () const { return type == BOW || type == ROD || type == WAND || type == HORN; } |
337 | |
343 | |
338 | MTH bool has_active_speed () const { return FABS(speed) >= MIN_ACTIVE_SPEED; } |
344 | MTH bool has_active_speed () const { return FABS(speed) >= MIN_ACTIVE_SPEED; } |
339 | |
345 | |
340 | // temporary: wether the object can be saved in a map file |
346 | // temporary: wether the object can be saved in a map file |
341 | // contr => is a player |
347 | // contr => is a player |
… | |
… | |
362 | MTH object *head_ () |
368 | MTH object *head_ () |
363 | { |
369 | { |
364 | return head ? head : this; |
370 | return head ? head : this; |
365 | } |
371 | } |
366 | |
372 | |
|
|
373 | MTH std::string long_desc (object *who = 0); |
|
|
374 | MTH std::string describe_monster (object *who = 0); |
|
|
375 | MTH std::string describe_item (object *who = 0); |
|
|
376 | MTH std::string describe (object *who = 0); |
|
|
377 | |
|
|
378 | // If this object has no extra parts but should have them, |
|
|
379 | // add them, effectively expanding heads into multipart |
|
|
380 | // objects. This method only works on objects not inserted |
|
|
381 | // anywhere. |
|
|
382 | MTH void expand_tail (); |
|
|
383 | |
|
|
384 | MTH void create_treasure (treasurelist *tl, int flags = 0); |
|
|
385 | |
367 | // insert object at same map position as 'where' |
386 | // insert object at same map position as 'where' |
368 | // handles both inventory and map "positions" |
387 | // handles both inventory and map "positions" |
369 | MTH object *insert_at (object *where, object *originator = 0, int flags = 0); |
388 | MTH object *insert_at (object *where, object *originator = 0, int flags = 0); |
370 | |
389 | |
371 | MTH void activate (); |
390 | MTH void activate (); |
… | |
… | |
374 | MTH void deactivate_recursive (); |
393 | MTH void deactivate_recursive (); |
375 | |
394 | |
376 | // set the givne flag on all objects in the inventory recursively |
395 | // set the givne flag on all objects in the inventory recursively |
377 | MTH void set_flag_inv (int flag, int value = 1); |
396 | MTH void set_flag_inv (int flag, int value = 1); |
378 | |
397 | |
379 | void enter_exit (object *exit);//PERL |
398 | void enter_exit (object *exit);//Perl |
380 | MTH void enter_map (maptile *newmap, int x, int y); |
399 | MTH void enter_map (maptile *newmap, int x, int y); |
381 | |
400 | |
382 | // returns the mapspace this object is in |
401 | // returns the mapspace this object is in |
383 | mapspace &ms () const; |
402 | mapspace &ms () const; |
384 | |
403 | |
… | |
… | |
447 | |
466 | |
448 | extern objectvec objects; |
467 | extern objectvec objects; |
449 | extern activevec actives; |
468 | extern activevec actives; |
450 | |
469 | |
451 | #define for_all_objects(var) \ |
470 | #define for_all_objects(var) \ |
452 | for (int _i = 0; _i < objects.size (); ++_i) \ |
471 | for (unsigned _i = 0; _i < objects.size (); ++_i) \ |
453 | declvar (object *, var, objects [_i]) |
472 | declvar (object *, var, objects [_i]) |
454 | |
473 | |
455 | #define for_all_actives(var) \ |
474 | #define for_all_actives(var) \ |
456 | for (int _i = 0; _i < actives.size (); ++_i) \ |
475 | for (unsigned _i = 0; _i < actives.size (); ++_i) \ |
457 | declvar (object *, var, actives [_i]) |
476 | declvar (object *, var, actives [_i]) |
458 | |
477 | |
459 | typedef struct oblnk |
478 | typedef struct oblnk |
460 | { /* Used to link together several objects */ |
479 | { /* Used to link together several objects */ |
461 | object_ptr ob; |
480 | object_ptr ob; |
… | |
… | |
483 | { |
502 | { |
484 | archetype (); |
503 | archetype (); |
485 | ~archetype (); |
504 | ~archetype (); |
486 | void gather_callbacks (AV *&callbacks, event_type event) const; |
505 | void gather_callbacks (AV *&callbacks, event_type event) const; |
487 | |
506 | |
|
|
507 | static archetype *read (object_thawer &f); |
|
|
508 | static archetype *get (const char *name); // find or create |
488 | static archetype *find (const char *name); |
509 | static archetype *find (const char *name); |
489 | |
510 | |
490 | void hash_add (); // add to hashtable |
511 | void hash_add (); // add to hashtable |
491 | void hash_del (); // remove from hashtable |
512 | void hash_del (); // remove from hashtable |
492 | |
513 | |
… | |
… | |
494 | struct archetype *ACC (RW, next); /* Next archetype in a linked list */ |
515 | struct archetype *ACC (RW, next); /* Next archetype in a linked list */ |
495 | struct archetype *ACC (RW, head); /* The main part of a linked object */ |
516 | struct archetype *ACC (RW, head); /* The main part of a linked object */ |
496 | struct archetype *ACC (RW, more); /* Next part of a linked object */ |
517 | struct archetype *ACC (RW, more); /* Next part of a linked object */ |
497 | object ACC (RO, clone); /* An object from which to do ->copy_to () */ |
518 | object ACC (RO, clone); /* An object from which to do ->copy_to () */ |
498 | uint32 ACC (RW, editable); /* editable flags (mainly for editor) */ |
519 | uint32 ACC (RW, editable); /* editable flags (mainly for editor) */ |
|
|
520 | bool ACC (RW, linked); // linked into list of heads |
499 | sint8 ACC (RW, tail_x), ACC (RW, tail_y); /* Where the lower right most portion of the object is |
521 | sint8 ACC (RW, tail_x), ACC (RW, tail_y); /* Where the lower right most portion of the object is |
500 | * in comparison to the head. |
522 | * in comparison to the head. |
501 | */ |
523 | */ |
502 | }; |
524 | }; |
503 | |
525 | |
… | |
… | |
542 | #define INS_ON_TOP 0x0008 |
564 | #define INS_ON_TOP 0x0008 |
543 | #define INS_BELOW_ORIGINATOR 0x0010 |
565 | #define INS_BELOW_ORIGINATOR 0x0010 |
544 | #define INS_MAP_LOAD 0x0020 |
566 | #define INS_MAP_LOAD 0x0020 |
545 | |
567 | |
546 | #define ARCH_SINGULARITY "singularity" |
568 | #define ARCH_SINGULARITY "singularity" |
547 | #define ARCH_SINGULARITY_LEN 11 |
|
|
548 | #define ARCH_DETECT_MAGIC "detect_magic" |
569 | #define ARCH_DETECT_MAGIC "detect_magic" |
549 | #define ARCH_DEPLETION "depletion" |
570 | #define ARCH_DEPLETION "depletion" |
550 | #define ARCH_SYMPTOM "symptom" |
571 | #define ARCH_SYMPTOM "symptom" |
551 | |
572 | |
552 | #endif |
573 | #endif |