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.196 by root, Thu Jan 8 03:03:24 2009 UTC vs.
Revision 1.201 by root, Sat Jun 27 03:51:05 2009 UTC

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
266 266
267 sint8 ACC (RW, item_power); /* power rating of the object */ 267 sint8 ACC (RW, item_power); /* power rating of the object */
268 // 8 free bits 268 // 8 free bits
269 269
270 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 */
271 char *ACC (RW, spellarg); 271 shstr ACC (RW, spellarg); /* only used in arrows - get rid of it? */
272 272
273 /* Following are values used by any object */ 273 /* Following are values used by any object */
274 /* this objects turns into or what this object creates */ 274 /* this objects turns into or what this object creates */
275 treasurelist *ACC (RW, randomitems); /* Items to be generated */ 275 treasurelist *ACC (RW, randomitems); /* Items to be generated */
276 276
290 shstr ACC (RW, msg); /* If this is a book/sign/magic mouth/etc */ 290 shstr ACC (RW, msg); /* If this is a book/sign/magic mouth/etc */
291 shstr ACC (RW, lore); /* Obscure information about this object, */ 291 shstr ACC (RW, lore); /* Obscure information about this object, */
292 /* To get put into books and the like. */ 292 /* To get put into books and the like. */
293 shstr ACC (RW, custom_name); /* Custom name assigned by player */ 293 shstr ACC (RW, custom_name); /* Custom name assigned by player */
294}; 294};
295
296const char *query_weight (const object *op);
297const char *query_short_name (const object *op);
298const char *query_name (const object *op);
299const char *query_base_name (const object *op, int plural);
295 300
296struct object : zero_initialised, object_copy 301struct object : zero_initialised, object_copy
297{ 302{
298 // These variables are not changed by ->copy_to 303 // These variables are not changed by ->copy_to
299 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 */
378 } 383 }
379 384
380 // 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
381 MTH void destroy_inv (bool drop_to_ground = false); 386 MTH void destroy_inv (bool drop_to_ground = false);
382 MTH object *insert (object *item); // insert into inventory 387 MTH object *insert (object *item); // insert into inventory
383 MTH void play_sound (faceidx sound); 388 MTH void play_sound (faceidx sound) const;
389 MTH void say_msg (const char *msg) const;
384 390
385 void do_remove (); 391 void do_remove ();
386 MTH void remove () 392 MTH void remove ()
387 { 393 {
388 if (!flag [FLAG_REMOVED]) 394 if (!flag [FLAG_REMOVED])
416 && can_merge_slow (op1, op2); 422 && can_merge_slow (op1, op2);
417 } 423 }
418 424
419 MTH void set_owner (object *owner); 425 MTH void set_owner (object *owner);
420 MTH void set_speed (float speed); 426 MTH void set_speed (float speed);
427 MTH void set_glow_radius (sint8 rad);
421 MTH bool change_weapon (object *ob); 428 MTH bool change_weapon (object *ob);
422 MTH bool change_skill (object *ob); 429 MTH bool change_skill (object *ob);
423 430
424 MTH void open_container (object *new_container); 431 MTH void open_container (object *new_container);
425 MTH void close_container () 432 MTH void close_container ()
523 530
524 return op; 531 return op;
525 } 532 }
526 533
527 // returns the outermost environment, never returns 0 534 // returns the outermost environment, never returns 0
528 MTH object *outer_env () 535 MTH object *outer_env () const
529 { 536 {
530 object *op; 537 const object *op;
531 538
532 for (op = this; op->env; op = op->env) 539 for (op = this; op->env; op = op->env)
533 ; 540 ;
534 541
535 return op; 542 return const_cast<object *>(op);
536 } 543 }
537 544
538 // returns the player that has this object in his inventory, or 0 545 // returns the player that has this object in his inventory, or 0
539 // we assume the player is always the outer env 546 // we assume the player is always the outer env
540 MTH object *in_player () 547 MTH object *in_player () const
541 { 548 {
542 object *op = outer_env (); 549 object *op = outer_env ();
543 550
544 return op->type == PLAYER ? op : 0; 551 return op->type == PLAYER ? op : 0;
545 } 552 }
546 553
547 // "temporary" helper function 554 // "temporary" helper function
548 MTH object *head_ () 555 MTH object *head_ () const
549 { 556 {
550 return head ? head : this; 557 return head ? head : const_cast<object *>(this);
551 } 558 }
552 559
553 MTH bool is_head () 560 MTH bool is_head () const
554 { 561 {
555 return head_ () == this; 562 return head_ () == this;
556 } 563 }
557 564
558 MTH bool is_on_map () const 565 MTH bool is_on_map () const
585 592
586 MTH std::string long_desc (object *who = 0); 593 MTH std::string long_desc (object *who = 0);
587 MTH std::string describe_monster (object *who = 0); 594 MTH std::string describe_monster (object *who = 0);
588 MTH std::string describe_item (object *who = 0); 595 MTH std::string describe_item (object *who = 0);
589 MTH std::string describe (object *who = 0); 596 MTH std::string describe (object *who = 0);
597
598 MTH const char *query_weight () { return ::query_weight (this); }
599 MTH const char *query_name () { return ::query_name (this); }
600 MTH const char *query_short_name () { return ::query_short_name (this); }
601 MTH const char *query_base_name (bool plural) { return ::query_base_name (this, plural); }
590 602
591 // If this object has no extra parts but should have them, 603 // If this object has no extra parts but should have them,
592 // add them, effectively expanding heads into multipart 604 // add them, effectively expanding heads into multipart
593 // objects. This method only works on objects not inserted 605 // objects. This method only works on objects not inserted
594 // anywhere. 606 // anywhere.
682 694
683 // make some noise with given item into direction dir, 695 // make some noise with given item into direction dir,
684 // currently only used for players to make them temporarily visible 696 // currently only used for players to make them temporarily visible
685 // when they are invisible. 697 // when they are invisible.
686 MTH void make_noise (); 698 MTH void make_noise ();
699
700 /* animation */
701 bool has_anim () { return animation_id; }
702 const animation &anim () const { return animations [animation_id]; }
703 faceidx get_anim_frame (int frame) const { return anim ().faces [frame]; }
704 void set_anim_frame (int frame) { face = get_anim_frame (frame); }
705 /* anim_frames () returns the number of animations allocated. The last
706 * usuable animation will be anim_frames () - 1 (for example, if an object
707 * has 8 animations, anim_frames () will return 8, but the values will
708 * range from 0 through 7.
709 */
710 int anim_frames () const { return anim ().num_animations; }
711 int anim_facings () const { return anim ().facings; }
687 712
688protected: 713protected:
689 void link (); 714 void link ();
690 void unlink (); 715 void unlink ();
691 716

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines