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 * Additional copyright for this file:
8 * Copyright (C) 1995-1997 Presto Studios, Inc.
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 *
23 */
24
25#ifndef PEGASUS_ITEMS_ITEM_H
26#define PEGASUS_ITEMS_ITEM_H
27
28#include "common/endian.h"
29
30#include "pegasus/types.h"
31#include "pegasus/util.h"
32
33namespace Common {
34 class Error;
35 class ReadStream;
36 class WriteStream;
37 class SeekableReadStream;
38}
39
40namespace Pegasus {
41
42// JMPItemInfo contains resource data used by all Items.
43
45 TimeValue infoLeftTime;
46 TimeValue infoRightStart;
47 TimeValue infoRightStop;
48 uint32 dragSpriteNormalID;
49 uint32 dragSpriteUsedID;
50};
51
52// ItemStateEntry contains a single state/TimeValue pair. The TimeValue is
53// the time value to set the shared area movie that corresponds with the given
54// state of an inventory item.
55
57 ItemState itemState;
58 TimeValue itemTime;
59};
60
62 uint16 numEntries; // For easy ResEdit access
63 ItemStateEntry *entries;
64};
65
66// ItemExtraEntry
67
68static const short kLeftAreaExtra = 0;
69static const short kMiddleAreaExtra = 1;
70static const short kRightAreaExtra = 2;
71
73 uint32 extraID;
74 uint16 extraArea;
75 TimeValue extraStart;
76 TimeValue extraStop;
77};
78
80 uint16 numEntries; // For easy ResEdit access
81 ItemExtraEntry *entries;
82};
83
84// Inventory info resource type and ID:
85// Individual inventory items are stored in these resource types.
86// Resource ID is item ID + kItemBaseResID.
87
88static const uint32 kItemInfoResType = MKTAG('I', 't', 'e', 'm'); // JMPItemInfoHandle
89static const uint32 kLeftAreaInfoResType = MKTAG('L', 'e', 'f', 't'); // ItemStateInfoHandle
90static const uint32 kMiddleAreaInfoResType = MKTAG('M', 'i', 'd', 'l'); // ItemStateInfoHandle
91static const uint32 kRightAreaInfoResType = MKTAG('R', 'g', 'h', 't'); // ItemStateInfoHandle
92static const uint32 kItemExtraInfoResType = MKTAG('I', 'X', 't', 'r'); // ItemExtraInfoHandle
93
94static const uint16 kItemBaseResID = 128;
95
96// Item IDs.
97
98static const ItemID kAirMask = 7;
99static const ItemID kAntidote = 8;
100static const ItemID kArgonCanister = 9;
101static const ItemID kCardBomb = 10;
102static const ItemID kCrowbar = 11;
103static const ItemID kGasCanister = 12;
104static const ItemID kHistoricalLog = 13;
105static const ItemID kJourneymanKey = 14;
106static const ItemID kKeyCard = 15;
107static const ItemID kMachineGun = 16;
108static const ItemID kMarsCard = 17;
109static const ItemID kNitrogenCanister = 18;
110static const ItemID kOrangeJuiceGlassFull = 19;
111static const ItemID kOrangeJuiceGlassEmpty = 20;
112static const ItemID kPoisonDart = 21;
113static const ItemID kSinclairKey = 22;
114static const ItemID kStunGun = 23;
115static const ItemID kArgonPickup = 24;
116
117// Biochips.
118
119static const ItemID kAIBiochip = 0;
120static const ItemID kArthurBiochip = 1;
121static const ItemID kInterfaceBiochip = 1;
122static const ItemID kMapBiochip = 2;
123static const ItemID kOpticalBiochip = 3;
124static const ItemID kPegasusBiochip = 4;
125static const ItemID kRetinalScanBiochip = 5;
126static const ItemID kShieldBiochip = 6;
127
128static const ItemID kNumItems = 25;
129
130// Item States.
131
132static const ItemState kAI000 = 0;
133static const ItemState kAI005 = 1;
134static const ItemState kAI006 = 2;
135static const ItemState kAI010 = 3;
136static const ItemState kAI015 = 4;
137static const ItemState kAI016 = 5;
138static const ItemState kAI020 = 6;
139static const ItemState kAI024 = 7;
140static const ItemState kAI100 = 8;
141static const ItemState kAI101 = 9;
142static const ItemState kAI105 = 10;
143static const ItemState kAI106 = 11;
144static const ItemState kAI110 = 12;
145static const ItemState kAI111 = 13;
146static const ItemState kAI115 = 14;
147static const ItemState kAI116 = 15;
148static const ItemState kAI120 = 16;
149static const ItemState kAI121 = 17;
150static const ItemState kAI124 = 18;
151static const ItemState kAI125 = 19;
152static const ItemState kAI126 = 20;
153static const ItemState kAI200 = 21;
154static const ItemState kAI201 = 22;
155static const ItemState kAI202 = 23;
156static const ItemState kAI205 = 24;
157static const ItemState kAI206 = 25;
158static const ItemState kAI210 = 26;
159static const ItemState kAI211 = 27;
160static const ItemState kAI212 = 28;
161static const ItemState kAI215 = 29;
162static const ItemState kAI216 = 30;
163static const ItemState kAI220 = 31;
164static const ItemState kAI221 = 32;
165static const ItemState kAI222 = 33;
166static const ItemState kAI224 = 34;
167static const ItemState kAI225 = 35;
168static const ItemState kAI226 = 36;
169static const ItemState kAI300 = 37;
170static const ItemState kAI301 = 38;
171static const ItemState kAI302 = 39;
172static const ItemState kAI303 = 40;
173static const ItemState kAI305 = 41;
174static const ItemState kAI306 = 42;
175static const ItemState kAI310 = 43;
176static const ItemState kAI311 = 44;
177static const ItemState kAI312 = 45;
178static const ItemState kAI313 = 46;
179static const ItemState kAI315 = 47;
180static const ItemState kAI316 = 48;
181static const ItemState kAI320 = 49;
182static const ItemState kAI321 = 50;
183static const ItemState kAI322 = 51;
184static const ItemState kAI323 = 52;
185static const ItemState kAI324 = 53;
186static const ItemState kAI325 = 54;
187static const ItemState kAI326 = 55;
188static const ItemState kNormalItem = 56;
189static const ItemState kMapUnavailable = 57;
190static const ItemState kMapEngaged = 58;
191static const ItemState kOptical000 = 59;
192static const ItemState kOptical001 = 60;
193static const ItemState kOptical002 = 61;
194static const ItemState kOptical010 = 62;
195static const ItemState kOptical011 = 63;
196static const ItemState kOptical012 = 64;
197static const ItemState kOptical020 = 65;
198static const ItemState kOptical021 = 66;
199static const ItemState kOptical100 = 67;
200static const ItemState kOptical101 = 68;
201static const ItemState kOptical102 = 69;
202static const ItemState kOptical110 = 70;
203static const ItemState kOptical111 = 71;
204static const ItemState kOptical112 = 72;
205static const ItemState kOptical120 = 73;
206static const ItemState kOptical121 = 74;
207static const ItemState kOptical200 = 75;
208static const ItemState kOptical201 = 76;
209static const ItemState kOptical210 = 77;
210static const ItemState kOptical211 = 78;
211static const ItemState kPegasusTSA00 = 79;
212static const ItemState kPegasusTSA10 = 80;
213static const ItemState kPegasusPrehistoric00 = 81;
214static const ItemState kPegasusPrehistoric01 = 82;
215static const ItemState kPegasusPrehistoric10 = 83;
216static const ItemState kPegasusPrehistoric11 = 84;
217static const ItemState kPegasusMars00 = 85;
218static const ItemState kPegasusMars01 = 86;
219static const ItemState kPegasusMars10 = 87;
220static const ItemState kPegasusMars11 = 88;
221static const ItemState kPegasusNorad00 = 89;
222static const ItemState kPegasusNorad01 = 90;
223static const ItemState kPegasusNorad10 = 91;
224static const ItemState kPegasusNorad11 = 92;
225static const ItemState kPegasusWSC00 = 93;
226static const ItemState kPegasusWSC01 = 94;
227static const ItemState kPegasusWSC10 = 95;
228static const ItemState kPegasusWSC11 = 96;
229static const ItemState kPegasusCaldoria = 97;
230static const ItemState kRetinalSimulating = 98;
231static const ItemState kShieldNormal = 99;
232static const ItemState kShieldRadiation = 100;
233static const ItemState kShieldPlasma = 101;
234static const ItemState kShieldCardBomb = 102;
235static const ItemState kShieldDraining = 103;
236static const ItemState kAirMaskEmptyOff = 104;
237static const ItemState kAirMaskEmptyFilter = 105;
238static const ItemState kAirMaskLowOff = 106;
239static const ItemState kAirMaskLowFilter = 107;
240static const ItemState kAirMaskLowOn = 108;
241static const ItemState kAirMaskFullOff = 109;
242static const ItemState kAirMaskFullFilter = 110;
243static const ItemState kAirMaskFullOn = 111;
244static const ItemState kArgonEmpty = 112;
245static const ItemState kArgonFull = 113;
246static const ItemState kFlashlightOff = 114;
247static const ItemState kFlashlightOn = 115;
248static const ItemState kNitrogenEmpty = 116;
249static const ItemState kNitrogenFull = 117;
250static const ItemState kFullGlass = 118;
251static const ItemState kArthur000 = 119;
252static const ItemState kArthur002 = 120;
253static const ItemState kArthur010 = 121;
254static const ItemState kArthur012 = 122;
255static const ItemState kArthur100 = 123;
256static const ItemState kArthur102 = 124;
257static const ItemState kArthur110 = 125;
258static const ItemState kArthur112 = 126;
259
260// Extra IDs.
261
262static const uint32 kRetinalScanSearching = 0;
263static const uint32 kRetinalScanActivated = 1;
264static const uint32 kShieldIntro = 2;
265static const uint32 kRemoveAirMask = 3;
266static const uint32 kRemoveArgon = 4;
267static const uint32 kRemoveCrowbar = 5;
268static const uint32 kGasCanLoop = 6;
269static const uint32 kRemoveJourneymanKey = 7;
270static const uint32 kRemoveMarsCard = 8;
271static const uint32 kRemoveNitrogen = 9;
272static const uint32 kRemoveGlass = 10;
273static const uint32 kRemoveDart = 11;
274static const uint32 kRemoveSinclairKey = 12;
275
276enum ItemType {
277 kInventoryItemType,
278 kBiochipItemType
279};
280
281class Sprite;
282
283/*
284
285 Item is an object which can be picked up and carried around.
286 Items have
287 a location
288 an ID.
289 weight
290 an owner (kNoActorID if no one is carrying the Item)
291
292*/
293
294class Item : public IDObject {
295public:
296 Item(const ItemID id, const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction);
297 virtual ~Item();
298
299 // WriteToStream writes everything EXCEPT the item's ID.
300 // It is assumed that the calling function will write and read the ID.
301 virtual void writeToStream(Common::WriteStream *stream);
302 virtual void readFromStream(Common::ReadStream *stream);
303
304 virtual ActorID getItemOwner() const;
305 virtual void setItemOwner(const ActorID owner);
306
307 void getItemRoom(NeighborhoodID &neighborhood, RoomID &room, DirectionConstant &direction) const;
308 void setItemRoom(const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction);
309 NeighborhoodID getItemNeighborhood() const;
310
311 virtual WeightType getItemWeight();
312
313 virtual void setItemState(const ItemState state);
314 virtual ItemState getItemState() const;
315
316 virtual ItemType getItemType() = 0;
317
318 TimeValue getInfoLeftTime() const;
319 void getInfoRightTimes(TimeValue &, TimeValue &) const;
320 TimeValue getSharedAreaTime() const;
321
322 Sprite *getDragSprite(const DisplayElementID) const;
323
324 /*
325 select -- called when this item becomes current. Also called when the inventory
326 panel holding this item is raised and this is the current item.
327 deselect -- called when this item is no longer current.
328 activate -- called on the current item when the panel is closed.
329 */
330 // In an override of these three member functions, you must call the inherited
331 // member functions.
332 virtual void select();
333 virtual void deselect();
334 virtual bool isSelected() { return _isSelected; }
335
336 virtual void activate() { _isActive = true; }
337 virtual bool isActive() { return _isActive; }
338 virtual void pickedUp() {}
339 virtual void addedToInventory() {}
340 virtual void removedFromInventory() {}
341 virtual void dropped() {}
342
343 // Called when the shared area is taken by another item, but this item is still
344 // selected.
345 virtual void giveUpSharedArea() {}
346 virtual void takeSharedArea() {}
347
348 void findItemExtra(const uint32 extraID, ItemExtraEntry &entry);
349
350 // Reset to its original state at the beginning of the game
351 void reset();
352
353protected:
354 NeighborhoodID _itemNeighborhood;
355 RoomID _itemRoom;
356 DirectionConstant _itemDirection;
357 ActorID _itemOwnerID;
358 WeightType _itemWeight;
359 ItemState _itemState;
360
361 NeighborhoodID _originalNeighborhood;
362 RoomID _originalRoom;
363 DirectionConstant _originalDirection;
364
365 JMPItemInfo _itemInfo;
366 ItemStateInfo _sharedAreaInfo;
367 ItemExtraInfo _itemExtras;
368 bool _isActive;
369 bool _isSelected;
370
371 static void getItemStateEntry(ItemStateInfo, uint32, ItemState &, TimeValue &);
372 static void findItemStateEntryByState(ItemStateInfo, ItemState, TimeValue &);
373 static ItemStateInfo readItemState(Common::SeekableReadStream *stream);
374};
375
376} // End of namespace Pegasus
377
378#endif
Definition: stream.h:385
Definition: stream.h:745
Definition: stream.h:77
Definition: util.h:38
Definition: item.h:294
Definition: elements.h:168
#define MKTAG(a0, a1, a2, a3)
Definition: endian.h:188
Definition: algorithm.h:29
Definition: item.h:72
Definition: item.h:79
Definition: item.h:56
Definition: item.h:61
Definition: item.h:44