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 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (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, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef NEVERHOOD_KLAYMEN_H 24 #define NEVERHOOD_KLAYMEN_H 25 26 #include "neverhood/neverhood.h" 27 #include "neverhood/sprite.h" 28 #include "neverhood/graphics.h" 29 #include "neverhood/resource.h" 30 31 namespace Neverhood { 32 33 // TODO This code is horrible and weird and a lot of stuff needs renaming once a better name is found 34 // TODO Also the methods should probably rearranged and be grouped together more consistently 35 36 class Scene; 37 38 const uint32 kKlaymenSpeedUpHash = 0x004A2148; 39 40 #include "common/pack-start.h" // START STRUCT PACKING 41 42 struct KlaymenIdleTableItem { 43 int weight; 44 uint idleAnimation; 45 }; 46 47 #include "common/pack-end.h" // END STRUCT PACKING 48 49 enum { 50 kIdlePickEar, 51 kIdleSpinHead, 52 kIdleArms, 53 kIdleChest, 54 kIdleHeadOff, 55 kIdleTeleporterHands, 56 kIdleTeleporterHands2, 57 kIdleWonderAbout 58 }; 59 60 class Klaymen : public AnimatedSprite { 61 public: 62 Klaymen(NeverhoodEngine *vm, Scene *parentScene, int16 x, int16 y, NRectArray *clipRects = NULL); 63 64 void update(); 65 66 void startIdleAnimation(uint32 fileHash, AnimationCb callback); 67 void upIdleAnimation(); 68 69 // Idle animations - start 70 void stIdlePickEar(); 71 void evIdlePickEarDone(); 72 void stIdleSpinHead(); 73 void stIdleArms(); 74 void evIdleArmsDone(); 75 void stIdleChest(); 76 void stIdleHeadOff(); 77 void stIdleWonderAbout(); 78 void stIdleTeleporterHands(); 79 void stIdleTeleporterHands2(); 80 81 uint32 hmIdlePickEar(int messageNum, const MessageParam ¶m, Entity *sender); 82 uint32 hmIdleSpinHead(int messageNum, const MessageParam ¶m, Entity *sender); 83 uint32 hmIdleArms(int messageNum, const MessageParam ¶m, Entity *sender); 84 uint32 hmIdleChest(int messageNum, const MessageParam ¶m, Entity *sender); 85 uint32 hmIdleHeadOff(int messageNum, const MessageParam ¶m, Entity *sender); 86 // Idle animations - end 87 88 void stTryStandIdle(); 89 void stStandAround(); 90 void upStandIdle(); 91 void stIdleBlink(); 92 93 bool stStartAction(AnimationCb callback3); 94 bool stStartActionFromIdle(AnimationCb callback); 95 uint32 hmStartAction(int messageNum, const MessageParam ¶m, Entity *sender); 96 97 void stSneak(); 98 uint32 hmSneaking(int messageNum, const MessageParam ¶m, Entity *sender); 99 void suSneaking(); 100 void evSneakingDone(); 101 102 void stStartWalking(); 103 void stStartWalkingExt(); 104 void stWalkingOpenDoor(); 105 void suWalkingOpenDoor(); 106 void stStepOver(); 107 uint32 hmStartWalking(int messageNum, const MessageParam ¶m, Entity *sender); 108 void evStartWalkingDone(); 109 110 void stWalkingFirst(); 111 void stWalkingFirstExt(); 112 void stStartWalkingResume(); 113 void stUpdateWalkingFirst(); 114 uint32 hmWalking(int messageNum, const MessageParam ¶m, Entity *sender); 115 void suWalkingFirst(); 116 117 void stWalkToFrontNoStep(); 118 void stWalkToFront(); 119 void stTurnToFront(); 120 void stTurnToBack(); 121 uint32 hmWalkToFront(int messageNum, const MessageParam ¶m, Entity *sender); 122 123 void stTurnToBackToUse(); 124 uint32 hmTurnToBackToUse(int messageNum, const MessageParam ¶m, Entity *sender); 125 126 void stPickUpGeneric(); 127 void stPickUpNeedle(); 128 uint32 hmPickUpObject(int messageNum, const MessageParam ¶m, Entity *sender); 129 130 void stPickUpTube(); 131 uint32 hmPickUpTube(int messageNum, const MessageParam ¶m, Entity *sender); 132 133 void stTurnToUse(); 134 void stTurnToUseHalf(); 135 void stTurnAwayFromUse(); 136 void stReturnFromUse(); 137 void stTurnToUseExt(); 138 uint32 hmTurnToUse(int messageNum, const MessageParam ¶m, Entity *sender); 139 140 void stLargeStep(); 141 uint32 hmLargeStep(int messageNum, const MessageParam ¶m, Entity *sender); 142 void suLargeStep(); 143 void evLargeStepDone(); 144 145 void stInsertKey(); 146 uint32 hmInsertKey(int messageNum, const MessageParam ¶m, Entity *sender); 147 148 void stPeekWall(); 149 uint32 hmPeekWall(int messageNum, const MessageParam ¶m, Entity *sender); 150 151 void stPeekWallReturn(); 152 uint32 hmPeekWallReturn(int messageNum, const MessageParam ¶m, Entity *sender); 153 154 void stPeekWallBlink(); 155 void upPeekWallBlink(); 156 157 void stPeekWall1(); 158 void stPeekWall2(); 159 160 void stGrow(); 161 uint32 hmGrow(int messageNum, const MessageParam ¶m, Entity *sender); 162 163 void stDrinkPotion(); 164 uint32 hmDrinkPotion(int messageNum, const MessageParam ¶m, Entity *sender); 165 166 void stPullCord(); 167 void stReleaseCord(); 168 uint32 hmPullReleaseCord(int messageNum, const MessageParam ¶m, Entity *sender); 169 170 void stUseTube(); 171 uint32 hmUseTube(int messageNum, const MessageParam ¶m, Entity *sender); 172 173 void stUseLever(); 174 void stUseLeverRelease(); 175 void stReleaseLever(); 176 void stInteractLever(); 177 uint32 hmLever(int messageNum, const MessageParam ¶m, Entity *sender); 178 179 void stLetGoOfLever(); 180 void evLeverReleasedEvent(); 181 182 void stPressButton(); 183 void stPressFloorButton(); 184 void stPressButtonSide(); 185 uint32 hmPressButton(int messageNum, const MessageParam ¶m, Entity *sender); 186 187 void stWonderAbout(); 188 void stWonderAboutHalf(); 189 void stWonderAboutAfter(); 190 191 void stStandWonderAbout(); 192 193 void stStartClimbLadderUp(); 194 void stStartClimbLadderDown(); 195 uint32 hmClimbLadderUpDown(int messageNum, const MessageParam ¶m, Entity *sender); 196 197 void stContinueClimbLadderUp(); 198 199 void stClimbLadderHalf(); 200 uint32 hmClimbLadderHalf(int messageNum, const MessageParam ¶m, Entity *sender); 201 202 void stReleaseRing(); 203 204 void stLandOnFeet(); 205 uint32 hmLandOnFeet(int messageNum, const MessageParam ¶m, Entity *sender); 206 207 void stPullLeverDown(); 208 void stHoldLeverDown(); 209 210 void stInsertDisk(); 211 uint32 hmInsertDisk(int messageNum, const MessageParam ¶m, Entity *sender); 212 213 void stMoveObjectSkipTurnFaceObject(); 214 void stMoveObjectSkipTurn(); 215 void stMoveObjectFaceObject(); 216 uint32 hmMoveObjectTurn(int messageNum, const MessageParam ¶m, Entity *sender); 217 void evMoveObjectTurnDone(); 218 219 void stJumpToGrab(); 220 void stJumpToGrabFall(); 221 uint32 hmJumpToGrab(int messageNum, const MessageParam ¶m, Entity *sender); 222 void suJumpToGrab(); 223 224 void stJumpToGrabRelease(); 225 uint32 hmJumpToGrabRelease(int messageNum, const MessageParam ¶m, Entity *sender); 226 227 void stSitInTeleporter(); 228 uint32 hmSitInTeleporter(int messageNum, const MessageParam ¶m, Entity *sender); 229 230 void stSitIdleTeleporter(); 231 void upSitIdleTeleporter(); 232 void stSitIdleTeleporterBlink(); 233 void stSitIdleTeleporterBlinkSecond(); 234 235 void stTurnToUseInTeleporter(); 236 void stReturnFromUseInTeleporter(); 237 void stGetUpFromTeleporter(); 238 239 void teleporterAppear(uint32 fileHash); 240 void teleporterDisappear(uint32 fileHash); 241 uint32 hmTeleporterAppearDisappear(int messageNum, const MessageParam ¶m, Entity *sender); 242 243 void stFallSkipJump(); 244 void suFallSkipJump(); 245 246 void stMoveObject(); 247 void stContinueMoveObject(); 248 uint32 hmMoveObject(int messageNum, const MessageParam ¶m, Entity *sender); 249 void upMoveObject(); 250 251 void stStandIdleSmall(); 252 void stWonderAboutSmall(); 253 void stWonderAboutHalfSmall(); 254 void stWonderAboutAfterSmall(); 255 256 void stWalkToFrontNoStepSmall(); 257 void stWalkToFrontSmall(); 258 void stWalkToFront2Small(); 259 void stTurnToBackHalfSmall(); 260 void stTurnToBackWalkSmall(); 261 void stTurnToBackSmall(); 262 uint32 hmWalkFrontBackSmall(int messageNum, const MessageParam ¶m, Entity *sender); 263 264 void stFinishGrow(); 265 uint32 hmFinishGrow(int messageNum, const MessageParam ¶m, Entity *sender); 266 267 void stStandIdleSpecial(); 268 uint32 hmStandIdleSpecial(int messageNum, const MessageParam ¶m, Entity *sender); 269 270 void stSpitOutFall0(); 271 void stSpitOutFall2(); 272 void suFallDown(); 273 void upSpitOutFall(); 274 275 void stFalling(); 276 void stFallTouchdown(); 277 278 void stPeekInside(); 279 void stPeekInsideReturn(); 280 void stPeekInsideBlink(); 281 void upPeekInsideBlink(); 282 283 //////////////////////////////////////////////////////////////////////////// 284 285 void stopWalking(); 286 287 void suAction(); 288 void suUpdateDestX(); 289 void suWalkingTestExit(); 290 291 uint32 hmLowLevel(int messageNum, const MessageParam ¶m, Entity *sender); 292 uint32 hmLowLevelAnimation(int messageNum, const MessageParam ¶m, Entity *sender); 293 294 void setKlaymenIdleTable(const KlaymenIdleTableItem *table, uint tableCount); 295 void setKlaymenIdleTable1(); 296 void setKlaymenIdleTable2(); 297 void setKlaymenIdleTable3(); 298 setSoundFlag(bool value)299 void setSoundFlag(bool value) { _soundFlag = value; } 300 301 void stRidePlatform(); 302 void suRidePlatform(); 303 void stPullLever(); 304 void stLookLeverDown(); 305 void stWaitLeverDown(); 306 307 protected: 308 Scene *_parentScene; 309 Sprite *_attachedSprite; 310 int _ladderStatus; 311 bool _isWalking; 312 bool _isSneaking; 313 bool _isLargeStep; 314 bool _isMoveObjectRequested; 315 bool _acceptInput; 316 int16 _destX, _destY; 317 int16 _idleCounter, _idleCounterMax; 318 int16 _blinkCounter, _blinkCounterMax; 319 int16 _tapesToInsert, _keysToInsert; 320 bool _doYHitIncr; 321 bool _isLeverDown; 322 bool _isWalkingOpenDoorNotified; 323 int _busyStatus; 324 bool _actionStatusChanged; 325 int _actionStatus; 326 327 const KlaymenIdleTableItem *_idleTable; 328 uint _idleTableCount; 329 int _idleTableTotalWeight; 330 int _idleTableNum; 331 332 NPointArray *_pathPoints; 333 bool _soundFlag; 334 335 int16 _spitOutCountdown; 336 337 bool _isSittingInTeleporter; 338 339 bool _potionFlag1; 340 bool _potionFlag2; 341 342 int16 _platformDeltaY; 343 344 Sprite *_otherSprite; 345 346 int16 _walkResumeFrameIncr; 347 348 int _moveObjectCountdown; 349 350 virtual void xUpdate(); 351 virtual uint32 xHandleMessage(int messageNum, const MessageParam ¶m); 352 353 void startWalkToX(int16 x, bool walkExt); 354 void startWalkToXExt(int16 x); 355 void startWalkToXSmall(int16 x); 356 void startSpecialWalkLeft(int16 x); 357 void startSpecialWalkRight(int16 x); 358 void startWalkToXDistance(int16 destX, int16 distance); 359 void startWalkToAttachedSpriteXDistance(int16 distance); 360 361 void gotoNextStateExt(); 362 void beginAction(); 363 void endAction(); 364 365 void stStartWalkingSmall(); 366 uint32 hmWalkingSmall(int messageNum, const MessageParam ¶m, Entity *sender); 367 368 void enterIdleAnimation(uint idleAnimation); 369 void walkAlongPathPoints(); 370 }; 371 372 } // End of namespace Neverhood 373 374 #endif /* NEVERHOOD_KLAYMEN_H */ 375