File: command.h

package info (click to toggle)
scummvm 2.9.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 450,580 kB
  • sloc: cpp: 4,299,825; asm: 28,322; python: 12,901; sh: 11,302; java: 9,289; xml: 7,895; perl: 2,639; ansic: 2,465; yacc: 1,670; javascript: 1,020; makefile: 933; lex: 578; awk: 275; objc: 82; sed: 11; php: 1
file content (294 lines) | stat: -rw-r--r-- 11,885 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef STARK_RESOURCES_COMMAND_H
#define STARK_RESOURCES_COMMAND_H

#include "common/array.h"
#include "common/str.h"

#include "math/vector3d.h"

#include "engines/stark/resources/object.h"
#include "engines/stark/resourcereference.h"

namespace Stark {

class ResourceReference;
namespace Formats {
class XRCReadStream;
}

namespace Resources {

class Script;

/**
 * Command resources are script operations.
 *
 * The operation code is the resource subtype.
 *
 * The operation arguments can be integers, strings or resource references.
 */
class Command : public Object {
public:
	static const Type::ResourceType TYPE = Type::kCommand;

	Command(Object *parent, byte subType, uint16 index, const Common::String &name);
	virtual ~Command();

	enum SubType {
		kCommandBegin = 0,
		kCommandEnd = 1,
		kScriptCall = 2,
		kDialogCall = 3,
		kSetInteractiveMode = 4,
		kLocationGoTo = 5,

		kWalkTo = 7,
		kGameLoop = 8,
		kScriptPause = 9,
		kScriptPauseRandom = 10,
		kScriptPauseSkippable = 11,

		kScriptAbort = 13,

		kExit2DLocation = 16,
		kGoto2DLocation = 17,

		kRumbleScene = 19,
		kFadeScene = 20,
		kSwayScene = 21,

		kLocationGoToNewCD = 22,
		kGameEnd = 23,
		kInventoryOpen = 24,
		kFloatScene = 25,
		kBookOfSecretsOpen = 26,

		kDoNothing = 80,
		kItem3DPlaceOn = 81,
		kItem3DWalkTo = 82,
		kItem3DFollowPath = 83,
		kItemLookAt = 84,

		kItem2DFollowPath = 86,
		kItemEnable = 87,
		kItemSetActivity = 88,
		kItemSelectInInventory = 89,

		kUseAnimHierarchy = 92,
		kPlayAnimation = 93,
		kScriptEnable = 94,
		kShowPlay = 95,
		kKnowledgeSetBoolean = 96,

		kKnowledgeSetInteger = 100,
		kKnowledgeAddInteger = 101,

		kEnableFloorField = 103,
		kPlayAnimScriptItem = 104,
		kItemAnimFollowPath = 105,

		kKnowledgeAssignBool = 107,

		kKnowledgeAssignInteger = 110,
		kLocationScrollTo = 111,
		kSoundPlay = 112,

		kKnowledgeSetIntRandom = 115,

		kKnowledgeSubValue = 117,
		kItemLookDirection = 118,

		kStopPlayingSound = 119,
		kLayerGoTo = 120,
		kLayerEnable = 121,
		kLocationScrollSet = 122,
		kFullMotionVideoPlay = 123,

		kAnimSetFrame = 125,
		kKnowledgeAssignNegatedBool = 126,
		kDiaryEnableEntry = 127,
		kPATChangeTooltip = 128,
		kSoundChange = 129,
		kLightSetColor = 130,
		kLightFollowPath = 131,
		kItem3DRunTo = 132,
		kItemPlaceDirection = 133,
		kItemRotateDirection = 134,
		kActivateTexture = 135,
		kActivateMesh = 136,
		kItem3DSetWalkTarget = 137,

		kSpeakWithoutTalking = 139,

		kIsOnFloorField = 162,
		kIsItemEnabled = 163,

		kIsScriptEnabled = 165,
		kIsKnowledgeBooleanSet = 166,

		kIsKnowledgeIntegerInRange = 170,
		kIsKnowledgeIntegerAbove = 171,
		kIsKnowledgeIntegerEqual = 172,
		kIsKnowledgeIntegerLower = 173,
		kIsScriptActive = 174,
		kIsRandom = 175,
		kIsAnimScriptItemReached = 176,
		kIsItemOnPlace = 177,

		kIsAnimPlaying = 179,
		kIsItemActivity = 180,

		kIsItemNearPlace = 183,

