ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/object.h
(Generate patch)

Comparing deliantra/server/include/object.h (file contents):
Revision 1.202 by root, Sat Jun 27 08:25:36 2009 UTC vs.
Revision 1.211 by sf-marcmagus, Sun Oct 11 05:43:35 2009 UTC

262 MoveType ACC (RW, move_off); /* Move types affected moving off this space */ 262 MoveType ACC (RW, move_off); /* Move types affected moving off this space */
263 MoveType ACC (RW, move_slow); /* Movement types this slows down */ 263 MoveType ACC (RW, move_slow); /* Movement types this slows down */
264 264
265 // 8 free bits 265 // 8 free bits
266 266
267 float ACC (RW, expmul); /* needed experience = (calc_exp*expmul) - means some */ 267 //float ACC (RW, expmul) = 1.0; /* needed experience = (calc_exp*expmul) - means some */
268 /* races/classes can need less/more exp to gain levels */ 268 // /* races/classes can need less/more exp to gain levels */
269 static const float expmul = 1.0;//D
269 float ACC (RW, move_slow_penalty); /* How much this slows down the object */ 270 float ACC (RW, move_slow_penalty); /* How much this slows down the object */
270 271
271 /* Following are values used by any object */ 272 /* Following are values used by any object */
272 /* this objects turns into or what this object creates */ 273 /* this objects turns into or what this object creates */
273 treasurelist *ACC (RW, randomitems); /* Items to be generated */ 274 treasurelist *ACC (RW, randomitems); /* Items to be generated */
435 { 436 {
436 open_container (0); 437 open_container (0);
437 } 438 }
438 439
439 MTH object *force_find (shstr_tmp name); 440 MTH object *force_find (shstr_tmp name);
441 MTH void force_set_timer (int duration);
440 MTH object *force_add (shstr_tmp name, int duration = 0); 442 MTH object *force_add (shstr_tmp name, int duration = 0);
441 443
442 oblinkpt *find_link () const; 444 oblinkpt *find_link () const;
443 MTH void add_link (maptile *map, shstr_tmp id); 445 MTH void add_link (maptile *map, shstr_tmp id);
444 MTH void remove_link (); 446 MTH void remove_link ();
490 return (uint64)total_weight () 492 return (uint64)total_weight ()
491 * 1000 493 * 1000
492 * (type == CONTAINER ? 1000 : 1) 494 * (type == CONTAINER ? 1000 : 1)
493 / dominant_material ()->density; 495 / dominant_material ()->density;
494 } 496 }
497
498 MTH bool is_arch () const { return this == (const object *)(const archetype *)arch; }
495 499
496 MTH bool is_wiz () const { return flag [FLAG_WIZ]; } 500 MTH bool is_wiz () const { return flag [FLAG_WIZ]; }
497 MTH bool is_weapon () const { return type == ARROW || type == BOW || type == WEAPON; } 501 MTH bool is_weapon () const { return type == ARROW || type == BOW || type == WEAPON; }
498 MTH bool is_armor () const { return type == ARMOUR || type == SHIELD || type == HELMET 502 MTH bool is_armor () const { return type == ARMOUR || type == SHIELD || type == HELMET
499 || type == CLOAK || type == BOOTS || type == GLOVES 503 || type == CLOAK || type == BOOTS || type == GLOVES
518 /* This return true if object has still randomitems which 522 /* This return true if object has still randomitems which
519 * could be expanded. 523 * could be expanded.
520 */ 524 */
521 MTH bool has_random_items () const { return randomitems && !flag [FLAG_IS_A_TEMPLATE]; } 525 MTH bool has_random_items () const { return randomitems && !flag [FLAG_IS_A_TEMPLATE]; }
522 526
523 MTH bool has_dialogue () const { return *&msg == '@'; } 527 static bool msg_has_dialogue (const char *msg) { return *msg == '@'; }
528
529 MTH bool has_dialogue () const { return msg_has_dialogue (&msg); }
524 530
525 // returns the outermost owner, never returns 0 531 // returns the outermost owner, never returns 0
526 MTH object *outer_owner () 532 MTH object *outer_owner ()
527 { 533 {
528 object *op; 534 object *op;
532 538
533 return op; 539 return op;
534 } 540 }
535 541
536 // returns the outermost environment, never returns 0 542 // returns the outermost environment, never returns 0
537 MTH object *outer_env () const 543 MTH object *outer_env_or_self () const
538 { 544 {
539 const object *op; 545 const object *op;
540 546
541 for (op = this; op->env; op = op->env) 547 for (op = this; op->env; op = op->env)
542 ; 548 ;
543 549
544 return const_cast<object *>(op); 550 return const_cast<object *>(op);
551 }
552
553 // returns the outermost environment, may return 0
554 MTH object *outer_env () const
555 {
556 return env ? outer_env_or_self () : 0;
545 } 557 }
546 558
547 // returns the player that has this object in his inventory, or 0 559 // returns the player that has this object in his inventory, or 0
548 // we assume the player is always the outer env 560 // we assume the player is always the outer env
549 MTH object *in_player () const 561 MTH object *in_player () const
550 { 562 {
551 object *op = outer_env (); 563 object *op = outer_env_or_self ();
552 564
553 return op->type == PLAYER ? op : 0; 565 return op->type == PLAYER ? op : 0;
554 } 566 }
555 567
556 // "temporary" helper function 568 // "temporary" helper function
590 } 602 }
591 603
592 // returns the player that cna see this object, if any 604 // returns the player that cna see this object, if any
593 MTH object *visible_to () const; 605 MTH object *visible_to () const;
594 606
595 MTH std::string long_desc (object *who = 0); 607 MTH std::string long_desc (object *who = 0); // query_name . " " . describe
596 MTH std::string describe_monster (object *who = 0); 608 MTH std::string describe_monster (object *who = 0);
597 MTH std::string describe_item (object *who = 0); 609 MTH std::string describe_item (object *who = 0);
598 MTH std::string describe (object *who = 0); 610 MTH std::string describe (object *who = 0); // long description, without name
599 611
600 MTH const char *query_weight () { return ::query_weight (this); } 612 MTH const char *query_weight () { return ::query_weight (this); }
601 MTH const char *query_name () { return ::query_name (this); } 613 MTH const char *query_name () { return ::query_name (this); }
602 MTH const char *query_short_name () { return ::query_short_name (this); } 614 MTH const char *query_short_name () { return ::query_short_name (this); }
603 MTH const char *query_base_name (bool plural) { return ::query_base_name (this, plural); } 615 MTH const char *query_base_name (bool plural) { return ::query_base_name (this, plural); }
698 // currently only used for players to make them temporarily visible 710 // currently only used for players to make them temporarily visible
699 // when they are invisible. 711 // when they are invisible.
700 MTH void make_noise (); 712 MTH void make_noise ();
701 713
702 /* animation */ 714 /* animation */
703 bool has_anim () { return animation_id; } 715 MTH bool has_anim () const { return animation_id; }
704 const animation &anim () const { return animations [animation_id]; } 716 const animation &anim () const { return animations [animation_id]; }
705 faceidx get_anim_frame (int frame) const { return anim ().faces [frame]; } 717 MTH faceidx get_anim_frame (int frame) const { return anim ().faces [frame]; }
706 void set_anim_frame (int frame) { face = get_anim_frame (frame); } 718 MTH void set_anim_frame (int frame) { face = get_anim_frame (frame); }
707 /* anim_frames () returns the number of animations allocated. The last 719 /* anim_frames () returns the number of animations allocated. The last
708 * usuable animation will be anim_frames () - 1 (for example, if an object 720 * usuable animation will be anim_frames () - 1 (for example, if an object
709 * has 8 animations, anim_frames () will return 8, but the values will 721 * has 8 animations, anim_frames () will return 8, but the values will
710 * range from 0 through 7. 722 * range from 0 through 7.
711 */ 723 */
712 int anim_frames () const { return anim ().num_animations; } 724 MTH int anim_frames () const { return anim ().num_animations; }
713 int anim_facings () const { return anim ().facings; } 725 MTH int anim_facings () const { return anim ().facings; }
726
727 MTH char *as_string ();
714 728
715protected: 729protected:
716 void link (); 730 void link ();
717 void unlink (); 731 void unlink ();
718 732
727// move this object to the top of its env's inventory to speed up 741// move this object to the top of its env's inventory to speed up
728// searches for it. 742// searches for it.
729static object * 743static object *
730splay (object *ob) 744splay (object *ob)
731{ 745{
732 if (ob->env && ob->env->inv != ob) 746 if (ob->above && ob->env)
733 { 747 {
734 if (ob->above) ob->above->below = ob->below; 748 if (ob->above) ob->above->below = ob->below;
735 if (ob->below) ob->below->above = ob->above; 749 if (ob->below) ob->below->above = ob->above;
736 750
737 ob->above = 0; 751 ob->above = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines