--- deliantra/server/include/object.h 2007/05/07 04:21:11 1.117 +++ deliantra/server/include/object.h 2007/05/19 00:08:11 1.125 @@ -32,8 +32,30 @@ typedef int tag_t; -#define NUM_BODY_LOCATIONS 14 -#define BODY_ARMS 1 +enum { + body_skill, + body_combat, + body_range, + body_shield, + body_arm, + body_torso, + body_head, + body_neck, + body_finger, + body_shoulder, + body_foot, + body_hand, + body_wrist, + body_waist, + NUM_BODY_LOCATIONS +}; + +enum slottype_t +{ + slot_none, + slot_combat, + slot_ranged, +}; /* See common/item.c */ @@ -254,9 +276,11 @@ key_value *key_values; /* Fields not explictly known by the loader. */ bool parse_kv (object_thawer &f); // parse kv pairs, (ab-)used by archetypes, which should not exist at all + void post_load_check (); // do some adjustments after parsing static object *read (object_thawer &f, maptile *map = 0); // map argument due to toal design bogosity, must go. bool write (object_freezer &f); + MTH int slottype () const; MTH static object *create (); object &operator =(const object &src); MTH void copy_to (object *dst); @@ -287,7 +311,8 @@ MTH void set_owner (object *owner); MTH void set_speed (float speed); - MTH void set_weapon (object *ob); + MTH bool change_weapon (object *ob); + MTH bool change_skill (object *ob); MTH void open_container (object *new_container); MTH void close_container () @@ -295,6 +320,18 @@ open_container (0); } + // overwrite the attachable invoke function with a version that also checks ev_want_type + bool invoke (event_type event, ...) + { + if (ev_want_event [event] || ev_want_type [type] || cb) + { + va_list ap; + va_start (ap, event); + vinvoke (event, ap); + va_end (ap); + } + } + MTH void instantiate (); // recalculate all stats @@ -467,6 +504,25 @@ ~object (); }; +// move this object to the top of its env's inventory to speed up +// searches for it. +static object * +splay (object *ob) +{ + if (ob->env && ob->env->inv != ob) + { + if (ob->above) ob->above->below = ob->below; + if (ob->below) ob->below->above = ob->above; + + ob->above = 0; + ob->below = ob->env->inv; + ob->below->above = ob; + ob->env->inv = ob; + } + + return ob; +} + typedef object_vector objectvec; typedef object_vector activevec; @@ -494,6 +550,10 @@ struct oblinkpt *next; } oblinkpt; +object *find_skill_by_name (object *who, const char *name); +object *find_skill_by_name (object *who, const shstr &sh); +object *find_skill_by_number (object *who, int skillno); + /* * The archetype structure is a set of rules on how to generate and manipulate * objects which point to archetypes.