		kIsAnimAtTime = 185,
		kIsLocation2D = 186,
		kIsInventoryOpen = 187
	};

	struct Argument {
		enum Type {
			kTypeInteger1 = 1,
			kTypeInteger2 = 2,
			kTypeResourceReference = 3,
			kTypeString = 4
		};

		uint32 type;
		uint32 intValue;
		Common::String stringValue;
		ResourceReference referenceValue;
	};

	/** Execute the command */
	Command *execute(uint32 callMode, Script *script);

	/** Obtain the next command to be executed */
	Command *nextCommand();

	/** Obtain the next command to be executed, depending on a predicate */
	Command *nextCommandIf(bool predicate);

	/** Get the command's list of arguments */
	Common::Array<Argument> getArguments() const;

	/** Resume the opcode ItemSetActivity after it has stopped waiting for the action anim to complete */
	void resumeItemSetActivity();

protected:
	void readData(Formats::XRCReadStream *stream) override;

	Command *resolveArgumentSiblingReference(const Argument &argument);

	Math::Vector3d getObjectPosition(const ResourceReference &targetRef, int32 *floorFace = nullptr);

	Command *opScriptBegin();
	Command *opScriptCall(Script *script, const ResourceReference &scriptRef, int32 synchronous);
	Command *opDialogCall(Script *script, const ResourceReference &dialogRef, int32 suspend);
	Command *opSetInteractiveMode(bool enabled);
	Command *opLocationGoTo(const Common::String &level, const Common::String &location, const ResourceReference &bookmarkRef, int32 direction);
	Command *opWalkTo(Script *script, const ResourceReference &objectRef, int32 suspend);
	Command *opScriptPauseGameLoop(Script *script, int32 count);
	Command *opScriptPause(Script *script, const ResourceReference &durationRef);
	Command *opScriptPauseRandom(Script *script, const ResourceReference &itemRef);
	Command *opScriptPauseSkippable(Script *script, const ResourceReference &durationRef);
	Command *opScriptAbort(ResourceReference scriptRef, bool disable);
	Command *opExit2DLocation();
	Command *opGoto2DLocation(const Common::String &level, const Common::String &location);
	Command *opRumbleScene(Script *script, int32 rumbleDuration, int32 pause);
	Command *opFadeScene(Script *script, bool fadeOut, int32 fadeDuration, bool pause);
	Command *opSwayScene(int32 periodMs, int32 angleIn, int32 amplitudeIn, int32 offsetIn);
	Command *opGameEnd();
	Command *opInventoryOpen(bool open);
	Command *opFloatScene(int32 periodMs, int32 amplitudeIn, int32 offsetIn);
	Command *opBookOfSecretsOpen();
	Command *opDoNothing();
	Command *opItem3DPlaceOn(const ResourceReference &itemRef, const ResourceReference &targetRef);
	Command *opItem3DWalkTo(Script *script, const ResourceReference &itemRef, const ResourceReference &targetRef, bool suspend);
	Command *opItemFollowPath(Script *script, ResourceReference itemRef, ResourceReference pathRef, uint32 speed, uint32 suspend);
	Command *opItemLookAt(Script *script, const ResourceReference &itemRef, const ResourceReference &objRef, bool suspend, int32 unknown);
	Command *opItemEnable(const ResourceReference &itemRef, int32 enable);
	Command *opItemSetActivity(Script *script, const ResourceReference &itemRef, int32 animActivity, bool wait);
	Command *opItemSelectInInventory(const ResourceReference &itemRef);
	Command *opUseAnimHierachy(const ResourceReference &animHierRef);
	Command *opPlayAnimation(Script *script, const ResourceReference &animRef, bool suspend);
	Command *opScriptEnable(const ResourceReference &scriptRef, int32 enable);
	Command *opShowPlay(Script *script, const ResourceReference &ref, int32 suspend);
	Command *opKnowledgeSetBoolean(const ResourceReference &knowledgeRef, int32 enable);
	Command *opKnowledgeSetInteger(const ResourceReference &knowledgeRef, int32 value);
	Command *opKnowledgeSetIntRandom(const ResourceReference &knowledgeRef, uint32 min, uint32 max);
	Command *opKnowledgeAddInteger(const ResourceReference &knowledgeRef, int32 increment);
	Command *opKnowledgeSubValue(const ResourceReference &knowledgeRef, const ResourceReference &valueRef);
	Command *opEnableFloorField(const ResourceReference &floorFieldRef, bool enable);
	Command *opPlayAnimScriptItem(Script *script, const ResourceReference &animScriptItemRef, int32 suspend);
	Command *opItemAnimFollowPath(Script *script, const ResourceReference &animRef, const ResourceReference &pathRef, int32 speed, bool suspend);
	Command *opKnowledgeAssignBool(const ResourceReference &knowledgeRef1, const ResourceReference &knowledgeRef2);
	Command *opKnowledgeAssignNegatedBool(const ResourceReference &knowledgeRef1, const ResourceReference &knowledgeRef2);
	Command *opKnowledgeAssignInteger(const ResourceReference &knowledgeRef1, const ResourceReference &knowledgeRef2);
	Command *opLocationScrollTo(Script *script, const ResourceReference &scrollRef, bool suspend);
	Command *opSoundPlay(Script *script, const ResourceReference &soundRef, int32 suspend);
	Command *opItemLookDirection(Script *script, const ResourceReference &itemRef, int32 direction, bool suspend);
	Command *opStopPlayingSound(const ResourceReference &soundRef);
	Command *opLayerGoTo(const ResourceReference &layerRef);
	Command *opLayerEnable(const ResourceReference &layerRef, int32 enable);
	Command *opLocationScrollSet(const ResourceReference &scrollRef);
	Command *opFullMotionVideoPlay(Script *script, const ResourceReference &movieRef, int32 unknown);
	Command *opAnimSetFrame(const ResourceReference &animRef, const ResourceReference &knowledgeRef);
	Command *opDiaryEnableEntry(const ResourceReference &knowledgeRef);
	Command *opPATChangeTooltip(const ResourceReference &patRef, const ResourceReference &stringRef);
	Command *opSoundChange(Script *script, const ResourceReference &soundRef, int32 volume, int32 pan, int32 duration, bool pause);
	Command *opLightSetColor(const ResourceReference &lightRef, int32 red, int32 green, int32 blue);
	Command *opLightFollowPath(Script *script, const ResourceReference &itemRef, const ResourceReference &lightRef, const ResourceReference &pathRef, int32 speed, bool suspend);
	Command *opItem3DRunTo(Script *script, const ResourceReference &itemRef, const ResourceReference &targetRef, int32 suspend);
	Command *opItemPlaceDirection(const ResourceReference &itemRef, int32 direction);
	Command *opItemRotateDirection(Script *script, const ResourceReference &itemRef, int32 direction, int32 speed, bool suspend);
	Command *opActivateTexture(const ResourceReference &textureRef);
	Command *opActivateMesh(const ResourceReference &meshRef);
	Command *opItem3DSetWalkTarget(const ResourceReference &itemRef, const ResourceReference &targetRef);
	Command *opSpeakWithoutTalking(Script *script, const ResourceReference &speechRef, int32 unknown);
	Command *opIsOnFloorField(const ResourceReference &itemRef, const ResourceReference &floorFieldRef);
	Command *opIsItemEnabled(const ResourceReference &itemRef);
	Command *opIsScriptEnabled(const ResourceReference &scriptRef);
	Command *opIsKnowledgeBooleanSet(const ResourceReference &knowledgeRef);
	Command *opIsKnowledgeIntegerInRange(const ResourceReference &knowledgeRef, int32 min, int32 max);
	Command *opIsKnowledgeIntegerAbove(const ResourceReference &knowledgeRef, int32 value);
	Command *opIsKnowledgeIntegerEqual(const ResourceReference &knowledgeRef, int32 value);
	Command *opIsKnowledgeIntegerLower(const ResourceReference &knowledgeRef, int32 value);
	Command *opIsScriptActive(const ResourceReference &scriptRef);
	Command *opIsRandom(int32 chance);
	Command *opIsAnimScriptItemReached(const ResourceReference &animScriptItemRef);
	Command *opIsItemNearPlace(const ResourceReference &itemRef, const ResourceReference &positionRef, int32 testDistance);
	Command *opIsItemOnPlace(const ResourceReference &itemRef, const ResourceReference &positionRef);
	Command *opIsAnimPlaying(const ResourceReference &animRef);
	Command *opIsItemActivity(const ResourceReference &itemRef, int32 value);
	Command *opIsAnimAtTime(const ResourceReference &animRef, int32 time);
	Command *opIsLocation2D();
	Command *opIsInventoryOpen();

	Common::Array<Argument> _arguments;
};

} // End of namespace Resources
} // End of namespace Stark

#endif // STARK_RESOURCES_COMMAND_H