2011-07-07 17:26:22 +00:00
|
|
|
/* 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 2
|
|
|
|
* 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, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
#include "neverhood/klaymen.h"
|
2011-07-07 17:26:22 +00:00
|
|
|
#include "neverhood/resourceman.h"
|
2013-01-10 23:17:16 +00:00
|
|
|
#include "neverhood/scene.h"
|
2011-07-08 19:09:33 +00:00
|
|
|
#include "neverhood/staticdata.h"
|
2011-07-07 17:26:22 +00:00
|
|
|
|
|
|
|
namespace Neverhood {
|
|
|
|
|
2013-01-25 09:12:49 +00:00
|
|
|
static const KlaymenIdleTableItem klaymenIdleTable1[] = {
|
|
|
|
{1, kIdlePickEar},
|
|
|
|
{1, kIdleSpinHead},
|
|
|
|
{1, kIdleArms},
|
|
|
|
{1, kIdleChest},
|
|
|
|
{1, kIdleHeadOff}
|
2013-07-14 17:01:47 +00:00
|
|
|
};
|
2011-07-07 17:26:22 +00:00
|
|
|
|
2013-01-25 09:12:49 +00:00
|
|
|
static const KlaymenIdleTableItem klaymenIdleTable2[] = {
|
|
|
|
{1, kIdlePickEar},
|
|
|
|
{1, kIdleSpinHead},
|
|
|
|
{1, kIdleChest},
|
|
|
|
{1, kIdleHeadOff}
|
2013-07-14 17:01:47 +00:00
|
|
|
};
|
2011-07-07 17:26:22 +00:00
|
|
|
|
2013-01-25 09:12:49 +00:00
|
|
|
static const KlaymenIdleTableItem klaymenIdleTable3[] = {
|
|
|
|
{1, kIdleTeleporterHands},
|
|
|
|
{1, kIdleTeleporterHands2}
|
2013-07-14 17:01:47 +00:00
|
|
|
};
|
2011-07-07 17:26:22 +00:00
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
// Klaymen
|
2011-07-11 18:47:03 +00:00
|
|
|
|
2013-01-24 09:07:07 +00:00
|
|
|
Klaymen::Klaymen(NeverhoodEngine *vm, Scene *parentScene, int16 x, int16 y, NRectArray *clipRects)
|
|
|
|
: AnimatedSprite(vm, 1000), _idleCounterMax(0), _idleCounter(0), _isMoveObjectRequested(false), _blinkCounterMax(0),
|
2013-01-25 13:47:06 +00:00
|
|
|
_isWalkingOpenDoorNotified(false), _spitOutCountdown(0), _tapesToInsert(0), _keysToInsert(0), _busyStatus(0), _acceptInput(true),
|
2013-01-24 19:10:27 +00:00
|
|
|
_attachedSprite(NULL), _isWalking(false), _actionStatus(1), _parentScene(parentScene), _isSneaking(false), _isLargeStep(false),
|
|
|
|
_doYHitIncr(false), _isLeverDown(false), _isSittingInTeleporter(false), _actionStatusChanged(false), _ladderStatus(0), _pathPoints(NULL), _soundFlag(false),
|
2013-10-06 15:55:10 +00:00
|
|
|
_idleTableNum(0), _otherSprite(NULL), _moveObjectCountdown(0), _walkResumeFrameIncr(0) {
|
2013-07-14 17:01:47 +00:00
|
|
|
|
2013-01-24 09:07:07 +00:00
|
|
|
createSurface(1000, 320, 200);
|
2011-07-07 17:26:22 +00:00
|
|
|
_x = x;
|
|
|
|
_y = y;
|
2011-10-28 10:37:07 +00:00
|
|
|
_destX = x;
|
|
|
|
_destY = y;
|
2011-07-07 17:26:22 +00:00
|
|
|
_flags = 2;
|
2013-01-21 11:34:50 +00:00
|
|
|
setKlaymenIdleTable1();
|
2011-10-21 09:13:49 +00:00
|
|
|
stTryStandIdle();
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::xUpdate() {
|
2011-07-07 20:26:12 +00:00
|
|
|
// Empty
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::xHandleMessage(int messageNum, const MessageParam ¶m) {
|
2011-07-07 20:26:12 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x4001:
|
|
|
|
case 0x4800:
|
2011-10-28 10:37:07 +00:00
|
|
|
startWalkToX(param.asPoint().x, false);
|
2011-07-07 20:26:12 +00:00
|
|
|
break;
|
|
|
|
case 0x4004:
|
2013-01-21 11:34:50 +00:00
|
|
|
GotoState(&Klaymen::stTryStandIdle);
|
2011-07-07 20:26:12 +00:00
|
|
|
break;
|
|
|
|
case 0x4818:
|
2011-10-28 10:37:07 +00:00
|
|
|
startWalkToX(_dataResource.getPoint(param.asInteger()).x, false);
|
2011-07-07 20:26:12 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-07-07 17:26:22 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::update() {
|
2011-07-07 17:28:51 +00:00
|
|
|
AnimatedSprite::update();
|
|
|
|
xUpdate();
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-25 09:12:49 +00:00
|
|
|
void Klaymen::setKlaymenIdleTable(const KlaymenIdleTableItem *table, uint tableCount) {
|
2011-10-27 11:33:12 +00:00
|
|
|
_idleTable = table;
|
|
|
|
_idleTableCount = tableCount;
|
2013-01-25 09:12:49 +00:00
|
|
|
_idleTableTotalWeight = 0;
|
|
|
|
for (uint i = 0; i < tableCount; i++)
|
|
|
|
_idleTableTotalWeight += table[i].weight;
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::setKlaymenIdleTable1() {
|
2013-01-25 09:12:49 +00:00
|
|
|
setKlaymenIdleTable(klaymenIdleTable1, ARRAYSIZE(klaymenIdleTable1));
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::setKlaymenIdleTable2() {
|
2013-01-25 09:12:49 +00:00
|
|
|
setKlaymenIdleTable(klaymenIdleTable2, ARRAYSIZE(klaymenIdleTable2));
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::setKlaymenIdleTable3() {
|
2013-01-25 09:12:49 +00:00
|
|
|
setKlaymenIdleTable(klaymenIdleTable3, ARRAYSIZE(klaymenIdleTable3));
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stIdlePickEar() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x5B20C814, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmIdlePickEar);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2013-01-21 11:34:50 +00:00
|
|
|
NextState(&Klaymen::stStandAround);
|
|
|
|
FinalizeState(&Klaymen::evIdlePickEarDone);
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmIdlePickEar(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2011-07-07 17:26:22 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
2011-07-08 19:09:33 +00:00
|
|
|
if (param.asInteger() == 0x04DBC02C) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x44528AA1);
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::evIdlePickEarDone() {
|
2012-10-01 17:21:36 +00:00
|
|
|
stopSound(0);
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stIdleSpinHead() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0xD122C137, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmIdleSpinHead);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2013-01-21 11:34:50 +00:00
|
|
|
NextState(&Klaymen::stStandAround);
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmIdleSpinHead(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2011-07-07 17:26:22 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
2011-07-08 19:09:33 +00:00
|
|
|
if (param.asInteger() == 0x808A0008) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0xD948A340);
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stIdleArms() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x543CD054, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmIdleArms);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2013-01-21 11:34:50 +00:00
|
|
|
NextState(&Klaymen::stStandAround);
|
|
|
|
FinalizeState(&Klaymen::evIdleArmsDone);
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::evIdleArmsDone() {
|
2012-10-01 17:21:36 +00:00
|
|
|
stopSound(0);
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmIdleArms(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2011-07-07 17:26:22 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
2011-07-08 19:09:33 +00:00
|
|
|
if (param.asInteger() == 0x5A0F0104) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x7970A100);
|
2011-07-08 19:09:33 +00:00
|
|
|
} else if (param.asInteger() == 0x9A9A0109) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0xD170CF04);
|
2011-07-08 19:09:33 +00:00
|
|
|
} else if (param.asInteger() == 0x989A2169) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0xD073CF14);
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stIdleChest() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x40A0C034, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmIdleChest);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2013-01-21 11:34:50 +00:00
|
|
|
NextState(&Klaymen::stStandAround);
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmIdleChest(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2011-07-07 17:26:22 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
2011-07-08 19:09:33 +00:00
|
|
|
if (param.asInteger() == 0x0D2A0288) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0xD192A368);
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stIdleHeadOff() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x5120E137, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmIdleHeadOff);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2013-01-21 11:34:50 +00:00
|
|
|
NextState(&Klaymen::stStandAround);
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmIdleHeadOff(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2011-07-07 17:26:22 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
2011-07-08 19:09:33 +00:00
|
|
|
if (param.asInteger() == 0xC006000C) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x9D406340);
|
2011-07-08 19:09:33 +00:00
|
|
|
} else if (param.asInteger() == 0x2E4A2940) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x53A4A1D4);
|
2011-07-08 19:09:33 +00:00
|
|
|
} else if (param.asInteger() == 0xAA0A0860) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x5BE0A3C6);
|
2011-07-08 19:09:33 +00:00
|
|
|
} else if (param.asInteger() == 0xC0180260) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x5D418366);
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stIdleWonderAbout() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2012-11-14 18:09:46 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0xD820A114, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevelAnimation);
|
2012-11-14 18:09:46 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2013-01-21 11:34:50 +00:00
|
|
|
NextState(&Klaymen::stStandAround);
|
2012-11-14 18:09:46 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stSitIdleTeleporter() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x582EC138, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::upSitIdleTeleporter);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevel);
|
2012-10-04 07:38:19 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
|
|
|
_idleCounter = 0;
|
2012-09-24 18:06:08 +00:00
|
|
|
_blinkCounter = 0;
|
|
|
|
_idleCounterMax = 8;
|
|
|
|
_blinkCounterMax = _vm->_rnd->getRandomNumber(64 - 1) + 24;
|
2011-07-26 08:38:19 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::upSitIdleTeleporter() {
|
2011-07-26 08:38:19 +00:00
|
|
|
update();
|
2013-01-25 09:12:49 +00:00
|
|
|
if (++_idleCounter >= _idleCounterMax) {
|
2012-09-24 18:06:08 +00:00
|
|
|
_idleCounter = 0;
|
2011-10-27 11:33:12 +00:00
|
|
|
if (_idleTable) {
|
2013-01-25 09:12:49 +00:00
|
|
|
int idleWeight = _vm->_rnd->getRandomNumber(_idleTableTotalWeight - 1);
|
|
|
|
for (uint i = 0; i < _idleTableCount; i++) {
|
|
|
|
if (idleWeight < _idleTable[i].weight) {
|
|
|
|
enterIdleAnimation(_idleTable[i].idleAnimation);
|
2012-09-24 18:06:08 +00:00
|
|
|
_idleCounterMax = _vm->_rnd->getRandomNumber(128 - 1) + 24;
|
2011-07-26 08:38:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-01-25 09:12:49 +00:00
|
|
|
idleWeight -= _idleTable[i].weight;
|
2011-07-26 08:38:19 +00:00
|
|
|
}
|
|
|
|
}
|
2012-09-24 18:06:08 +00:00
|
|
|
} else if (++_blinkCounter >= _blinkCounterMax) {
|
|
|
|
_blinkCounter = 0;
|
|
|
|
_blinkCounterMax = _vm->_rnd->getRandomNumber(64 - 1) + 24;
|
2012-10-04 07:08:09 +00:00
|
|
|
stSitIdleTeleporterBlink();
|
2011-07-26 08:38:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stSitIdleTeleporterBlink() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x5C24C018, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevelAnimation);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2013-01-21 11:34:50 +00:00
|
|
|
NextState(&Klaymen::stSitIdleTeleporterBlinkSecond);
|
2011-07-26 08:38:19 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stSitIdleTeleporterBlinkSecond() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
2013-11-03 02:19:17 +00:00
|
|
|
startAnimation(0x582EC138, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::upSitIdleTeleporter);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevel);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2011-07-26 08:38:19 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stPickUpNeedle() {
|
2011-10-21 09:13:49 +00:00
|
|
|
setDoDeltaX(_attachedSprite->getX() < _x ? 1 : 0);
|
2013-01-21 11:34:50 +00:00
|
|
|
if (!stStartAction(AnimationCallback(&Klaymen::stPickUpNeedle))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x1449C169, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmPickUpObject);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2011-07-26 08:38:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stPickUpTube() {
|
2011-10-21 09:13:49 +00:00
|
|
|
setDoDeltaX(_attachedSprite->getX() < _x ? 1 : 0);
|
2013-01-21 11:34:50 +00:00
|
|
|
if (!stStartAction(AnimationCallback(&Klaymen::stPickUpTube))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x0018C032, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmPickUpTube);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2011-07-26 08:38:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmPickUpTube(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2011-07-26 08:38:19 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0xC1380080) {
|
2012-10-02 07:26:05 +00:00
|
|
|
sendMessage(_attachedSprite, 0x4806, 0);
|
|
|
|
playSound(0, 0xC8004340);
|
2011-07-26 08:38:19 +00:00
|
|
|
} else if (param.asInteger() == 0x02B20220) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0xC5408620);
|
2011-07-26 08:38:19 +00:00
|
|
|
} else if (param.asInteger() == 0x03020231) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0xD4C08010);
|
2011-07-26 08:38:19 +00:00
|
|
|
} else if (param.asInteger() == 0x67221A03) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x44051000);
|
2011-07-26 08:38:19 +00:00
|
|
|
} else if (param.asInteger() == 0x925A0C1E) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x40E5884D);
|
2011-07-26 08:38:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stTurnToUseInTeleporter() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0xD229823D, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevelAnimation);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2011-07-26 08:38:19 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stReturnFromUseInTeleporter() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x9A2801E0, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevelAnimation);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2011-07-26 08:38:19 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stStepOver() {
|
|
|
|
if (!stStartAction(AnimationCallback(&Klaymen::stStepOver))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 2;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x004AA310, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmStartWalking);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2011-07-26 08:38:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stSitInTeleporter() {
|
|
|
|
if (!stStartAction(AnimationCallback(&Klaymen::stSitInTeleporter))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x392A0330, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmSitInTeleporter);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2011-07-26 08:38:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmSitInTeleporter(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2011-07-26 08:38:19 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x001A2832) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0xC0E4884C);
|
2011-07-26 08:38:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stGetUpFromTeleporter() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x913AB120, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevelAnimation);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2011-07-26 08:38:19 +00:00
|
|
|
}
|
|
|
|
|
2011-07-07 17:26:22 +00:00
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stopWalking() {
|
2011-10-28 10:37:07 +00:00
|
|
|
_destX = _x;
|
|
|
|
if (!_isWalking && !_isSneaking && !_isLargeStep) {
|
2011-10-21 09:13:49 +00:00
|
|
|
gotoState(NULL);
|
2011-10-28 10:37:07 +00:00
|
|
|
gotoNextStateExt();
|
2011-09-09 09:04:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::startIdleAnimation(uint32 fileHash, AnimationCb callback) {
|
2013-06-12 08:16:05 +00:00
|
|
|
debug(1, "startIdleAnimation(%08X)", fileHash);
|
2012-09-24 18:06:08 +00:00
|
|
|
NextState(callback);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::upIdleAnimation);
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::upIdleAnimation() {
|
2012-09-24 18:06:08 +00:00
|
|
|
gotoNextStateExt();
|
2011-07-07 17:26:22 +00:00
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
bool Klaymen::stStartActionFromIdle(AnimationCb callback) {
|
2013-01-24 19:10:27 +00:00
|
|
|
if (_busyStatus == 2) {
|
|
|
|
_busyStatus = 1;
|
2013-07-14 17:01:47 +00:00
|
|
|
_acceptInput = false;
|
2011-10-27 11:33:12 +00:00
|
|
|
startAnimation(0x9A7020B8, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmStartAction);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2011-10-21 09:13:49 +00:00
|
|
|
NextState(callback);
|
2011-07-09 18:45:51 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::gotoNextStateExt() {
|
2011-10-21 09:13:49 +00:00
|
|
|
if (_finalizeStateCb) {
|
|
|
|
AnimationCb cb = _finalizeStateCb;
|
|
|
|
_finalizeStateCb = NULL;
|
2011-07-09 18:45:51 +00:00
|
|
|
(this->*cb)();
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
2011-10-21 09:13:49 +00:00
|
|
|
if (_nextStateCb) {
|
|
|
|
AnimationCb cb = _nextStateCb;
|
|
|
|
_nextStateCb = NULL;
|
2011-07-07 17:26:22 +00:00
|
|
|
(this->*cb)();
|
|
|
|
} else {
|
2013-01-21 11:34:50 +00:00
|
|
|
// Inform the scene that the current Klaymen animation sequence has finished
|
2011-09-16 12:23:26 +00:00
|
|
|
sendMessage(_parentScene, 0x1006, 0);
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-24 19:10:27 +00:00
|
|
|
void Klaymen::beginAction() {
|
|
|
|
_actionStatusChanged = false;
|
|
|
|
_actionStatus = 1;
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-24 19:10:27 +00:00
|
|
|
void Klaymen::endAction() {
|
|
|
|
if (_actionStatusChanged)
|
|
|
|
_actionStatus = 0;
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stTryStandIdle() {
|
|
|
|
if (!stStartActionFromIdle(AnimationCallback(&Klaymen::stTryStandIdle))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x5420E254, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::upStandIdle);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevel);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2012-10-04 07:38:19 +00:00
|
|
|
_idleCounter = 0;
|
|
|
|
_blinkCounter = 0;
|
|
|
|
_blinkCounterMax = _vm->_rnd->getRandomNumber(64) + 24;
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::upStandIdle() {
|
2011-07-07 17:26:22 +00:00
|
|
|
update();
|
2012-09-24 18:06:08 +00:00
|
|
|
if (++_idleCounter >= 720) {
|
|
|
|
_idleCounter = 0;
|
2011-10-27 11:33:12 +00:00
|
|
|
if (_idleTable) {
|
2013-01-25 09:12:49 +00:00
|
|
|
int idleWeight = _vm->_rnd->getRandomNumber(_idleTableTotalWeight - 1);
|
|
|
|
for (uint i = 0; i < _idleTableCount; i++) {
|
|
|
|
if (idleWeight < _idleTable[i].weight) {
|
|
|
|
enterIdleAnimation(_idleTable[i].idleAnimation);
|
2011-07-07 17:26:22 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-01-25 09:12:49 +00:00
|
|
|
idleWeight -= _idleTable[i].weight;
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
}
|
2012-09-24 18:06:08 +00:00
|
|
|
} else if (++_blinkCounter >= _blinkCounterMax) {
|
|
|
|
_blinkCounter = 0;
|
|
|
|
_blinkCounterMax = _vm->_rnd->getRandomNumber(64 - 1) + 24;
|
|
|
|
stIdleBlink();
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmLowLevel(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2011-07-07 17:26:22 +00:00
|
|
|
Sprite::handleMessage(messageNum, param, sender);
|
|
|
|
uint32 messageResult = xHandleMessage(messageNum, param);
|
|
|
|
switch (messageNum) {
|
|
|
|
case 0x1008:
|
2011-10-27 11:33:12 +00:00
|
|
|
messageResult = _acceptInput;
|
2011-07-07 17:26:22 +00:00
|
|
|
break;
|
|
|
|
case 0x1014:
|
2011-10-21 09:13:49 +00:00
|
|
|
_attachedSprite = (Sprite*)(param.asEntity());
|
2011-07-07 17:26:22 +00:00
|
|
|
break;
|
|
|
|
case 0x1019:
|
2011-10-28 10:37:07 +00:00
|
|
|
gotoNextStateExt();
|
2011-07-07 17:26:22 +00:00
|
|
|
break;
|
|
|
|
case 0x101C:
|
2013-01-24 19:10:27 +00:00
|
|
|
beginAction();
|
2011-07-07 17:26:22 +00:00
|
|
|
break;
|
|
|
|
case 0x1021:
|
2013-01-24 19:10:27 +00:00
|
|
|
endAction();
|
2011-07-07 17:26:22 +00:00
|
|
|
break;
|
|
|
|
case 0x481C:
|
2013-01-24 19:10:27 +00:00
|
|
|
_actionStatus = param.asInteger();
|
|
|
|
_actionStatusChanged = true;
|
2011-07-07 17:26:22 +00:00
|
|
|
messageResult = 1;
|
|
|
|
break;
|
|
|
|
case 0x482C:
|
2011-07-08 19:09:33 +00:00
|
|
|
if (param.asInteger() != 0) {
|
2012-08-17 15:03:38 +00:00
|
|
|
_pathPoints = _dataResource.getPointArray(param.asInteger());
|
2011-07-07 17:26:22 +00:00
|
|
|
} else {
|
2012-08-17 15:03:38 +00:00
|
|
|
_pathPoints = NULL;
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stIdleBlink() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x5900C41E, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevelAnimation);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2013-01-21 11:34:50 +00:00
|
|
|
NextState(&Klaymen::stStandAround);
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmLowLevelAnimation(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevel(messageNum, param, sender);
|
2011-07-07 17:26:22 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x3002:
|
2011-10-28 10:37:07 +00:00
|
|
|
gotoNextStateExt();
|
2011-07-07 17:26:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stStandAround() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x5420E254, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::upStandIdle);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevel);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2011-07-07 17:26:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmStartAction(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2011-07-07 20:26:12 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
2011-07-08 19:09:33 +00:00
|
|
|
if (param.asInteger() == 0x271AA210) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x4924AAC4);
|
2011-07-08 19:09:33 +00:00
|
|
|
} else if (param.asInteger() == 0x2B22AA81) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x0A2AA8E0);
|
2011-07-07 20:26:12 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-24 19:10:27 +00:00
|
|
|
void Klaymen::startWalkToX(int16 x, bool walkExt) {
|
2011-07-07 20:26:12 +00:00
|
|
|
int16 xdiff = ABS(x - _x);
|
2011-07-09 18:45:51 +00:00
|
|
|
if (x == _x) {
|
2011-10-28 10:37:07 +00:00
|
|
|
_destX = x;
|
|
|
|
if (!_isWalking && !_isSneaking && !_isLargeStep) {
|
2011-10-21 09:13:49 +00:00
|
|
|
gotoState(NULL);
|
2011-10-28 10:37:07 +00:00
|
|
|
gotoNextStateExt();
|
2011-07-07 20:26:12 +00:00
|
|
|
}
|
2011-10-28 10:37:07 +00:00
|
|
|
} else if (xdiff <= 36 && !_isWalking && !_isSneaking && !_isLargeStep) {
|
|
|
|
_destX = x;
|
2011-10-21 09:13:49 +00:00
|
|
|
gotoState(NULL);
|
2011-10-28 10:37:07 +00:00
|
|
|
gotoNextStateExt();
|
2013-01-24 19:10:27 +00:00
|
|
|
} else if (xdiff <= 42 && _actionStatus != 3) {
|
2011-10-28 10:37:07 +00:00
|
|
|
if (_isSneaking && ((!_doDeltaX && x - _x > 0) || (_doDeltaX && x - _x < 0)) && ABS(_destX - _x) > xdiff) {
|
|
|
|
_destX = x;
|
2011-07-07 20:26:12 +00:00
|
|
|
} else {
|
2011-10-28 10:37:07 +00:00
|
|
|
_destX = x;
|
2013-01-21 11:34:50 +00:00
|
|
|
GotoState(&Klaymen::stSneak);
|
2011-07-07 20:26:12 +00:00
|
|
|
}
|
2011-10-28 10:37:07 +00:00
|
|
|
} else if (_isWalking && ((!_doDeltaX && x - _x > 0) || (_doDeltaX && x - _x < 0))) {
|
|
|
|
_destX = x;
|
2013-01-24 19:10:27 +00:00
|
|
|
} else if (walkExt) {
|
2011-10-28 10:37:07 +00:00
|
|
|
_destX = x;
|
2013-01-21 11:34:50 +00:00
|
|
|
GotoState(&Klaymen::stStartWalkingExt);
|
2011-07-07 20:26:12 +00:00
|
|
|
} else {
|
2011-10-28 10:37:07 +00:00
|
|
|
_destX = x;
|
2013-01-21 11:34:50 +00:00
|
|
|
GotoState(&Klaymen::stStartWalking);
|
2011-07-08 19:09:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
bool Klaymen::stStartAction(AnimationCb callback3) {
|
2013-01-24 19:10:27 +00:00
|
|
|
if (_busyStatus == 1) {
|
|
|
|
_busyStatus = 2;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x5C7080D4, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmStartAction);
|
|
|
|
SetSpriteUpdate(&Klaymen::suAction);
|
2011-10-21 09:13:49 +00:00
|
|
|
NextState(callback3);
|
2011-07-08 19:09:33 +00:00
|
|
|
return true;
|
|
|
|
} else {
|
2011-10-28 10:37:07 +00:00
|
|
|
_x = _destX;
|
2011-07-08 19:09:33 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::suAction() {
|
2011-07-09 18:45:51 +00:00
|
|
|
|
2011-10-28 10:37:07 +00:00
|
|
|
int16 xdiff = _destX - _x;
|
2011-07-09 18:45:51 +00:00
|
|
|
|
|
|
|
if (_doDeltaX) {
|
|
|
|
_x -= _deltaX;
|
|
|
|
} else {
|
|
|
|
_x += _deltaX;
|
|
|
|
}
|
|
|
|
_deltaX = 0;
|
2013-07-14 17:01:47 +00:00
|
|
|
|
2011-07-09 18:45:51 +00:00
|
|
|
if (_doDeltaY) {
|
|
|
|
_y -= _deltaY;
|
|
|
|
} else {
|
|
|
|
_y += _deltaY;
|
|
|
|
}
|
|
|
|
_deltaY = 0;
|
2013-07-14 17:01:47 +00:00
|
|
|
|
2011-10-27 11:33:12 +00:00
|
|
|
if (_frameChanged) {
|
2011-07-09 18:45:51 +00:00
|
|
|
if (xdiff > 6)
|
|
|
|
_x += 6;
|
|
|
|
else if (xdiff < -6)
|
|
|
|
_x -= 6;
|
|
|
|
else
|
2013-07-14 17:01:47 +00:00
|
|
|
_x = _destX;
|
2011-07-09 18:45:51 +00:00
|
|
|
}
|
2013-07-14 17:01:47 +00:00
|
|
|
|
2012-10-22 12:26:53 +00:00
|
|
|
updateBounds();
|
2013-07-14 17:01:47 +00:00
|
|
|
|
2011-07-08 19:09:33 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::suSneaking() {
|
2013-07-14 17:01:47 +00:00
|
|
|
|
2011-10-28 10:37:07 +00:00
|
|
|
int16 xdiff = _destX - _x;
|
2013-07-14 17:01:47 +00:00
|
|
|
|
2011-10-27 11:33:12 +00:00
|
|
|
if (_currFrameIndex == 9) {
|
2011-07-09 18:45:51 +00:00
|
|
|
if (xdiff > 26)
|
|
|
|
_deltaX += xdiff - 26;
|
2013-07-14 17:01:47 +00:00
|
|
|
else if (xdiff < -26)
|
2011-07-09 18:45:51 +00:00
|
|
|
_deltaX -= xdiff + 26;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xdiff > _deltaX)
|
|
|
|
xdiff = _deltaX;
|
|
|
|
else if (xdiff < -_deltaX)
|
|
|
|
xdiff = -_deltaX;
|
2013-07-14 17:01:47 +00:00
|
|
|
_deltaX = 0;
|
2011-07-09 18:45:51 +00:00
|
|
|
|
2011-10-28 10:37:07 +00:00
|
|
|
if (_destX != _x) {
|
2013-01-10 23:17:16 +00:00
|
|
|
HitRect *hitRectPrev = _parentScene->findHitRectAtPos(_x, _y);
|
2011-07-09 18:45:51 +00:00
|
|
|
_x += xdiff;
|
2012-08-17 15:03:38 +00:00
|
|
|
if (_pathPoints) {
|
|
|
|
walkAlongPathPoints();
|
2011-07-09 18:45:51 +00:00
|
|
|
} else {
|
2013-01-10 23:17:16 +00:00
|
|
|
HitRect *hitRectNext = _parentScene->findHitRectAtPos(_x, _y);
|
2011-07-09 18:45:51 +00:00
|
|
|
if (hitRectNext->type == 0x5002) {
|
|
|
|
_y = MAX<int16>(hitRectNext->rect.y1, hitRectNext->rect.y2 - (hitRectNext->rect.x2 - _x) / 2);
|
|
|
|
} else if (hitRectNext->type == 0x5003) {
|
|
|
|
_y = MAX<int16>(hitRectNext->rect.y1, hitRectNext->rect.y2 - (_x - hitRectNext->rect.x1) / 2);
|
|
|
|
} else if (hitRectPrev->type == 0x5002) {
|
|
|
|
if (xdiff > 0) {
|
|
|
|
_y = hitRectPrev->rect.y2;
|
|
|
|
} else {
|
|
|
|
_y = hitRectPrev->rect.y1;
|
|
|
|
}
|
|
|
|
} else if (hitRectPrev->type == 0x5003) {
|
|
|
|
if (xdiff < 0) {
|
|
|
|
_y = hitRectPrev->rect.y2;
|
|
|
|
} else {
|
|
|
|
_y = hitRectPrev->rect.y1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-10-22 12:26:53 +00:00
|
|
|
updateBounds();
|
2011-07-09 18:45:51 +00:00
|
|
|
}
|
2013-07-14 17:01:47 +00:00
|
|
|
|
2011-07-08 19:09:33 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stSneak() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2011-10-28 10:37:07 +00:00
|
|
|
_isSneaking = true;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
2011-10-28 10:37:07 +00:00
|
|
|
setDoDeltaX(_destX < _x ? 1 : 0);
|
2011-10-27 11:33:12 +00:00
|
|
|
startAnimation(0x5C48C506, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmSneaking);
|
|
|
|
SetSpriteUpdate(&Klaymen::suSneaking);
|
2013-07-14 17:01:47 +00:00
|
|
|
FinalizeState(&Klaymen::evSneakingDone);
|
2011-07-08 19:09:33 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::evSneakingDone() {
|
2011-10-28 10:37:07 +00:00
|
|
|
_isSneaking = false;
|
2011-07-08 19:09:33 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmSneaking(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevel(messageNum, param, sender);
|
2011-07-08 19:09:33 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x32180101) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x4924AAC4);
|
2011-07-08 19:09:33 +00:00
|
|
|
} else if (param.asInteger() == 0x0A2A9098) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x0A2AA8E0);
|
2011-07-08 19:09:33 +00:00
|
|
|
} else if (param.asInteger() == 0x32188010) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, _soundFlag ? 0x48498E46 : 0x405002D8);
|
2011-07-08 19:09:33 +00:00
|
|
|
} else if (param.asInteger() == 0x02A2909C) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, _soundFlag ? 0x50399F64 : 0x0460E2FA);
|
2011-07-08 19:09:33 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x3002:
|
2011-10-28 10:37:07 +00:00
|
|
|
_x = _destX;
|
|
|
|
gotoNextStateExt();
|
2011-07-08 19:09:33 +00:00
|
|
|
break;
|
2011-07-07 20:26:12 +00:00
|
|
|
}
|
2011-07-08 19:09:33 +00:00
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stStartWalking() {
|
|
|
|
if (!stStartActionFromIdle(AnimationCallback(&Klaymen::stStartWalking))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2011-10-28 10:37:07 +00:00
|
|
|
_isWalking = true;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
2011-10-28 10:37:07 +00:00
|
|
|
setDoDeltaX(_destX < _x ? 1 : 0);
|
2011-10-27 11:33:12 +00:00
|
|
|
startAnimation(0x242C0198, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmStartWalking);
|
|
|
|
SetSpriteUpdate(&Klaymen::suWalkingTestExit);
|
|
|
|
NextState(&Klaymen::stWalkingFirst);
|
2013-07-14 17:01:47 +00:00
|
|
|
FinalizeState(&Klaymen::evStartWalkingDone);
|
2011-07-08 19:09:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::evStartWalkingDone() {
|
2011-10-28 10:37:07 +00:00
|
|
|
_isWalking = false;
|
2011-07-08 19:09:33 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmStartWalking(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2011-07-08 19:09:33 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x32180101) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, _soundFlag ? 0x48498E46 : 0x405002D8);
|
2011-07-08 19:09:33 +00:00
|
|
|
} else if (param.asInteger() == 0x0A2A9098) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, _soundFlag ? 0x50399F64 : 0x0460E2FA);
|
2011-07-08 19:09:33 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stWalkingFirst() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2011-10-28 10:37:07 +00:00
|
|
|
_isWalking = true;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x1A249001, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmWalking);
|
|
|
|
SetSpriteUpdate(&Klaymen::suWalkingFirst);
|
|
|
|
NextState(&Klaymen::stUpdateWalkingFirst);
|
2013-07-14 17:01:47 +00:00
|
|
|
FinalizeState(&Klaymen::evStartWalkingDone);
|
2011-07-08 19:09:33 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::suWalkingFirst() {
|
|
|
|
SetSpriteUpdate(&Klaymen::suWalkingTestExit);
|
2011-07-08 19:09:33 +00:00
|
|
|
_deltaX = 0;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmWalking(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevel(messageNum, param, sender);
|
2011-07-08 19:09:33 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x32180101) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, _soundFlag ? 0x48498E46 : 0x405002D8);
|
2011-07-08 19:09:33 +00:00
|
|
|
} else if (param.asInteger() == 0x0A2A9098) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, _soundFlag ? 0x50399F64 : 0x0460E2FA);
|
2011-07-08 19:09:33 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stUpdateWalkingFirst() {
|
2013-01-24 19:10:27 +00:00
|
|
|
if (_actionStatus == 2) {
|
2011-10-28 10:37:07 +00:00
|
|
|
gotoNextStateExt();
|
2013-01-24 19:10:27 +00:00
|
|
|
} else if (_actionStatus == 3) {
|
2011-10-27 11:33:12 +00:00
|
|
|
stWalkingOpenDoor();
|
2011-07-08 19:09:33 +00:00
|
|
|
} else {
|
2011-10-28 10:37:07 +00:00
|
|
|
_isSneaking = true;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
2011-10-28 10:37:07 +00:00
|
|
|
if (ABS(_destX - _x) <= 42 && _currFrameIndex >= 5 && _currFrameIndex <= 11) {
|
2013-01-24 19:10:27 +00:00
|
|
|
if (_actionStatus == 0) {
|
|
|
|
_busyStatus = 1;
|
2011-10-27 11:33:12 +00:00
|
|
|
startAnimation(0xF234EE31, 0, -1);
|
2011-07-08 19:09:33 +00:00
|
|
|
} else {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 2;
|
2011-10-27 11:33:12 +00:00
|
|
|
startAnimation(0xF135CC21, 0, -1);
|
2011-07-08 19:09:33 +00:00
|
|
|
}
|
2011-10-28 10:37:07 +00:00
|
|
|
} else if (ABS(_destX - _x) <= 10 && (_currFrameIndex >= 12 || _currFrameIndex <= 4)) {
|
2013-01-24 19:10:27 +00:00
|
|
|
if (_actionStatus == 0) {
|
|
|
|
_busyStatus = 1;
|
2011-10-27 11:33:12 +00:00
|
|
|
startAnimation(0x8604A152, 0, -1);
|
2011-07-08 19:09:33 +00:00
|
|
|
} else {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 2;
|
2011-10-27 11:33:12 +00:00
|
|
|
startAnimation(0xA246A132, 0, -1);
|
2011-07-08 19:09:33 +00:00
|
|
|
}
|
|
|
|
}
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmSneaking);
|
|
|
|
SetSpriteUpdate(&Klaymen::suSneaking);
|
2013-07-14 17:01:47 +00:00
|
|
|
FinalizeState(&Klaymen::evSneakingDone);
|
2011-07-08 19:09:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::suWalkingTestExit() {
|
2011-10-28 10:37:07 +00:00
|
|
|
int16 xdiff = ABS(_destX - _x);
|
|
|
|
int16 xdelta = _destX - _x;
|
2013-07-14 17:01:47 +00:00
|
|
|
|
2011-07-08 19:09:33 +00:00
|
|
|
if (xdelta > _deltaX)
|
|
|
|
xdelta = _deltaX;
|
2011-07-09 18:45:51 +00:00
|
|
|
else if (xdelta < -_deltaX)
|
2011-07-08 19:09:33 +00:00
|
|
|
xdelta = -_deltaX;
|
2013-07-14 17:01:47 +00:00
|
|
|
|
|
|
|
_deltaX = 0;
|
2011-07-08 19:09:33 +00:00
|
|
|
|
2011-10-28 10:37:07 +00:00
|
|
|
if (xdiff == 0 ||
|
2013-01-24 19:10:27 +00:00
|
|
|
(_actionStatus != 2 && _actionStatus != 3 && xdiff <= 42 && _currFrameIndex >= 5 && _currFrameIndex <= 11) ||
|
|
|
|
(_actionStatus != 2 && _actionStatus != 3 && xdiff <= 10 && (_currFrameIndex >= 12 || _currFrameIndex <= 4)) ||
|
|
|
|
(_actionStatus == 3 && xdiff < 30) ||
|
|
|
|
(_actionStatus == 3 && xdiff < 150 && _currFrameIndex >= 6)) {
|
2011-09-16 12:23:26 +00:00
|
|
|
sendMessage(this, 0x1019, 0);
|
2011-07-08 19:09:33 +00:00
|
|
|
} else {
|
2013-01-10 23:17:16 +00:00
|
|
|
HitRect *hitRectPrev = _parentScene->findHitRectAtPos(_x, _y);
|
2011-07-08 19:09:33 +00:00
|
|
|
_x += xdelta;
|
2012-08-17 15:03:38 +00:00
|
|
|
if (_pathPoints) {
|
|
|
|
walkAlongPathPoints();
|
2011-07-08 19:09:33 +00:00
|
|
|
} else {
|
2013-01-10 23:17:16 +00:00
|
|
|
HitRect *hitRectNext = _parentScene->findHitRectAtPos(_x, _y);
|
2011-07-08 19:09:33 +00:00
|
|
|
if (hitRectNext->type == 0x5002) {
|
|
|
|
_y = MAX<int16>(hitRectNext->rect.y1, hitRectNext->rect.y2 - (hitRectNext->rect.x2 - _x) / 2);
|
|
|
|
} else if (hitRectNext->type == 0x5003) {
|
|
|
|
_y = MAX<int16>(hitRectNext->rect.y1, hitRectNext->rect.y2 - (_x - hitRectNext->rect.x1) / 2);
|
|
|
|
} else if (hitRectPrev->type == 0x5002) {
|
2011-10-28 10:37:07 +00:00
|
|
|
_y = xdelta > 0 ? hitRectPrev->rect.y2 : hitRectPrev->rect.y1;
|
2011-07-08 19:09:33 +00:00
|
|
|
} else if (hitRectPrev->type == 0x5003) {
|
2011-10-28 10:37:07 +00:00
|
|
|
_y = xdelta < 0 ? hitRectPrev->rect.y2 : hitRectPrev->rect.y1;
|
2013-01-24 19:10:27 +00:00
|
|
|
} else if (_doYHitIncr && xdelta != 0) {
|
2011-07-08 19:09:33 +00:00
|
|
|
if (hitRectNext->type == 0x5000) {
|
|
|
|
_y++;
|
|
|
|
} else if (hitRectNext->type == 0x5001 && _y > hitRectNext->rect.y1) {
|
|
|
|
_y--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-10-22 12:26:53 +00:00
|
|
|
updateBounds();
|
2011-07-08 19:09:33 +00:00
|
|
|
}
|
2013-07-14 17:01:47 +00:00
|
|
|
|
2011-07-07 20:26:12 +00:00
|
|
|
}
|
2011-07-07 17:26:22 +00:00
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmLever(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2011-07-09 18:45:51 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x4AB28209) {
|
2011-09-16 12:23:26 +00:00
|
|
|
sendMessage(_attachedSprite, 0x482A, 0);
|
2011-07-09 18:45:51 +00:00
|
|
|
} else if (param.asInteger() == 0x88001184) {
|
2011-09-16 12:23:26 +00:00
|
|
|
sendMessage(_attachedSprite, 0x482B, 0);
|
2011-07-09 18:45:51 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stPickUpGeneric() {
|
2011-10-21 09:13:49 +00:00
|
|
|
setDoDeltaX(_attachedSprite->getX() < _x ? 1 : 0);
|
2013-01-21 11:34:50 +00:00
|
|
|
if (!stStartAction(AnimationCallback(&Klaymen::stPickUpGeneric))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x1C28C178, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmPickUpObject);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2011-07-10 18:21:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmPickUpObject(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2011-07-10 18:21:48 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0xC1380080) {
|
2012-10-02 07:26:05 +00:00
|
|
|
sendMessage(_attachedSprite, 0x4806, 0);
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x40208200);
|
2011-07-10 18:21:48 +00:00
|
|
|
} else if (param.asInteger() == 0x02B20220) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0xC5408620);
|
2011-07-10 18:21:48 +00:00
|
|
|
} else if (param.asInteger() == 0x03020231) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0xD4C08010);
|
2011-07-10 18:21:48 +00:00
|
|
|
} else if (param.asInteger() == 0x67221A03) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x44051000);
|
2011-07-10 18:21:48 +00:00
|
|
|
} else if (param.asInteger() == 0x2EAE0303) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x03630300);
|
2011-07-10 18:21:48 +00:00
|
|
|
} else if (param.asInteger() == 0x61CE4467) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x03630300);
|
2011-07-10 18:21:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stPressButton() {
|
|
|
|
if (!stStartAction(AnimationCallback(&Klaymen::stPressButton))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 2;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x1C02B03D, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmPressButton);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2011-07-10 18:21:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmPressButton(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2011-07-10 18:21:48 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x0D01B294) {
|
2012-10-02 07:26:05 +00:00
|
|
|
sendMessage(_attachedSprite, 0x480B, 0);
|
2011-07-10 18:21:48 +00:00
|
|
|
} else if (param.asInteger() == 0x32180101) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x4924AAC4);
|
2011-07-10 18:21:48 +00:00
|
|
|
} else if (param.asInteger() == 0x0A2A9098) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x0A2AA8E0);
|
2011-07-10 18:21:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stPressFloorButton() {
|
|
|
|
if (!stStartAction(AnimationCallback(&Klaymen::stPressFloorButton))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 2;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x1C16B033, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmPressButton);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2011-07-10 18:21:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stPressButtonSide() {
|
|
|
|
if (!stStartActionFromIdle(AnimationCallback(&Klaymen::stPressButtonSide))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x1CD89029, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmPressButton);
|
|
|
|
SetSpriteUpdate(&Klaymen::suAction);
|
2011-07-10 18:21:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::startSpecialWalkRight(int16 x) {
|
2011-10-28 10:37:07 +00:00
|
|
|
if (_x == x) {
|
|
|
|
_destX = x;
|
|
|
|
gotoState(NULL);
|
|
|
|
gotoNextStateExt();
|
2011-07-10 18:21:48 +00:00
|
|
|
} else if (_x < x) {
|
2011-10-28 10:37:07 +00:00
|
|
|
startWalkToX(x, false);
|
|
|
|
} else if (_x - x <= 105) {
|
2012-09-26 17:57:06 +00:00
|
|
|
startWalkToXExt(x);
|
2011-07-10 18:21:48 +00:00
|
|
|
} else {
|
2011-10-28 10:37:07 +00:00
|
|
|
startWalkToX(x, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::startSpecialWalkLeft(int16 x) {
|
2011-10-28 10:37:07 +00:00
|
|
|
if (x == _x) {
|
|
|
|
_destX = x;
|
2011-10-21 09:13:49 +00:00
|
|
|
gotoState(NULL);
|
2011-10-28 10:37:07 +00:00
|
|
|
gotoNextStateExt();
|
|
|
|
} else if (x < _x) {
|
|
|
|
startWalkToX(x, false);
|
|
|
|
} else if (x - _x <= 105) {
|
2012-09-26 17:57:06 +00:00
|
|
|
startWalkToXExt(x);
|
2011-10-28 10:37:07 +00:00
|
|
|
} else {
|
|
|
|
startWalkToX(x, false);
|
2011-07-10 18:21:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::startWalkToXSmall(int16 x) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_actionStatus = 2;
|
2012-08-17 15:03:38 +00:00
|
|
|
if (_x == x) {
|
|
|
|
_destX = x;
|
|
|
|
if (_isWalking) {
|
|
|
|
GotoState(NULL);
|
|
|
|
gotoNextStateExt();
|
|
|
|
}
|
|
|
|
} else if (_isWalking && ((!_doDeltaX && x - _x > 0) || (_doDeltaX && x - _x < 0))) {
|
|
|
|
_destX = x;
|
|
|
|
} else {
|
|
|
|
_destX = x;
|
2013-01-21 11:34:50 +00:00
|
|
|
GotoState(&Klaymen::stStartWalkingSmall);
|
2012-08-17 15:03:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stStartWalkingSmall() {
|
2012-08-17 15:03:38 +00:00
|
|
|
_isWalking = true;
|
|
|
|
_acceptInput = true;
|
2013-01-24 19:10:27 +00:00
|
|
|
_actionStatus = 2;
|
2012-08-17 15:03:38 +00:00
|
|
|
setDoDeltaX(_destX < _x ? 1 : 0);
|
|
|
|
startAnimation(0x3A4CD934, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmWalkingSmall);
|
|
|
|
SetSpriteUpdate(&Klaymen::suWalkingTestExit);
|
|
|
|
FinalizeState(&Klaymen::evStartWalkingDone);
|
2012-08-17 15:03:38 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmWalkingSmall(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevel(messageNum, param, sender);
|
2012-08-17 15:03:38 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x32180101)
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x4924AAC4);
|
2012-08-17 15:03:38 +00:00
|
|
|
else if (param.asInteger() == 0x0A2A9098)
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x0A2AA8E0);
|
2012-08-17 15:03:38 +00:00
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stStandIdleSmall() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-08-17 15:03:38 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x90D0D1D0, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevel);
|
2012-08-17 15:03:38 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stWonderAboutAfterSmall() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-08-17 15:03:38 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x11C8D156, 30, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevelAnimation);
|
2012-08-17 15:03:38 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stWonderAboutHalfSmall() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-08-17 15:03:38 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x11C8D156, 0, 10);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevelAnimation);
|
2012-08-17 15:03:38 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stWonderAboutSmall() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-08-17 15:03:38 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x11C8D156, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevelAnimation);
|
2012-08-17 15:03:38 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stWalkToFrontNoStepSmall() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-08-17 15:03:38 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimationByHash(0x3F9CC394, 0x14884392, 0);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmWalkFrontBackSmall);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2012-08-17 15:03:38 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmWalkFrontBackSmall(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2012-08-17 15:03:38 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x80C110B5)
|
|
|
|
sendMessage(_parentScene, 0x482A, 0);
|
|
|
|
else if (param.asInteger() == 0x110010D1)
|
|
|
|
sendMessage(_parentScene, 0x482B, 0);
|
|
|
|
else if (param.asInteger() == 0x32180101)
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x4924AAC4);
|
2012-08-17 15:03:38 +00:00
|
|
|
else if (param.asInteger() == 0x0A2A9098)
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x0A2AA8E0);
|
2012-08-17 15:03:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stWalkToFront2Small() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-08-17 15:03:38 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x2F1C4694, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmWalkFrontBackSmall);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2012-08-17 15:03:38 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stWalkToFrontSmall() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-08-17 15:03:38 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x3F9CC394, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmWalkFrontBackSmall);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2012-08-17 15:03:38 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stTurnToBackHalfSmall() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-08-17 15:03:38 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimationByHash(0x37ECD436, 0, 0x8520108C);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmWalkFrontBackSmall);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2012-08-17 15:03:38 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stTurnToBackWalkSmall() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-08-17 15:03:38 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x16EDDE36, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmWalkFrontBackSmall);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2012-08-17 15:03:38 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stTurnToBackSmall() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-08-17 15:03:38 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x37ECD436, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmWalkFrontBackSmall);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2012-08-17 15:03:38 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stPullCord() {
|
|
|
|
if (!stStartAction(AnimationCallback(&Klaymen::stPullCord))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 2;
|
2012-08-29 17:54:46 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x3F28E094, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmPullReleaseCord);
|
2012-08-29 17:54:46 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2013-01-21 11:34:50 +00:00
|
|
|
NextState(&Klaymen::stReleaseCord);
|
2012-08-29 17:54:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stReleaseCord() {
|
2012-08-29 17:54:46 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x3A28C094, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmPullReleaseCord);
|
2012-08-29 17:54:46 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmPullReleaseCord(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2012-08-29 17:54:46 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x4AB28209) {
|
|
|
|
sendMessage(_attachedSprite, 0x482A, 0);
|
|
|
|
sendMessage(_attachedSprite, 0x480F, 0);
|
|
|
|
} else if (param.asInteger() == 0x88001184) {
|
|
|
|
sendMessage(_attachedSprite, 0x482B, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stUseTube() {
|
|
|
|
if (!stStartAction(AnimationCallback(&Klaymen::stUseTube))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2012-08-29 17:54:46 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x1A38A814, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmUseTube);
|
2012-08-29 17:54:46 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmUseTube(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2012-08-29 17:54:46 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x02B20220)
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0xC5408620);
|
2012-08-29 17:54:46 +00:00
|
|
|
else if (param.asInteger() == 0x0A720138)
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0xD4C08010);
|
2012-08-29 17:54:46 +00:00
|
|
|
else if (param.asInteger() == 0x03020231)
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0xD4C08010);
|
2012-08-29 17:54:46 +00:00
|
|
|
else if (param.asInteger() == 0xB613A180)
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x44051000);
|
2012-08-29 17:54:46 +00:00
|
|
|
else if (param.asInteger() == 0x67221A03)
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x44051000);
|
2012-08-29 17:54:46 +00:00
|
|
|
else if (param.asInteger() == 0x038A010B)
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x00018040);
|
2012-08-29 17:54:46 +00:00
|
|
|
else if (param.asInteger() == 0x422B0280)
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x166FC6E0);
|
2012-08-29 17:54:46 +00:00
|
|
|
else if (param.asInteger() == 0x925A0C1E)
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x40E5884D);
|
2012-08-29 17:54:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stWalkingFirstExt() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-08-29 17:54:46 +00:00
|
|
|
_isWalking = true;
|
|
|
|
_acceptInput = true;
|
2012-09-26 17:57:06 +00:00
|
|
|
startAnimation(0x5A2CBC00, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmWalking);
|
|
|
|
SetSpriteUpdate(&Klaymen::suWalkingFirst);
|
|
|
|
NextState(&Klaymen::stUpdateWalkingFirst);
|
|
|
|
FinalizeState(&Klaymen::evStartWalkingDone);
|
2012-08-29 17:54:46 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stStartWalkingExt() {
|
|
|
|
if (!stStartActionFromIdle(AnimationCallback(&Klaymen::stStartWalkingExt))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-08-29 17:54:46 +00:00
|
|
|
_isWalking = true;
|
|
|
|
_acceptInput = true;
|
|
|
|
setDoDeltaX(_destX < _x ? 1 : 0);
|
|
|
|
startAnimation(0x272C1199, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmStartWalking);
|
|
|
|
SetSpriteUpdate(&Klaymen::suWalkingTestExit);
|
|
|
|
NextState(&Klaymen::stWalkingFirstExt);
|
|
|
|
FinalizeState(&Klaymen::evStartWalkingDone);
|
2012-08-29 17:54:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-24 19:10:27 +00:00
|
|
|
void Klaymen::startWalkToXDistance(int16 destX, int16 distance) {
|
|
|
|
if (_x > destX) {
|
|
|
|
if (_x == destX + distance) {
|
|
|
|
_destX = destX + distance;
|
2011-10-21 09:13:49 +00:00
|
|
|
gotoState(NULL);
|
2011-10-28 10:37:07 +00:00
|
|
|
gotoNextStateExt();
|
2013-01-24 19:10:27 +00:00
|
|
|
} else if (_x < destX + distance) {
|
|
|
|
startWalkToXExt(destX + distance);
|
2011-07-10 18:21:48 +00:00
|
|
|
} else {
|
2013-01-24 19:10:27 +00:00
|
|
|
startWalkToX(destX + distance, false);
|
2011-07-10 18:21:48 +00:00
|
|
|
}
|
|
|
|
} else {
|
2013-01-24 19:10:27 +00:00
|
|
|
if (_x == destX - distance) {
|
|
|
|
_destX = destX - distance;
|
2011-10-21 09:13:49 +00:00
|
|
|
gotoState(NULL);
|
2011-10-28 10:37:07 +00:00
|
|
|
gotoNextStateExt();
|
2013-01-24 19:10:27 +00:00
|
|
|
} else if (_x > destX - distance) {
|
|
|
|
startWalkToXExt(destX - distance);
|
2011-07-10 18:21:48 +00:00
|
|
|
} else {
|
2013-01-24 19:10:27 +00:00
|
|
|
startWalkToX(destX - distance, false);
|
2011-07-10 18:21:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::startWalkToXExt(int16 x) {
|
2011-07-10 18:21:48 +00:00
|
|
|
int16 xdiff = ABS(x - _x);
|
|
|
|
if (x == _x) {
|
2011-10-28 10:37:07 +00:00
|
|
|
_destX = x;
|
|
|
|
if (!_isWalking && !_isSneaking && !_isLargeStep) {
|
2011-10-21 09:13:49 +00:00
|
|
|
gotoState(NULL);
|
2011-10-28 10:37:07 +00:00
|
|
|
gotoNextStateExt();
|
2011-07-10 18:21:48 +00:00
|
|
|
}
|
2011-10-28 10:37:07 +00:00
|
|
|
} else if (xdiff <= 36 && !_isWalking && !_isSneaking && !_isLargeStep) {
|
|
|
|
_destX = x;
|
2011-10-21 09:13:49 +00:00
|
|
|
gotoState(NULL);
|
2011-10-28 10:37:07 +00:00
|
|
|
gotoNextStateExt();
|
2013-01-24 19:10:27 +00:00
|
|
|
} else if (xdiff <= 42 && _actionStatus != 3) {
|
2011-10-28 10:37:07 +00:00
|
|
|
if (_isSneaking && ((!_doDeltaX && x - _x > 0) || (_doDeltaX && x - _x < 0)) && ABS(_destX - _x) > xdiff) {
|
|
|
|
_destX = x;
|
2011-07-10 18:21:48 +00:00
|
|
|
} else {
|
2011-10-28 10:37:07 +00:00
|
|
|
_destX = x;
|
2013-01-21 11:34:50 +00:00
|
|
|
GotoState(&Klaymen::stSneak);
|
2011-07-10 18:21:48 +00:00
|
|
|
}
|
2011-10-28 10:37:07 +00:00
|
|
|
} else if (_isLargeStep && ((!_doDeltaX && x - _x > 0) || (_doDeltaX && x - _x < 0))) {
|
|
|
|
_destX = x;
|
2011-07-10 18:21:48 +00:00
|
|
|
} else {
|
2011-10-28 10:37:07 +00:00
|
|
|
_destX = x;
|
2013-01-21 11:34:50 +00:00
|
|
|
GotoState(&Klaymen::stLargeStep);
|
2011-07-10 18:21:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stLargeStep() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 2;
|
2011-10-28 10:37:07 +00:00
|
|
|
_isLargeStep = true;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
2011-10-28 10:37:07 +00:00
|
|
|
setDoDeltaX(_destX >= _x ? 1 : 0);
|
2011-10-27 11:33:12 +00:00
|
|
|
startAnimation(0x08B28116, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLargeStep);
|
|
|
|
SetSpriteUpdate(&Klaymen::suLargeStep);
|
2013-07-14 17:01:47 +00:00
|
|
|
FinalizeState(&Klaymen::evLargeStepDone);
|
2011-07-10 18:21:48 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::evLargeStepDone() {
|
2011-10-28 10:37:07 +00:00
|
|
|
_isLargeStep = false;
|
2011-07-10 18:21:48 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::suLargeStep() {
|
2011-10-28 10:37:07 +00:00
|
|
|
int16 xdiff = _destX - _x;
|
2013-07-14 17:01:47 +00:00
|
|
|
|
2011-07-10 18:21:48 +00:00
|
|
|
if (_doDeltaX) {
|
|
|
|
_deltaX = -_deltaX;
|
|
|
|
}
|
2013-07-14 17:01:47 +00:00
|
|
|
|
2011-10-27 11:33:12 +00:00
|
|
|
if (_currFrameIndex == 7) {
|
2011-07-10 18:21:48 +00:00
|
|
|
_deltaX = xdiff;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((xdiff > 0 && xdiff > _deltaX) || (xdiff < 0 && xdiff < _deltaX))
|
|
|
|
xdiff = _deltaX;
|
|
|
|
|
|
|
|
_deltaX = 0;
|
2013-07-14 17:01:47 +00:00
|
|
|
|
2011-10-28 10:37:07 +00:00
|
|
|
if (_x != _destX) {
|
2013-01-10 23:17:16 +00:00
|
|
|
HitRect *hitRectPrev = _parentScene->findHitRectAtPos(_x, _y);
|
2011-07-10 18:21:48 +00:00
|
|
|
_x += xdiff;
|
2012-08-17 15:03:38 +00:00
|
|
|
if (_pathPoints) {
|
|
|
|
walkAlongPathPoints();
|
2011-07-10 18:21:48 +00:00
|
|
|
} else {
|
2013-01-10 23:17:16 +00:00
|
|
|
HitRect *hitRectNext = _parentScene->findHitRectAtPos(_x, _y);
|
2011-07-10 18:21:48 +00:00
|
|
|
if (hitRectNext->type == 0x5002) {
|
|
|
|
_y = MAX<int16>(hitRectNext->rect.y1, hitRectNext->rect.y2 - (hitRectNext->rect.x2 - _x) / 2);
|
|
|
|
} else if (hitRectNext->type == 0x5003) {
|
|
|
|
_y = MAX<int16>(hitRectNext->rect.y1, hitRectNext->rect.y2 - (_x - hitRectNext->rect.x1) / 2);
|
|
|
|
} else if (hitRectPrev->type == 0x5002) {
|
2011-10-28 10:37:07 +00:00
|
|
|
_y = xdiff > 0 ? hitRectPrev->rect.y2 : hitRectPrev->rect.y1;
|
2011-07-10 18:21:48 +00:00
|
|
|
} else if (hitRectPrev->type == 0x5003) {
|
2011-10-28 10:37:07 +00:00
|
|
|
_y = xdiff < 0 ? hitRectPrev->rect.y2 : hitRectPrev->rect.y1;
|
2011-07-10 18:21:48 +00:00
|
|
|
}
|
|
|
|
}
|
2012-10-22 12:26:53 +00:00
|
|
|
updateBounds();
|
2011-07-10 18:21:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmLargeStep(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevel(messageNum, param, sender);
|
2011-07-10 18:21:48 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x32180101) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x4924AAC4);
|
2011-07-10 18:21:48 +00:00
|
|
|
} else if (param.asInteger() == 0x0A2A9098) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x0A2AA8E0);
|
2011-07-10 18:21:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x3002:
|
2011-10-28 10:37:07 +00:00
|
|
|
_x = _destX;
|
|
|
|
gotoNextStateExt();
|
2013-07-14 17:01:47 +00:00
|
|
|
break;
|
2011-07-10 18:21:48 +00:00
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stWonderAboutHalf() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0xD820A114, 0, 10);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevelAnimation);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2011-07-11 09:37:00 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stWonderAboutAfter() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0xD820A114, 30, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevelAnimation);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2011-07-11 09:37:00 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stTurnToUseHalf() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x9B250AD2, 0, 7);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmTurnToUse);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2011-07-11 09:37:00 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmTurnToUse(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2011-07-11 09:37:00 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x32180101) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x4924AAC4);
|
2011-07-11 09:37:00 +00:00
|
|
|
} else if (param.asInteger() == 0x0A2A9098) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x0A2AA8E0);
|
2011-07-11 09:37:00 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stTurnAwayFromUse() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x98F88391, 4, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmTurnToUse);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2011-07-11 09:37:00 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stWonderAbout() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0xD820A114, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevelAnimation);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2011-07-11 09:37:00 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stPeekWall() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0xAC20C012, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmPeekWall);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmPeekWall(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2011-09-16 20:37:24 +00:00
|
|
|
int16 speedUpFrameIndex;
|
2011-07-13 18:38:40 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x1008:
|
2013-01-21 11:34:50 +00:00
|
|
|
speedUpFrameIndex = getFrameIndex(kKlaymenSpeedUpHash);
|
2011-10-27 11:33:12 +00:00
|
|
|
if (_currFrameIndex < speedUpFrameIndex)
|
|
|
|
startAnimation(0xAC20C012, speedUpFrameIndex, -1);
|
2011-07-13 18:38:40 +00:00
|
|
|
return 0;
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x32180101) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x405002D8);
|
2011-07-13 18:38:40 +00:00
|
|
|
} else if (param.asInteger() == 0x0A2A9098) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x0460E2FA);
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-10-02 07:26:05 +00:00
|
|
|
return hmLowLevelAnimation(messageNum, param, sender);
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::suUpdateDestX() {
|
2011-07-13 18:38:40 +00:00
|
|
|
AnimatedSprite::updateDeltaXY();
|
2011-10-28 10:37:07 +00:00
|
|
|
_destX = _x;
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stReleaseRing() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
2012-10-02 07:26:05 +00:00
|
|
|
sendMessage(_attachedSprite, 0x4807, 0);
|
|
|
|
_attachedSprite = NULL;
|
2011-10-27 11:33:12 +00:00
|
|
|
startAnimation(0xB869A4B9, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevelAnimation);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
|
2013-01-24 19:10:27 +00:00
|
|
|
void Klaymen::startWalkToAttachedSpriteXDistance(int16 distance) {
|
|
|
|
startWalkToXDistance(_attachedSprite->getX(), distance);
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stContinueClimbLadderUp() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
2011-10-28 10:37:07 +00:00
|
|
|
_ladderStatus = 3;
|
2011-10-27 11:33:12 +00:00
|
|
|
startAnimationByHash(0x3A292504, 0x01084280, 0);
|
|
|
|
_newStickFrameHash = 0x01084280;
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevel);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2011-10-28 10:37:07 +00:00
|
|
|
gotoNextStateExt();
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stStartClimbLadderDown() {
|
|
|
|
if (!stStartAction(AnimationCallback(&Klaymen::stStartClimbLadderDown))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2011-10-28 10:37:07 +00:00
|
|
|
if (_destY < _y) {
|
|
|
|
if (_ladderStatus == 1) {
|
|
|
|
_ladderStatus = 2;
|
|
|
|
stClimbLadderHalf();
|
2011-07-13 18:38:40 +00:00
|
|
|
} else {
|
2011-10-28 10:37:07 +00:00
|
|
|
gotoNextStateExt();
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
2011-10-28 10:37:07 +00:00
|
|
|
} else if (_ladderStatus == 0) {
|
|
|
|
_ladderStatus = 2;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x122D1505, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmClimbLadderUpDown);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2011-10-28 10:37:07 +00:00
|
|
|
} else if (_ladderStatus == 3) {
|
|
|
|
_ladderStatus = 2;
|
|
|
|
_acceptInput = true;
|
2011-10-27 11:33:12 +00:00
|
|
|
startAnimationByHash(0x122D1505, 0x01084280, 0);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmClimbLadderUpDown);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2011-10-28 10:37:07 +00:00
|
|
|
} else if (_ladderStatus == 1) {
|
|
|
|
_ladderStatus = 2;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x122D1505, 29 - _currFrameIndex, -1);
|
2013-07-14 17:01:47 +00:00
|
|
|
}
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stClimbLadderHalf() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 2;
|
2011-10-28 10:37:07 +00:00
|
|
|
if (_ladderStatus == 1) {
|
|
|
|
_ladderStatus = 0;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimationByHash(0x3A292504, 0x02421405, 0);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmClimbLadderHalf);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2011-10-28 10:37:07 +00:00
|
|
|
} else if (_ladderStatus == 2) {
|
|
|
|
_ladderStatus = 0;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimationByHash(0x122D1505, 0x02421405, 0);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmClimbLadderHalf);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2011-07-13 18:38:40 +00:00
|
|
|
} else {
|
2011-10-28 10:37:07 +00:00
|
|
|
gotoNextStateExt();
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmClimbLadderHalf(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2011-07-13 18:38:40 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x489B025C) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x52C4C2D7);
|
2011-07-13 18:38:40 +00:00
|
|
|
} else if (param.asInteger() == 0x400A0E64) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x50E081D9);
|
2011-07-13 18:38:40 +00:00
|
|
|
} else if (param.asInteger() == 0x32180101) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x405002D8);
|
2011-07-13 18:38:40 +00:00
|
|
|
} else if (param.asInteger() == 0x0A2A9098) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x0460E2FA);
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmClimbLadderUpDown(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevel(messageNum, param, sender);
|
2011-07-13 18:38:40 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x01084280) {
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
2011-07-13 18:38:40 +00:00
|
|
|
} else if (param.asInteger() == 0x489B025C) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x52C4C2D7);
|
2011-07-13 18:38:40 +00:00
|
|
|
} else if (param.asInteger() == 0x400A0E64) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x50E081D9);
|
2011-07-13 18:38:40 +00:00
|
|
|
} else if (param.asInteger() == 0x02421405) {
|
2011-10-28 10:37:07 +00:00
|
|
|
if (_ladderStatus == 1) {
|
2011-10-27 11:33:12 +00:00
|
|
|
startAnimationByHash(0x3A292504, 0x01084280, 0);
|
2011-10-28 10:37:07 +00:00
|
|
|
if (_destY >= _y - 30)
|
2011-09-16 12:23:26 +00:00
|
|
|
sendMessage(this, 0x1019, 0);
|
2011-07-13 18:38:40 +00:00
|
|
|
} else {
|
2011-10-28 10:37:07 +00:00
|
|
|
startAnimationByHash(0x122D1505, 0x01084280, 0);
|
|
|
|
if (_destY <= _y)
|
2011-09-16 12:23:26 +00:00
|
|
|
sendMessage(this, 0x1019, 0);
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stStartClimbLadderUp() {
|
|
|
|
if (!stStartAction(AnimationCallback(&Klaymen::stStartClimbLadderUp))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2011-10-28 10:37:07 +00:00
|
|
|
if (_destY >= _y - 30) {
|
|
|
|
gotoNextStateExt();
|
|
|
|
} else if (_ladderStatus == 0) {
|
|
|
|
_ladderStatus = 1;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x3A292504, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmClimbLadderUpDown);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2011-10-28 10:37:07 +00:00
|
|
|
} else if (_ladderStatus == 3) {
|
|
|
|
_ladderStatus = 1;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimationByHash(0x3A292504, 0x01084280, 0);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmClimbLadderUpDown);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2011-10-28 10:37:07 +00:00
|
|
|
} else if (_ladderStatus == 2) {
|
|
|
|
_ladderStatus = 1;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x3A292504, 29 - _currFrameIndex, -1);
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stWalkToFrontNoStep() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 2;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimationByHash(0xF229C003, 0x14884392, 0);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmWalkToFront);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmWalkToFront(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2011-07-13 18:38:40 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x80C110B5) {
|
2011-09-16 12:23:26 +00:00
|
|
|
sendMessage(_parentScene, 0x482A, 0);
|
2011-07-13 18:38:40 +00:00
|
|
|
} else if (param.asInteger() == 0x110010D1) {
|
2011-09-16 12:23:26 +00:00
|
|
|
sendMessage(_parentScene, 0x482B, 0);
|
2011-07-13 18:38:40 +00:00
|
|
|
} else if (param.asInteger() == 0x32180101) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, _soundFlag ? 0x48498E46 : 0x405002D8);
|
2011-07-13 18:38:40 +00:00
|
|
|
} else if (param.asInteger() == 0x0A2A9098) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, _soundFlag ? 0x50399F64 : 0x0460E2FA);
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stWalkToFront() {
|
|
|
|
if (!stStartAction(AnimationCallback(&Klaymen::stWalkToFront))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 2;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0xF229C003, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmWalkToFront);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stTurnToFront() {
|
|
|
|
if (!stStartAction(AnimationCallback(&Klaymen::stTurnToFront))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
2012-10-23 17:58:59 +00:00
|
|
|
startAnimationByHash(0xCA221107, 0, 0x8520108C);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmWalkToFront);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stTurnToBack() {
|
|
|
|
if (!stStartAction(AnimationCallback(&Klaymen::stTurnToBack))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 2;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0xCA221107, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmWalkToFront);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stLandOnFeet() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x18118554, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLandOnFeet);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmLandOnFeet(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2011-07-13 18:38:40 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x320AC306) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x5860C640);
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stTurnToBackToUse() {
|
|
|
|
if (!stStartAction(AnimationCallback(&Klaymen::stTurnToBackToUse))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 2;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x91540140, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmTurnToBackToUse);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2011-07-16 17:27:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmTurnToBackToUse(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2011-07-16 17:27:21 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0xC61A0119) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x402338C2);
|
2011-07-16 17:27:21 +00:00
|
|
|
} else if (param.asInteger() == 0x32180101) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x4924AAC4);
|
2011-07-16 17:27:21 +00:00
|
|
|
} else if (param.asInteger() == 0x0A2A9098) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x0A2AA8E0);
|
2011-07-16 17:27:21 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stTurnToUse() {
|
|
|
|
if (!stStartAction(AnimationCallback(&Klaymen::stTurnToUse))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 2;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x9B250AD2, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmTurnToUse);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2011-07-18 18:54:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stReturnFromUse() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 2;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x98F88391, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmTurnToUse);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2011-07-18 18:54:43 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stWalkingOpenDoor() {
|
2011-10-28 10:37:07 +00:00
|
|
|
_isWalkingOpenDoorNotified = false;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x11A8E012, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmStartWalking);
|
|
|
|
SetSpriteUpdate(&Klaymen::suWalkingOpenDoor);
|
2011-07-18 20:20:23 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::suWalkingOpenDoor() {
|
2011-10-28 10:37:07 +00:00
|
|
|
if (!_isWalkingOpenDoorNotified && ABS(_destX - _x) < 80) {
|
2011-09-16 12:23:26 +00:00
|
|
|
sendMessage(_parentScene, 0x4829, 0);
|
2011-10-28 10:37:07 +00:00
|
|
|
_isWalkingOpenDoorNotified = true;
|
2011-07-18 20:20:23 +00:00
|
|
|
}
|
|
|
|
AnimatedSprite::updateDeltaXY();
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stMoveObjectSkipTurnFaceObject() {
|
2011-10-21 09:13:49 +00:00
|
|
|
setDoDeltaX(_attachedSprite->getX() < _x ? 1 : 0);
|
2011-10-28 10:37:07 +00:00
|
|
|
_isMoveObjectRequested = false;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimationByHash(0x0C1CA072, 0x01084280, 0);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
|
|
|
SetMessageHandler(&Klaymen::hmMoveObjectTurn);
|
2011-07-26 08:38:19 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::evMoveObjectTurnDone() {
|
2011-09-16 12:23:26 +00:00
|
|
|
sendMessage(_attachedSprite, 0x4807, 0);
|
2011-07-26 08:38:19 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmMoveObjectTurn(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2011-07-26 08:38:19 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x01084280) {
|
2012-10-02 07:26:05 +00:00
|
|
|
sendMessage(_attachedSprite, 0x480B, _doDeltaX ? 1 : 0);
|
2011-07-26 08:38:19 +00:00
|
|
|
} else if (param.asInteger() == 0x02421405) {
|
2011-10-28 10:37:07 +00:00
|
|
|
if (_isMoveObjectRequested && sendMessage(_attachedSprite, 0x480C, _doDeltaX ? 1 : 0) != 0) {
|
2011-10-21 09:13:49 +00:00
|
|
|
stMoveObjectSkipTurn();
|
2011-07-26 08:38:19 +00:00
|
|
|
} else {
|
2013-01-21 11:34:50 +00:00
|
|
|
FinalizeState(&Klaymen::evMoveObjectTurnDone);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevelAnimation);
|
2011-07-26 08:38:19 +00:00
|
|
|
}
|
|
|
|
} else if (param.asInteger() == 0x32180101) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x405002D8);
|
2011-07-26 08:38:19 +00:00
|
|
|
} else if (param.asInteger() == 0x0A2A9098) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x0460E2FA);
|
2011-07-26 08:38:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x480A:
|
2011-10-28 10:37:07 +00:00
|
|
|
_isMoveObjectRequested = true;
|
2013-07-14 17:01:47 +00:00
|
|
|
return 0;
|
2011-07-26 08:38:19 +00:00
|
|
|
}
|
2012-10-02 07:26:05 +00:00
|
|
|
return hmLowLevelAnimation(messageNum, param, sender);
|
2011-07-26 08:38:19 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stMoveObjectSkipTurn() {
|
2011-10-28 10:37:07 +00:00
|
|
|
_isMoveObjectRequested = false;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimationByHash(0x0C1CA072, 0x01084280, 0);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
|
|
|
SetMessageHandler(&Klaymen::hmMoveObjectTurn);
|
2011-07-26 08:38:19 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stMoveObjectFaceObject() {
|
2011-10-21 09:13:49 +00:00
|
|
|
setDoDeltaX(_attachedSprite->getX() < _x ? 1 : 0);
|
2013-01-21 11:34:50 +00:00
|
|
|
if (!stStartAction(AnimationCallback(&Klaymen::stMoveObjectFaceObject))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 2;
|
2011-10-28 10:37:07 +00:00
|
|
|
_isMoveObjectRequested = false;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x0C1CA072, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmMoveObjectTurn);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2011-07-26 08:38:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stUseLever() {
|
|
|
|
if (!stStartAction(AnimationCallback(&Klaymen::stUseLever))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2011-10-27 11:33:12 +00:00
|
|
|
if (_isLeverDown) {
|
|
|
|
stUseLeverRelease();
|
2011-07-27 18:02:30 +00:00
|
|
|
} else {
|
2011-09-16 12:23:26 +00:00
|
|
|
sendMessage(_attachedSprite, 0x482B, 0);
|
2011-10-27 11:33:12 +00:00
|
|
|
startAnimation(0x0C303040, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
|
|
|
SetMessageHandler(&Klaymen::hmLever);
|
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
NextState(&Klaymen::stPullLeverDown);
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
2011-07-27 18:02:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-21 09:13:49 +00:00
|
|
|
// Exactly the same code as sub420DA0 which was removed
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stPullLeverDown() {
|
2011-10-27 11:33:12 +00:00
|
|
|
startAnimation(0x0D318140, 0, -1);
|
2011-09-16 12:23:26 +00:00
|
|
|
sendMessage(_attachedSprite, 0x480F, 0);
|
2013-01-21 11:34:50 +00:00
|
|
|
NextState(&Klaymen::stHoldLeverDown);
|
2011-07-27 18:02:30 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stHoldLeverDown() {
|
2011-10-27 11:33:12 +00:00
|
|
|
startAnimation(0x4464A440, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevel);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2011-10-27 11:33:12 +00:00
|
|
|
_isLeverDown = true;
|
|
|
|
_acceptInput = true;
|
2011-07-27 18:02:30 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stUseLeverRelease() {
|
2011-10-27 11:33:12 +00:00
|
|
|
startAnimation(0x09018068, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLever);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2011-09-16 12:23:26 +00:00
|
|
|
sendMessage(_attachedSprite, 0x4807, 0);
|
2013-01-21 11:34:50 +00:00
|
|
|
NextState(&Klaymen::stPullLeverDown);
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
2011-07-27 18:02:30 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stReleaseLever() {
|
2011-10-27 11:33:12 +00:00
|
|
|
if (_isLeverDown) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 2;
|
2011-10-27 11:33:12 +00:00
|
|
|
startAnimation(0x09018068, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLever);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2011-09-16 12:23:26 +00:00
|
|
|
sendMessage(_attachedSprite, 0x4807, 0);
|
2013-01-21 11:34:50 +00:00
|
|
|
NextState(&Klaymen::stLetGoOfLever);
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
_isLeverDown = false;
|
2011-07-27 18:02:30 +00:00
|
|
|
} else {
|
2011-10-28 10:37:07 +00:00
|
|
|
gotoNextStateExt();
|
2011-07-27 18:02:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stLetGoOfLever() {
|
2011-10-27 11:33:12 +00:00
|
|
|
startAnimation(0x0928C048, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
FinalizeState(&Klaymen::evLeverReleasedEvent);
|
2011-07-27 18:02:30 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::evLeverReleasedEvent() {
|
2011-09-16 12:23:26 +00:00
|
|
|
sendMessage(_attachedSprite, 0x482A, 0);
|
2011-07-27 18:02:30 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stInsertDisk() {
|
|
|
|
if (!stStartActionFromIdle(AnimationCallback(&Klaymen::stInsertDisk))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 2;
|
2012-09-22 00:55:40 +00:00
|
|
|
_tapesToInsert = 0;
|
2011-07-27 18:02:30 +00:00
|
|
|
for (uint32 i = 0; i < 20; i++) {
|
2012-10-11 15:34:11 +00:00
|
|
|
if (getSubVar(VA_HAS_TAPE, i)) {
|
|
|
|
setSubVar(VA_IS_TAPE_INSERTED, i, 1);
|
|
|
|
setSubVar(VA_HAS_TAPE, i, 0);
|
2012-09-22 00:55:40 +00:00
|
|
|
_tapesToInsert++;
|
2011-07-27 18:02:30 +00:00
|
|
|
}
|
|
|
|
}
|
2012-09-22 00:55:40 +00:00
|
|
|
if (_tapesToInsert == 0) {
|
|
|
|
GotoState(NULL);
|
2011-10-28 10:37:07 +00:00
|
|
|
gotoNextStateExt();
|
2011-07-27 18:02:30 +00:00
|
|
|
} else {
|
2011-10-27 11:33:12 +00:00
|
|
|
startAnimation(0xD8C8D100, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmInsertDisk);
|
|
|
|
SetSpriteUpdate(&Klaymen::suAction);
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
2012-09-22 00:55:40 +00:00
|
|
|
_tapesToInsert--;
|
2011-07-27 18:02:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmInsertDisk(int messageNum, const MessageParam ¶m, Entity *sender) {
|
|
|
|
uint32 messageResult = Klaymen::hmLowLevelAnimation(messageNum, param, sender);
|
2011-07-27 18:02:30 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
2012-10-01 17:21:36 +00:00
|
|
|
if (_tapesToInsert == 0 && param.asInteger() == 0x06040580) {
|
|
|
|
nextAnimationByHash(0xD8C8D100, calcHash("GoToStartLoop/Finish"), 0);
|
2012-09-22 00:55:40 +00:00
|
|
|
} else if (_tapesToInsert != 0 && param.asInteger() == calcHash("GoToStartLoop/Finish")) {
|
|
|
|
_tapesToInsert--;
|
2011-10-27 11:33:12 +00:00
|
|
|
startAnimationByHash(0xD8C8D100, 0x01084280, 0);
|
2011-07-27 18:02:30 +00:00
|
|
|
} else if (param.asInteger() == 0x062A1510) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x41688704);
|
2011-07-27 18:02:30 +00:00
|
|
|
} else if (param.asInteger() == 0x02B20220) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0xC5408620);
|
2011-07-27 18:02:30 +00:00
|
|
|
} else if (param.asInteger() == 0x0A720138) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0xD4C08010);
|
2011-07-27 18:02:30 +00:00
|
|
|
} else if (param.asInteger() == 0xB613A180) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x44051000);
|
2011-07-27 18:02:30 +00:00
|
|
|
} else if (param.asInteger() == 0x0E040501) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(1, 0xC6A129C1);
|
2011-07-27 18:02:30 +00:00
|
|
|
}
|
|
|
|
}
|
2012-10-01 17:21:36 +00:00
|
|
|
return messageResult;
|
2011-07-27 18:02:30 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::walkAlongPathPoints() {
|
2012-08-17 15:03:38 +00:00
|
|
|
if (_x <= (*_pathPoints)[0].x)
|
|
|
|
_y = (*_pathPoints)[0].y;
|
|
|
|
else if (_x >= (*_pathPoints)[_pathPoints->size() - 1].x)
|
|
|
|
_y = (*_pathPoints)[_pathPoints->size() - 1].y;
|
|
|
|
else {
|
|
|
|
int16 deltaX = _x - (*_pathPoints)[0].x, deltaXIncr = 0;
|
|
|
|
uint index = 0;
|
|
|
|
while (deltaX > 0) {
|
|
|
|
NPoint pt2 = (*_pathPoints)[index];
|
|
|
|
NPoint pt1 = index + 1 >= _pathPoints->size() ? (*_pathPoints)[0] : (*_pathPoints)[index + 1];
|
|
|
|
int16 xd = ABS(pt1.x - pt2.x);
|
|
|
|
int16 yd = ABS(pt1.y - pt2.y);
|
|
|
|
if (deltaX + deltaXIncr >= xd) {
|
|
|
|
deltaX -= xd;
|
|
|
|
deltaX += deltaXIncr;
|
|
|
|
++index;
|
|
|
|
if (index >= _pathPoints->size())
|
|
|
|
index = 0;
|
|
|
|
_y = (*_pathPoints)[index].y;
|
|
|
|
} else {
|
|
|
|
deltaXIncr += deltaX;
|
|
|
|
if (pt1.y >= pt2.y) {
|
|
|
|
_y = pt2.y + (yd * deltaXIncr) / xd;
|
|
|
|
} else {
|
|
|
|
_y = pt2.y - (yd * deltaXIncr) / xd;
|
|
|
|
}
|
|
|
|
deltaX = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-25 09:12:49 +00:00
|
|
|
void Klaymen::enterIdleAnimation(uint idleAnimation) {
|
|
|
|
switch (idleAnimation) {
|
|
|
|
case kIdlePickEar:
|
|
|
|
startIdleAnimation(0x5B20C814, AnimationCallback(&Klaymen::stIdlePickEar));
|
|
|
|
break;
|
|
|
|
case kIdleSpinHead:
|
|
|
|
startIdleAnimation(0xD122C137, AnimationCallback(&Klaymen::stIdleSpinHead));
|
|
|
|
break;
|
|
|
|
case kIdleArms:
|
|
|
|
startIdleAnimation(0x543CD054, AnimationCallback(&Klaymen::stIdleArms));
|
|
|
|
break;
|
|
|
|
case kIdleChest:
|
|
|
|
startIdleAnimation(0x40A0C034, AnimationCallback(&Klaymen::stIdleChest));
|
|
|
|
break;
|
|
|
|
case kIdleHeadOff:
|
|
|
|
startIdleAnimation(0x5120E137, AnimationCallback(&Klaymen::stIdleHeadOff));
|
|
|
|
break;
|
|
|
|
case kIdleTeleporterHands:
|
|
|
|
startIdleAnimation(0x90EF8D38, AnimationCallback(&Klaymen::stIdleTeleporterHands));
|
|
|
|
break;
|
|
|
|
case kIdleTeleporterHands2:
|
|
|
|
startIdleAnimation(0x900F0930, AnimationCallback(&Klaymen::stIdleTeleporterHands2));
|
|
|
|
break;
|
|
|
|
case kIdleWonderAbout:
|
|
|
|
stIdleWonderAbout();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stJumpToGrab() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-09-06 12:25:04 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimationByHash(0x00AB8C10, 0x01084280, 0);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetSpriteUpdate(&Klaymen::suJumpToGrab);
|
|
|
|
SetMessageHandler(&Klaymen::hmJumpToGrab);
|
2012-09-06 12:25:04 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::suJumpToGrab() {
|
2012-09-06 12:25:04 +00:00
|
|
|
updateDeltaXY();
|
|
|
|
if (_y >= _destY) {
|
|
|
|
_y = _destY;
|
2012-10-22 12:26:53 +00:00
|
|
|
updateBounds();
|
2012-09-06 12:25:04 +00:00
|
|
|
gotoNextStateExt();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmJumpToGrab(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevel(messageNum, param, sender);
|
2012-09-06 12:25:04 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x168050A0)
|
|
|
|
sendMessage(_attachedSprite, 0x4806, 0);
|
|
|
|
else if (param.asInteger() == 0x320AC306)
|
|
|
|
startAnimationByHash(0x00AB8C10, 0x01084280, 0);
|
|
|
|
else if (param.asInteger() == 0x4AB28209)
|
|
|
|
sendMessage(_attachedSprite, 0x482A, 0);
|
|
|
|
else if (param.asInteger() == 0x88001184)
|
|
|
|
sendMessage(_attachedSprite, 0x482B, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stFinishGrow() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 2;
|
2012-09-06 12:25:04 +00:00
|
|
|
_acceptInput = false;
|
2012-11-19 22:24:03 +00:00
|
|
|
startAnimation(0x38445000, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
2012-09-06 12:25:04 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetMessageHandler(&Klaymen::hmFinishGrow);
|
2012-09-06 12:25:04 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmFinishGrow(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2012-09-06 12:25:04 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x040C4C01)
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x01E11140);
|
2012-09-06 12:25:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stTurnToUseExt() {
|
|
|
|
if (!stStartAction(AnimationCallback(&Klaymen::stTurnToUseExt))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 2;
|
2012-09-06 12:25:04 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x1B3D8216, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmTurnToUse);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2012-09-06 12:25:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stJumpToGrabFall() {
|
|
|
|
if (!stStartAction(AnimationCallback(&Klaymen::stJumpToGrabFall))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-09-07 17:33:55 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x00AB8C10, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmJumpToGrab);
|
|
|
|
SetSpriteUpdate(&Klaymen::suJumpToGrab);
|
2012-09-07 17:33:55 +00:00
|
|
|
sendMessage(_attachedSprite, 0x482B, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stJumpToGrabRelease() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2012-09-10 18:15:30 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimationByHash(0x00AB8C10, 0x320AC306, 0);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmJumpToGrabRelease);
|
2012-10-04 07:08:09 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2013-01-21 11:34:50 +00:00
|
|
|
NextState(&Klaymen::stReleaseRing);
|
2012-09-10 18:15:30 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmJumpToGrabRelease(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2012-09-10 18:15:30 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x320AC306)
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x5860C640);
|
2012-09-10 18:15:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stIdleTeleporterHands() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-09-24 18:06:08 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x90EF8D38, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevelAnimation);
|
2012-09-24 18:06:08 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2013-01-21 11:34:50 +00:00
|
|
|
NextState(&Klaymen::stSitIdleTeleporterBlinkSecond);
|
2012-09-24 18:06:08 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stIdleTeleporterHands2() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-09-24 18:06:08 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x900F0930, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevelAnimation);
|
2012-09-24 18:06:08 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2013-01-21 11:34:50 +00:00
|
|
|
NextState(&Klaymen::stSitIdleTeleporterBlinkSecond);
|
2012-09-24 18:06:08 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::teleporterAppear(uint32 fileHash) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-09-28 11:03:00 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(fileHash, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmTeleporterAppearDisappear);
|
2012-09-28 11:03:00 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::teleporterDisappear(uint32 fileHash) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-09-28 11:03:00 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(fileHash, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmTeleporterAppearDisappear);
|
2012-09-28 11:03:00 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmTeleporterAppearDisappear(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2012-09-28 11:03:00 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x4E0A2C24) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x85B10BB8);
|
2012-09-28 11:03:00 +00:00
|
|
|
} else if (param.asInteger() == 0x4E6A0CA0) {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0xC5B709B0);
|
2012-09-28 11:03:00 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stStandWonderAbout() {
|
2012-09-28 11:23:05 +00:00
|
|
|
if (_x > 260)
|
|
|
|
setDoDeltaX(1);
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-09-28 11:23:05 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0xD820A114, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevel);
|
2012-09-28 11:23:05 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2012-10-04 07:38:19 +00:00
|
|
|
_newStickFrameIndex = 10;
|
2012-09-28 11:23:05 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmDrinkPotion(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2012-10-01 17:21:36 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x1008:
|
|
|
|
if (_potionFlag1) {
|
|
|
|
startAnimationByHash(0x1C388C04, 0x004A2148, 0);
|
|
|
|
messageResult = 0;
|
|
|
|
} else
|
|
|
|
_potionFlag2 = true;
|
|
|
|
break;
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x0002418E)
|
|
|
|
sendMessage(_parentScene, 0x2000, 0);
|
|
|
|
else if (param.asInteger() == 0x924090C2) {
|
|
|
|
_potionFlag1 = true;
|
|
|
|
if (_potionFlag2) {
|
|
|
|
startAnimationByHash(0x1C388C04, 0x004A2148, 0);
|
|
|
|
messageResult = 0;
|
|
|
|
}
|
|
|
|
} else if (param.asInteger() == 0x004A2148)
|
|
|
|
_potionFlag1 = false;
|
|
|
|
else if (param.asInteger() == 0x02B20220)
|
|
|
|
playSound(0, 0xC5408620);
|
|
|
|
else if (param.asInteger() == 0x0A720138)
|
|
|
|
playSound(0, 0xD4C08010);
|
|
|
|
else if (param.asInteger() == 0x03020231)
|
|
|
|
playSound(0, 0xD4C08010);
|
|
|
|
else if (param.asInteger() == 0xB613A180)
|
|
|
|
playSound(0, 0x44051000);
|
|
|
|
else if (param.asInteger() == 0x67221A03)
|
|
|
|
playSound(0, 0x44051000);
|
|
|
|
else if (param.asInteger() == 0x038A010B)
|
|
|
|
playSound(0, 0x00018040);
|
|
|
|
else if (param.asInteger() == 0x422B0280)
|
|
|
|
playSound(0, 0x166FC6E0);
|
|
|
|
else if (param.asInteger() == 0x925A0C1E)
|
|
|
|
playSound(0, 0x40E5884D);
|
|
|
|
else if (param.asInteger() == 0x000F0082)
|
|
|
|
playSound(0, 0x546CDCC1);
|
|
|
|
else if (param.asInteger() == 0x00020814)
|
|
|
|
playSound(0, 0x786CC6D0);
|
|
|
|
else if (param.asInteger() == 0x06020500)
|
|
|
|
playSound(0, 0x1069C0E1);
|
|
|
|
else if (param.asInteger() == 0x02128C00)
|
|
|
|
playSound(0, 0x5068C4C3);
|
|
|
|
else if (param.asInteger() == 0x82022030)
|
|
|
|
playSound(0, 0x5C48C0E8);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmGrow(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2012-10-01 17:21:36 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x32180101)
|
|
|
|
playSound(0, 0x405002D8);
|
|
|
|
else if (param.asInteger() == 0x0A2A9098)
|
|
|
|
playSound(0, 0x0460E2FA);
|
|
|
|
else if (param.asInteger() == 0xD00A0C0C)
|
|
|
|
playSound(3);
|
|
|
|
else if (param.asInteger() == 0x04121920)
|
|
|
|
playSound(4);
|
|
|
|
else if (param.asInteger() == 0x030B4480)
|
|
|
|
playSound(5);
|
|
|
|
else if (param.asInteger() == 0x422B0280)
|
|
|
|
playSound(6);
|
|
|
|
else if (param.asInteger() == 0x038A010B)
|
|
|
|
playSound(7);
|
|
|
|
else if (param.asInteger() == 0x67221A03)
|
|
|
|
playSound(0, 0x44051000);
|
|
|
|
else if (param.asInteger() == 0x02B20220)
|
|
|
|
playSound(0, 0xC5408620);
|
|
|
|
else if (param.asInteger() == 0x925A0C1E)
|
|
|
|
playSound(0, 0x40E5884D);
|
|
|
|
else if (param.asInteger() == 0x03020231)
|
|
|
|
playSound(0, 0xD4C08010);
|
|
|
|
else if (param.asInteger() == 0x08040840)
|
|
|
|
setDoDeltaX(2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stGrow() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-10-01 17:21:36 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x2838C010, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmGrow);
|
2012-10-01 17:21:36 +00:00
|
|
|
SetSpriteUpdate(&AnimatedSprite::updateDeltaXY);
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stDrinkPotion() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2012-10-01 17:21:36 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
_potionFlag1 = false;
|
|
|
|
_potionFlag2 = false;
|
|
|
|
startAnimation(0x1C388C04, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmDrinkPotion);
|
2012-10-01 17:21:36 +00:00
|
|
|
SetSpriteUpdate(&AnimatedSprite::updateDeltaXY);
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmInsertKey(int messageNum, const MessageParam ¶m, Entity *sender) {
|
|
|
|
uint32 messageResult = Klaymen::hmLowLevelAnimation(messageNum, param, sender);
|
2012-10-01 17:21:36 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (_keysToInsert == 0 && param.asInteger() == 0x06040580) {
|
|
|
|
nextAnimationByHash(0xDC409440, 0x46431401, 0);
|
|
|
|
} else if (_keysToInsert != 0 && param.asInteger() == 0x46431401) {
|
|
|
|
_keysToInsert--;
|
|
|
|
startAnimationByHash(0xDC409440, 0x01084280, 0);
|
|
|
|
} else if (param.asInteger() == 0x062A1510) {
|
|
|
|
playSound(0, 0x41688704);
|
|
|
|
} else if (param.asInteger() == 0x02B20220) {
|
|
|
|
playSound(0, 0xC5408620);
|
|
|
|
} else if (param.asInteger() == 0x0A720138) {
|
|
|
|
playSound(0, 0xD4C08010);
|
|
|
|
} else if (param.asInteger() == 0xB613A180) {
|
|
|
|
playSound(0, 0x44051000);
|
|
|
|
} else if (param.asInteger() == 0x0E4C8141) {
|
|
|
|
playSound(0, 0xDC4A1280);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stInsertKey() {
|
|
|
|
if (!stStartActionFromIdle(AnimationCallback(&Klaymen::stInsertKey))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 2;
|
2012-10-01 17:21:36 +00:00
|
|
|
_keysToInsert = 0;
|
|
|
|
for (uint32 i = 0; i < 3; i++) {
|
2012-10-11 15:34:11 +00:00
|
|
|
if (getSubVar(VA_HAS_KEY, i)) {
|
2012-10-01 17:21:36 +00:00
|
|
|
bool more;
|
2012-10-11 15:34:11 +00:00
|
|
|
setSubVar(VA_IS_KEY_INSERTED, i, 1);
|
|
|
|
setSubVar(VA_HAS_KEY, i, 0);
|
2012-10-01 17:21:36 +00:00
|
|
|
do {
|
|
|
|
more = false;
|
2012-10-11 15:34:11 +00:00
|
|
|
setSubVar(VA_CURR_KEY_SLOT_NUMBERS, i, _vm->_rnd->getRandomNumber(16 - 1));
|
2012-10-01 17:21:36 +00:00
|
|
|
for (uint j = 0; j < i && !more; j++) {
|
2012-10-11 15:34:11 +00:00
|
|
|
if (getSubVar(VA_IS_KEY_INSERTED, j) && getSubVar(VA_CURR_KEY_SLOT_NUMBERS, j) == getSubVar(VA_CURR_KEY_SLOT_NUMBERS, i))
|
2012-10-01 17:21:36 +00:00
|
|
|
more = true;
|
|
|
|
}
|
2012-10-11 15:34:11 +00:00
|
|
|
if (getSubVar(VA_CURR_KEY_SLOT_NUMBERS, i) == getSubVar(VA_GOOD_KEY_SLOT_NUMBERS, i))
|
2012-10-01 17:21:36 +00:00
|
|
|
more = true;
|
|
|
|
} while (more);
|
|
|
|
_keysToInsert++;
|
2013-07-14 17:01:47 +00:00
|
|
|
}
|
2012-10-01 17:21:36 +00:00
|
|
|
}
|
|
|
|
if (_keysToInsert == 0) {
|
|
|
|
GotoState(NULL);
|
|
|
|
gotoNextStateExt();
|
|
|
|
} else {
|
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0xDC409440, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmInsertKey);
|
|
|
|
SetSpriteUpdate(&Klaymen::suAction);
|
2012-10-01 17:21:36 +00:00
|
|
|
_keysToInsert--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmPeekWallReturn(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
uint32 messageResult = hmLowLevelAnimation(messageNum, param, sender);
|
2012-10-01 18:08:08 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == calcHash("PopBalloon")) {
|
|
|
|
sendMessage(_parentScene, 0x2000, 0);
|
|
|
|
} else if (param.asInteger() == 0x02B20220) {
|
|
|
|
playSound(0, 0xC5408620);
|
|
|
|
} else if (param.asInteger() == 0x0A720138) {
|
|
|
|
playSound(0, 0xD4C08010);
|
|
|
|
} else if (param.asInteger() == 0xB613A180) {
|
|
|
|
playSound(0, 0x44051000);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return messageResult;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::upPeekWallBlink() {
|
|
|
|
Klaymen::update();
|
2012-10-01 18:08:08 +00:00
|
|
|
_blinkCounter++;
|
|
|
|
if (_blinkCounter >= _blinkCounterMax)
|
|
|
|
stPeekWallBlink();
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stPeekWall1() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-10-01 18:08:08 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0xAC20C012, 8, 37);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevelAnimation);
|
2012-10-04 07:38:19 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2013-01-21 11:34:50 +00:00
|
|
|
NextState(&Klaymen::stPeekWallBlink);
|
2012-10-01 18:08:08 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stPeekWall2() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2012-10-01 18:08:08 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0xAC20C012, 43, 49);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
2012-10-01 18:08:08 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetMessageHandler(&Klaymen::hmLowLevelAnimation);
|
2012-10-01 18:08:08 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stPeekWallBlink() {
|
2012-10-01 18:08:08 +00:00
|
|
|
_blinkCounter = 0;
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-10-01 18:08:08 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
_blinkCounterMax = _vm->_rnd->getRandomNumber(64) + 24;
|
|
|
|
startAnimation(0xAC20C012, 38, 42);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::upPeekWallBlink);
|
2012-10-01 18:08:08 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetMessageHandler(&Klaymen::hmLowLevel);
|
2012-10-01 18:08:08 +00:00
|
|
|
_newStickFrameIndex = 42;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stPeekWallReturn() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-10-01 18:08:08 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x2426932E, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmPeekWallReturn);
|
2012-10-04 07:38:19 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2012-10-01 18:08:08 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::upSpitOutFall() {
|
|
|
|
Klaymen::update();
|
2013-01-25 13:47:06 +00:00
|
|
|
if (_spitOutCountdown != 0 && (--_spitOutCountdown == 0)) {
|
2011-07-13 18:38:40 +00:00
|
|
|
_surface->setVisible(true);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmStandIdleSpecial(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2011-07-13 18:38:40 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x4811:
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x5252A0E4);
|
2011-07-13 18:38:40 +00:00
|
|
|
setDoDeltaX(((Sprite*)sender)->isDoDeltaX() ? 1 : 0);
|
|
|
|
if (_doDeltaX) {
|
|
|
|
_x = ((Sprite*)sender)->getX() - 75;
|
|
|
|
} else {
|
|
|
|
_x = ((Sprite*)sender)->getX() + 75;
|
|
|
|
}
|
|
|
|
_y = ((Sprite*)sender)->getY() - 200;
|
|
|
|
if (param.asInteger() == 0) {
|
2012-09-27 17:56:17 +00:00
|
|
|
stSpitOutFall0();
|
2011-07-13 18:38:40 +00:00
|
|
|
} else if (param.asInteger() == 1) {
|
2012-09-27 17:56:17 +00:00
|
|
|
// NOTE This is never used and the code was removed
|
|
|
|
// Also the animations used here in the original don't exist...
|
2011-07-13 18:38:40 +00:00
|
|
|
} else if (param.asInteger() == 2) {
|
2012-09-27 17:56:17 +00:00
|
|
|
stSpitOutFall2();
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::suFallDown() {
|
2011-07-13 18:38:40 +00:00
|
|
|
AnimatedSprite::updateDeltaXY();
|
2013-01-10 23:17:16 +00:00
|
|
|
HitRect *hitRect = _parentScene->findHitRectAtPos(_x, _y + 10);
|
2011-07-13 18:38:40 +00:00
|
|
|
if (hitRect->type == 0x5001) {
|
|
|
|
_y = hitRect->rect.y1;
|
2012-10-22 12:26:53 +00:00
|
|
|
updateBounds();
|
2011-09-16 12:23:26 +00:00
|
|
|
sendMessage(this, 0x1019, 0);
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
2013-01-10 23:17:16 +00:00
|
|
|
_parentScene->checkCollision(this, 0xFFFF, 0x4810, 0);
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stStandIdleSpecial() {
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x56548280);
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
2011-07-13 18:38:40 +00:00
|
|
|
_surface->setVisible(false);
|
2011-10-27 11:33:12 +00:00
|
|
|
startAnimation(0x5420E254, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmStandIdleSpecial);
|
2012-10-04 07:38:19 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stSpitOutFall0() {
|
2013-01-25 13:47:06 +00:00
|
|
|
_spitOutCountdown = 1;
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x000BAB02, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::upSpitOutFall);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevel);
|
|
|
|
SetSpriteUpdate(&Klaymen::suFallDown);
|
|
|
|
NextState(&Klaymen::stFalling);
|
2012-10-01 18:08:08 +00:00
|
|
|
sendMessage(_parentScene, 0x8000, 0);
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stSpitOutFall2() {
|
2013-01-25 13:47:06 +00:00
|
|
|
_spitOutCountdown = 1;
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-10-04 07:08:09 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x9308C132, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::upSpitOutFall);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevelAnimation);
|
|
|
|
SetSpriteUpdate(&Klaymen::suFallDown);
|
|
|
|
NextState(&Klaymen::stFalling);
|
2012-10-04 07:08:09 +00:00
|
|
|
sendMessage(_parentScene, 0x8000, 0);
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stFalling() {
|
2011-09-16 12:23:26 +00:00
|
|
|
sendMessage(_parentScene, 0x1024, 1);
|
2012-10-01 17:21:36 +00:00
|
|
|
playSound(0, 0x41648271);
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2011-10-27 11:33:12 +00:00
|
|
|
_acceptInput = false;
|
2011-10-28 10:37:07 +00:00
|
|
|
_isWalking = false;
|
2011-10-27 11:33:12 +00:00
|
|
|
startAnimationByHash(0x000BAB02, 0x88003000, 0);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
2012-05-11 11:03:40 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetMessageHandler(&Klaymen::hmLowLevelAnimation);
|
|
|
|
NextState(&Klaymen::stFallTouchdown);
|
2011-09-16 12:23:26 +00:00
|
|
|
sendMessage(_parentScene, 0x2002, 0);
|
2011-07-13 18:38:40 +00:00
|
|
|
_attachedSprite = NULL;
|
2012-10-01 18:08:08 +00:00
|
|
|
sendMessage(_parentScene, 0x8001, 0);
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stFallTouchdown() {
|
2011-07-13 18:38:40 +00:00
|
|
|
setDoDeltaX(2);
|
2011-10-21 09:13:49 +00:00
|
|
|
stTryStandIdle();
|
2011-07-13 18:38:40 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::suFallSkipJump() {
|
2012-10-02 07:26:05 +00:00
|
|
|
updateDeltaXY();
|
2013-01-10 23:17:16 +00:00
|
|
|
HitRect *hitRect = _parentScene->findHitRectAtPos(_x, _y + 10);
|
2012-10-02 07:26:05 +00:00
|
|
|
if (hitRect->type == 0x5001) {
|
|
|
|
_y = hitRect->rect.y1;
|
2012-10-22 12:26:53 +00:00
|
|
|
updateBounds();
|
2012-10-02 07:26:05 +00:00
|
|
|
sendMessage(this, 0x1019, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stFallSkipJump() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 2;
|
2012-10-02 07:26:05 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimationByHash(0xB93AB151, 0x40A100F8, 0);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetSpriteUpdate(&Klaymen::suFallSkipJump);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevel);
|
|
|
|
NextState(&Klaymen::stLandOnFeet);
|
2012-10-02 07:26:05 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::upMoveObject() {
|
2012-10-02 07:26:05 +00:00
|
|
|
if (_x >= 380)
|
|
|
|
gotoNextStateExt();
|
2013-07-14 17:01:47 +00:00
|
|
|
Klaymen::update();
|
2012-10-02 07:26:05 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
uint32 Klaymen::hmMoveObject(int messageNum, const MessageParam ¶m, Entity *sender) {
|
2012-10-02 07:26:05 +00:00
|
|
|
switch (messageNum) {
|
|
|
|
case 0x100D:
|
|
|
|
if (param.asInteger() == 0x01084280) {
|
|
|
|
playSound(0, 0x405002D8);
|
|
|
|
sendMessage(_attachedSprite, 0x480B, 0);
|
|
|
|
} else if (param.asInteger() == 0x02421405) {
|
|
|
|
if (_moveObjectCountdown != 0) {
|
|
|
|
_moveObjectCountdown--;
|
|
|
|
stContinueMoveObject();
|
|
|
|
} else {
|
2013-01-21 11:34:50 +00:00
|
|
|
SetMessageHandler(&Klaymen::hmLowLevelAnimation);
|
2012-10-02 07:26:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2013-01-21 11:34:50 +00:00
|
|
|
return Klaymen::hmLowLevelAnimation(messageNum, param, sender);
|
2012-10-02 07:26:05 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stMoveObject() {
|
|
|
|
if (!stStartAction(AnimationCallback(&Klaymen::stMoveObject))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 2;
|
2012-10-02 07:26:05 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
_moveObjectCountdown = 8;
|
|
|
|
setDoDeltaX(0);
|
|
|
|
startAnimation(0x0C1CA072, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::upMoveObject);
|
|
|
|
SetMessageHandler(&Klaymen::hmMoveObject);
|
2012-10-04 07:38:19 +00:00
|
|
|
SetSpriteUpdate(&AnimatedSprite::updateDeltaXY);
|
2012-10-02 07:26:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stContinueMoveObject() {
|
2012-10-02 07:26:05 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimationByHash(0x0C1CA072, 0x01084280, 0);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::upMoveObject);
|
2012-10-02 07:26:05 +00:00
|
|
|
SetSpriteUpdate(&AnimatedSprite::updateDeltaXY);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetMessageHandler(&Klaymen::hmMoveObject);
|
2012-10-02 07:26:05 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::suRidePlatform() {
|
2012-10-02 07:26:05 +00:00
|
|
|
_x = _attachedSprite->getX() - 20;
|
|
|
|
_y = _attachedSprite->getY() + 46;
|
2012-10-22 12:26:53 +00:00
|
|
|
updateBounds();
|
2012-10-02 07:26:05 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stRidePlatform() {
|
|
|
|
if (!stStartActionFromIdle(AnimationCallback(&Klaymen::stRidePlatform))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2012-10-02 07:26:05 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x5420E254, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevel);
|
|
|
|
SetSpriteUpdate(&Klaymen::suRidePlatform);
|
2012-10-02 07:26:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stInteractLever() {
|
|
|
|
if (!stStartAction(AnimationCallback(&Klaymen::stInteractLever))) {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-10-02 07:26:05 +00:00
|
|
|
if (_isLeverDown) {
|
|
|
|
stUseLeverRelease();
|
|
|
|
} else {
|
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0x0C303040, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLever);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
|
|
|
NextState(&Klaymen::stPullLever);
|
2012-10-02 07:26:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stPullLever() {
|
2012-10-02 07:26:05 +00:00
|
|
|
startAnimation(0x0D318140, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
NextState(&Klaymen::stLookLeverDown);
|
2012-10-04 07:38:19 +00:00
|
|
|
sendMessage(_attachedSprite, 0x480F, 0);
|
2012-10-02 07:26:05 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stLookLeverDown() {
|
2012-10-04 07:38:19 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
_isLeverDown = true;
|
2012-10-02 07:26:05 +00:00
|
|
|
startAnimation(0x1564A2C0, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
|
|
|
NextState(&Klaymen::stWaitLeverDown);
|
2012-10-02 07:26:05 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stWaitLeverDown() {
|
2012-10-04 07:38:19 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
_isLeverDown = true;
|
2012-10-02 07:26:05 +00:00
|
|
|
startAnimation(0x4464A440, 0, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevel);
|
|
|
|
SetSpriteUpdate(&Klaymen::suUpdateDestX);
|
2012-10-02 07:26:05 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stStartWalkingResume() {
|
|
|
|
int16 frameIndex = getGlobalVar(V_KLAYMEN_FRAMEINDEX) + _walkResumeFrameIncr;
|
2012-10-02 07:26:05 +00:00
|
|
|
if (frameIndex < 0 || frameIndex > 13)
|
|
|
|
frameIndex = 0;
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-10-02 07:26:05 +00:00
|
|
|
_isWalking = true;
|
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0x1A249001, frameIndex, -1);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmWalking);
|
|
|
|
SetSpriteUpdate(&Klaymen::suWalkingFirst);
|
|
|
|
NextState(&Klaymen::stUpdateWalkingFirst);
|
|
|
|
FinalizeState(&Klaymen::evStartWalkingDone);
|
2012-10-02 07:26:05 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::upPeekInsideBlink() {
|
2012-10-24 13:33:00 +00:00
|
|
|
update();
|
|
|
|
++_blinkCounter;
|
|
|
|
if (_blinkCounter >= _blinkCounterMax)
|
|
|
|
stPeekInsideBlink();
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stPeekInside() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-10-24 13:33:00 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0xAC20C012, 8, 37);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevelAnimation);
|
2012-10-24 13:33:00 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
2013-01-21 11:34:50 +00:00
|
|
|
NextState(&Klaymen::stPeekInsideBlink);
|
2012-10-24 13:33:00 +00:00
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stPeekInsideReturn() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 1;
|
2012-10-24 13:33:00 +00:00
|
|
|
_acceptInput = false;
|
|
|
|
startAnimation(0xAC20C012, 43, 49);
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::update);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevelAnimation);
|
2012-10-24 13:33:00 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
|
|
|
}
|
|
|
|
|
2013-01-21 11:34:50 +00:00
|
|
|
void Klaymen::stPeekInsideBlink() {
|
2013-01-24 19:10:27 +00:00
|
|
|
_busyStatus = 0;
|
2012-10-24 13:33:00 +00:00
|
|
|
_acceptInput = true;
|
|
|
|
startAnimation(0xAC20C012, 38, 42);
|
|
|
|
_newStickFrameIndex = 42;
|
2013-01-21 11:34:50 +00:00
|
|
|
SetUpdateHandler(&Klaymen::upPeekInsideBlink);
|
|
|
|
SetMessageHandler(&Klaymen::hmLowLevel);
|
2012-10-24 13:33:00 +00:00
|
|
|
SetSpriteUpdate(NULL);
|
|
|
|
_blinkCounter = 0;
|
|
|
|
_blinkCounterMax = _vm->_rnd->getRandomNumber(64 - 1) + 24;
|
|
|
|
}
|
|
|
|
|
2011-07-07 17:26:22 +00:00
|
|
|
} // End of namespace Neverhood
|