1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef NUVIE_CORE_OBJ_H 24 #define NUVIE_CORE_OBJ_H 25 26 #include "ultima/nuvie/core/nuvie_defs.h" 27 #include "ultima/nuvie/misc/u6_llist.h" 28 29 namespace Ultima { 30 namespace Nuvie { 31 32 class Actor; 33 34 #define NO_OBJ_STATUS 0 35 36 // obj status bit flags 37 #define OBJ_STATUS_OK_TO_TAKE 0x1 38 //#define OBJ_STATUS_SEEN_EGG 0x2 // something to do with eggs <- not sure about this one. 39 #define OBJ_STATUS_INVISIBLE 0x2 // I think this is correct 40 #define OBJ_STATUS_CHARMED 0x4 // objlist.txt says 'charmed' 41 42 43 // position: A 2 bit field, so can't use plain | to check / |= to set these. 44 // FIXME: check to make sure we don't do this anywhere anymore 45 #define OBJ_STATUS_ON_MAP 0x0 46 #define OBJ_STATUS_IN_CONTAINER 0x8 47 #define OBJ_STATUS_IN_INVENTORY 0x10 48 #define OBJ_STATUS_READIED 0x18 49 #define OBJ_STATUS_MASK_GET 0x18 50 #define OBJ_STATUS_MASK_SET 0xE7 51 52 #define OBJ_STATUS_TEMPORARY 0x20 53 #define OBJ_STATUS_EGG_ACTIVE 0x40 // something to do with eggs 54 #define OBJ_STATUS_BROKEN 0x40 55 #define OBJ_STATUS_MUTANT 0x40 56 #define OBJ_STATUS_CURSED 0x40 57 #define OBJ_STATUS_LIT 0x80 58 59 60 //first 3 bits of nuvie_status code object location 61 //in the nuvie engine. 62 63 //Nuvie engine obj locations 64 #define OBJ_LOC_NONE 0 65 #define OBJ_LOC_INV 1 66 #define OBJ_LOC_MAP 2 67 #define OBJ_LOC_READIED 3 68 #define OBJ_LOC_CONT 4 69 70 #define NUVIE_OBJ_STATUS_LOC_MASK_GET 0x7 71 #define NUVIE_OBJ_STATUS_LOC_MASK_SET 0xf8 72 73 #define NUVIE_OBJ_STATUS_SCRIPTING 0x8 74 #define NUVIE_OBJ_STATUS_ACTOR_OBJ 0x10 75 76 #define OBJ_MATCH_QUALITY true 77 #define OBJ_NOMATCH_QUALITY false 78 79 #define OBJ_MATCH_FRAME_N true 80 #define OBJ_NOMATCH_FRAME_N false 81 82 //We use this in Obj::is_in_inventory() 83 #define OBJ_DONT_CHECK_PARENT false 84 85 class Obj { 86 uint8 nuvie_status; 87 88 public: 89 //uint16 objblk_n; 90 91 uint16 obj_n; 92 uint8 frame_n; 93 uint8 status; 94 uint16 x; 95 uint16 y; 96 uint8 z; 97 98 uint16 qty; 99 uint8 quality; 100 void *parent; //either an Obj pointer or an Actor pointer depending on engine_loc. 101 U6LList *container; 102 103 public: 104 Obj(); 105 Obj(Obj *sobj); 106 is_script_obj()107 bool is_script_obj() { 108 return (nuvie_status & NUVIE_OBJ_STATUS_SCRIPTING); 109 } is_actor_obj()110 bool is_actor_obj() { 111 return (nuvie_status & NUVIE_OBJ_STATUS_ACTOR_OBJ); 112 } 113 114 bool is_ok_to_take(); is_invisible()115 bool is_invisible() { 116 return (status & OBJ_STATUS_INVISIBLE); 117 } is_charmed()118 bool is_charmed() { 119 return (status & OBJ_STATUS_CHARMED); 120 } is_temporary()121 bool is_temporary() { 122 return (status & OBJ_STATUS_TEMPORARY); 123 } is_egg_active()124 bool is_egg_active() { 125 return (status & OBJ_STATUS_EGG_ACTIVE); 126 } is_broken()127 bool is_broken() { 128 return (status & OBJ_STATUS_BROKEN); 129 } is_mutant()130 bool is_mutant() { 131 return (status & OBJ_STATUS_MUTANT); 132 } is_cursed()133 bool is_cursed() { 134 return (status & OBJ_STATUS_CURSED); 135 } is_lit()136 bool is_lit() { 137 return (status & OBJ_STATUS_LIT); 138 } 139 is_on_map()140 bool is_on_map() { 141 return ((nuvie_status & NUVIE_OBJ_STATUS_LOC_MASK_GET) == OBJ_LOC_MAP); 142 } is_in_container()143 bool is_in_container() { 144 return ((nuvie_status & NUVIE_OBJ_STATUS_LOC_MASK_GET) == OBJ_LOC_CONT); 145 } 146 bool is_in_inventory(bool check_parent = true); 147 is_readied()148 bool is_readied() { 149 return ((nuvie_status & NUVIE_OBJ_STATUS_LOC_MASK_GET) == OBJ_LOC_READIED); 150 } 151 has_container()152 bool has_container() { 153 return (container != NULL); 154 } 155 void make_container(); 156 Obj *get_container_obj(bool recursive = false); 157 uint32 container_count_objects(); 158 159 uint8 get_engine_loc(); 160 Actor *get_actor_holding_obj(); 161 162 void set_on_map(U6LList *map_list); 163 void set_in_container(Obj *container_obj); 164 void set_in_inventory(); 165 166 void set_invisible(bool flag); 167 168 void set_temporary(bool flag = true); 169 170 void set_ok_to_take(bool flag, bool recursive = false); 171 172 void readied(); 173 void set_noloc(); 174 void set_in_script(bool flag); 175 void set_actor_obj(bool flag); 176 177 void add(Obj *obj, bool stack = false); 178 179 bool remove(Obj *obj); 180 181 Obj *find_in_container(uint16 obj_n, uint8 quality, bool match_quality = OBJ_MATCH_QUALITY, uint8 frame_n = 0, bool match_frame_n = OBJ_NOMATCH_FRAME_N, Obj **prev_obj = NULL); 182 183 uint32 get_total_qty(uint16 match_obj_n); 184 185 protected: 186 187 void add_and_stack(Obj *obj); 188 189 }; 190 191 } // End of namespace Nuvie 192 } // End of namespace Ultima 193 194 #endif 195