ScummVM API documentation
story.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 // Definitions are the enum for the set of global definitions in Story.GS
23 #include "immortal/definitions.h"
24 
25 // Sprite List is a list of all sprite definitions (could be included in definitions.h, but sprite_list.gs was a separate source file and is sprite specific)
26 #include "immortal/sprite_list.h"
27 
28 #ifndef IMMORTAL_STORY_H
29 #define IMMORTAL_STORY_H
30 
31 namespace Immortal {
32 
33 // These maximum numbers aren't really needed, because most of these are vectors and have .size()
34 enum StoryMaxes {
35  kMaxRooms = 16,
36  kMaxDoors = 10,
37  kMaxFlames = 32,
38  kMaxFlamesInRoom = 5,
39  kMaxObjects = 42,
40  kMaxMonsters = 20,
41  kMaxGenSprites = 6,
42  kMaxCycles = 32
43 };
44 
45 // These are flags that are relevant to their specific story data structures
46 enum RoomFlag : uint8 { // Generic properties available to each room
47  kRoomFlag0 = 0x01,
48  kRoomFlag1 = 0x02,
49  kRoomFlag2 = 0x04,
50  kRoomFlag3 = 0x08
51 };
52 
53 enum ObjFlag : uint8 { // Properties of the object essentially
54  kObjUsesFireButton = 0x40,
55  kObjIsInvisible = 0x20,
56  kObjIsRunning = 0x10,
57  kObjIsChest = 0x08,
58  kObjIsOnGround = 0x04,
59  kObjIsF1 = 0x02,
60  kObjIsF2 = 0x01,
61  kObjNone = 0x0
62 };
63 
64 enum IsA : uint8 { // To be completely honest, I'm not really sure what this is. It seems to be more object flags, but they act a little strangely
65  kIsAF1 = 0x20,
66  kIsAF2 = 0x40,
67  kIsANone = 0x0,
68 };
69 
70 enum MonsterFlag : uint8 { // Mostly properties of the AI for a given monster, *including the player*
71  kMonstIsNone = 0x00,
72  kMonstIsTough = 0x10,
73  kMonstIsDead = 0x20,
74  kMonstIsPoss = 0x40,
75  kMonstIsBaby = 0x40,
76  kMonstIsEngage = 0x80,
77  kMonstPlayer = 0x00,
78  kMonstMonster = 0x01,
79  kMonstAnybody = 0x02,
80  kMonstNobody = 0x03,
81  kMonstA = 0x04,
82  kMonstB = 0x05,
83  kMonstC = 0x06,
84  kMonstD = 0x07
85 };
86 
87 // Flame pattern is used by the story data, in-room data, *and* the level based total flame data. So it needs to be in story.h to be used by immortal.h and room.h
88 enum FPattern : uint8 { // This defines which Cyc animation it uses
89  kFlameNormal,
90  kFlameCandle,
91  kFlameOff,
92  kFlameGusty
93 };
94 
95 // Object Pickup defines how an object can be picked up by the player, with different functions
96 enum SObjPickup {
97 };
98 
99 struct Pickup {
100  int _param;
101  // This will be a pointer to function
102 };
103 
104 // Damage is used by object types as well as enemy types
105 enum SDamage {
106 };
107 
108 struct Damage {
109 };
110 
111 // Use defines the function and parameters for using an object
112 enum SObjUse {
113 };
114 
115 struct Use {
116  int _param;
117  // This will be a pointer to function
118 };
119 
120 struct ObjType {
121  Str _str = kStrNull;
122  Str _desc = kStrNull;
123  int _size = 0;
124  Use _use;
125  Use _run;
126  Pickup _pickup;
127 };
128 
129 // Cycles define the animation of sprites within a level. There is a fixed total of cycles available, and they are not room dependant
130 struct Cycle {
131  int _index; // In source this is actually the position within the *instruction list*, but since cycle's are structs, it's just the index of frames now
132  CycID _cycList;
133 };
134 
135 /* Strictly speaking, many of these structs (which were rom data written dynamically
136  * with compiler macros) combine multiple properties into single bytes (ex. room uses
137  * bits 0-2 of X to also hold the roomOP, and bits 0-2 of Y to hold flags). However
138  * for the moment there's no need to replicate this particular bit of space saving.
139  */
140 struct SCycle {
141  SpriteName _sName;
142  Common::Array<int> _frames;
143  bool _repeat;
144  SCycle() {}
145  SCycle(SpriteName s, bool r, Common::Array<int> f) {
146  _sName = s;
147  _repeat = r;
148  _frames = f;
149  }
150 };
151 
152 struct SRoom {
153  uint16 _x = 0;
154  uint16 _y = 0;
155 
156  RoomFlag _flags = kRoomFlag0;
157  SRoom() {}
158  SRoom(uint16 x, uint16 y, RoomFlag f) {
159  _x = x;
160  _y = y;
161  _flags = f;
162  }
163 };
164 
165 struct SDoor {
166  uint8 _dir = 0;
167  uint16 _x = 0;
168  uint16 _y = 0;
169 
170  uint16 _fromRoom = 0;
171  uint16 _toRoom = 0;
172 
173  bool _isLocked = false;
174  SDoor() {}
175  SDoor(uint8 d, uint16 x, uint16 y, uint16 f, uint16 t, bool l) {
176  _dir = d;
177  _x = x;
178  _y = y;
179 
180  _fromRoom = f;
181  _toRoom = t;
182 
183  _isLocked = l;
184  }
185 };
186 
187 struct SFlame {
188  uint16 _x = 0;
189  uint16 _y = 0;
190 
191  FPattern _p = kFlameOff;
192  SFlame() {}
193  SFlame(uint16 x, uint16 y, FPattern p) {
194  _x = x;
195  _y = y;
196  _p = p;
197  }
198 };
199 
200 struct SObj {
201  uint16 _x = 0;
202  uint16 _y = 0;
203  uint8 _flags = 0;
204 
205  SObjType _type = kTypeTrap;
206  SpriteFrame _frame = kNoFrame;
207  Common::Array<uint8> _traps;
208  SObj() {}
209  SObj(uint16 x, uint16 y, SObjType t, SpriteFrame s, uint8 f, Common::Array<uint8> traps) {
210  _x = x;
211  _y = y;
212  _type = t;
213  _flags = f;
214  _traps = traps;
215  _frame = s;
216  }
217 };
218 
219 struct SMonster {
220  uint16 _x = 0;
221  uint16 _y = 0;
222  uint16 _hits = 0;
223  uint8 _flags = 0;
224 
225  MonsterFlag _madAt = kMonstIsNone;
226  SpriteName _sprite = kCandle;
227  Common::Array<Motive> _program;
228  SMonster() {}
229  SMonster(uint16 x, uint16 y, uint16 h, MonsterFlag m, uint8 f, Common::Array<Motive> p, SpriteName s) {
230  _x = x;
231  _y = y;
232  _hits = h;
233  _madAt = m;
234  _flags = f;
235  _program = p;
236  _sprite = s;
237  }
238 };
239 
240 struct Story {
241  int _level = 0;
242  int _part = 1;
243 
244  uint16 _initialUnivX = 0;
245  uint16 _initialUnivY = 0;
246  uint16 _playerPointX = 0;
247  uint16 _playerPointY = 0;
248 
249  Common::Array<int> _ladders;
250  Common::Array<SRoom> _rooms;
251  Common::Array<SDoor> _doors;
252  CArray2D<SFlame> _flames;
253  CArray2D<SObj> _objects;
254  CArray2D<SMonster> _monsters;
255 };
256 
257 } // namespace Immortal
258 
259 #endif
Definition: story.h:152
Definition: story.h:115
Definition: story.h:219
Definition: definitions.h:25
Definition: story.h:108
Definition: story.h:187
Definition: story.h:99
Definition: story.h:120
Definition: story.h:140
Definition: story.h:165
Definition: story.h:200
Definition: story.h:240
Definition: story.h:130