Crossfire Server, Branch 1.12  R12190
object.h
Go to the documentation of this file.
00001 /*
00002  * static char *rcsid_object_h =
00003  *   "$Id: object.h 11578 2009-02-23 22:02:27Z lalo $";
00004  */
00005 
00006 /*
00007     CrossFire, A Multiplayer game for X-windows
00008 
00009     Copyright (C) 2001 Mark Wedel & Crossfire Development Team
00010     Copyright (C) 1992 Frank Tore Johansen
00011 
00012     This program is free software; you can redistribute it and/or modify
00013     it under the terms of the GNU General Public License as published by
00014     the Free Software Foundation; either version 2 of the License, or
00015     (at your option) any later version.
00016 
00017     This program is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020     GNU General Public License for more details.
00021 
00022     You should have received a copy of the GNU General Public License
00023     along with this program; if not, write to the Free Software
00024     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00025 
00026     The authors can be reached via e-mail at crossfire-devel@real-time.com
00027 */
00028 
00034 #include "dialog.h"
00035 
00036 #ifndef OBJECT_H
00037 #define OBJECT_H
00038 
00040 typedef uint32 tag_t;
00041 #define NUM_BODY_LOCATIONS      13  
00042 #define BODY_ARMS               1   
00048 typedef struct body_locations_struct {
00049     const char *save_name;      
00050     const char *use_name;       
00051     const char *nonuse_name;    
00052 } body_locations_struct;
00053 
00054 extern body_locations_struct body_locations[NUM_BODY_LOCATIONS];
00055 
00066 typedef struct _key_value {
00067     const char *key;
00068     const char *value;
00069     struct _key_value *next;
00070 } key_value;
00071 
00078 #define WILL_APPLY_HANDLE       0x1
00079 #define WILL_APPLY_TREASURE     0x2
00080 #define WILL_APPLY_EARTHWALL    0x4
00081 #define WILL_APPLY_DOOR         0x8
00082 #define WILL_APPLY_FOOD         0x10
00083 
00094 #define was_destroyed(op, old_tag) \
00095     (op->count != old_tag || QUERY_FLAG(op, FLAG_FREED))
00096 
00097 
00107 #define SPELL_TAG_SIZE 16
00108 #define OB_SPELL_TAG_HASH(op, count)    (op->spell_tags[count&0xf])
00109 #define OB_SPELL_TAG_MATCH(op, count)   (op->spell_tags[count&0xf] == count)
00110 
00132 typedef struct obj {
00133     /* These variables are not changed by copy_object() */
00134     struct pl   *contr;         
00135     struct obj  *next;          
00136     struct obj  *prev;          
00137     struct obj  *active_next;   
00141     struct obj  *active_prev;   
00145     struct obj  *below;         
00146     struct obj  *above;         
00147                                 /* Note: stacked in the *same *environment*/
00148     struct obj  *inv;           
00149     struct obj  *container;     
00151     struct obj  *env;           
00153     struct obj  *more;          
00154     struct obj  *head;          
00155     struct mapdef *map;         
00157     tag_t       count;          
00158     struct struct_dialog_information *dialog_information; 
00161     /* These get an extra add_refcount(), after having been copied by memcpy().
00162      * All fields beow this point are automatically copied by memcpy.  If
00163      * adding something that needs a refcount updated, make sure you modify
00164      * copy_object to do so.  Everything below here also gets cleared
00165      * by clear_object()
00166      */
00167     const char  *name;          
00168     const char  *name_pl;       
00169     const char  *anim_suffix;   
00170     const char  *title;         
00171     const char  *race;          
00172     const char  *slaying;       
00174     const char  *skill;         
00175     const char  *msg;           
00176     const char  *lore;          
00179     sint16      x, y;           
00180     sint16      ox, oy;         
00181     float       speed;          
00182     float       speed_left;     
00183     New_Face    *face;          
00184     uint32      nrof;           
00185     sint8       direction;      
00186     sint8       facing;         
00188     /* This next big block are basically used for monsters and equipment */
00189     uint8       type;           
00190     uint8       subtype;        
00191     uint16      client_type;    
00192     sint16      resist[NROFATTACKS]; 
00193     uint32      attacktype;     
00194     uint32      path_attuned;   
00195     uint32      path_repelled;  
00196     uint32      path_denied;    
00197     const char  *materialname;  
00198     uint16      material;       
00199     sint8       magic;          
00200     uint8       state;          
00201     sint32      value;          
00202     sint16      level;          
00204     /* Note that the last_.. values are sometimes used for non obvious
00205      * meanings by some objects, eg, sp penalty, permanent exp.
00206      */
00207     sint32      last_eat;       
00208     sint32      last_heal;      
00209     sint32      last_sp;        
00210     sint16      last_grace;     
00211     sint16      invisible;      
00212     uint8       pick_up;        
00213     sint8       item_power;     
00214     sint8       gen_sp_armour;  
00215     sint8       glow_radius;    
00216     sint32      weight;         
00217     sint32      weight_limit;   
00218     sint32      carrying;       
00219     living      stats;          
00220     sint64      perm_exp;       
00221     struct obj  *current_weapon; 
00222     uint32      weapontype;     
00223     sint8       body_info[NUM_BODY_LOCATIONS];  
00224     sint8       body_used[NUM_BODY_LOCATIONS];  
00225                                 /* See the doc/Developers/objects for more info about body locations */
00226 
00227     /* Following mostly refers to fields only used for monsters */
00228     struct obj  *owner;         
00231     tag_t       ownercount;     
00232     struct obj  *enemy;         
00233     struct obj  *attacked_by;   
00234     tag_t       attacked_by_count; 
00235     uint16      run_away;          
00236     struct treasureliststruct *randomitems; 
00237     struct obj  *chosen_skill;  
00238     uint32      hide;           
00239     /* changes made by kholland@sunlab.cit.cornell.edu */
00240     /* allows different movement patterns for attackers */
00241     sint32      move_status;    
00242     uint16      attack_movement;
00243     uint8       will_apply;     
00244     sint8       sound_chance;   
00245     struct obj  *spellitem;     
00246     double      expmul;         
00249     /* Spell related information, may be useful elsewhere
00250      * Note that other fields are used - these files are basically
00251      * only used in spells.
00252      */
00253     sint16      casting_time;   
00254     sint16      duration;       
00255     uint8       duration_modifier; 
00256     sint8       range;          
00257     uint8       range_modifier; 
00258     uint8       dam_modifier;   
00259     struct obj  *spell;         
00260     char        *spellarg;
00261 
00262     /* Following are values used by any object */
00263     struct archt *arch;         
00264     struct archt *other_arch;   
00266     uint32      flags[4];       
00267     uint16      animation_id;   
00268     uint8       anim_speed;     
00269     uint8       last_anim;      
00270     uint16      temp_animation_id; 
00271     uint8       temp_anim_speed; 
00272     uint8       temp_last_anim; 
00273     sint32      elevation;      
00274     uint8       smoothlevel;    
00275     uint8       map_layer;      
00277     MoveType    move_type;      
00278     MoveType    move_block;     
00279     MoveType    move_allow;     
00280     MoveType    move_on;        
00281     MoveType    move_off;       
00282     MoveType    move_slow;      
00283     float       move_slow_penalty; 
00285     const char  *custom_name;   
00286     key_value   *key_values;    
00288     uint8       no_save;        
00291     sint16      *discrete_damage; 
00292     tag_t       *spell_tags;
00293 } object;
00294 
00298 typedef struct oblnk {
00299     object *ob;
00300     struct oblnk *next;
00301     tag_t id;
00302 } objectlink;
00303 
00307 typedef struct oblinkpt {
00308     struct oblnk *link;
00309     long value;           
00310     struct oblinkpt *next;
00311 } oblinkpt;
00312 
00321 typedef struct archt {
00322     const char *name;       
00323     struct archt *next;     
00324     struct archt *head;     
00325     struct archt *more;     
00326     object clone;           
00327     sint8 tail_x, tail_y;   
00329     int reference_count;    
00330 } archetype;
00331 
00332 extern object *objects;
00333 extern object *active_objects;
00334 extern object *free_objects;
00335 extern object objarray[STARTMAX];
00336 
00337 extern int nrofallocobjects;
00338 extern int nroffreeobjects;
00339 
00344 #define LOOK_OBJ(ob) (!ob->invisible && ob->type != PLAYER && ob->type != EVENT_CONNECTOR)
00345 
00353 #define UP_OBJ_INSERT   1   
00354 #define UP_OBJ_REMOVE   2   
00355 #define UP_OBJ_CHANGE   3   
00356 #define UP_OBJ_FACE     4   
00360 
00361 
00392 #define INS_NO_MERGE            0x0001
00393 #define INS_ABOVE_FLOOR_ONLY    0x0002
00394 #define INS_NO_WALK_ON          0x0004
00395 #define INS_ON_TOP              0x0008
00396 #define INS_BELOW_ORIGINATOR    0x0010
00397 #define INS_MAP_LOAD            0x0020
00398 
00400 #define ARCH_SINGULARITY        "singularity"   
00401 #define ARCH_SINGULARITY_LEN    11              
00402 #define ARCH_DETECT_MAGIC       "detect_magic"  
00403 #define ARCH_DEPLETION          "depletion"     
00404 #define ARCH_SYMPTOM            "symptom"       
00406 #endif /* OBJECT_H */