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.11 2006/08/29 05:03:55 root 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 | |
… | |
… | |
26 | The authors can be reached via e-mail at crossfire-devel@real-time.com |
26 | The authors can be reached via e-mail at crossfire-devel@real-time.com |
27 | */ |
27 | */ |
28 | |
28 | |
29 | #ifndef OBJECT_H |
29 | #ifndef OBJECT_H |
30 | #define OBJECT_H |
30 | #define OBJECT_H |
|
|
31 | |
|
|
32 | #include "cfperl.h" |
|
|
33 | #include "shstr.h" |
31 | |
34 | |
32 | typedef uint32 tag_t; |
35 | typedef uint32 tag_t; |
33 | #define NUM_BODY_LOCATIONS 12 |
36 | #define NUM_BODY_LOCATIONS 12 |
34 | #define BODY_ARMS 1 |
37 | #define BODY_ARMS 1 |
35 | |
38 | |
… | |
… | |
95 | * more logically together (put the item related ones together, the monster |
98 | * more logically together (put the item related ones together, the monster |
96 | * related ones, etc. |
99 | * related ones, etc. |
97 | * This structure is best viewed with about a 100 width screen. |
100 | * This structure is best viewed with about a 100 width screen. |
98 | * MSW 2002-07-05 |
101 | * MSW 2002-07-05 |
99 | */ |
102 | */ |
100 | typedef struct obj { |
103 | |
|
|
104 | struct object_simple : attachable<object> { |
|
|
105 | static data_type get_dt () { return DT_OBJECT; } |
|
|
106 | |
101 | /* These variables are not changed by copy_object() */ |
107 | /* These variables are not changed by copy_object() */ |
102 | struct pl *contr; /* Pointer to the player which control this object */ |
108 | 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 */ |
109 | 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*/ |
110 | struct object *prev; /* Pointer to the previous object in the free/used list*/ |
105 | struct obj *active_next; /* Next & previous object in the 'active' */ |
111 | struct object *active_next; /* Next & previous object in the 'active' */ |
106 | struct obj *active_prev; /* List. This is used in process_events */ |
112 | struct object *active_prev; /* List. This is used in process_events */ |
107 | /* so that the entire object list does not */ |
113 | /* so that the entire object list does not */ |
108 | /* need to be gone through. */ |
114 | /* need to be gone through. */ |
109 | struct obj *below; /* Pointer to the object stacked below this one */ |
115 | struct object *below; /* Pointer to the object stacked below this one */ |
110 | struct obj *above; /* Pointer to the object stacked above this one */ |
116 | struct object *above; /* Pointer to the object stacked above this one */ |
111 | /* Note: stacked in the *same* environment*/ |
117 | /* Note: stacked in the *same* environment*/ |
112 | struct obj *inv; /* Pointer to the first object in the inventory */ |
118 | struct object *inv; /* Pointer to the first object in the inventory */ |
113 | struct obj *container; /* Current container being used. I think this |
119 | struct object *container; /* Current container being used. I think this |
114 | * is only used by the player right now. |
120 | * is only used by the player right now. |
115 | */ |
121 | */ |
116 | struct obj *env; /* Pointer to the object which is the environment. |
122 | struct object *env; /* Pointer to the object which is the environment. |
117 | * This is typically the container that the object is in. |
123 | * This is typically the container that the object is in. |
118 | */ |
124 | */ |
119 | struct obj *more; /* Pointer to the rest of a large body of objects */ |
125 | 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 */ |
126 | 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 */ |
127 | struct mapstruct *map; /* Pointer to the map in which this object is present */ |
122 | |
128 | |
123 | tag_t count; /* Unique object number for this object */ |
129 | tag_t count; /* Unique object number for this object */ |
124 | uint16 refcount; /* How many objects points to this object */ |
130 | uint16 refcount; /* How many objects points to this object */ |
|
|
131 | }; |
125 | |
132 | |
|
|
133 | struct object_special { |
126 | /* These get an extra add_refcount(), after having been copied by memcpy(). |
134 | /* These get an extra add_refcount(), after having been copied by memcpy(). |
127 | * All fields beow this point are automatically copied by memcpy. If |
135 | * All fields beow this point are automatically copied by memcpy. If |
128 | * adding something that needs a refcount updated, make sure you modify |
136 | * adding something that needs a refcount updated, make sure you modify |
129 | * copy_object to do so. Everything below here also gets cleared |
137 | * copy_object to do so. Everything below here also gets cleared |
130 | * by clear_object() |
138 | * by clear_object() |
… | |
… | |
179 | sint32 weight_limit; /* Weight-limit of object */ |
187 | sint32 weight_limit; /* Weight-limit of object */ |
180 | sint32 carrying; /* How much weight this object contains */ |
188 | sint32 carrying; /* How much weight this object contains */ |
181 | sint8 glow_radius; /* indicates the glow radius of the object */ |
189 | sint8 glow_radius; /* indicates the glow radius of the object */ |
182 | living stats; /* Str, Con, Dex, etc */ |
190 | living stats; /* Str, Con, Dex, etc */ |
183 | sint64 perm_exp; /* Permanent exp */ |
191 | sint64 perm_exp; /* Permanent exp */ |
184 | const char *current_weapon_script; /* The script of the currently used weapon. Executed */ |
|
|
185 | /* each time the object attacks something */ |
|
|
186 | struct obj *current_weapon; /* Pointer to the weapon currently used */ |
192 | struct object *current_weapon; /* Pointer to the weapon currently used */ |
187 | uint32 weapontype; /* type of weapon */ |
193 | uint32 weapontype; /* type of weapon */ |
188 | uint32 tooltype; /* type of tool or build facility */ |
194 | uint32 tooltype; /* type of tool or build facility */ |
189 | sint8 body_info[NUM_BODY_LOCATIONS]; /* body info as loaded from the file */ |
195 | 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 */ |
196 | sint8 body_used[NUM_BODY_LOCATIONS]; /* Calculated value based on items equipped */ |
191 | /* See the doc/Developers/objects for more info about body locations */ |
197 | /* See the doc/Developers/objects for more info about body locations */ |
192 | |
198 | |
193 | /* Following mostly refers to fields only used for monsters */ |
199 | /* Following mostly refers to fields only used for monsters */ |
194 | struct obj *owner; /* Pointer to the object which controls this one */ |
200 | struct object *owner; /* Pointer to the object which controls this one */ |
195 | /* Owner should not be referred to directly - */ |
201 | /* Owner should not be referred to directly - */ |
196 | /* get_owner should be used instead. */ |
202 | /* get_owner should be used instead. */ |
197 | tag_t ownercount; /* What count the owner had (in case owner */ |
203 | tag_t ownercount; /* What count the owner had (in case owner */ |
198 | /* has been freed) */ |
204 | /* has been freed) */ |
199 | struct obj *enemy; /* Monster/player to follow even if not closest */ |
205 | 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 */ |
206 | 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 */ |
207 | tag_t attacked_by_count; /* the tag of attacker, so we can be sure */ |
202 | struct treasureliststruct *randomitems; /* Items to be generated */ |
208 | struct treasureliststruct *randomitems; /* Items to be generated */ |
203 | uint16 run_away; /* Monster runs away if it's hp goes below this percentage. */ |
209 | uint16 run_away; /* Monster runs away if it's hp goes below this percentage. */ |
204 | struct obj *chosen_skill; /* the skill chosen to use */ |
210 | struct object *chosen_skill; /* the skill chosen to use */ |
205 | uint32 hide; /* The object is hidden, not invisible */ |
211 | uint32 hide; /* The object is hidden, not invisible */ |
206 | /* changes made by kholland@sunlab.cit.cornell.edu */ |
212 | /* changes made by kholland@sunlab.cit.cornell.edu */ |
207 | /* allows different movement patterns for attackers */ |
213 | /* allows different movement patterns for attackers */ |
208 | sint32 move_status; /* What stage in attack mode */ |
214 | sint32 move_status; /* What stage in attack mode */ |
209 | uint16 attack_movement;/* What kind of attack movement */ |
215 | uint16 attack_movement;/* What kind of attack movement */ |
210 | uint8 will_apply; /* See crossfire.doc */ |
216 | uint8 will_apply; /* See crossfire.doc */ |
211 | struct obj *spellitem; /* Spell ability monster is choosing to use */ |
217 | struct object *spellitem; /* Spell ability monster is choosing to use */ |
212 | double expmul; /* needed experience = (calc_exp*expmul) - means some */ |
218 | double expmul; /* needed experience = (calc_exp*expmul) - means some */ |
213 | /* races/classes can need less/more exp to gain levels */ |
219 | /* races/classes can need less/more exp to gain levels */ |
214 | |
220 | |
215 | /* Spell related information, may be useful elsewhere |
221 | /* Spell related information, may be useful elsewhere |
216 | * Note that other fields are used - these files are basically |
222 | * Note that other fields are used - these files are basically |
217 | * only used in spells. |
223 | * only used in spells. |
218 | */ |
224 | */ |
219 | sint16 duration; /* How long the spell lasts */ |
225 | sint16 duration; /* How long the spell lasts */ |
220 | uint8 duration_modifier; /* how level modifies duration */ |
226 | uint8 duration_modifier; /* how level modifies duration */ |
221 | sint16 casting_time; /* time left before spell goes off */ |
227 | sint16 casting_time; /* time left before spell goes off */ |
222 | struct obj *spell; /* Spell that was being cast */ |
228 | struct object *spell; /* Spell that was being cast */ |
223 | uint16 start_holding; |
229 | uint16 start_holding; |
224 | char *spellarg; |
230 | char *spellarg; |
225 | uint8 dam_modifier; /* How going up in level effects damage */ |
231 | uint8 dam_modifier; /* How going up in level effects damage */ |
226 | sint8 range; /* Range of the spell */ |
232 | sint8 range; /* Range of the spell */ |
227 | uint8 range_modifier; /* How going up in level effects range */ |
233 | uint8 range_modifier; /* How going up in level effects range */ |
… | |
… | |
247 | |
253 | |
248 | event *events; |
254 | event *events; |
249 | |
255 | |
250 | const char *custom_name; /* Custom name assigned by player */ |
256 | const char *custom_name; /* Custom name assigned by player */ |
251 | key_value *key_values; /* Fields not explictly known by the loader. */ |
257 | key_value *key_values; /* Fields not explictly known by the loader. */ |
252 | } object; |
258 | }; |
|
|
259 | |
|
|
260 | struct object : object_special, object_simple { |
|
|
261 | void clone (object *destination) |
|
|
262 | { |
|
|
263 | if (attach) |
|
|
264 | destination->attach = add_refcount (attach); |
|
|
265 | |
|
|
266 | if (self || cb) |
|
|
267 | INVOKE_OBJECT (CLONE, this, ARG_OBJECT (destination)); |
|
|
268 | } |
|
|
269 | }; |
253 | |
270 | |
254 | typedef struct oblnk { /* Used to link together several objects */ |
271 | typedef struct oblnk { /* Used to link together several objects */ |
255 | object *ob; |
272 | object *ob; |
256 | struct oblnk *next; |
273 | struct oblnk *next; |
257 | tag_t id; |
274 | tag_t id; |
… | |
… | |
343 | #define ARCH_SINGULARITY_LEN 11 |
360 | #define ARCH_SINGULARITY_LEN 11 |
344 | #define ARCH_DETECT_MAGIC "detect_magic" |
361 | #define ARCH_DETECT_MAGIC "detect_magic" |
345 | #define ARCH_DEPLETION "depletion" |
362 | #define ARCH_DEPLETION "depletion" |
346 | #define ARCH_SYMPTOM "symptom" |
363 | #define ARCH_SYMPTOM "symptom" |
347 | |
364 | |
348 | extern void (*object_free_callback)(object *ob); // called for every object_free |
|
|
349 | |
|
|
350 | #endif |
365 | #endif |