00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef STARK_RESOURCES_COMMAND_H
00024 #define STARK_RESOURCES_COMMAND_H
00025
00026 #include "common/array.h"
00027 #include "common/str.h"
00028
00029 #include "math/vector3d.h"
00030
00031 #include "engines/stark/resources/object.h"
00032 #include "engines/stark/resourcereference.h"
00033
00034 namespace Stark {
00035
00036 class ResourceReference;
00037 namespace Formats {
00038 class XRCReadStream;
00039 }
00040
00041 namespace Resources {
00042
00043 class Script;
00044
00052 class Command : public Object {
00053 public:
00054 static const Type::ResourceType TYPE = Type::kCommand;
00055
00056 Command(Object *parent, byte subType, uint16 index, const Common::String &name);
00057 virtual ~Command();
00058
00059 enum SubType {
00060 kCommandBegin = 0,
00061 kCommandEnd = 1,
00062 kScriptCall = 2,
00063 kDialogCall = 3,
00064 kSetInteractiveMode = 4,
00065 kLocationGoTo = 5,
00066
00067 kWalkTo = 7,
00068 kGameLoop = 8,
00069 kScriptPause = 9,
00070 kScriptPauseRandom = 10,
00071 kScriptPauseSkippable = 11,
00072
00073 kScriptAbort = 13,
00074
00075 kExit2DLocation = 16,
00076 kGoto2DLocation = 17,
00077
00078 kRumbleScene = 19,
00079 kFadeScene = 20,
00080 kSwayScene = 21,
00081
00082 kLocationGoToNewCD = 22,
00083 kGameEnd = 23,
00084 kInventoryOpen = 24,
00085 kFloatScene = 25,
00086 kBookOfSecretsOpen = 26,
00087
00088 kDoNothing = 80,
00089 kItem3DPlaceOn = 81,
00090 kItem3DWalkTo = 82,
00091 kItem3DFollowPath = 83,
00092 kItemLookAt = 84,
00093
00094 kItem2DFollowPath = 86,
00095 kItemEnable = 87,
00096 kItemSetActivity = 88,
00097 kItemSelectInInventory = 89,
00098
00099 kUseAnimHierarchy = 92,
00100 kPlayAnimation = 93,
00101 kScriptEnable = 94,
00102 kShowPlay = 95,
00103 kKnowledgeSetBoolean = 96,
00104
00105 kKnowledgeSetInteger = 100,
00106 kKnowledgeAddInteger = 101,
00107
00108 kEnableFloorField = 103,
00109 kPlayAnimScriptItem = 104,
00110 kItemAnimFollowPath = 105,
00111
00112 kKnowledgeAssignBool = 107,
00113
00114 kKnowledgeAssignInteger = 110,
00115 kLocationScrollTo = 111,
00116 kSoundPlay = 112,
00117
00118 kKnowledgeSetIntRandom = 115,
00119
00120 kKnowledgeSubValue = 117,
00121 kItemLookDirection = 118,
00122
00123 kStopPlayingSound = 119,
00124 kLayerGoTo = 120,
00125 kLayerEnable = 121,
00126 kLocationScrollSet = 122,
00127 kFullMotionVideoPlay = 123,
00128
00129 kAnimSetFrame = 125,
00130 kKnowledgeAssignNegatedBool = 126,
00131 kDiaryEnableEntry = 127,
00132 kPATChangeTooltip = 128,
00133 kSoundChange = 129,
00134 kLightSetColor = 130,
00135 kLightFollowPath = 131,
00136 kItem3DRunTo = 132,
00137 kItemPlaceDirection = 133,
00138 kItemRotateDirection = 134,
00139 kActivateTexture = 135,
00140 kActivateMesh = 136,
00141 kItem3DSetWalkTarget = 137,
00142
00143 kSpeakWithoutTalking = 139,
00144
00145 kIsOnFloorField = 162,
00146 kIsItemEnabled = 163,
00147
00148 kIsScriptEnabled = 165,
00149 kIsKnowledgeBooleanSet = 166,
00150
00151 kIsKnowledgeIntegerInRange = 170,
00152 kIsKnowledgeIntegerAbove = 171,
00153 kIsKnowledgeIntegerEqual = 172,
00154 kIsKnowledgeIntegerLower = 173,
00155 kIsScriptActive = 174,
00156 kIsRandom = 175,
00157 kIsAnimScriptItemReached = 176,
00158 kIsItemOnPlace = 177,
00159
00160 kIsAnimPlaying = 179,
00161 kIsItemActivity = 180,
00162
00163 kIsItemNearPlace = 183,
00164
00165 kIsAnimAtTime = 185,
00166 kIsLocation2D = 186,
00167 kIsInventoryOpen = 187
00168 };
00169
00170 struct Argument {
00171 enum Type {
00172 kTypeInteger1 = 1,
00173 kTypeInteger2 = 2,
00174 kTypeResourceReference = 3,
00175 kTypeString = 4
00176 };
00177
00178 uint32 type;
00179 uint32 intValue;
00180 Common::String stringValue;
00181 ResourceReference referenceValue;
00182 };
00183
00185 Command *execute(uint32 callMode, Script *script);
00186
00188 Command *nextCommand();
00189
00191 Command *nextCommandIf(bool predicate);
00192
00194 Common::Array<Argument> getArguments() const;
00195
00197 void resumeItemSetActivity();
00198
00199 protected:
00200 void readData(Formats::XRCReadStream *stream) override;
00201
00202 Command *resolveArgumentSiblingReference(const Argument &argument);
00203
00204 Math::Vector3d getObjectPosition(const ResourceReference &targetRef, int32 *floorFace = nullptr);
00205
00206 Command *opScriptBegin();
00207 Command *opScriptCall(Script *script, const ResourceReference &scriptRef, int32 synchronous);
00208 Command *opDialogCall(Script *script, const ResourceReference &dialogRef, int32 suspend);
00209 Command *opSetInteractiveMode(bool enabled);
00210 Command *opLocationGoTo(const Common::String &level, const Common::String &location, const ResourceReference &bookmarkRef, int32 direction);
00211 Command *opWalkTo(Script *script, const ResourceReference &objectRef, int32 suspend);
00212 Command *opScriptPauseGameLoop(Script *script, int32 count);
00213 Command *opScriptPause(Script *script, const ResourceReference &durationRef);
00214 Command *opScriptPauseRandom(Script *script, const ResourceReference &itemRef);
00215 Command *opScriptPauseSkippable(Script *script, const ResourceReference &durationRef);
00216 Command *opScriptAbort(ResourceReference scriptRef, bool disable);
00217 Command *opExit2DLocation();
00218 Command *opGoto2DLocation(const Common::String &level, const Common::String &location);
00219 Command *opRumbleScene(Script *script, int32 rumbleDuration, int32 pause);
00220 Command *opFadeScene(Script *script, bool fadeOut, int32 fadeDuration, bool pause);
00221 Command *opSwayScene(int32 periodMs, int32 angleIn, int32 amplitudeIn, int32 offsetIn);
00222 Command *opGameEnd();
00223 Command *opInventoryOpen(bool open);
00224 Command *opFloatScene(int32 periodMs, int32 amplitudeIn, int32 offsetIn);
00225 Command *opBookOfSecretsOpen();
00226 Command *opDoNothing();
00227 Command *opItem3DPlaceOn(const ResourceReference &itemRef, const ResourceReference &targetRef);
00228 Command *opItem3DWalkTo(Script *script, const ResourceReference &itemRef, const ResourceReference &targetRef, bool suspend);
00229 Command *opItemFollowPath(Script *script, ResourceReference itemRef, ResourceReference pathRef, uint32 speed, uint32 suspend);
00230 Command *opItemLookAt(Script *script, const ResourceReference &itemRef, const ResourceReference &objRef, bool suspend, int32 unknown);
00231 Command *opItemEnable(const ResourceReference &itemRef, int32 enable);
00232 Command *opItemSetActivity(Script *script, const ResourceReference &itemRef, int32 animActivity, bool wait);
00233 Command *opItemSelectInInventory(const ResourceReference &itemRef);
00234 Command *opUseAnimHierachy(const ResourceReference &animHierRef);
00235 Command *opPlayAnimation(Script *script, const ResourceReference &animRef, bool suspend);
00236 Command *opScriptEnable(const ResourceReference &scriptRef, int32 enable);
00237 Command *opShowPlay(Script *script, const ResourceReference &ref, int32 suspend);
00238 Command *opKnowledgeSetBoolean(const ResourceReference &knowledgeRef, int32 enable);
00239 Command *opKnowledgeSetInteger(const ResourceReference &knowledgeRef, int32 value);
00240 Command *opKnowledgeSetIntRandom(const ResourceReference &knowledgeRef, uint32 min, uint32 max);
00241 Command *opKnowledgeAddInteger(const ResourceReference &knowledgeRef, int32 increment);
00242 Command *opKnowledgeSubValue(const ResourceReference &knowledgeRef, const ResourceReference &valueRef);
00243 Command *opEnableFloorField(const ResourceReference &floorFieldRef, bool enable);
00244 Command *opPlayAnimScriptItem(Script *script, const ResourceReference &animScriptItemRef, int32 suspend);
00245 Command *opItemAnimFollowPath(Script *script, const ResourceReference &animRef, const ResourceReference &pathRef, int32 speed, bool suspend);
00246 Command *opKnowledgeAssignBool(const ResourceReference &knowledgeRef1, const ResourceReference &knowledgeRef2);
00247 Command *opKnowledgeAssignNegatedBool(const ResourceReference &knowledgeRef1, const ResourceReference &knowledgeRef2);
00248 Command *opKnowledgeAssignInteger(const ResourceReference &knowledgeRef1, const ResourceReference &knowledgeRef2);
00249 Command *opLocationScrollTo(Script *script, const ResourceReference &scrollRef, bool suspend);
00250 Command *opSoundPlay(Script *script, const ResourceReference &soundRef, int32 suspend);
00251 Command *opItemLookDirection(Script *script, const ResourceReference &itemRef, int32 direction, bool suspend);
00252 Command *opStopPlayingSound(const ResourceReference &soundRef);
00253 Command *opLayerGoTo(const ResourceReference &layerRef);
00254 Command *opLayerEnable(const ResourceReference &layerRef, int32 enable);
00255 Command *opLocationScrollSet(const ResourceReference &scrollRef);
00256 Command *opFullMotionVideoPlay(Script *script, const ResourceReference &movieRef, int32 unknown);
00257 Command *opAnimSetFrame(const ResourceReference &animRef, const ResourceReference &knowledgeRef);
00258 Command *opDiaryEnableEntry(const ResourceReference &knowledgeRef);
00259 Command *opPATChangeTooltip(const ResourceReference &patRef, const ResourceReference &stringRef);
00260 Command *opSoundChange(Script *script, const ResourceReference &soundRef, int32 volume, int32 pan, int32 duration, bool pause);
00261 Command *opLightSetColor(const ResourceReference &lightRef, int32 red, int32 green, int32 blue);
00262 Command *opLightFollowPath(Script *script, const ResourceReference &itemRef, const ResourceReference &lightRef, const ResourceReference &pathRef, int32 speed, bool suspend);
00263 Command *opItem3DRunTo(Script *script, const ResourceReference &itemRef, const ResourceReference &targetRef, int32 suspend);
00264 Command *opItemPlaceDirection(const ResourceReference &itemRef, int32 direction);
00265 Command *opItemRotateDirection(Script *script, const ResourceReference &itemRef, int32 direction, int32 speed, bool suspend);
00266 Command *opActivateTexture(const ResourceReference &textureRef);
00267 Command *opActivateMesh(const ResourceReference &meshRef);
00268 Command *opItem3DSetWalkTarget(const ResourceReference &itemRef, const ResourceReference &targetRef);
00269 Command *opSpeakWithoutTalking(Script *script, const ResourceReference &speechRef, int32 unknown);
00270 Command *opIsOnFloorField(const ResourceReference &itemRef, const ResourceReference &floorFieldRef);
00271 Command *opIsItemEnabled(const ResourceReference &itemRef);
00272 Command *opIsScriptEnabled(const ResourceReference &scriptRef);
00273 Command *opIsKnowledgeBooleanSet(const ResourceReference &knowledgeRef);
00274 Command *opIsKnowledgeIntegerInRange(const ResourceReference &knowledgeRef, int32 min, int32 max);
00275 Command *opIsKnowledgeIntegerAbove(const ResourceReference &knowledgeRef, int32 value);
00276 Command *opIsKnowledgeIntegerEqual(const ResourceReference &knowledgeRef, int32 value);
00277 Command *opIsKnowledgeIntegerLower(const ResourceReference &knowledgeRef, int32 value);
00278 Command *opIsScriptActive(const ResourceReference &scriptRef);
00279 Command *opIsRandom(int32 chance);
00280 Command *opIsAnimScriptItemReached(const ResourceReference &animScriptItemRef);
00281 Command *opIsItemNearPlace(const ResourceReference &itemRef, const ResourceReference &positionRef, int32 testDistance);
00282 Command *opIsItemOnPlace(const ResourceReference &itemRef, const ResourceReference &positionRef);
00283 Command *opIsAnimPlaying(const ResourceReference &animRef);
00284 Command *opIsItemActivity(const ResourceReference &itemRef, int32 value);
00285 Command *opIsAnimAtTime(const ResourceReference &animRef, int32 time);
00286 Command *opIsLocation2D();
00287 Command *opIsInventoryOpen();
00288
00289 Common::Array<Argument> _arguments;
00290 };
00291
00292 }
00293 }
00294
00295 #endif // STARK_RESOURCES_COMMAND_H