1 | /* |
1 | /* |
2 | * static char *rcsid_object_h = |
2 | * static char *rcsid_object_h = |
3 | * "$Id: object.h,v 1.3 2006/02/22 18:53:48 elmex Exp $"; |
3 | * "$Id: object.h,v 1.4 2006/08/13 17:16:02 elmex Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
95 | * more logically together (put the item related ones together, the monster |
95 | * more logically together (put the item related ones together, the monster |
96 | * related ones, etc. |
96 | * related ones, etc. |
97 | * This structure is best viewed with about a 100 width screen. |
97 | * This structure is best viewed with about a 100 width screen. |
98 | * MSW 2002-07-05 |
98 | * MSW 2002-07-05 |
99 | */ |
99 | */ |
100 | typedef struct obj { |
100 | |
|
|
101 | struct object_simple { |
101 | /* These variables are not changed by copy_object() */ |
102 | /* These variables are not changed by copy_object() */ |
102 | struct pl *contr; /* Pointer to the player which control this object */ |
103 | struct pl *contr; /* Pointer to the player which control this object */ |
103 | struct obj *next; /* Pointer to the next object in the free/used list */ |
104 | struct object *next; /* Pointer to the next object in the free/used list */ |
104 | struct obj *prev; /* Pointer to the previous object in the free/used list*/ |
105 | struct object *prev; /* Pointer to the previous object in the free/used list*/ |
105 | struct obj *active_next; /* Next & previous object in the 'active' */ |
106 | struct object *active_next; /* Next & previous object in the 'active' */ |
106 | struct obj *active_prev; /* List. This is used in process_events */ |
107 | struct object *active_prev; /* List. This is used in process_events */ |
107 | /* so that the entire object list does not */ |
108 | /* so that the entire object list does not */ |
108 | /* need to be gone through. */ |
109 | /* need to be gone through. */ |
109 | struct obj *below; /* Pointer to the object stacked below this one */ |
110 | struct object *below; /* Pointer to the object stacked below this one */ |
110 | struct obj *above; /* Pointer to the object stacked above this one */ |
111 | struct object *above; /* Pointer to the object stacked above this one */ |
111 | /* Note: stacked in the *same* environment*/ |
112 | /* Note: stacked in the *same* environment*/ |
112 | struct obj *inv; /* Pointer to the first object in the inventory */ |
113 | struct object *inv; /* Pointer to the first object in the inventory */ |
113 | struct obj *container; /* Current container being used. I think this |
114 | struct object *container; /* Current container being used. I think this |
114 | * is only used by the player right now. |
115 | * is only used by the player right now. |
115 | */ |
116 | */ |
116 | struct obj *env; /* Pointer to the object which is the environment. |
117 | struct object *env; /* Pointer to the object which is the environment. |
117 | * This is typically the container that the object is in. |
118 | * This is typically the container that the object is in. |
118 | */ |
119 | */ |
119 | struct obj *more; /* Pointer to the rest of a large body of objects */ |
120 | struct object *more; /* Pointer to the rest of a large body of objects */ |
120 | struct obj *head; /* Points to the main object of a large body */ |
121 | struct object *head; /* Points to the main object of a large body */ |
121 | struct mapdef *map; /* Pointer to the map in which this object is present */ |
122 | struct mapstruct *map; /* Pointer to the map in which this object is present */ |
122 | |
123 | |
123 | tag_t count; /* Unique object number for this object */ |
124 | tag_t count; /* Unique object number for this object */ |
124 | uint16 refcount; /* How many objects points to this object */ |
125 | uint16 refcount; /* How many objects points to this object */ |
|
|
126 | }; |
125 | |
127 | |
|
|
128 | struct object_special { |
126 | /* These get an extra add_refcount(), after having been copied by memcpy(). |
129 | /* These get an extra add_refcount(), after having been copied by memcpy(). |
127 | * All fields beow this point are automatically copied by memcpy. If |
130 | * All fields beow this point are automatically copied by memcpy. If |
128 | * adding something that needs a refcount updated, make sure you modify |
131 | * adding something that needs a refcount updated, make sure you modify |
129 | * copy_object to do so. Everything below here also gets cleared |
132 | * copy_object to do so. Everything below here also gets cleared |
130 | * by clear_object() |
133 | * by clear_object() |
… | |
… | |
181 | sint8 glow_radius; /* indicates the glow radius of the object */ |
184 | sint8 glow_radius; /* indicates the glow radius of the object */ |
182 | living stats; /* Str, Con, Dex, etc */ |
185 | living stats; /* Str, Con, Dex, etc */ |
183 | sint64 perm_exp; /* Permanent exp */ |
186 | sint64 perm_exp; /* Permanent exp */ |
184 | const char *current_weapon_script; /* The script of the currently used weapon. Executed */ |
187 | const char *current_weapon_script; /* The script of the currently used weapon. Executed */ |
185 | /* each time the object attacks something */ |
188 | /* each time the object attacks something */ |
186 | struct obj *current_weapon; /* Pointer to the weapon currently used */ |
189 | struct object *current_weapon; /* Pointer to the weapon currently used */ |
187 | uint32 weapontype; /* type of weapon */ |
190 | uint32 weapontype; /* type of weapon */ |
188 | uint32 tooltype; /* type of tool or build facility */ |
191 | uint32 tooltype; /* type of tool or build facility */ |
189 | sint8 body_info[NUM_BODY_LOCATIONS]; /* body info as loaded from the file */ |
192 | sint8 body_info[NUM_BODY_LOCATIONS]; /* body info as loaded from the file */ |
190 | sint8 body_used[NUM_BODY_LOCATIONS]; /* Calculated value based on items equipped */ |
193 | sint8 body_used[NUM_BODY_LOCATIONS]; /* Calculated value based on items equipped */ |
191 | /* See the doc/Developers/objects for more info about body locations */ |
194 | /* See the doc/Developers/objects for more info about body locations */ |
192 | |
195 | |
193 | /* Following mostly refers to fields only used for monsters */ |
196 | /* Following mostly refers to fields only used for monsters */ |
194 | struct obj *owner; /* Pointer to the object which controls this one */ |
197 | struct object *owner; /* Pointer to the object which controls this one */ |
195 | /* Owner should not be referred to directly - */ |
198 | /* Owner should not be referred to directly - */ |
196 | /* get_owner should be used instead. */ |
199 | /* get_owner should be used instead. */ |
197 | tag_t ownercount; /* What count the owner had (in case owner */ |
200 | tag_t ownercount; /* What count the owner had (in case owner */ |
198 | /* has been freed) */ |
201 | /* has been freed) */ |
199 | struct obj *enemy; /* Monster/player to follow even if not closest */ |
202 | struct object *enemy; /* Monster/player to follow even if not closest */ |
200 | struct obj *attacked_by; /* This object start to attack us! only player & monster */ |
203 | struct object *attacked_by; /* This object start to attack us! only player & monster */ |
201 | tag_t attacked_by_count; /* the tag of attacker, so we can be sure */ |
204 | tag_t attacked_by_count; /* the tag of attacker, so we can be sure */ |
202 | struct treasureliststruct *randomitems; /* Items to be generated */ |
205 | struct treasureliststruct *randomitems; /* Items to be generated */ |
203 | uint16 run_away; /* Monster runs away if it's hp goes below this percentage. */ |
206 | uint16 run_away; /* Monster runs away if it's hp goes below this percentage. */ |
204 | struct obj *chosen_skill; /* the skill chosen to use */ |
207 | struct object *chosen_skill; /* the skill chosen to use */ |
205 | uint32 hide; /* The object is hidden, not invisible */ |
208 | uint32 hide; /* The object is hidden, not invisible */ |
206 | /* changes made by kholland@sunlab.cit.cornell.edu */ |
209 | /* changes made by kholland@sunlab.cit.cornell.edu */ |
207 | /* allows different movement patterns for attackers */ |
210 | /* allows different movement patterns for attackers */ |
208 | sint32 move_status; /* What stage in attack mode */ |
211 | sint32 move_status; /* What stage in attack mode */ |
209 | uint16 attack_movement;/* What kind of attack movement */ |
212 | uint16 attack_movement;/* What kind of attack movement */ |
210 | uint8 will_apply; /* See crossfire.doc */ |
213 | uint8 will_apply; /* See crossfire.doc */ |
211 | struct obj *spellitem; /* Spell ability monster is choosing to use */ |
214 | struct object *spellitem; /* Spell ability monster is choosing to use */ |
212 | double expmul; /* needed experience = (calc_exp*expmul) - means some */ |
215 | double expmul; /* needed experience = (calc_exp*expmul) - means some */ |
213 | /* races/classes can need less/more exp to gain levels */ |
216 | /* races/classes can need less/more exp to gain levels */ |
214 | |
217 | |
215 | /* Spell related information, may be useful elsewhere |
218 | /* Spell related information, may be useful elsewhere |
216 | * Note that other fields are used - these files are basically |
219 | * Note that other fields are used - these files are basically |
217 | * only used in spells. |
220 | * only used in spells. |
218 | */ |
221 | */ |
219 | sint16 duration; /* How long the spell lasts */ |
222 | sint16 duration; /* How long the spell lasts */ |
220 | uint8 duration_modifier; /* how level modifies duration */ |
223 | uint8 duration_modifier; /* how level modifies duration */ |
221 | sint16 casting_time; /* time left before spell goes off */ |
224 | sint16 casting_time; /* time left before spell goes off */ |
222 | struct obj *spell; /* Spell that was being cast */ |
225 | struct object *spell; /* Spell that was being cast */ |
223 | uint16 start_holding; |
226 | uint16 start_holding; |
224 | char *spellarg; |
227 | char *spellarg; |
225 | uint8 dam_modifier; /* How going up in level effects damage */ |
228 | uint8 dam_modifier; /* How going up in level effects damage */ |
226 | sint8 range; /* Range of the spell */ |
229 | sint8 range; /* Range of the spell */ |
227 | uint8 range_modifier; /* How going up in level effects range */ |
230 | uint8 range_modifier; /* How going up in level effects range */ |
… | |
… | |
247 | |
250 | |
248 | event *events; |
251 | event *events; |
249 | |
252 | |
250 | const char *custom_name; /* Custom name assigned by player */ |
253 | const char *custom_name; /* Custom name assigned by player */ |
251 | key_value *key_values; /* Fields not explictly known by the loader. */ |
254 | key_value *key_values; /* Fields not explictly known by the loader. */ |
252 | } object; |
255 | }; |
|
|
256 | |
|
|
257 | struct object : object_special, object_simple { |
|
|
258 | }; |
253 | |
259 | |
254 | typedef struct oblnk { /* Used to link together several objects */ |
260 | typedef struct oblnk { /* Used to link together several objects */ |
255 | object *ob; |
261 | object *ob; |
256 | struct oblnk *next; |
262 | struct oblnk *next; |
257 | tag_t id; |
263 | tag_t id; |