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 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
… | |
… | |
136 | { |
136 | { |
137 | signed char info:4; /* body info as loaded from the file */ |
137 | signed char info:4; /* body info as loaded from the file */ |
138 | signed char used:4; /* Calculated value based on items equipped */ |
138 | signed char used:4; /* Calculated value based on items equipped */ |
139 | }; |
139 | }; |
140 | |
140 | |
|
|
141 | typedef struct oblnk |
|
|
142 | { /* Used to link together several objects */ |
|
|
143 | object_ptr ob; |
|
|
144 | struct oblnk *next; |
|
|
145 | } objectlink; |
|
|
146 | |
|
|
147 | typedef struct oblinkpt |
|
|
148 | { /* Used to link together several object links */ |
|
|
149 | struct oblnk *link; |
|
|
150 | struct oblinkpt *next; |
|
|
151 | shstr id; /* Used as connected value in buttons/gates */ |
|
|
152 | } oblinkpt; |
|
|
153 | |
141 | INTERFACE_CLASS (object) |
154 | INTERFACE_CLASS (object) |
142 | // these are being copied |
155 | // these are being copied |
143 | struct object_copy : attachable |
156 | struct object_copy : attachable |
144 | { |
157 | { |
145 | sint16 ACC (RW, x), ACC (RW, y); /* Position in the map for this object */ |
158 | sint16 ACC (RW, x), ACC (RW, y); /* Position in the map for this object */ |
… | |
… | |
278 | shstr ACC (RW, lore); /* Obscure information about this object, */ |
291 | shstr ACC (RW, lore); /* Obscure information about this object, */ |
279 | /* To get put into books and the like. */ |
292 | /* To get put into books and the like. */ |
280 | shstr ACC (RW, custom_name); /* Custom name assigned by player */ |
293 | shstr ACC (RW, custom_name); /* Custom name assigned by player */ |
281 | }; |
294 | }; |
282 | |
295 | |
|
|
296 | const char *query_weight (const object *op); |
|
|
297 | const char *query_short_name (const object *op); |
|
|
298 | const char *query_name (const object *op); |
|
|
299 | const char *query_base_name (const object *op, int plural); |
|
|
300 | |
283 | struct object : zero_initialised, object_copy |
301 | struct object : zero_initialised, object_copy |
284 | { |
302 | { |
285 | // These variables are not changed by ->copy_to |
303 | // These variables are not changed by ->copy_to |
286 | maptile *ACC (RW, map); /* Pointer to the map in which this object is present */ |
304 | maptile *ACC (RW, map); /* Pointer to the map in which this object is present */ |
287 | |
305 | |
… | |
… | |
365 | } |
383 | } |
366 | |
384 | |
367 | // recursively destroy all objects in inventory, optionally dropping them to the ground instead |
385 | // recursively destroy all objects in inventory, optionally dropping them to the ground instead |
368 | MTH void destroy_inv (bool drop_to_ground = false); |
386 | MTH void destroy_inv (bool drop_to_ground = false); |
369 | MTH object *insert (object *item); // insert into inventory |
387 | MTH object *insert (object *item); // insert into inventory |
370 | MTH void play_sound (faceidx sound); |
388 | MTH void play_sound (faceidx sound) const; |
|
|
389 | MTH void say_msg (const char *msg) const; |
371 | |
390 | |
372 | void do_remove (); |
391 | void do_remove (); |
373 | MTH void remove () |
392 | MTH void remove () |
374 | { |
393 | { |
375 | if (!flag [FLAG_REMOVED]) |
394 | if (!flag [FLAG_REMOVED]) |
… | |
… | |
414 | open_container (0); |
433 | open_container (0); |
415 | } |
434 | } |
416 | |
435 | |
417 | MTH object *force_find (shstr_tmp name); |
436 | MTH object *force_find (shstr_tmp name); |
418 | MTH object *force_add (shstr_tmp name, int duration = 0); |
437 | MTH object *force_add (shstr_tmp name, int duration = 0); |
|
|
438 | |
|
|
439 | oblinkpt *find_link () const; |
|
|
440 | MTH void add_link (maptile *map, shstr_tmp id); |
|
|
441 | MTH void remove_link (); |
419 | |
442 | |
420 | // overwrite the attachable should_invoke function with a version that also checks ev_want_type |
443 | // overwrite the attachable should_invoke function with a version that also checks ev_want_type |
421 | bool should_invoke (event_type event) |
444 | bool should_invoke (event_type event) |
422 | { |
445 | { |
423 | return ev_want_event [event] || ev_want_type [type] || cb; |
446 | return ev_want_event [event] || ev_want_type [type] || cb; |
… | |
… | |
506 | |
529 | |
507 | return op; |
530 | return op; |
508 | } |
531 | } |
509 | |
532 | |
510 | // returns the outermost environment, never returns 0 |
533 | // returns the outermost environment, never returns 0 |
511 | MTH object *outer_env () |
534 | MTH object *outer_env () const |
512 | { |
535 | { |
513 | object *op; |
536 | const object *op; |
514 | |
537 | |
515 | for (op = this; op->env; op = op->env) |
538 | for (op = this; op->env; op = op->env) |
516 | ; |
539 | ; |
517 | |
540 | |
518 | return op; |
541 | return const_cast<object *>(op); |
519 | } |
542 | } |
520 | |
543 | |
521 | // returns the player that has this object in his inventory, or 0 |
544 | // returns the player that has this object in his inventory, or 0 |
522 | // we assume the player is always the outer env |
545 | // we assume the player is always the outer env |
523 | MTH object *in_player () |
546 | MTH object *in_player () const |
524 | { |
547 | { |
525 | object *op = outer_env (); |
548 | object *op = outer_env (); |
526 | |
549 | |
527 | return op->type == PLAYER ? op : 0; |
550 | return op->type == PLAYER ? op : 0; |
528 | } |
551 | } |
529 | |
552 | |
530 | // "temporary" helper function |
553 | // "temporary" helper function |
531 | MTH object *head_ () |
554 | MTH object *head_ () const |
532 | { |
555 | { |
533 | return head ? head : this; |
556 | return head ? head : const_cast<object *>(this); |
534 | } |
557 | } |
535 | |
558 | |
536 | MTH bool is_head () |
559 | MTH bool is_head () const |
537 | { |
560 | { |
538 | return head_ () == this; |
561 | return head_ () == this; |
539 | } |
562 | } |
540 | |
563 | |
541 | MTH bool is_on_map () const |
564 | MTH bool is_on_map () const |
… | |
… | |
554 | } |
577 | } |
555 | |
578 | |
556 | MTH bool affects_los () const |
579 | MTH bool affects_los () const |
557 | { |
580 | { |
558 | return glow_radius || flag [FLAG_BLOCKSVIEW]; |
581 | return glow_radius || flag [FLAG_BLOCKSVIEW]; |
|
|
582 | } |
|
|
583 | |
|
|
584 | MTH bool has_carried_lights () const |
|
|
585 | { |
|
|
586 | return glow_radius; |
559 | } |
587 | } |
560 | |
588 | |
561 | // returns the player that cna see this object, if any |
589 | // returns the player that cna see this object, if any |
562 | MTH object *visible_to () const; |
590 | MTH object *visible_to () const; |
563 | |
591 | |
564 | MTH std::string long_desc (object *who = 0); |
592 | MTH std::string long_desc (object *who = 0); |
565 | MTH std::string describe_monster (object *who = 0); |
593 | MTH std::string describe_monster (object *who = 0); |
566 | MTH std::string describe_item (object *who = 0); |
594 | MTH std::string describe_item (object *who = 0); |
567 | MTH std::string describe (object *who = 0); |
595 | MTH std::string describe (object *who = 0); |
|
|
596 | |
|
|
597 | MTH const char *query_weight () { return ::query_weight (this); } |
|
|
598 | MTH const char *query_name () { return ::query_name (this); } |
|
|
599 | MTH const char *query_short_name () { return ::query_short_name (this); } |
|
|
600 | MTH const char *query_base_name (bool plural) { return ::query_base_name (this, plural); } |
568 | |
601 | |
569 | // If this object has no extra parts but should have them, |
602 | // If this object has no extra parts but should have them, |
570 | // add them, effectively expanding heads into multipart |
603 | // add them, effectively expanding heads into multipart |
571 | // objects. This method only works on objects not inserted |
604 | // objects. This method only works on objects not inserted |
572 | // anywhere. |
605 | // anywhere. |
… | |
… | |
691 | ob->env->inv = ob; |
724 | ob->env->inv = ob; |
692 | } |
725 | } |
693 | |
726 | |
694 | return ob; |
727 | return ob; |
695 | } |
728 | } |
696 | |
|
|
697 | typedef struct oblnk |
|
|
698 | { /* Used to link together several objects */ |
|
|
699 | object_ptr ob; |
|
|
700 | struct oblnk *next; |
|
|
701 | } objectlink; |
|
|
702 | |
|
|
703 | typedef struct oblinkpt |
|
|
704 | { /* Used to link together several object links */ |
|
|
705 | struct oblnk *link; |
|
|
706 | sint32 value; /* Used as connected value in buttons/gates */ |
|
|
707 | struct oblinkpt *next; |
|
|
708 | } oblinkpt; |
|
|
709 | |
729 | |
710 | object *find_skill_by_name_fuzzy (object *who, const char *name); |
730 | object *find_skill_by_name_fuzzy (object *who, const char *name); |
711 | object *find_skill_by_name (object *who, shstr_cmp sh); |
731 | object *find_skill_by_name (object *who, shstr_cmp sh); |
712 | object *find_skill_by_number (object *who, int skillno); |
732 | object *find_skill_by_number (object *who, int skillno); |
713 | |
733 | |