1 | /* |
1 | /* |
2 | * static char *rcsid_object_h = |
2 | * static char *rcsid_object_h = |
3 | * "$Id: object.h,v 1.1 2006/02/03 07:12:50 root Exp $"; |
3 | * "$Id: object.h,v 1.13 2006/08/31 09:19:34 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 | |
… | |
… | |
27 | */ |
27 | */ |
28 | |
28 | |
29 | #ifndef OBJECT_H |
29 | #ifndef OBJECT_H |
30 | #define OBJECT_H |
30 | #define OBJECT_H |
31 | |
31 | |
|
|
32 | #include "cfperl.h" |
|
|
33 | #include "shstr.h" |
|
|
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 | |
36 | /* See common/item.c */ |
39 | /* See common/item.c */ |
37 | |
40 | |
38 | typedef struct Body_Locations { |
41 | typedef struct Body_Locations { |
39 | char *save_name; /* Name used to load/save it to disk */ |
42 | const char *save_name; /* Name used to load/save it to disk */ |
40 | char *use_name; /* Name used when describing an item we can use */ |
43 | const char *use_name; /* Name used when describing an item we can use */ |
41 | char *nonuse_name; /* Name to describe objects we can't use */ |
44 | const char *nonuse_name; /* Name to describe objects we can't use */ |
42 | } Body_Locations; |
45 | } Body_Locations; |
43 | |
46 | |
44 | extern Body_Locations body_locations[NUM_BODY_LOCATIONS]; |
47 | extern Body_Locations body_locations[NUM_BODY_LOCATIONS]; |
45 | |
48 | |
46 | typedef struct _event |
49 | typedef struct _event |
… | |
… | |
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> { |
101 | /* These variables are not changed by copy_object() */ |
105 | /* These variables are not changed by copy_object() */ |
102 | struct pl *contr; /* Pointer to the player which control this object */ |
106 | 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 */ |
107 | 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*/ |
108 | struct object *prev; /* Pointer to the previous object in the free/used list*/ |
105 | struct obj *active_next; /* Next & previous object in the 'active' */ |
109 | struct object *active_next; /* Next & previous object in the 'active' */ |
106 | struct obj *active_prev; /* List. This is used in process_events */ |
110 | struct object *active_prev; /* List. This is used in process_events */ |
107 | /* so that the entire object list does not */ |
111 | /* so that the entire object list does not */ |
108 | /* need to be gone through. */ |
112 | /* need to be gone through. */ |
109 | struct obj *below; /* Pointer to the object stacked below this one */ |
113 | struct object *below; /* Pointer to the object stacked below this one */ |
110 | struct obj *above; /* Pointer to the object stacked above this one */ |
114 | struct object *above; /* Pointer to the object stacked above this one */ |
111 | /* Note: stacked in the *same* environment*/ |
115 | /* Note: stacked in the *same* environment*/ |
112 | struct obj *inv; /* Pointer to the first object in the inventory */ |
116 | struct object *inv; /* Pointer to the first object in the inventory */ |
113 | struct obj *container; /* Current container being used. I think this |
117 | struct object *container; /* Current container being used. I think this |
114 | * is only used by the player right now. |
118 | * is only used by the player right now. |
115 | */ |
119 | */ |
116 | struct obj *env; /* Pointer to the object which is the environment. |
120 | struct object *env; /* Pointer to the object which is the environment. |
117 | * This is typically the container that the object is in. |
121 | * This is typically the container that the object is in. |
118 | */ |
122 | */ |
119 | struct obj *more; /* Pointer to the rest of a large body of objects */ |
123 | 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 */ |
124 | 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 */ |
125 | struct mapstruct *map; /* Pointer to the map in which this object is present */ |
122 | |
126 | |
123 | tag_t count; /* Unique object number for this object */ |
127 | tag_t count; /* Unique object number for this object */ |
124 | uint16 refcount; /* How many objects points to this object */ |
128 | uint16 refcount; /* How many objects points to this object */ |
|
|
129 | }; |
125 | |
130 | |
|
|
131 | struct object_special { |
126 | /* These get an extra add_refcount(), after having been copied by memcpy(). |
132 | /* These get an extra add_refcount(), after having been copied by memcpy(). |
127 | * All fields beow this point are automatically copied by memcpy. If |
133 | * All fields beow this point are automatically copied by memcpy. If |
128 | * adding something that needs a refcount updated, make sure you modify |
134 | * adding something that needs a refcount updated, make sure you modify |
129 | * copy_object to do so. Everything below here also gets cleared |
135 | * copy_object to do so. Everything below here also gets cleared |
130 | * by clear_object() |
136 | * by clear_object() |
… | |
… | |
132 | const char *name; /* The name of the object, obviously... */ |
138 | const char *name; /* The name of the object, obviously... */ |
133 | const char *name_pl; /* The plural name of the object */ |
139 | const char *name_pl; /* The plural name of the object */ |
134 | const char *title; /* Of foo, etc */ |
140 | const char *title; /* Of foo, etc */ |
135 | const char *race; /* human, goblin, dragon, etc */ |
141 | const char *race; /* human, goblin, dragon, etc */ |
136 | const char *slaying; /* Which race to do double damage to */ |
142 | const char *slaying; /* Which race to do double damage to */ |
137 | /* If this is an exit, this is the filename */ |
143 | /* If this is an exit, this is the filename */ |
138 | const char *skill; /* Name of the skill this object uses/grants */ |
144 | const char *skill; /* Name of the skill this object uses/grants */ |
139 | const char *msg; /* If this is a book/sign/magic mouth/etc */ |
145 | const char *msg; /* If this is a book/sign/magic mouth/etc */ |
140 | const char *lore; /* Obscure information about this object, */ |
146 | const char *lore; /* Obscure information about this object, */ |
141 | /* To get put into books and the like. */ |
147 | /* To get put into books and the like. */ |
142 | |
148 | |
143 | sint16 x,y; /* Position in the map for this object */ |
149 | sint16 x,y; /* Position in the map for this object */ |
144 | sint16 ox,oy; /* For debugging: Where it was last inserted */ |
150 | sint16 ox,oy; /* For debugging: Where it was last inserted */ |
145 | float speed; /* The overall speed of this object */ |
151 | float speed; /* The overall speed of this object */ |
146 | float speed_left; /* How much speed is left to spend this round */ |
152 | float speed_left; /* How much speed is left to spend this round */ |
… | |
… | |
179 | sint32 weight_limit; /* Weight-limit of object */ |
185 | sint32 weight_limit; /* Weight-limit of object */ |
180 | sint32 carrying; /* How much weight this object contains */ |
186 | sint32 carrying; /* How much weight this object contains */ |
181 | sint8 glow_radius; /* indicates the glow radius of the object */ |
187 | sint8 glow_radius; /* indicates the glow radius of the object */ |
182 | living stats; /* Str, Con, Dex, etc */ |
188 | living stats; /* Str, Con, Dex, etc */ |
183 | sint64 perm_exp; /* Permanent exp */ |
189 | 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 */ |
190 | struct object *current_weapon; /* Pointer to the weapon currently used */ |
187 | uint32 weapontype; /* type of weapon */ |
191 | uint32 weapontype; /* type of weapon */ |
188 | uint32 tooltype; /* type of tool or build facility */ |
192 | uint32 tooltype; /* type of tool or build facility */ |
189 | sint8 body_info[NUM_BODY_LOCATIONS]; /* body info as loaded from the file */ |
193 | 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 */ |
194 | sint8 body_used[NUM_BODY_LOCATIONS]; /* Calculated value based on items equipped */ |
191 | /* See the doc/Developers/objects for more info about body locations */ |
195 | /* See the doc/Developers/objects for more info about body locations */ |
192 | |
196 | |
193 | /* Following mostly refers to fields only used for monsters */ |
197 | /* Following mostly refers to fields only used for monsters */ |
194 | struct obj *owner; /* Pointer to the object which controls this one */ |
198 | struct object *owner; /* Pointer to the object which controls this one */ |
195 | /* Owner should not be referred to directly - */ |
199 | /* Owner should not be referred to directly - */ |
196 | /* get_owner should be used instead. */ |
200 | /* get_owner should be used instead. */ |
197 | tag_t ownercount; /* What count the owner had (in case owner */ |
201 | tag_t ownercount; /* What count the owner had (in case owner */ |
198 | /* has been freed) */ |
202 | /* has been freed) */ |
199 | struct obj *enemy; /* Monster/player to follow even if not closest */ |
203 | 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 */ |
204 | 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 */ |
205 | tag_t attacked_by_count; /* the tag of attacker, so we can be sure */ |
202 | struct treasureliststruct *randomitems; /* Items to be generated */ |
206 | struct treasureliststruct *randomitems; /* Items to be generated */ |
203 | uint16 run_away; /* Monster runs away if it's hp goes below this percentage. */ |
207 | uint16 run_away; /* Monster runs away if it's hp goes below this percentage. */ |
204 | struct obj *chosen_skill; /* the skill chosen to use */ |
208 | struct object *chosen_skill; /* the skill chosen to use */ |
205 | uint32 hide; /* The object is hidden, not invisible */ |
209 | uint32 hide; /* The object is hidden, not invisible */ |
206 | /* changes made by kholland@sunlab.cit.cornell.edu */ |
210 | /* changes made by kholland@sunlab.cit.cornell.edu */ |
207 | /* allows different movement patterns for attackers */ |
211 | /* allows different movement patterns for attackers */ |
208 | sint32 move_status; /* What stage in attack mode */ |
212 | sint32 move_status; /* What stage in attack mode */ |
209 | uint16 attack_movement;/* What kind of attack movement */ |
213 | uint16 attack_movement;/* What kind of attack movement */ |
210 | uint8 will_apply; /* See crossfire.doc */ |
214 | uint8 will_apply; /* See crossfire.doc */ |
211 | struct obj *spellitem; /* Spell ability monster is choosing to use */ |
215 | struct object *spellitem; /* Spell ability monster is choosing to use */ |
212 | double expmul; /* needed experience = (calc_exp*expmul) - means some */ |
216 | double expmul; /* needed experience = (calc_exp*expmul) - means some */ |
213 | /* races/classes can need less/more exp to gain levels */ |
217 | /* races/classes can need less/more exp to gain levels */ |
214 | |
218 | |
215 | /* Spell related information, may be useful elsewhere |
219 | /* Spell related information, may be useful elsewhere |
216 | * Note that other fields are used - these files are basically |
220 | * Note that other fields are used - these files are basically |
217 | * only used in spells. |
221 | * only used in spells. |
218 | */ |
222 | */ |
219 | sint16 duration; /* How long the spell lasts */ |
223 | sint16 duration; /* How long the spell lasts */ |
220 | uint8 duration_modifier; /* how level modifies duration */ |
224 | uint8 duration_modifier; /* how level modifies duration */ |
221 | sint16 casting_time; /* time left before spell goes off */ |
225 | sint16 casting_time; /* time left before spell goes off */ |
222 | struct obj *spell; /* Spell that was being cast */ |
226 | struct object *spell; /* Spell that was being cast */ |
223 | uint16 start_holding; |
227 | uint16 start_holding; |
224 | char *spellarg; |
228 | char *spellarg; |
225 | uint8 dam_modifier; /* How going up in level effects damage */ |
229 | uint8 dam_modifier; /* How going up in level effects damage */ |
226 | sint8 range; /* Range of the spell */ |
230 | sint8 range; /* Range of the spell */ |
227 | uint8 range_modifier; /* How going up in level effects range */ |
231 | uint8 range_modifier; /* How going up in level effects range */ |
228 | |
232 | |
229 | /* Following are values used by any object */ |
233 | /* Following are values used by any object */ |
230 | struct archt *arch; /* Pointer to archetype */ |
234 | struct archt *arch; /* Pointer to archetype */ |
231 | struct archt *other_arch; /* Pointer used for various things - mostly used for what */ |
235 | struct archt *other_arch; /* Pointer used for various things - mostly used for what */ |
232 | /* this objects turns into or what this object creates */ |
236 | /* this objects turns into or what this object creates */ |
233 | uint32 flags[4]; /* various flags */ |
237 | uint32 flags[4]; /* various flags */ |
234 | uint16 animation_id; /* An index into the animation array */ |
238 | uint16 animation_id; /* An index into the animation array */ |
235 | uint8 anim_speed; /* ticks between animation-frames */ |
239 | uint8 anim_speed; /* ticks between animation-frames */ |
236 | uint8 last_anim; /* last sequence used to draw face */ |
240 | uint8 last_anim; /* last sequence used to draw face */ |
237 | sint32 elevation; /* elevation of this terrain - not currently used */ |
241 | sint32 elevation; /* elevation of this terrain - not currently used */ |
238 | uint8 smoothlevel; /* how to smooth this square around*/ |
242 | uint8 smoothlevel; /* how to smooth this square around*/ |
239 | |
243 | |
240 | MoveType move_type; /* Type of movement this object uses */ |
244 | MoveType move_type; /* Type of movement this object uses */ |
241 | MoveType move_block; /* What movement types this blocks */ |
245 | MoveType move_block; /* What movement types this blocks */ |
|
|
246 | MoveType move_allow; /* What movement types explicitly allowd */ |
242 | MoveType move_on; /* Move types affected moving on to this space */ |
247 | MoveType move_on; /* Move types affected moving on to this space */ |
243 | MoveType move_off; /* Move types affected moving off this space */ |
248 | MoveType move_off; /* Move types affected moving off this space */ |
244 | MoveType move_slow; /* Movement types this slows down */ |
249 | MoveType move_slow; /* Movement types this slows down */ |
245 | float move_slow_penalty; /* How much this slows down the object */ |
250 | float move_slow_penalty; /* How much this slows down the object */ |
246 | |
251 | |
247 | event *events; |
252 | event *events; |
248 | |
253 | |
249 | const char *custom_name; /* Custom name assigned by player */ |
254 | const char *custom_name; /* Custom name assigned by player */ |
250 | key_value *key_values; /* Fields not explictly known by the loader. */ |
255 | key_value *key_values; /* Fields not explictly known by the loader. */ |
|
|
256 | }; |
251 | |
257 | |
252 | } object; |
258 | struct object : object_special, object_simple { |
|
|
259 | void clone (object *destination) |
|
|
260 | { |
|
|
261 | if (attach) |
|
|
262 | destination->attach = add_refcount (attach); |
|
|
263 | |
|
|
264 | if (self || cb) |
|
|
265 | INVOKE_OBJECT (CLONE, this, ARG_OBJECT (destination)); |
|
|
266 | } |
|
|
267 | }; |
253 | |
268 | |
254 | typedef struct oblnk { /* Used to link together several objects */ |
269 | typedef struct oblnk { /* Used to link together several objects */ |
255 | object *ob; |
270 | object *ob; |
256 | struct oblnk *next; |
271 | struct oblnk *next; |
257 | tag_t id; |
272 | tag_t id; |
… | |
… | |
278 | struct archt *head; /* The main part of a linked object */ |
293 | struct archt *head; /* The main part of a linked object */ |
279 | struct archt *more; /* Next part of a linked object */ |
294 | struct archt *more; /* Next part of a linked object */ |
280 | object clone; /* An object from which to do copy_object() */ |
295 | object clone; /* An object from which to do copy_object() */ |
281 | uint32 editable; /* editable flags (mainly for editor) */ |
296 | uint32 editable; /* editable flags (mainly for editor) */ |
282 | sint8 tail_x, tail_y; /* Where the lower right most portion of the object is |
297 | sint8 tail_x, tail_y; /* Where the lower right most portion of the object is |
283 | * in comparison to the head. |
298 | * in comparison to the head. |
284 | */ |
299 | */ |
285 | } archetype; |
300 | } archetype; |
286 | |
301 | |
287 | extern object *objects; |
302 | extern object *objects; |
288 | extern object *active_objects; |
303 | extern object *active_objects; |
289 | extern object *free_objects; |
304 | extern object *free_objects; |