… | |
… | |
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 | { |
… | |
… | |
157 | sint32 ACC (RW, weight_limit);/* Weight-limit of object */ |
164 | sint32 ACC (RW, weight_limit);/* Weight-limit of object */ |
158 | sint32 ACC (RW, carrying); /* How much weight this object contains */ |
165 | sint32 ACC (RW, carrying); /* How much weight this object contains */ |
159 | sint64 ACC (RW, perm_exp); /* Permanent exp */ |
166 | sint64 ACC (RW, perm_exp); /* Permanent exp */ |
160 | uint32 ACC (RW, weapontype); /* type of weapon */ |
167 | uint32 ACC (RW, weapontype); /* type of weapon */ |
161 | uint32 ACC (RW, tooltype); /* type of tool or build facility */ |
168 | uint32 ACC (RW, tooltype); /* type of tool or build facility */ |
162 | sint8 ACC (RW, body_info[NUM_BODY_LOCATIONS]); /* body info as loaded from the file */ |
169 | body_slot slot [NUM_BODY_LOCATIONS]; |
163 | sint8 ACC (RW, body_used[NUM_BODY_LOCATIONS]); /* Calculated value based on items equipped */ |
|
|
164 | faceidx ACC (RW, face); /* Face with colors */ |
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 */ |
… | |
… | |
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. */ |
243 | |
249 | |
244 | bool parse_kv (object_thawer &f); // parse kv pairs, (ab-)used by archetypes, which should not exist at all |
250 | bool parse_kv (object_thawer &f); // parse kv pairs, (ab-)used by archetypes, which should not exist at all |
245 | static object *read (object_thawer &f, maptile *map = 0); // map argument due to toal design bogosity, must go. |
251 | static object *read (object_thawer &f, maptile *map = 0); // map argument due to toal design bogosity, must go. |
246 | bool write (object_freezer &f); |
252 | bool write (object_freezer &f); |
247 | |
253 | |
248 | MTH static object *create (); |
254 | MTH static object *create (); |
|
|
255 | object &operator =(const object &src); |
249 | MTH void copy_to (object *dst); |
256 | MTH void copy_to (object *dst); |
250 | MTH object *clone (); // create + copy_to |
257 | MTH object *clone (); // create + copy_to |
251 | void do_destroy (); |
258 | void do_destroy (); |
252 | void gather_callbacks (AV *&callbacks, event_type event) const; |
259 | void gather_callbacks (AV *&callbacks, event_type event) const; |
253 | MTH void destroy (bool destroy_inventory = false); |
260 | MTH void destroy (bool destroy_inventory = false); |
… | |
… | |
272 | && can_merge_slow (op1, op2); |
279 | && can_merge_slow (op1, op2); |
273 | } |
280 | } |
274 | |
281 | |
275 | MTH void set_owner (object *owner); |
282 | MTH void set_owner (object *owner); |
276 | MTH void set_speed (float speed); |
283 | MTH void set_speed (float speed); |
|
|
284 | MTH void set_weapon (object *ob); |
277 | |
285 | |
278 | MTH void open_container (object *new_container); |
286 | MTH void open_container (object *new_container); |
279 | MTH void close_container () |
287 | MTH void close_container () |
280 | { |
288 | { |
281 | open_container (0); |
289 | open_container (0); |
… | |
… | |
293 | MTH void drain_specific_stat (int deplete_stats); |
301 | MTH void drain_specific_stat (int deplete_stats); |
294 | MTH void change_luck (int value); |
302 | MTH void change_luck (int value); |
295 | |
303 | |
296 | // info must hold 256 * 3 bytes currently |
304 | // info must hold 256 * 3 bytes currently |
297 | const char *debug_desc (char *info) const; |
305 | const char *debug_desc (char *info) const; |
298 | MTH const char *debug_desc () const; |
306 | MTH const char *debug_desc () const; // uses at least 3 round-robin buffers |
299 | const char *debug_desc2 () const; // another debug_desc, pure convinience function |
|
|
300 | const char *flag_desc (char *desc, int len) const; |
307 | const char *flag_desc (char *desc, int len) const; |
301 | |
308 | |
302 | int number_of () const |
309 | int number_of () const |
303 | { |
310 | { |
304 | return nrof ? nrof : 1; |
311 | return nrof ? nrof : 1; |
… | |
… | |
330 | || (flag [FLAG_ALIVE] && !flag [FLAG_GENERATOR] && type != DOOR)) |
337 | || (flag [FLAG_ALIVE] && !flag [FLAG_GENERATOR] && type != DOOR)) |
331 | && !flag [FLAG_IS_A_TEMPLATE]; } |
338 | && !flag [FLAG_IS_A_TEMPLATE]; } |
332 | MTH bool is_arrow () const { return type == ARROW |
339 | MTH bool is_arrow () const { return type == ARROW |
333 | || (type == SPELL_EFFECT |
340 | || (type == SPELL_EFFECT |
334 | && (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; } |
335 | |
343 | |
336 | 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; } |
337 | |
345 | |
338 | // temporary: wether the object can be saved in a map file |
346 | // temporary: wether the object can be saved in a map file |
339 | // contr => is a player |
347 | // contr => is a player |
… | |
… | |
360 | MTH object *head_ () |
368 | MTH object *head_ () |
361 | { |
369 | { |
362 | return head ? head : this; |
370 | return head ? head : this; |
363 | } |
371 | } |
364 | |
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 | |
365 | // insert object at same map position as 'where' |
386 | // insert object at same map position as 'where' |
366 | // handles both inventory and map "positions" |
387 | // handles both inventory and map "positions" |
367 | 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); |
368 | |
389 | |
369 | MTH void activate (); |
390 | MTH void activate (); |
… | |
… | |
372 | MTH void deactivate_recursive (); |
393 | MTH void deactivate_recursive (); |
373 | |
394 | |
374 | // set the givne flag on all objects in the inventory recursively |
395 | // set the givne flag on all objects in the inventory recursively |
375 | MTH void set_flag_inv (int flag, int value = 1); |
396 | MTH void set_flag_inv (int flag, int value = 1); |
376 | |
397 | |
377 | void enter_exit (object *exit);//PERL |
398 | void enter_exit (object *exit);//Perl |
378 | MTH void enter_map (maptile *newmap, int x, int y); |
399 | MTH void enter_map (maptile *newmap, int x, int y); |
379 | |
400 | |
380 | // returns the mapspace this object is in |
401 | // returns the mapspace this object is in |
381 | mapspace &ms () const; |
402 | mapspace &ms () const; |
382 | |
403 | |
… | |
… | |
482 | archetype (); |
503 | archetype (); |
483 | ~archetype (); |
504 | ~archetype (); |
484 | void gather_callbacks (AV *&callbacks, event_type event) const; |
505 | void gather_callbacks (AV *&callbacks, event_type event) const; |
485 | |
506 | |
486 | static archetype *read (object_thawer &f); |
507 | static archetype *read (object_thawer &f); |
|
|
508 | static archetype *get (const char *name); // find or create |
487 | static archetype *find (const char *name); |
509 | static archetype *find (const char *name); |
488 | |
510 | |
489 | void hash_add (); // add to hashtable |
511 | void hash_add (); // add to hashtable |
490 | void hash_del (); // remove from hashtable |
512 | void hash_del (); // remove from hashtable |
491 | |
513 | |
… | |
… | |
493 | struct archetype *ACC (RW, next); /* Next archetype in a linked list */ |
515 | struct archetype *ACC (RW, next); /* Next archetype in a linked list */ |
494 | 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 */ |
495 | struct archetype *ACC (RW, more); /* Next part of a linked object */ |
517 | struct archetype *ACC (RW, more); /* Next part of a linked object */ |
496 | 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 () */ |
497 | 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 |
498 | 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 |
499 | * in comparison to the head. |
522 | * in comparison to the head. |
500 | */ |
523 | */ |
501 | }; |
524 | }; |
502 | |
525 | |
… | |
… | |
541 | #define INS_ON_TOP 0x0008 |
564 | #define INS_ON_TOP 0x0008 |
542 | #define INS_BELOW_ORIGINATOR 0x0010 |
565 | #define INS_BELOW_ORIGINATOR 0x0010 |
543 | #define INS_MAP_LOAD 0x0020 |
566 | #define INS_MAP_LOAD 0x0020 |
544 | |
567 | |
545 | #define ARCH_SINGULARITY "singularity" |
568 | #define ARCH_SINGULARITY "singularity" |
546 | #define ARCH_SINGULARITY_LEN 11 |
|
|
547 | #define ARCH_DETECT_MAGIC "detect_magic" |
569 | #define ARCH_DETECT_MAGIC "detect_magic" |
548 | #define ARCH_DEPLETION "depletion" |
570 | #define ARCH_DEPLETION "depletion" |
549 | #define ARCH_SYMPTOM "symptom" |
571 | #define ARCH_SYMPTOM "symptom" |
550 | |
572 | |
551 | #endif |
573 | #endif |