… | |
… | |
79 | // these are not being copied |
79 | // these are not being copied |
80 | ACC_CLASS (object) |
80 | ACC_CLASS (object) |
81 | struct object_keep |
81 | struct object_keep |
82 | { |
82 | { |
83 | tag_t ACC (RW, count); /* Unique object number for this object */ |
83 | tag_t ACC (RW, count); /* Unique object number for this object */ |
84 | uint16 ACC (RW, refcount); /* How many objects points to this object */ |
84 | sint32 ACC (RW, refcount); /* How many objects points to this object */ |
85 | |
85 | |
86 | /* These variables are not changed by copy_object() */ |
86 | /* These variables are not changed by copy_object() */ |
87 | struct pl *ACC (RW, contr); /* Pointer to the player which control this object */ |
87 | struct pl *ACC (RW, contr); /* Pointer to the player which control this object */ |
88 | struct object *ACC (RW, next); /* Pointer to the next object in the free/used list */ |
88 | struct object *ACC (RW, next); /* Pointer to the next object in the free/used list */ |
89 | struct object *ACC (RW, prev); /* Pointer to the previous object in the free/used list */ |
89 | struct object *ACC (RW, prev); /* Pointer to the previous object in the free/used list */ |
… | |
… | |
105 | struct object *ACC (RW, head); /* Points to the main object of a large body */ |
105 | struct object *ACC (RW, head); /* Points to the main object of a large body */ |
106 | struct mapstruct *ACC (RW, map); /* Pointer to the map in which this object is present */ |
106 | struct mapstruct *ACC (RW, map); /* Pointer to the map in which this object is present */ |
107 | }; |
107 | }; |
108 | |
108 | |
109 | // these are being copied |
109 | // these are being copied |
110 | struct object_copy:attachable<object> |
110 | struct object_copy : attachable<object> |
111 | { |
111 | { |
112 | /* These get an extra add_refcount(), after having been copied by memcpy(). |
112 | /* These get an extra add_refcount(), after having been copied by memcpy(). |
113 | * All fields beow this point are automatically copied by memcpy. If |
113 | * All fields beow this point are automatically copied by memcpy. If |
114 | * adding something that needs a refcount updated, make sure you modify |
114 | * adding something that needs a refcount updated, make sure you modify |
115 | * copy_object to do so. Everything below here also gets cleared |
115 | * copy_object to do so. Everything below here also gets cleared |
… | |
… | |
151 | uint32 ACC (RW, path_denied); /* Paths the object is denied access to */ |
151 | uint32 ACC (RW, path_denied); /* Paths the object is denied access to */ |
152 | uint16 ACC (RW, material); /* What materials this object consist of */ |
152 | uint16 ACC (RW, material); /* What materials this object consist of */ |
153 | sint8 ACC (RW, magic); /* Any magical bonuses to this item */ |
153 | sint8 ACC (RW, magic); /* Any magical bonuses to this item */ |
154 | uint8 ACC (RW, state); /* How the object was last drawn (animation) */ |
154 | uint8 ACC (RW, state); /* How the object was last drawn (animation) */ |
155 | sint32 ACC (RW, value); /* How much money it is worth (or contains) */ |
155 | sint32 ACC (RW, value); /* How much money it is worth (or contains) */ |
156 | sint16 ACC (RW, level); /* Level of creature or object */ |
|
|
157 | /* Note that the last_.. values are sometimes used for non obvious |
156 | /* Note that the last_.. values are sometimes used for non obvious |
158 | * meanings by some objects, eg, sp penalty, permanent exp. |
157 | * meanings by some objects, eg, sp penalty, permanent exp. |
159 | */ |
158 | */ |
160 | sint32 ACC (RW, last_heal); /* Last healed. Depends on constitution */ |
159 | sint32 ACC (RW, last_heal); /* Last healed. Depends on constitution */ |
161 | sint32 ACC (RW, last_sp); /* As last_heal, but for spell points */ |
160 | sint32 ACC (RW, last_sp); /* As last_heal, but for spell points */ |
162 | sint16 ACC (RW, last_grace); /* as last_sp, except for grace */ |
161 | sint16 ACC (RW, last_grace); /* as last_sp, except for grace */ |
163 | sint16 ACC (RW, last_eat); /* How long since we last ate */ |
162 | sint16 ACC (RW, last_eat); /* How long since we last ate */ |
164 | sint16 ACC (RW, invisible); /* How much longer the object will be invis */ |
163 | sint16 ACC (RW, invisible); /* How much longer the object will be invis */ |
|
|
164 | sint16 ACC (RW, level); /* Level of creature or object */ |
165 | uint8 ACC (RW, pick_up); /* See crossfire.doc */ |
165 | uint8 ACC (RW, pick_up); /* See crossfire.doc */ |
166 | sint8 ACC (RW, item_power); /* power rating of the object */ |
166 | sint8 ACC (RW, item_power); /* power rating of the object */ |
167 | sint8 ACC (RW, gen_sp_armour); /* sp regen penalty this object has (was last_heal) */ |
167 | sint8 ACC (RW, gen_sp_armour); /* sp regen penalty this object has (was last_heal) */ |
|
|
168 | sint8 ACC (RW, glow_radius); /* indicates the glow radius of the object */ |
168 | sint32 ACC (RW, weight); /* Attributes of the object */ |
169 | sint32 ACC (RW, weight); /* Attributes of the object */ |
169 | sint32 ACC (RW, weight_limit); /* Weight-limit of object */ |
170 | sint32 ACC (RW, weight_limit); /* Weight-limit of object */ |
170 | sint32 ACC (RW, carrying); /* How much weight this object contains */ |
171 | sint32 ACC (RW, carrying); /* How much weight this object contains */ |
171 | sint8 ACC (RW, glow_radius); /* indicates the glow radius of the object */ |
|
|
172 | living ACC (RO, stats); /* Str, Con, Dex, etc */ |
172 | living ACC (RO, stats); /* Str, Con, Dex, etc */ |
173 | sint64 ACC (RW, perm_exp); /* Permanent exp */ |
173 | sint64 ACC (RW, perm_exp); /* Permanent exp */ |
174 | struct object *ACC (RW, current_weapon); /* Pointer to the weapon currently used */ |
174 | struct object *ACC (RW, current_weapon); /* Pointer to the weapon currently used */ |
175 | uint32 ACC (RW, weapontype); /* type of weapon */ |
175 | uint32 ACC (RW, weapontype); /* type of weapon */ |
176 | uint32 ACC (RW, tooltype); /* type of tool or build facility */ |
176 | uint32 ACC (RW, tooltype); /* type of tool or build facility */ |
177 | sint8 body_info[NUM_BODY_LOCATIONS]; /* body info as loaded from the file */ |
177 | sint8 body_info[NUM_BODY_LOCATIONS]; /* body info as loaded from the file */ |
178 | sint8 body_used[NUM_BODY_LOCATIONS]; /* Calculated value based on items equipped */ |
178 | sint8 body_used[NUM_BODY_LOCATIONS]; /* Calculated value based on items equipped */ |
|
|
179 | uint8 ACC (RW, will_apply); /* See crossfire.doc */ |
179 | /* See the doc/Developers/objects for more info about body locations */ |
180 | /* See the doc/Developers/objects for more info about body locations */ |
180 | |
181 | |
181 | /* Following mostly refers to fields only used for monsters */ |
182 | /* Following mostly refers to fields only used for monsters */ |
182 | struct object *ACC (RW, owner); /* Pointer to the object which controls this one */ |
183 | struct object *ACC (RW, owner); /* Pointer to the object which controls this one */ |
183 | /* Owner should not be referred to directly - */ |
184 | /* Owner should not be referred to directly - */ |
… | |
… | |
186 | /* has been freed) */ |
187 | /* has been freed) */ |
187 | struct object *ACC (RW, enemy); /* Monster/player to follow even if not closest */ |
188 | struct object *ACC (RW, enemy); /* Monster/player to follow even if not closest */ |
188 | struct object *ACC (RW, attacked_by); /* This object start to attack us! only player & monster */ |
189 | struct object *ACC (RW, attacked_by); /* This object start to attack us! only player & monster */ |
189 | tag_t ACC (RW, attacked_by_count); /* the tag of attacker, so we can be sure */ |
190 | tag_t ACC (RW, attacked_by_count); /* the tag of attacker, so we can be sure */ |
190 | struct treasureliststruct *ACC (RW, randomitems); /* Items to be generated */ |
191 | struct treasureliststruct *ACC (RW, randomitems); /* Items to be generated */ |
191 | uint16 ACC (RW, run_away); /* Monster runs away if it's hp goes below this percentage. */ |
|
|
192 | struct object *ACC (RW, chosen_skill); /* the skill chosen to use */ |
192 | struct object *ACC (RW, chosen_skill); /* the skill chosen to use */ |
193 | uint32 ACC (RW, hide); /* The object is hidden, not invisible */ |
193 | uint32 ACC (RW, hide); /* The object is hidden, not invisible */ |
194 | /* changes made by kholland@sunlab.cit.cornell.edu */ |
194 | /* changes made by kholland@sunlab.cit.cornell.edu */ |
195 | /* allows different movement patterns for attackers */ |
195 | /* allows different movement patterns for attackers */ |
196 | sint32 ACC (RW, move_status); /* What stage in attack mode */ |
196 | sint32 ACC (RW, move_status); /* What stage in attack mode */ |
197 | uint16 ACC (RW, attack_movement); /* What kind of attack movement */ |
197 | uint16 ACC (RW, attack_movement); /* What kind of attack movement */ |
198 | uint8 ACC (RW, will_apply); /* See crossfire.doc */ |
198 | uint16 ACC (RW, run_away); /* Monster runs away if it's hp goes below this percentage. */ |
199 | struct object *ACC (RW, spellitem); /* Spell ability monster is choosing to use */ |
199 | struct object *ACC (RW, spellitem); /* Spell ability monster is choosing to use */ |
200 | double ACC (RW, expmul); /* needed experience = (calc_exp*expmul) - means some */ |
200 | float ACC (RW, expmul); /* needed experience = (calc_exp*expmul) - means some */ |
201 | /* races/classes can need less/more exp to gain levels */ |
201 | /* races/classes can need less/more exp to gain levels */ |
202 | |
202 | |
203 | /* Spell related information, may be useful elsewhere |
203 | /* Spell related information, may be useful elsewhere |
204 | * Note that other fields are used - these files are basically |
204 | * Note that other fields are used - these files are basically |
205 | * only used in spells. |
205 | * only used in spells. |
206 | */ |
206 | */ |
207 | sint16 ACC (RW, duration); /* How long the spell lasts */ |
207 | sint16 ACC (RW, duration); /* How long the spell lasts */ |
|
|
208 | sint16 ACC (RW, casting_time); /* time left before spell goes off */ |
|
|
209 | uint16 ACC (RW, start_holding); |
|
|
210 | struct object *ACC (RW, spell); /* Spell that was being cast */ |
|
|
211 | char *ACC (RW, spellarg); |
208 | uint8 ACC (RW, duration_modifier); /* how level modifies duration */ |
212 | uint8 ACC (RW, duration_modifier); /* how level modifies duration */ |
209 | sint16 ACC (RW, casting_time); /* time left before spell goes off */ |
|
|
210 | struct object *ACC (RW, spell); /* Spell that was being cast */ |
|
|
211 | uint16 ACC (RW, start_holding); |
|
|
212 | char *ACC (RW, spellarg); |
|
|
213 | uint8 ACC (RW, dam_modifier); /* How going up in level effects damage */ |
213 | uint8 ACC (RW, dam_modifier); /* How going up in level effects damage */ |
214 | sint8 ACC (RW, range); /* Range of the spell */ |
214 | sint8 ACC (RW, range); /* Range of the spell */ |
215 | uint8 ACC (RW, range_modifier); /* How going up in level effects range */ |
215 | uint8 ACC (RW, range_modifier); /* How going up in level effects range */ |
216 | |
216 | |
217 | /* Following are values used by any object */ |
217 | /* Following are values used by any object */ |
218 | struct archt *ACC (RW, arch); /* Pointer to archetype */ |
218 | struct archetype *ACC (RW, arch); /* Pointer to archetype */ |
219 | struct archt *ACC (RW, other_arch); /* Pointer used for various things - mostly used for what */ |
219 | struct archetype *ACC (RW, other_arch); /* Pointer used for various things - mostly used for what */ |
220 | /* this objects turns into or what this object creates */ |
220 | /* this objects turns into or what this object creates */ |
221 | uint32 flags[4]; /* various flags */ |
221 | uint32 flags[4]; /* various flags */ |
222 | uint16 ACC (RW, animation_id); /* An index into the animation array */ |
222 | uint16 ACC (RW, animation_id); /* An index into the animation array */ |
223 | uint8 ACC (RW, anim_speed); /* ticks between animation-frames */ |
223 | uint8 ACC (RW, anim_speed); /* ticks between animation-frames */ |
224 | uint8 ACC (RW, last_anim); /* last sequence used to draw face */ |
224 | uint8 ACC (RW, last_anim); /* last sequence used to draw face */ |
… | |
… | |
233 | MoveType ACC (RW, move_slow); /* Movement types this slows down */ |
233 | MoveType ACC (RW, move_slow); /* Movement types this slows down */ |
234 | float ACC (RW, move_slow_penalty); /* How much this slows down the object */ |
234 | float ACC (RW, move_slow_penalty); /* How much this slows down the object */ |
235 | key_value *key_values; /* Fields not explictly known by the loader. */ |
235 | key_value *key_values; /* Fields not explictly known by the loader. */ |
236 | }; |
236 | }; |
237 | |
237 | |
|
|
238 | #define get_object() object::create () |
|
|
239 | #define free_object(op) (op)->free (0) |
|
|
240 | #define free_object2(op, free_inv) (op)->free (free_inv) |
|
|
241 | |
238 | struct object : zero_initialised, object_keep, object_copy, object_pod |
242 | struct object : zero_initialised, object_keep, object_copy, object_pod |
239 | { |
243 | { |
|
|
244 | static object *create (); |
|
|
245 | void free (bool free_inventory = false); |
|
|
246 | |
|
|
247 | static void free_mortals (); |
240 | static bool can_merge (object * op1, object * op2); |
248 | static bool can_merge (object *op1, object *op2); |
241 | |
249 | |
242 | void clear (); |
250 | void clear (); |
243 | void clone (object * destination); |
251 | void clone (object *destination); |
|
|
252 | |
|
|
253 | protected: |
|
|
254 | friend struct archetype; |
|
|
255 | |
|
|
256 | void link (); |
|
|
257 | void unlink (); |
|
|
258 | |
|
|
259 | object (); |
|
|
260 | ~object (); |
244 | }; |
261 | }; |
245 | |
262 | |
246 | #define CAN_MERGE(op1,op2) ((op1)->value == (op2)->value && (op1)->name == (op2)->name && object::can_merge ((op1), (op2))) |
263 | #define CAN_MERGE(op1,op2) ((op1)->value == (op2)->value && (op1)->name == (op2)->name && object::can_merge ((op1), (op2))) |
247 | |
264 | |
248 | typedef struct oblnk |
265 | typedef struct oblnk |
… | |
… | |
267 | * object and pointers. This structure should get removed, and just replaced |
284 | * object and pointers. This structure should get removed, and just replaced |
268 | * by the object structure |
285 | * by the object structure |
269 | */ |
286 | */ |
270 | |
287 | |
271 | ACC_CLASS(archetype) |
288 | ACC_CLASS(archetype) |
272 | struct archt : zero_initialised |
289 | struct archetype : zero_initialised |
273 | { |
290 | { |
|
|
291 | archetype (); |
|
|
292 | ~archetype (); |
|
|
293 | |
274 | shstr ACC (RW, name); /* More definite name, like "generate_kobold" */ |
294 | shstr ACC (RW, name); /* More definite name, like "generate_kobold" */ |
275 | struct archt *ACC (RW, next); /* Next archetype in a linked list */ |
295 | struct archetype *ACC (RW, next); /* Next archetype in a linked list */ |
276 | struct archt *ACC (RW, head); /* The main part of a linked object */ |
296 | struct archetype *ACC (RW, head); /* The main part of a linked object */ |
277 | struct archt *ACC (RW, more); /* Next part of a linked object */ |
297 | struct archetype *ACC (RW, more); /* Next part of a linked object */ |
278 | object ACC (RO, clone); /* An object from which to do copy_object() */ |
298 | object ACC (RO, clone); /* An object from which to do copy_object() */ |
279 | uint32 ACC (RW, editable); /* editable flags (mainly for editor) */ |
299 | uint32 ACC (RW, editable); /* editable flags (mainly for editor) */ |
280 | sint8 ACC (RW, tail_x), ACC (RW, tail_y); /* Where the lower right most portion of the object is |
300 | sint8 ACC (RW, tail_x), ACC (RW, tail_y); /* Where the lower right most portion of the object is |
281 | * in comparison to the head. |
301 | * in comparison to the head. |
282 | */ |
302 | */ |
283 | } archetype; |
303 | }; |
284 | |
304 | |
285 | extern object *objects; |
305 | extern object *objects; |
286 | extern object *active_objects; |
306 | extern object *active_objects; |
287 | |
307 | |
288 | extern int nrofallocobjects; |
308 | extern int nrofallocobjects; |