22 #ifndef NUVIE_CORE_OBJ_MANAGER_H 23 #define NUVIE_CORE_OBJ_MANAGER_H 25 #include "ultima/nuvie/misc/iavl_tree.h" 26 #include "ultima/nuvie/core/tile_manager.h" 27 #include "ultima/nuvie/misc/u6_llist.h" 28 #include "ultima/nuvie/core/obj.h" 43 #define OBJ_NOT_PASSABLE 1 44 #define OBJ_PASSABLE 2 46 #define OBJ_WEIGHT_INCLUDE_CONTAINER_ITEMS true 47 #define OBJ_WEIGHT_EXCLUDE_CONTAINER_ITEMS false 49 #define OBJ_WEIGHT_DO_SCALE true 50 #define OBJ_WEIGHT_DONT_SCALE false 52 #define OBJ_WEIGHT_EXCLUDE_QTY false 54 #define OBJ_ADD_TOP true 56 #define OBJ_SHOW_PREFIX true 58 #define OBJ_TEMP_INIT 255 // this is used to stop temporary objects from being cleaned upon startup. 60 #define OBJ_SEARCH_TOP true 61 #define OBJ_INCLUDE_IGNORED true 62 #define OBJ_EXCLUDE_IGNORED false 69 Obj *new_obj(uint16 obj_n, uint8 frame_n, uint16 x, uint16 y, uint16 z);
70 void delete_obj(
Obj *obj);
72 void clean_obj_tree_node(
void *node);
83 uint16 obj_to_tile[1024];
84 uint8 obj_weight[1024];
85 uint8 obj_stackable[1024];
86 U6LList *actor_inventories[256];
95 uint16 last_obj_blk_x, last_obj_blk_y;
98 uint16 obj_save_count;
100 bool custom_actor_tiles;
107 bool use_custom_actor_tiles() {
108 return custom_actor_tiles;
110 bool is_showing_eggs() {
113 void set_show_eggs(
bool value) {
118 bool load_super_chunk(
NuvieIO *chunk_buf, uint8 level, uint8 chunk_offset);
121 void clean_actor_inventories();
123 bool save_super_chunk(
NuvieIO *save_buf, uint8 level, uint8 chunk_offset);
124 bool save_eggs(
NuvieIO *save_buf);
125 bool save_inventories(
NuvieIO *save_buf);
126 bool save_obj(
NuvieIO *save_buf,
Obj *obj, uint16 parent_objblk_n);
128 void set_usecode(
UseCode *uc) {
139 bool is_boundary(uint16 x, uint16 y, uint8 level, uint8 boundary_type = TILEFLAG_BOUNDARY,
Obj *excluded_obj =
nullptr);
141 bool is_damaging(uint16 x, uint16 y, uint8 level);
142 uint8 is_passable(uint16 x, uint16 y, uint8 level);
143 bool is_forced_passable(uint16 x, uint16 y, uint8 level);
144 bool is_stackable(
const Obj *obj)
const;
145 bool is_breakable(
const Obj *obj);
146 bool can_store_obj(
const Obj *target,
Obj *src)
const;
147 bool can_get_obj(
Obj *obj)
const;
148 bool has_reduced_weight(uint16 obj_n)
const;
149 bool has_reduced_weight(
const Obj *obj)
const {
150 return has_reduced_weight(obj->obj_n);
152 bool has_toptile(
const Obj *obj)
const;
153 bool obj_is_damaging(
const Obj *obj,
Actor *actor =
nullptr);
154 bool is_door(uint16 x, uint16 y, uint8 level);
156 U6LList *get_obj_list(uint16 x, uint16 y, uint8 level)
const;
158 Tile *get_obj_tile(uint16 obj_n, uint8 frame_n);
159 const Tile *get_obj_tile(uint16 x, uint16 y, uint8 level,
bool top_obj =
true);
160 const Tile *get_obj_dmg_tile(uint16 x, uint16 y, uint8 level);
161 Obj *get_obj(uint16 x, uint16 y, uint8 level,
bool top_obj = OBJ_SEARCH_TOP,
bool include_ignored_objects = OBJ_EXCLUDE_IGNORED,
Obj *excluded_obj =
nullptr);
162 Obj *get_obj_of_type_from_location_inc_multi_tile(uint16 obj_n, uint16 x, uint16 y, uint8 z);
163 Obj *get_obj_of_type_from_location_inc_multi_tile(uint16 obj_n, sint16 quality, sint32 qty, uint16 x, uint16 y, uint8 z);
164 Obj *get_obj_of_type_from_location(uint16 obj_n, uint16 x, uint16 y, uint8 z);
165 Obj *get_obj_of_type_from_location(uint16 obj_n, sint16 quality, sint32 qty, uint16 x, uint16 y, uint8 z);
166 Obj *get_objBasedAt(uint16 x, uint16 y, uint8 level,
bool top_obj,
bool include_ignored_objects =
true,
Obj *excluded_obj =
nullptr);
167 Obj *get_tile_obj(uint16 obj_n);
169 uint16 get_obj_tile_num(uint16 obj_num)
const;
170 inline bool is_corpse(
const Obj *obj)
const;
171 uint16 get_obj_tile_num(
const Obj *obj)
const;
172 void set_obj_tile_num(uint16 obj_num, uint16 tile_num);
174 U6LList *get_actor_inventory(uint16 actor_num);
175 bool actor_has_inventory(uint16 actor_num);
177 Obj *find_next_obj(uint8 level,
Obj *prev_obj,
bool match_frame_n = OBJ_NOMATCH_FRAME_N,
bool match_quality = OBJ_MATCH_QUALITY);
178 Obj *find_obj(uint8 level, uint16 obj_n, uint8 quality,
bool match_quality = OBJ_MATCH_QUALITY, uint16 frame_n = 0,
bool match_frame_n = OBJ_NOMATCH_FRAME_N,
Obj **prev_obj =
nullptr);
180 bool move(
Obj *obj, uint16 x, uint16 y, uint8 level);
181 bool add_obj(
Obj *obj,
bool addOnTop =
false);
182 bool remove_obj_from_map(
Obj *obj);
183 bool remove_obj_type_from_location(uint16 obj_n, uint16 x, uint16 y, uint8 z);
186 Obj *copy_obj(
const Obj *obj);
187 const char *look_obj(
Obj *obj,
bool show_prefix =
false);
188 Obj *get_obj_from_stack(
Obj *obj, uint32 count);
190 bool list_add_obj(
U6LList *list,
Obj *obj,
bool stack_objects =
true, uint32 pos = 0);
192 const char *get_obj_name(
Obj *obj);
193 const char *get_obj_name(uint16 obj_n);
194 const char *get_obj_name(uint16 obj_n, uint8 frame_n);
196 float get_obj_weight(
const Obj *obj,
bool include_container_items = OBJ_WEIGHT_INCLUDE_CONTAINER_ITEMS,
bool scale =
true,
bool include_qty =
true)
const;
197 uint8 get_obj_weight_unscaled(uint16 obj_n)
const {
198 return obj_weight[obj_n];
200 float get_obj_weight(uint16 obj_n)
const;
202 void animate_forwards(
Obj *obj, uint32 loop_count = 1);
203 void animate_backwards(
Obj *obj, uint32 loop_count = 1);
205 void update(uint16 x, uint16 y, uint8 z,
bool teleport =
false);
207 bool unlink_from_engine(
Obj *obj,
bool run_usecode =
true);
210 bool moveto_inventory(
Obj *obj, uint16 actor_num);
211 bool moveto_inventory(
Obj *obj,
Actor *actor);
212 bool moveto_container(
Obj *obj,
Obj *container_obj,
bool stack =
true);
216 void remove_obj(
Obj *obj);
218 bool load_basetile();
219 bool load_weight_table();
222 bool addObjToContainer(
U6LList *list,
Obj *obj);
224 iAVLTree *get_obj_tree(uint16 x, uint16 y, uint8 level)
const;
227 iAVLKey get_obj_tree_key(uint16 x, uint16 y, uint8 level)
const;
230 bool temp_obj_list_add(
Obj *obj);
231 bool temp_obj_list_remove(
Obj *obj);
232 void temp_obj_list_clean_level(uint8 z);
233 void temp_obj_list_clean_area(uint16 x, uint16 y);
235 void remove_temp_obj(
Obj *tmp_obj);
237 inline Obj *find_obj_in_tree(uint16 obj_n, uint8 quality,
bool match_quality, uint8 frame_n,
bool match_frame_n,
Obj **prev_obj,
iAVLTree *obj_tree);
238 inline void start_obj_usecode(
iAVLTree *obj_tree);
239 inline void print_egg_tree(
iAVLTree *obj_tree);
242 void print_object_list();
243 void print_egg_list();
244 void print_obj(
const Obj *obj,
bool in_container, uint8 indent = 0);
Definition: iavl_tree.h:50
Definition: egg_manager.h:45
Definition: configuration.h:60
Definition: usecode.h:151
Definition: tile_manager.h:145
Definition: detection.h:27
Definition: iavl_tree.h:31
Definition: u6_llist.h:46
Out move(In first, In last, Out dst)
Definition: algorithm.h:109
Definition: obj_manager.h:74
Definition: tile_manager.h:113
Definition: obj_manager.h:64
Definition: nuvie_io.h:32