22 #ifndef ASYLUM_RESOURCES_ENCOUNTERS_H 23 #define ASYLUM_RESOURCES_ENCOUNTERS_H 25 #include "common/array.h" 26 #include "common/serializer.h" 28 #include "asylum/eventhandler.h" 29 #include "asylum/shared.h" 36 uint32 speechResourceId;
37 ResourceId scriptResourceId;
43 scriptResourceId = kResourceNone;
44 memset(&keywords, 0,
sizeof(keywords));
52 s.syncAsSint32LE(speechResourceId);
53 s.syncAsSint32LE(scriptResourceId);
55 for (int32 i = 0; i <
ARRAYSIZE(keywords); i++)
56 s.syncAsSint16LE(keywords[i]);
58 s.syncAsByte(variable2);
68 for (uint i = 0; i < _size; i++)
69 s.syncAsSint16LE(_storage[i]);
79 for (uint i = 0; i < _size; i++)
80 _storage[i].saveLoadWithSerializer(s);
89 void run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2, ActorIndex actorIndex);
95 void setShouldEnablePlayer(
bool state) { _shouldEnablePlayer = state; }
96 bool shouldEnablePlayer() {
return _shouldEnablePlayer; }
107 enum KeywordOptions {
108 kKeywordOptionsDisabled = 0x20,
109 kKeywordOptionsUnknown = 0x40,
110 kKeywordOptionsVisible = 0x80
113 struct EncounterGraphic {
117 ResourceId resourceId;
128 resourceId = kResourceNone;
138 struct EncounterDrawingStruct {
144 ResourceId resourceId;
146 EncounterDrawingStruct() {
150 resourceId = kResourceNone;
156 EncounterDrawingStruct _drawingStructs[2];
157 int32 _keywordIndexes[50];
160 EncounterGraphic _background;
161 EncounterGraphic _portrait1;
162 EncounterGraphic _portrait2;
169 int32 _speechResourceId;
170 ResourceId _soundResourceId;
175 ActorIndex _actorIndex;
186 bool _shouldCloseDialog;
190 bool _shouldCloseBackground;
194 uint32 _keywordStartIndex;
195 uint32 _keywordsOffset;
198 bool _shouldEnablePlayer;
199 bool _wasPlayerDisabled;
201 bool _isScriptRunning;
207 void initBackground();
208 void initPortraits();
209 void initDrawStructs();
220 void setVariable(uint32 index, int16 val);
221 int16 getVariable(uint32 index);
222 int16 getVariableInv(int16 index);
226 uint32 findKeyword(
EncounterItem *item, int16 keyword)
const;
227 int32 getKeywordIndex();
228 void choose(int32 keywordIndex);
229 bool checkKeywords()
const;
230 bool checkKeywords2()
const;
231 void updateFromRect(int32 rectIndex);
235 void resetSpeech(int16 a1, int16 a2);
236 void setupPortraits();
237 void setupSpeechText();
238 void setupSpeechData(
char val, EncounterGraphic *encounterGraphic)
const;
239 void setupSpeech(ResourceId textResourceId, ResourceId fontResourceId);
240 bool setupSpeechTest(ResourceId
id);
245 bool drawBackground();
246 bool drawPortraits();
248 void drawDialogOptions();
249 void drawSubtitle(
char *text, ResourceId font, int16 y);
253 void exitEncounter();
254 void setupEntities(
bool type4);
256 void updateDrawingStatus();
257 void updateDrawingStatus1(int32 rectIndex);
258 void updateDrawingStatus2(int32 rectIndex);
260 void updatePalette1();
261 void updatePalette2();
263 bool isKeywordVisible(int16 keyword)
const {
return (
bool)(BYTE1(keyword) & kKeywordOptionsVisible); }
264 bool isKeywordDisabled(int16 keyword)
const {
return (
bool)(BYTE1(keyword) & kKeywordOptionsDisabled); }
268 enum EncounterOpcode {
269 kOpcodeEncounterReturn = 0,
270 kOpcodeSetScriptVariable = 1,
271 kOpcodeSetCounterFromVars = 2,
272 kOpcodeSetOffset = 3,
273 kOpcodeSetOffsetIfCounterNegative = 4,
274 kOpcodeSetOffsetIfCounterNegativeOrNull = 5,
275 kOpcodeSetOffsetIfCounterIsNull = 6,
276 kOpcodeSetOffsetIfCounterIsNotNull = 7,
277 kOpcodeSetOffsetIfCounterPositiveOrNull = 8,
278 kOpcodeSetOffsetIfCounterPositive = 9,
279 kOpcodeSetCurrentItemOptions = 10,
280 kOpcodeClearCurrentItemOptions = 11,
281 kOpcodeSetItemOptions = 12,
282 kOpcodeCloseDialog = 13,
283 kOpcodeResetSpeech = 14,
284 kOpcodeSetVariable = 15,
285 kOpcodeIncrementScriptVariable = 16,
286 kOpcodeProcessVariable3 = 17,
287 kOpcodeAddRemoveInventoryItem = 18,
288 kOpcodeSetCounterIfInventoryOmits = 21,
289 kOpcodePrepareMovie = 23,
290 kOpcodeSetClearGameFlag = 24,
291 kOpcodeSetCounterFromGameFlag = 25
299 ScriptEntry(byte *data) {
301 param1 = *(data + 1);
302 param2 = READ_LE_UINT16(data + 2);
312 ResourceId resourceId;
315 reset(kResourceNone);
318 void reset(ResourceId
id) {
319 memset(&vars, 0,
sizeof(vars));
326 ScriptData _scriptData;
328 void initScript(ResourceId resourceId);
329 ScriptEntry getScriptEntry(ResourceId resourceId, uint32 offset);
337 #endif // ASYLUM_RESOURCES_ENCOUNTERS_H #define ARRAYSIZE(x)
Definition: util.h:91
Definition: encounters.h:35
Definition: encounters.h:84
Definition: encounters.h:73
Definition: serializer.h:79
Definition: eventhandler.h:43
Definition: eventhandler.h:61
Definition: serializer.h:308
Definition: encounters.h:62