ScummVM API documentation
command.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 STARK_RESOURCES_COMMAND_H
23 #define STARK_RESOURCES_COMMAND_H
24 
25 #include "common/array.h"
26 #include "common/str.h"
27 
28 #include "math/vector3d.h"
29 
30 #include "engines/stark/resources/object.h"
31 #include "engines/stark/resourcereference.h"
32 
33 namespace Stark {
34 
35 class ResourceReference;
36 namespace Formats {
37 class XRCReadStream;
38 }
39 
40 namespace Resources {
41 
42 class Script;
43 
51 class Command : public Object {
52 public:
53  static const Type::ResourceType TYPE = Type::kCommand;
54 
55  Command(Object *parent, byte subType, uint16 index, const Common::String &name);
56  virtual ~Command();
57 
58  enum SubType {
59  kCommandBegin = 0,
60  kCommandEnd = 1,
61  kScriptCall = 2,
62  kDialogCall = 3,
63  kSetInteractiveMode = 4,
64  kLocationGoTo = 5,
65 
66  kWalkTo = 7,
67  kGameLoop = 8,
68  kScriptPause = 9,
69  kScriptPauseRandom = 10,
70  kScriptPauseSkippable = 11,
71 
72  kScriptAbort = 13,
73 
74  kExit2DLocation = 16,
75  kGoto2DLocation = 17,
76 
77  kRumbleScene = 19,
78  kFadeScene = 20,
79  kSwayScene = 21,
80 
81  kLocationGoToNewCD = 22,
82  kGameEnd = 23,
83  kInventoryOpen = 24,
84  kFloatScene = 25,
85  kBookOfSecretsOpen = 26,
86 
87  kDoNothing = 80,
88  kItem3DPlaceOn = 81,
89  kItem3DWalkTo = 82,
90  kItem3DFollowPath = 83,
91  kItemLookAt = 84,
92 
93  kItem2DFollowPath = 86,
94  kItemEnable = 87,
95  kItemSetActivity = 88,
96  kItemSelectInInventory = 89,
97 
98  kUseAnimHierarchy = 92,
99  kPlayAnimation = 93,
100  kScriptEnable = 94,
101  kShowPlay = 95,
102  kKnowledgeSetBoolean = 96,
103 
104  kKnowledgeSetInteger = 100,
105  kKnowledgeAddInteger = 101,
106 
107  kEnableFloorField = 103,
108  kPlayAnimScriptItem = 104,
109  kItemAnimFollowPath = 105,
110 
111  kKnowledgeAssignBool = 107,
112 
113  kKnowledgeAssignInteger = 110,
114  kLocationScrollTo = 111,
115  kSoundPlay = 112,
116 
117  kKnowledgeSetIntRandom = 115,
118 
119  kKnowledgeSubValue = 117,
120  kItemLookDirection = 118,
121 
122  kStopPlayingSound = 119,
123  kLayerGoTo = 120,
124  kLayerEnable = 121,
125  kLocationScrollSet = 122,
126  kFullMotionVideoPlay = 123,
127 
128  kAnimSetFrame = 125,
129  kKnowledgeAssignNegatedBool = 126,
130  kDiaryEnableEntry = 127,
131  kPATChangeTooltip = 128,
132  kSoundChange = 129,
133  kLightSetColor = 130,
134  kLightFollowPath = 131,
135  kItem3DRunTo = 132,
136  kItemPlaceDirection = 133,
137  kItemRotateDirection = 134,
138  kActivateTexture = 135,
139  kActivateMesh = 136,
140  kItem3DSetWalkTarget = 137,
141 
142  kSpeakWithoutTalking = 139,
143 
144  kIsOnFloorField = 162,
145  kIsItemEnabled = 163,
146 
147  kIsScriptEnabled = 165,
148  kIsKnowledgeBooleanSet = 166,
149 
150  kIsKnowledgeIntegerInRange = 170,
151  kIsKnowledgeIntegerAbove = 171,
152  kIsKnowledgeIntegerEqual = 172,
153  kIsKnowledgeIntegerLower = 173,
154  kIsScriptActive = 174,
155  kIsRandom = 175,
156  kIsAnimScriptItemReached = 176,
157  kIsItemOnPlace = 177,
158 
159  kIsAnimPlaying = 179,
160  kIsItemActivity = 180,
161 
162  kIsItemNearPlace = 183,
163 
164  kIsAnimAtTime = 185,
165  kIsLocation2D = 186,
166  kIsInventoryOpen = 187
167  };
168 
169  struct Argument {
170  enum Type {
171  kTypeInteger1 = 1,
172  kTypeInteger2 = 2,
173  kTypeResourceReference = 3,
174  kTypeString = 4
175  };
176 
177  uint32 type;
178  uint32 intValue;
179  Common::String stringValue;
180  ResourceReference referenceValue;
181  };
182 
184  Command *execute(uint32 callMode, Script *script);
185 
187  Command *nextCommand();
188 
190  Command *nextCommandIf(bool predicate);
191 
193  Common::Array<Argument> getArguments() const;
194 
196  void resumeItemSetActivity();
197 
198 protected:
199  void readData(Formats::XRCReadStream *stream) override;
200 
201  Command *resolveArgumentSiblingReference(const Argument &argument);
202 
203  Math::Vector3d getObjectPosition(const ResourceReference &targetRef, int32 *floorFace = nullptr);
204 
205  Command *opScriptBegin();
206  Command *opScriptCall(Script *script, const ResourceReference &scriptRef, int32 synchronous);
207  Command *opDialogCall(Script *script, const ResourceReference &dialogRef, int32 suspend);
208  Command *opSetInteractiveMode(bool enabled);
209  Command *opLocationGoTo(const Common::String &level, const Common::String &location, const ResourceReference &bookmarkRef, int32 direction);
210  Command *opWalkTo(Script *script, const ResourceReference &objectRef, int32 suspend);
211  Command *opScriptPauseGameLoop(Script *script, int32 count);
212  Command *opScriptPause(Script *script, const ResourceReference &durationRef);
213  Command *opScriptPauseRandom(Script *script, const ResourceReference &itemRef);
214  Command *opScriptPauseSkippable(Script *script, const ResourceReference &durationRef);
215  Command *opScriptAbort(ResourceReference scriptRef, bool disable);
216  Command *opExit2DLocation();
217  Command *opGoto2DLocation(const Common::String &level, const Common::String &location);
218  Command *opRumbleScene(Script *script, int32 rumbleDuration, int32 pause);
219  Command *opFadeScene(Script *script, bool fadeOut, int32 fadeDuration, bool pause);
220  Command *opSwayScene(int32 periodMs, int32 angleIn, int32 amplitudeIn, int32 offsetIn);
221  Command *opGameEnd();
222  Command *opInventoryOpen(bool open);
223  Command *opFloatScene(int32 periodMs, int32 amplitudeIn, int32 offsetIn);
224  Command *opBookOfSecretsOpen();
225  Command *opDoNothing();
226  Command *opItem3DPlaceOn(const ResourceReference &itemRef, const ResourceReference &targetRef);
227  Command *opItem3DWalkTo(Script *script, const ResourceReference &itemRef, const ResourceReference &targetRef, bool suspend);
228  Command *opItemFollowPath(Script *script, ResourceReference itemRef, ResourceReference pathRef, uint32 speed, uint32 suspend);
229  Command *opItemLookAt(Script *script, const ResourceReference &itemRef, const ResourceReference &objRef, bool suspend, int32 unknown);
230  Command *opItemEnable(const ResourceReference &itemRef, int32 enable);
231  Command *opItemSetActivity(Script *script, const ResourceReference &itemRef, int32 animActivity, bool wait);
232  Command *opItemSelectInInventory(const ResourceReference &itemRef);
233  Command *opUseAnimHierachy(const ResourceReference &animHierRef);
234  Command *opPlayAnimation(Script *script, const ResourceReference &animRef, bool suspend);
235  Command *opScriptEnable(const ResourceReference &scriptRef, int32 enable);
236  Command *opShowPlay(Script *script, const ResourceReference &ref, int32 suspend);
237  Command *opKnowledgeSetBoolean(const ResourceReference &knowledgeRef, int32 enable);
238  Command *opKnowledgeSetInteger(const ResourceReference &knowledgeRef, int32 value);
239  Command *opKnowledgeSetIntRandom(const ResourceReference &knowledgeRef, uint32 min, uint32 max);
240  Command *opKnowledgeAddInteger(const ResourceReference &knowledgeRef, int32 increment);
241  Command *opKnowledgeSubValue(const ResourceReference &knowledgeRef, const ResourceReference &valueRef);
242  Command *opEnableFloorField(const ResourceReference &floorFieldRef, bool enable);
243  Command *opPlayAnimScriptItem(Script *script, const ResourceReference &animScriptItemRef, int32 suspend);
244  Command *opItemAnimFollowPath(Script *script, const ResourceReference &animRef, const ResourceReference &pathRef, int32 speed, bool suspend);
245  Command *opKnowledgeAssignBool(const ResourceReference &knowledgeRef1, const ResourceReference &knowledgeRef2);
246  Command *opKnowledgeAssignNegatedBool(const ResourceReference &knowledgeRef1, const ResourceReference &knowledgeRef2);
247  Command *opKnowledgeAssignInteger(const ResourceReference &knowledgeRef1, const ResourceReference &knowledgeRef2);
248  Command *opLocationScrollTo(Script *script, const ResourceReference &scrollRef, bool suspend);
249  Command *opSoundPlay(Script *script, const ResourceReference &soundRef, int32 suspend);
250  Command *opItemLookDirection(Script *script, const ResourceReference &itemRef, int32 direction, bool suspend);
251  Command *opStopPlayingSound(const ResourceReference &soundRef);
252  Command *opLayerGoTo(const ResourceReference &layerRef);
253  Command *opLayerEnable(const ResourceReference &layerRef, int32 enable);
254  Command *opLocationScrollSet(const ResourceReference &scrollRef);
255  Command *opFullMotionVideoPlay(Script *script, const ResourceReference &movieRef, int32 unknown);
256  Command *opAnimSetFrame(const ResourceReference &animRef, const ResourceReference &knowledgeRef);
257  Command *opDiaryEnableEntry(const ResourceReference &knowledgeRef);
258  Command *opPATChangeTooltip(const ResourceReference &patRef, const ResourceReference &stringRef);
259  Command *opSoundChange(Script *script, const ResourceReference &soundRef, int32 volume, int32 pan, int32 duration, bool pause);
260  Command *opLightSetColor(const ResourceReference &lightRef, int32 red, int32 green, int32 blue);
261  Command *opLightFollowPath(Script *script, const ResourceReference &itemRef, const ResourceReference &lightRef, const ResourceReference &pathRef, int32 speed, bool suspend);
262  Command *opItem3DRunTo(Script *script, const ResourceReference &itemRef, const ResourceReference &targetRef, int32 suspend);
263  Command *opItemPlaceDirection(const ResourceReference &itemRef, int32 direction);
264  Command *opItemRotateDirection(Script *script, const ResourceReference &itemRef, int32 direction, int32 speed, bool suspend);
265  Command *opActivateTexture(const ResourceReference &textureRef);
266  Command *opActivateMesh(const ResourceReference &meshRef);
267  Command *opItem3DSetWalkTarget(const ResourceReference &itemRef, const ResourceReference &targetRef);
268  Command *opSpeakWithoutTalking(Script *script, const ResourceReference &speechRef, int32 unknown);
269  Command *opIsOnFloorField(const ResourceReference &itemRef, const ResourceReference &floorFieldRef);
270  Command *opIsItemEnabled(const ResourceReference &itemRef);
271  Command *opIsScriptEnabled(const ResourceReference &scriptRef);
272  Command *opIsKnowledgeBooleanSet(const ResourceReference &knowledgeRef);
273  Command *opIsKnowledgeIntegerInRange(const ResourceReference &knowledgeRef, int32 min, int32 max);
274  Command *opIsKnowledgeIntegerAbove(const ResourceReference &knowledgeRef, int32 value);
275  Command *opIsKnowledgeIntegerEqual(const ResourceReference &knowledgeRef, int32 value);
276  Command *opIsKnowledgeIntegerLower(const ResourceReference &knowledgeRef, int32 value);
277  Command *opIsScriptActive(const ResourceReference &scriptRef);
278  Command *opIsRandom(int32 chance);
279  Command *opIsAnimScriptItemReached(const ResourceReference &animScriptItemRef);
280  Command *opIsItemNearPlace(const ResourceReference &itemRef, const ResourceReference &positionRef, int32 testDistance);
281  Command *opIsItemOnPlace(const ResourceReference &itemRef, const ResourceReference &positionRef);
282  Command *opIsAnimPlaying(const ResourceReference &animRef);
283  Command *opIsItemActivity(const ResourceReference &itemRef, int32 value);
284  Command *opIsAnimAtTime(const ResourceReference &animRef, int32 time);
285  Command *opIsLocation2D();
286  Command *opIsInventoryOpen();
287 
288  Common::Array<Argument> _arguments;
289 };
290 
291 } // End of namespace Resources
292 } // End of namespace Stark
293 
294 #endif // STARK_RESOURCES_COMMAND_H
Definition: str.h:59
Definition: array.h:52
Definition: command.h:169
Definition: resourcereference.h:39
Definition: console.h:27
Definition: object.h:143
Definition: command.h:51
Definition: xrc.h:45
Definition: script.h:45