ScummVM API documentation
item.h
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 modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef ULTIMA4_GAME_ITEM_H
23 #define ULTIMA4_GAME_ITEM_H
24 
25 #include "ultima/ultima4/core/types.h"
26 #include "common/str.h"
27 
28 namespace Ultima {
29 namespace Ultima4 {
30 
31 class Coords;
32 class Map;
33 struct Portal;
34 
35 enum SearchCondition {
36  SC_NONE = 0x00,
37  SC_NEWMOONS = 0x01,
38  SC_FULLAVATAR = 0x02,
39  SC_REAGENTDELAY = 0x04
40 };
41 
42 class Items;
43 typedef bool (Items::*IsInInventoryProc)(int item);
44 typedef void (Items::*InventoryActionProc)(int item);
45 
46 struct
47 #ifndef NO_CXX11_ALIGNAS
48 alignas(8)
49 #endif
51  const char *_name;
52  const char *_shortName;
53  const char *_locationLabel;
54  IsInInventoryProc _isItemInInventory;
55  InventoryActionProc _putItemInInventory;
56  InventoryActionProc _useItem;
57  int _data;
58  byte _conditions;
59 };
60 
61 typedef void (*DestroyAllCreaturesCallback)();
62 #define N_ITEMS 34
63 
64 class Items {
65 private:
66 
67  static const ItemLocation ITEMS[N_ITEMS];
68  DestroyAllCreaturesCallback destroyAllCreaturesCallback;
69  int needStoneNames;
70  byte stoneMask;
71 private:
72  bool isRuneInInventory(int virt);
73  void putRuneInInventory(int virt);
74  bool isStoneInInventory(int virt);
75  void putStoneInInventory(int virt);
76  bool isItemInInventory(int item);
77  bool isSkullInInventory(int item);
78  void putItemInInventory(int item);
79 
83  void useBBC(int item);
84 
88  void useHorn(int item);
89 
93  void useWheel(int item);
94 
98  void useSkull(int item);
99 
103  void useStone(int item);
104  void useKey(int item);
105  bool isMysticInInventory(int mystic);
106  void putMysticInInventory(int mystic);
107  bool isWeaponInInventory(int weapon);
108  void putWeaponInInventory(int weapon);
109  void useTelescope(int notused);
110  bool isReagentInInventory(int reag);
111  void putReagentInInventory(int reag);
112 
116  void itemHandleStones(const Common::String &color);
117 
121  bool itemConditionsMet(byte conditions);
122 public:
123  Items();
124  ~Items();
125 
126  void setDestroyAllCreaturesCallback(DestroyAllCreaturesCallback callback);
127 
132  const ItemLocation *itemAtLocation(const Map *map, const Coords &coords);
133 
137  void itemUse(const Common::String &shortName);
138 
142  static bool isAbyssOpened(const Portal *p);
143 };
144 
145 extern Items *g_items;
146 
147 } // End of namespace Ultima4
148 } // End of namespace Ultima
149 
150 #endif
Definition: portal.h:53
static bool isAbyssOpened(const Portal *p)
Definition: str.h:59
Definition: map.h:134
Definition: coords.h:31
void itemUse(const Common::String &shortName)
Definition: detection.h:27
Definition: item.h:64
Definition: item.h:46
const ItemLocation * itemAtLocation(const Map *map, const Coords &coords)