diff options
-rw-r--r-- | engines/titanic/messages/messages.h | 6 | ||||
-rw-r--r-- | engines/titanic/npcs/true_talk_npc.cpp | 37 | ||||
-rw-r--r-- | engines/titanic/npcs/true_talk_npc.h | 5 |
3 files changed, 39 insertions, 9 deletions
diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h index fb3169cc71..f9589ce76a 100644 --- a/engines/titanic/messages/messages.h +++ b/engines/titanic/messages/messages.h @@ -269,9 +269,9 @@ MESSAGE2(CMovieFrameMsg, int, value1, 0, int, value2, 0); MESSAGE0(CMusicHasStartedMsg); MESSAGE0(CMusicHasStoppedMsg); MESSAGE0(CMusicSettingChangedMsg); -MESSAGE2(CNPCPlayAnimationMsg, int, value1, 0, int, value2, 0); -MESSAGE1(CNPCPlayIdleAnimationMsg, int, value, 0); -MESSAGE3(CNPCPlayTalkingAnimationMsg, int, value1, 0, int, value2, 0, int, value3, 0); +MESSAGE2(CNPCPlayAnimationMsg, void *, data, 0, int, value2, 0); +MESSAGE1(CNPCPlayIdleAnimationMsg, void *, value, 0); +MESSAGE3(CNPCPlayTalkingAnimationMsg, int, value1, 0, int, value2, 0, void *, value3, nullptr); MESSAGE0(CNPCQueueIdleAnimMsg); MESSAGE1(CNutPuzzleMsg, CString, value, ""); MESSAGE1(COnSummonBotMsg, int, value, 0); diff --git a/engines/titanic/npcs/true_talk_npc.cpp b/engines/titanic/npcs/true_talk_npc.cpp index 72b3cf2537..183c189f8a 100644 --- a/engines/titanic/npcs/true_talk_npc.cpp +++ b/engines/titanic/npcs/true_talk_npc.cpp @@ -160,18 +160,35 @@ bool CTrueTalkNPC::MovieEndMsg(CMovieEndMsg *msg) { } bool CTrueTalkNPC::NPCQueueIdleAnimMsg(CNPCQueueIdleAnimMsg *msg) { - // TODO - return false; + int rndVal = g_vm->getRandomNumber(_fieldF8 - 1) - (_fieldF8 / 2); + _speechTimerId = startAnimTimer("NPCIdleAnim", _fieldF4 + rndVal, 0); + + return true; } bool CTrueTalkNPC::TimerMsg(CTimerMsg *msg) { - // TODO - return false; + if (_npcFlags & NPCFLAG_4) { + if (_field100 > 0) + return false; + + CNPCPlayIdleAnimationMsg idleMsg; + if (idleMsg.execute(this)) { + if (idleMsg._value) { + CNPCPlayAnimationMsg animMsg(idleMsg._value, 0); + animMsg.execute(this); + } + + _npcFlags &= ~NPCFLAG_2; + } + } + + _speechTimerId = 0; + return true; } bool CTrueTalkNPC::NPCPlayAnimationMsg(CNPCPlayAnimationMsg *msg) { - // TODO - return false; + warning("CTrueTalkNPC::NPCPlayAnimationMsg"); + return true; } void CTrueTalkNPC::processInput(CTextInputMsg *msg, CViewItem *view) { @@ -182,4 +199,12 @@ void CTrueTalkNPC::performAction(int val1, int val2) { // TODO } +int CTrueTalkNPC::startAnimTimer(const CString &action, uint firstDuration, uint duration) { + CTimeEventInfo *timer = new CTimeEventInfo(g_vm->_events->getTicksCount(), + duration > 0, firstDuration, duration, this, 0, action); + getGameManager()->addTimer(timer); + + return timer->_id; +} + } // End of namespace Titanic diff --git a/engines/titanic/npcs/true_talk_npc.h b/engines/titanic/npcs/true_talk_npc.h index 74bf044a57..ad436a5582 100644 --- a/engines/titanic/npcs/true_talk_npc.h +++ b/engines/titanic/npcs/true_talk_npc.h @@ -60,6 +60,11 @@ protected: protected: void processInput(CTextInputMsg *msg, CViewItem *view); void performAction(int val1, int val2); + + /** + * Start an animation timer + */ + int startAnimTimer(const CString &action, uint firstDuration, uint duration); public: CLASSDEF CTrueTalkNPC(); |