aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2016-04-16 12:41:18 -0400
committerPaul Gilbert2016-07-10 16:11:12 -0400
commitee2a70f466057eaebfc05118374d3def81eca6f3 (patch)
treeb290870f888c9ac76c17e93597154a172de71be7 /engines
parentbc716fda4b11b69eecfc0931afd3b12ef0afb589 (diff)
downloadscummvm-rg350-ee2a70f466057eaebfc05118374d3def81eca6f3.tar.gz
scummvm-rg350-ee2a70f466057eaebfc05118374d3def81eca6f3.tar.bz2
scummvm-rg350-ee2a70f466057eaebfc05118374d3def81eca6f3.zip
TITANIC: Implemented CChicken message handlers
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/carry/chicken.cpp176
-rw-r--r--engines/titanic/carry/chicken.h15
-rw-r--r--engines/titanic/messages/messages.h2
3 files changed, 188 insertions, 5 deletions
diff --git a/engines/titanic/carry/chicken.cpp b/engines/titanic/carry/chicken.cpp
index 52f3c25cef..50fcb8f500 100644
--- a/engines/titanic/carry/chicken.cpp
+++ b/engines/titanic/carry/chicken.cpp
@@ -21,13 +21,28 @@
*/
#include "titanic/carry/chicken.h"
+#include "titanic/game/sauce_dispensor.h"
+#include "titanic/npcs/succubus.h"
+#include "titanic/pet_control/pet_control.h"
namespace Titanic {
+BEGIN_MESSAGE_MAP(CChicken, CCarry)
+ ON_MESSAGE(UseWithCharMsg)
+ ON_MESSAGE(ActMsg)
+ ON_MESSAGE(VisibleMsg)
+ ON_MESSAGE(TimerMsg)
+ ON_MESSAGE(PETGainedObjectMsg)
+ ON_MESSAGE(ParrotTriesChickenMsg)
+ ON_MESSAGE(MouseDragEndMsg)
+ ON_MESSAGE(PETObjectStateMsg)
+ ON_MESSAGE(PETLostObjectMsg)
+END_MESSAGE_MAP()
+
int CChicken::_v1;
CChicken::CChicken() : CCarry(), _string6("None"),
- _field12C(1), _field13C(0), _field140(0) {
+ _field12C(1), _field13C(0), _timerId(0) {
}
void CChicken::save(SimpleFile *file, int indent) const {
@@ -36,7 +51,7 @@ void CChicken::save(SimpleFile *file, int indent) const {
file->writeQuotedLine(_string6, indent);
file->writeNumberLine(_v1, indent);
file->writeNumberLine(_field13C, indent);
- file->writeNumberLine(_field140, indent);
+ file->writeNumberLine(_timerId, indent);
CCarry::save(file, indent);
}
@@ -47,9 +62,164 @@ void CChicken::load(SimpleFile *file) {
_string6 = file->readString();
_v1 = file->readNumber();
_field13C = file->readNumber();
- _field140 = file->readNumber();
+ _timerId = file->readNumber();
CCarry::load(file);
}
+bool CChicken::UseWithOtherMsg(CUseWithOtherMsg *msg) {
+ if (msg->_other->getName() == "Napkin") {
+ if (_field12C || _string6 == "None") {
+ CActMsg actMsg("Clean");
+ actMsg.execute(this);
+ dropOnPet();
+ } else {
+ CShowTextMsg textMsg("The chicken is already clean.");
+ textMsg.execute("PET");
+ }
+
+ dropOnPet();
+ } else {
+ CSauceDispensor *dispensor = static_cast<CSauceDispensor *>(msg->_other);
+ if (!dispensor || _string6 == "None") {
+ return CCarry::UseWithOtherMsg(msg);
+ } else {
+ setVisible(false);
+ CUse use(this);
+ use.execute(msg->_other);
+ }
+ }
+
+ return true;
+}
+
+bool CChicken::UseWithCharMsg(CUseWithCharMsg *msg) {
+ CSuccUBus *succubus = static_cast<CSuccUBus *>(msg->_character);
+ if (succubus) {
+ setPosition(Point(330, 300));
+ CSubAcceptCCarryMsg acceptMsg;
+ acceptMsg._item = this;
+ acceptMsg.execute(succubus);
+ } else {
+ dropOnPet();
+ }
+
+ return true;
+}
+
+bool CChicken::ActMsg(CActMsg *msg) {
+ if (msg->_action == "GoToPET") {
+ setVisible(true);
+ dropOnPet();
+ } else if (msg->_action == "Tomato") {
+ _string6 = "Tomato";
+ loadFrame(4);
+ _visibleFrame = 4;
+ } else if (msg->_action == "Mustard") {
+ _string6 = "Mustard";
+ loadFrame(5);
+ _visibleFrame = 5;
+ } else if (msg->_action == "Bird") {
+ _string6 = "Bird";
+ loadFrame(2);
+ _visibleFrame = 2;
+ } else if (msg->_action == "None") {
+ setVisible(false);
+ } else if (msg->_action == "Clean") {
+ _string6 = "None";
+ loadFrame(3);
+ _field12C = 0;
+ _visibleFrame = 3;
+ }
+ else if (msg->_action == "Dispense Chicken") {
+ _string6 = "None";
+ _field13C = 0;
+ _field12C = 1;
+ loadFrame(1);
+ _visibleFrame = 1;
+ _v1 = 120;
+ } else if (msg->_action == "Hot") {
+ _v1 = 120;
+ } else if (msg->_action == "Eaten") {
+ setVisible(false);
+ moveToHiddenRoom();
+ _field13C = 1;
+ }
+
+ return true;
+}
+
+bool CChicken::VisibleMsg(CVisibleMsg *msg) {
+ setVisible(msg->_visible);
+ if (msg->_visible)
+ loadFrame(_visibleFrame);
+
+ return true;
+}
+
+bool CChicken::TimerMsg(CTimerMsg *msg) {
+ CGameObject *obj = getMailManFirstObject();
+ while (obj && obj->getName() != "Chicken")
+ obj = getMailManNextObject(obj);
+
+ bool flag = false;
+ if (obj) {
+ flag = _v1;
+ } else if (_v1 > 0) {
+ --_v1;
+ flag = _v1;
+ }
+
+ if (flag) {
+ addToInventory();
+ stopTimer(_timerId);
+ }
+
+ return true;
+}
+
+bool CChicken::PETGainedObjectMsg(CPETGainedObjectMsg *msg) {
+ stopTimer(_timerId);
+ _timerId = addTimer(1000, 1000);
+ return true;
+}
+
+bool CChicken::ParrotTriesChickenMsg(CParrotTriesChickenMsg *msg) {
+ if (_v1 > 0)
+ msg->_value1 = 1;
+
+ if (_string6 == "Tomato") {
+ msg->_value2 = 1;
+ } else if (_string6 == "Mustard") {
+ msg->_value2 = 2;
+ } else if (_string6 == "Bird") {
+ msg->_value2 = 3;
+ }
+
+ return true;
+}
+
+bool CChicken::MouseDragEndMsg(CMouseDragEndMsg *msg) {
+ if (_field13C)
+ return true;
+ else
+ return CCarry::MouseDragEndMsg(msg);
+}
+
+bool CChicken::PETObjectStateMsg(CPETObjectStateMsg *msg) {
+ if (_v1 > 0)
+ msg->_value = 2;
+
+ return true;
+}
+
+bool CChicken::PETLostObjectMsg(CPETLostObjectMsg *msg) {
+ if (compareViewNameTo("ParrotLobby.Node 1.N")) {
+ CActMsg actMsg("StartChickenDrag");
+ actMsg.execute("PerchedParrot");
+ }
+
+ return true;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/carry/chicken.h b/engines/titanic/carry/chicken.h
index bbc46f8464..946c102c48 100644
--- a/engines/titanic/carry/chicken.h
+++ b/engines/titanic/carry/chicken.h
@@ -24,17 +24,30 @@
#define TITANIC_CHICKEN_H
#include "titanic/carry/carry.h"
+#include "titanic/messages/messages.h"
+#include "titanic/messages/pet_messages.h"
namespace Titanic {
class CChicken : public CCarry {
+ DECLARE_MESSAGE_MAP
+ bool UseWithOtherMsg(CUseWithOtherMsg *msg);
+ bool UseWithCharMsg(CUseWithCharMsg *msg);
+ bool ActMsg(CActMsg *msg);
+ bool VisibleMsg(CVisibleMsg *msg);
+ bool TimerMsg(CTimerMsg *msg);
+ bool PETGainedObjectMsg(CPETGainedObjectMsg *msg);
+ bool ParrotTriesChickenMsg(CParrotTriesChickenMsg *msg);
+ bool MouseDragEndMsg(CMouseDragEndMsg *msg);
+ bool PETObjectStateMsg(CPETObjectStateMsg *msg);
+ bool PETLostObjectMsg(CPETLostObjectMsg *msg);
private:
static int _v1;
public:
int _field12C;
CString _string6;
int _field13C;
- int _field140;
+ int _timerId;
public:
CLASSDEF
CChicken();
diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h
index 76469a85e5..649b20b779 100644
--- a/engines/titanic/messages/messages.h
+++ b/engines/titanic/messages/messages.h
@@ -362,7 +362,7 @@ MESSAGE0(CTrueTalkSelfQueueAnimSetMsg);
MESSAGE3(CTrueTalkTriggerActionMsg, int, value1, 0, int, value2, 0, int, value3, 0);
MESSAGE0(CTurnOff);
MESSAGE0(CTurnOn);
-MESSAGE1(CUse, int, value, 0);
+MESSAGE1(CUse, CCarry *, item, nullptr);
MESSAGE1(CUseWithCharMsg, CCharacter *, character, nullptr);
MESSAGE1(CUseWithOtherMsg, CGameObject *, other, 0);
MESSAGE1(CVirtualKeyCharMsg, Common::KeyState, keyState, Common::KeyState());