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