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.10 2006/08/28 16:52:51 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> { |
|
|
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() |
… | |
… | |
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 */ |
192 | const char *current_weapon_script; /* The script of the currently used weapon. Executed */ |
185 | /* each time the object attacks something */ |
193 | /* each time the object attacks something */ |
186 | struct obj *current_weapon; /* Pointer to the weapon currently used */ |
194 | struct object *current_weapon; /* Pointer to the weapon currently used */ |
187 | uint32 weapontype; /* type of weapon */ |
195 | uint32 weapontype; /* type of weapon */ |
188 | uint32 tooltype; /* type of tool or build facility */ |
196 | uint32 tooltype; /* type of tool or build facility */ |
189 | sint8 body_info[NUM_BODY_LOCATIONS]; /* body info as loaded from the file */ |
197 | 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 */ |
198 | sint8 body_used[NUM_BODY_LOCATIONS]; /* Calculated value based on items equipped */ |
191 | /* See the doc/Developers/objects for more info about body locations */ |
199 | /* See the doc/Developers/objects for more info about body locations */ |
192 | |
200 | |
193 | /* Following mostly refers to fields only used for monsters */ |
201 | /* Following mostly refers to fields only used for monsters */ |
194 | struct obj *owner; /* Pointer to the object which controls this one */ |
202 | struct object *owner; /* Pointer to the object which controls this one */ |
195 | /* Owner should not be referred to directly - */ |
203 | /* Owner should not be referred to directly - */ |
196 | /* get_owner should be used instead. */ |
204 | /* get_owner should be used instead. */ |
197 | tag_t ownercount; /* What count the owner had (in case owner */ |
205 | tag_t ownercount; /* What count the owner had (in case owner */ |
198 | /* has been freed) */ |
206 | /* has been freed) */ |
199 | struct obj *enemy; /* Monster/player to follow even if not closest */ |
207 | 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 */ |
208 | 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 */ |
209 | tag_t attacked_by_count; /* the tag of attacker, so we can be sure */ |
202 | struct treasureliststruct *randomitems; /* Items to be generated */ |
210 | struct treasureliststruct *randomitems; /* Items to be generated */ |
203 | uint16 run_away; /* Monster runs away if it's hp goes below this percentage. */ |
211 | uint16 run_away; /* Monster runs away if it's hp goes below this percentage. */ |
204 | struct obj *chosen_skill; /* the skill chosen to use */ |
212 | struct object *chosen_skill; /* the skill chosen to use */ |
205 | uint32 hide; /* The object is hidden, not invisible */ |
213 | uint32 hide; /* The object is hidden, not invisible */ |
206 | /* changes made by kholland@sunlab.cit.cornell.edu */ |
214 | /* changes made by kholland@sunlab.cit.cornell.edu */ |
207 | /* allows different movement patterns for attackers */ |
215 | /* allows different movement patterns for attackers */ |
208 | sint32 move_status; /* What stage in attack mode */ |
216 | sint32 move_status; /* What stage in attack mode */ |
209 | uint16 attack_movement;/* What kind of attack movement */ |
217 | uint16 attack_movement;/* What kind of attack movement */ |
210 | uint8 will_apply; /* See crossfire.doc */ |
218 | uint8 will_apply; /* See crossfire.doc */ |
211 | struct obj *spellitem; /* Spell ability monster is choosing to use */ |
219 | struct object *spellitem; /* Spell ability monster is choosing to use */ |
212 | double expmul; /* needed experience = (calc_exp*expmul) - means some */ |
220 | double expmul; /* needed experience = (calc_exp*expmul) - means some */ |
213 | /* races/classes can need less/more exp to gain levels */ |
221 | /* races/classes can need less/more exp to gain levels */ |
214 | |
222 | |
215 | /* Spell related information, may be useful elsewhere |
223 | /* Spell related information, may be useful elsewhere |
216 | * Note that other fields are used - these files are basically |
224 | * Note that other fields are used - these files are basically |
217 | * only used in spells. |
225 | * only used in spells. |
218 | */ |
226 | */ |
219 | sint16 duration; /* How long the spell lasts */ |
227 | sint16 duration; /* How long the spell lasts */ |
220 | uint8 duration_modifier; /* how level modifies duration */ |
228 | uint8 duration_modifier; /* how level modifies duration */ |
221 | sint16 casting_time; /* time left before spell goes off */ |
229 | sint16 casting_time; /* time left before spell goes off */ |
222 | struct obj *spell; /* Spell that was being cast */ |
230 | struct object *spell; /* Spell that was being cast */ |
223 | uint16 start_holding; |
231 | uint16 start_holding; |
224 | char *spellarg; |
232 | char *spellarg; |
225 | uint8 dam_modifier; /* How going up in level effects damage */ |
233 | uint8 dam_modifier; /* How going up in level effects damage */ |
226 | sint8 range; /* Range of the spell */ |
234 | sint8 range; /* Range of the spell */ |
227 | uint8 range_modifier; /* How going up in level effects range */ |
235 | uint8 range_modifier; /* How going up in level effects range */ |
… | |
… | |
237 | sint32 elevation; /* elevation of this terrain - not currently used */ |
245 | sint32 elevation; /* elevation of this terrain - not currently used */ |
238 | uint8 smoothlevel; /* how to smooth this square around*/ |
246 | uint8 smoothlevel; /* how to smooth this square around*/ |
239 | |
247 | |
240 | MoveType move_type; /* Type of movement this object uses */ |
248 | MoveType move_type; /* Type of movement this object uses */ |
241 | MoveType move_block; /* What movement types this blocks */ |
249 | MoveType move_block; /* What movement types this blocks */ |
|
|
250 | MoveType move_allow; /* What movement types explicitly allowd */ |
242 | MoveType move_on; /* Move types affected moving on to this space */ |
251 | MoveType move_on; /* Move types affected moving on to this space */ |
243 | MoveType move_off; /* Move types affected moving off this space */ |
252 | MoveType move_off; /* Move types affected moving off this space */ |
244 | MoveType move_slow; /* Movement types this slows down */ |
253 | MoveType move_slow; /* Movement types this slows down */ |
245 | float move_slow_penalty; /* How much this slows down the object */ |
254 | float move_slow_penalty; /* How much this slows down the object */ |
246 | |
255 | |
247 | event *events; |
256 | event *events; |
248 | |
257 | |
249 | const char *custom_name; /* Custom name assigned by player */ |
258 | const char *custom_name; /* Custom name assigned by player */ |
250 | key_value *key_values; /* Fields not explictly known by the loader. */ |
259 | key_value *key_values; /* Fields not explictly known by the loader. */ |
|
|
260 | }; |
251 | |
261 | |
252 | } object; |
262 | struct object : object_special, object_simple { |
|
|
263 | void clone (object *destination) |
|
|
264 | { |
|
|
265 | if (attach) |
|
|
266 | destination->attach = add_refcount (attach); |
|
|
267 | |
|
|
268 | if (self || cb) |
|
|
269 | INVOKE_OBJECT (CLONE, this, ARG_OBJECT (destination)); |
|
|
270 | } |
|
|
271 | }; |
253 | |
272 | |
254 | typedef struct oblnk { /* Used to link together several objects */ |
273 | typedef struct oblnk { /* Used to link together several objects */ |
255 | object *ob; |
274 | object *ob; |
256 | struct oblnk *next; |
275 | struct oblnk *next; |
257 | tag_t id; |
276 | tag_t id; |