… | |
… | |
244 | |
244 | |
245 | static vector active; // active objects, not yet used |
245 | static vector active; // active objects, not yet used |
246 | static vector objects; // not used yet, use first->next->... |
246 | static vector objects; // not used yet, use first->next->... |
247 | static object *first; // will be replaced by "objects" |
247 | static object *first; // will be replaced by "objects" |
248 | |
248 | |
249 | static object *create (); |
249 | MTH static object *create (); |
250 | void copy_to (object *dst); |
250 | MTH void copy_to (object *dst); |
251 | object *clone (); // create + copy_to |
251 | MTH object *clone (); // create + copy_to |
252 | void do_destroy (); |
252 | void do_destroy (); |
253 | void gather_callbacks (AV *&callbacks, event_type event) const; |
253 | void gather_callbacks (AV *&callbacks, event_type event) const; |
254 | void destroy (bool destroy_inventory = false); |
254 | MTH void destroy (bool destroy_inventory = false); |
255 | |
255 | |
256 | // recursively destroy all objects in inventory, optionally dropping them to the ground instead |
256 | // recursively destroy all objects in inventory, optionally dropping them to the ground instead |
257 | void destroy_inv (bool drop_to_ground = false); |
257 | MTH void destroy_inv (bool drop_to_ground = false); |
258 | void remove (); |
258 | MTH void remove (); |
259 | object *insert (object *item); // insert into inventory |
259 | MTH object *insert (object *item); // insert into inventory |
260 | |
260 | |
261 | static bool can_merge_slow (object *op1, object *op2); |
261 | static bool can_merge_slow (object *op1, object *op2); |
262 | |
262 | |
263 | // this is often used in time-critical code, so optimise |
263 | // this is often used in time-critical code, so optimise |
264 | static bool can_merge (object *op1, object *op2) |
264 | MTH static bool can_merge (object *op1, object *op2) |
265 | { |
265 | { |
266 | return op1->value == op2->value |
266 | return op1->value == op2->value |
267 | && op1->name == op2->name |
267 | && op1->name == op2->name |
268 | && can_merge_slow (op1, op2); |
268 | && can_merge_slow (op1, op2); |
269 | } |
269 | } |
270 | |
270 | |
271 | void set_owner (object *owner); |
271 | MTH void set_owner (object *owner); |
|
|
272 | MTH void set_speed (float speed); |
272 | |
273 | |
273 | void instantiate () |
274 | MTH void instantiate () |
274 | { |
275 | { |
275 | if (!uuid.seq) // HACK |
276 | if (!uuid.seq) // HACK |
276 | uuid = gen_uuid (); |
277 | uuid = gen_uuid (); |
277 | |
278 | |
278 | attachable::instantiate (); |
279 | attachable::instantiate (); |
279 | } |
280 | } |
280 | |
281 | |
281 | // recalculate all stats |
282 | // recalculate all stats |
282 | void update_stats (); |
283 | MTH void update_stats (); |
283 | void roll_stats (); |
284 | MTH void roll_stats (); |
284 | void swap_stats (int a, int b); |
285 | MTH void swap_stats (int a, int b); |
285 | void add_statbonus (); |
286 | MTH void add_statbonus (); |
286 | void remove_statbonus (); |
287 | MTH void remove_statbonus (); |
287 | void drain_stat (); |
288 | MTH void drain_stat (); |
288 | void drain_specific_stat (int deplete_stats); |
289 | MTH void drain_specific_stat (int deplete_stats); |
289 | void change_luck (int value); |
290 | MTH void change_luck (int value); |
290 | |
291 | |
291 | // info must hold 256 * 3 bytes currently |
292 | // info must hold 256 * 3 bytes currently |
292 | const char *debug_desc (char *info) const; |
293 | MTH const char *debug_desc (char *info) const; |
293 | const char *debug_desc () const; |
294 | MTH const char *debug_desc () const; |
294 | |
295 | |
295 | bool is_weapon () const { return type == ARROW || type == BOW || type == WEAPON; } |
296 | MTH bool is_weapon () const { return type == ARROW || type == BOW || type == WEAPON; } |
296 | bool is_armor () const { return type == ARMOUR || type == SHIELD || type == HELMET |
297 | MTH bool is_armor () const { return type == ARMOUR || type == SHIELD || type == HELMET |
297 | || type == CLOAK || type == BOOTS || type == GLOVES |
298 | || type == CLOAK || type == BOOTS || type == GLOVES |
298 | || type == BRACERS || type == GIRDLE; } |
299 | || type == BRACERS || type == GIRDLE; } |
299 | bool is_alive () const { return (type == PLAYER |
300 | MTH bool is_alive () const { return (type == PLAYER |
300 | || flag [FLAG_MONSTER] |
301 | || flag [FLAG_MONSTER] |
301 | || (flag [FLAG_ALIVE] && !flag [FLAG_GENERATOR] && type != DOOR)) |
302 | || (flag [FLAG_ALIVE] && !flag [FLAG_GENERATOR] && type != DOOR)) |
302 | && !flag [FLAG_IS_A_TEMPLATE]; } |
303 | && !flag [FLAG_IS_A_TEMPLATE]; } |
303 | bool is_arrow () const { return type == ARROW |
304 | MTH bool is_arrow () const { return type == ARROW |
304 | || (type == SPELL_EFFECT |
305 | || (type == SPELL_EFFECT |
305 | && (subtype == SP_BULLET || subtype == SP_MAGIC_MISSILE)); } |
306 | && (subtype == SP_BULLET || subtype == SP_MAGIC_MISSILE)); } |
306 | |
307 | |
307 | /* This return true if object has still randomitems which |
308 | /* This return true if object has still randomitems which |
308 | * could be expanded. |
309 | * could be expanded. |
309 | */ |
310 | */ |
310 | bool has_random_items () const { return randomitems && !flag [FLAG_IS_A_TEMPLATE]; } |
311 | MTH bool has_random_items () const { return randomitems && !flag [FLAG_IS_A_TEMPLATE]; } |
311 | |
312 | |
312 | // returns the player that has this object in his inventory, or 0 |
313 | // returns the player that has this object in his inventory, or 0 |
313 | object *in_player () const |
314 | MTH object *in_player () const |
314 | { |
315 | { |
315 | for (object *op = env; op; op = op->env) |
316 | for (object *op = env; op; op = op->env) |
316 | if (op->type == PLAYER) |
317 | if (op->type == PLAYER) |
317 | return op; |
318 | return op; |
318 | |
319 | |