diff options
| author | Paul Gilbert | 2016-08-22 21:52:29 -0400 |
|---|---|---|
| committer | Paul Gilbert | 2016-08-22 21:52:29 -0400 |
| commit | df3e545976f401e4be999eb1c8fa9726b9dfcb38 (patch) | |
| tree | b2142a922f5ade01d95fdc5cb197d0dae29219f0 /engines/titanic/game | |
| parent | 2822fb5811dd4764a5d5dda5f77ce8f838b604e8 (diff) | |
| download | scummvm-rg350-df3e545976f401e4be999eb1c8fa9726b9dfcb38.tar.gz scummvm-rg350-df3e545976f401e4be999eb1c8fa9726b9dfcb38.tar.bz2 scummvm-rg350-df3e545976f401e4be999eb1c8fa9726b9dfcb38.zip | |
TITANIC: Implemented more game classes
Diffstat (limited to 'engines/titanic/game')
| -rw-r--r-- | engines/titanic/game/idle_summoner.cpp | 79 | ||||
| -rw-r--r-- | engines/titanic/game/idle_summoner.h | 7 | ||||
| -rw-r--r-- | engines/titanic/game/lemon_dispensor.cpp | 78 | ||||
| -rw-r--r-- | engines/titanic/game/lemon_dispensor.h | 15 | ||||
| -rw-r--r-- | engines/titanic/game/placeholder/lemon_on_bar.cpp | 17 | ||||
| -rw-r--r-- | engines/titanic/game/placeholder/lemon_on_bar.h | 4 |
6 files changed, 179 insertions, 21 deletions
diff --git a/engines/titanic/game/idle_summoner.cpp b/engines/titanic/game/idle_summoner.cpp index 19d760a8db..5ca3209e28 100644 --- a/engines/titanic/game/idle_summoner.cpp +++ b/engines/titanic/game/idle_summoner.cpp @@ -24,10 +24,16 @@ namespace Titanic { -CIdleSummoner::CIdleSummoner() : CGameObject(), _fieldBC(0x57E40), - _fieldC0(0xEA60), _fieldC4(0x57E40), _fieldC8(0xEA60), - _fieldCC(0xEA60), _fieldD0(0xEA60), _fieldD4(0xEA60), - _fieldD8(0xEA60), _fieldDC(0xEA60) { +BEGIN_MESSAGE_MAP(CIdleSummoner, CGameObject) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(TimerMsg) + ON_MESSAGE(ActMsg) + ON_MESSAGE(LoadSuccessMsg) +END_MESSAGE_MAP() + +CIdleSummoner::CIdleSummoner() : CGameObject(), _fieldBC(360000), + _fieldC0(60000), _fieldC4(360000), _fieldC8(60000), + _fieldCC(0), _fieldD0(0), _fieldD4(0), _fieldD8(0), _ticks(0) { } void CIdleSummoner::save(SimpleFile *file, int indent) { @@ -40,7 +46,7 @@ void CIdleSummoner::save(SimpleFile *file, int indent) { file->writeNumberLine(_fieldD0, indent); file->writeNumberLine(_fieldD4, indent); file->writeNumberLine(_fieldD8, indent); - file->writeNumberLine(_fieldDC, indent); + file->writeNumberLine(_ticks, indent); CGameObject::save(file, indent); } @@ -55,9 +61,70 @@ void CIdleSummoner::load(SimpleFile *file) { _fieldD0 = file->readNumber(); _fieldD4 = file->readNumber(); _fieldD8 = file->readNumber(); - _fieldDC = file->readNumber(); + _ticks = file->readNumber(); CGameObject::load(file); } +bool CIdleSummoner::EnterViewMsg(CEnterViewMsg *msg) { + CActMsg actMsg("Enable"); + actMsg.execute(this); + return true; +} + +bool CIdleSummoner::TimerMsg(CTimerMsg *msg) { + uint nodesCtr = getNodeChangedCtr(); + if (msg->_actionVal == 1 && !petDoorOrBellbotPresent() + && nodesCtr > 0 && _fieldD8) { + if (!compareRoomNameTo("TopOfWell") && !compareRoomNameTo("EmbLobby")) + return true; + + int region = talkGetDialRegion("BellBot", 1); + uint delay = region == 1 ? 15000 : 12000; + uint enterTicks = MIN(getNodeEnterTicks(), _ticks); + + CString name; + uint ticks = getTicksCount() - enterTicks; + if (ticks > delay) { + if (region == 1 || getRandomNumber(1) == 1) { + name = "BellBot"; + } else { + name = "DoorBot"; + } + _fieldD8 = nodesCtr; + + if (getRoom()) { + CSummonBotQueryMsg queryMsg(name); + if (queryMsg.execute(this)) { + CSummonBotMsg summonMsg(name, 1); + summonMsg.execute(this); + } + } + } + } + + return true; +} + +bool CIdleSummoner::ActMsg(CActMsg *msg) { + if (msg->_action == "Enable") { + if (!_fieldD4) + _fieldD4 = addTimer(15000, 15000); + } else if (msg->_action == "Disable") { + if (_fieldD4 > 0) { + stopAnimTimer(_fieldD4); + _fieldD4 = 0; + } + } else if (msg->_action == "DoorbotDismissed" || msg->_action == "BellbotDismissed") { + _ticks = getTicksCount(); + } + + return true; +} + +bool CIdleSummoner::LoadSuccessMsg(CLoadSuccessMsg *msg) { + _ticks = getTicksCount(); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/idle_summoner.h b/engines/titanic/game/idle_summoner.h index 1d9fcdd176..0066694b68 100644 --- a/engines/titanic/game/idle_summoner.h +++ b/engines/titanic/game/idle_summoner.h @@ -28,6 +28,11 @@ namespace Titanic { class CIdleSummoner : public CGameObject { + DECLARE_MESSAGE_MAP; + bool EnterViewMsg(CEnterViewMsg *msg); + bool TimerMsg(CTimerMsg *msg); + bool ActMsg(CActMsg *msg); + bool LoadSuccessMsg(CLoadSuccessMsg *msg); public: int _fieldBC; int _fieldC0; @@ -37,7 +42,7 @@ public: int _fieldD0; int _fieldD4; int _fieldD8; - int _fieldDC; + uint _ticks; public: CIdleSummoner(); CLASSDEF; diff --git a/engines/titanic/game/lemon_dispensor.cpp b/engines/titanic/game/lemon_dispensor.cpp index 8e1674cb2d..31a04cbeca 100644 --- a/engines/titanic/game/lemon_dispensor.cpp +++ b/engines/titanic/game/lemon_dispensor.cpp @@ -24,22 +24,36 @@ namespace Titanic { -int CLemonDispensor::_v1; +BEGIN_MESSAGE_MAP(CLemonDispensor, CBackground) + ON_MESSAGE(FrameMsg) + ON_MESSAGE(ChangeSeasonMsg) + ON_MESSAGE(LeaveViewMsg) +END_MESSAGE_MAP() + +bool CLemonDispensor::_isSummer; int CLemonDispensor::_v2; int CLemonDispensor::_v3; +CGameObject *CLemonDispensor::_draggingObject; CLemonDispensor::CLemonDispensor() : CBackground(), - _fieldE0(0), _fieldE4(9), _fieldE8(15), _fieldEC(0) { + _fieldE0(0), _origPt(Point(9, 15)), _fieldEC(0) { +} + +void CLemonDispensor::init() { + _isSummer = false; + _v2 = 0; + _v3 = 0; + _draggingObject = nullptr; } void CLemonDispensor::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_v1, indent); + file->writeNumberLine(_isSummer, indent); file->writeNumberLine(_v2, indent); file->writeNumberLine(_v3, indent); file->writeNumberLine(_fieldE0, indent); - file->writeNumberLine(_fieldE4, indent); - file->writeNumberLine(_fieldE8, indent); + file->writeNumberLine(_origPt.x, indent); + file->writeNumberLine(_origPt.y, indent); file->writeNumberLine(_fieldEC, indent); CBackground::save(file, indent); @@ -47,15 +61,63 @@ void CLemonDispensor::save(SimpleFile *file, int indent) { void CLemonDispensor::load(SimpleFile *file) { file->readNumber(); - _v1 = file->readNumber(); + _isSummer = file->readNumber(); _v2 = file->readNumber(); _v3 = file->readNumber(); _fieldE0 = file->readNumber(); - _fieldE4 = file->readNumber(); - _fieldE8 = file->readNumber(); + _origPt.x = file->readNumber(); + _origPt.y = file->readNumber(); _fieldEC = file->readNumber(); CBackground::load(file); } +bool CLemonDispensor::FrameMsg(CFrameMsg *msg) { + if (_v2 || !_isSummer) + return true; + + if (!_draggingObject) { + CGameObject *obj = getDraggingObject(); + if (obj && getView() == findView()) { + if (obj->isEquals("Perch")) { + petDisplayMessage(1, "This stick is too short to reach the branches."); + return true; + } + + if (obj->isEquals("LongStick")) + _draggingObject = obj; + } + } + + if (_draggingObject) { + Point pt(_origPt.x + _draggingObject->_bounds.left, + _origPt.y + _draggingObject->_bounds.top); + bool flag = checkPoint(pt, true); + + if (_fieldEC == 0) { + if (flag && ++_v3 > 10) { + CLemonFallsFromTreeMsg lemonMsg(pt); + lemonMsg.execute("Lemon"); + _v2 = 1; + } + } else if (_fieldEC == 1 && !flag) { + _fieldEC = 0; + } + } + + return true; +} + +bool CLemonDispensor::ChangeSeasonMsg(CChangeSeasonMsg *msg) { + _isSummer = msg->_season == "Summer"; + return true; +} + +bool CLemonDispensor::LeaveViewMsg(CLeaveViewMsg *msg) { + _draggingObject = nullptr; + _v3 = 0; + _fieldEC = 0; + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/lemon_dispensor.h b/engines/titanic/game/lemon_dispensor.h index d6315ed620..933e0b6af0 100644 --- a/engines/titanic/game/lemon_dispensor.h +++ b/engines/titanic/game/lemon_dispensor.h @@ -28,20 +28,29 @@ namespace Titanic { class CLemonDispensor : public CBackground { + DECLARE_MESSAGE_MAP; + bool FrameMsg(CFrameMsg *msg); + bool ChangeSeasonMsg(CChangeSeasonMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); private: - static int _v1; + static bool _isSummer; static int _v2; static int _v3; + static CGameObject *_draggingObject; int _fieldE0; - int _fieldE4; - int _fieldE8; + Point _origPt; int _fieldEC; public: CLASSDEF; CLemonDispensor(); /** + * Initialize statics + */ + static void init(); + + /** * Save the data for the class to file */ virtual void save(SimpleFile *file, int indent); diff --git a/engines/titanic/game/placeholder/lemon_on_bar.cpp b/engines/titanic/game/placeholder/lemon_on_bar.cpp index 08d686e81a..917c751e67 100644 --- a/engines/titanic/game/placeholder/lemon_on_bar.cpp +++ b/engines/titanic/game/placeholder/lemon_on_bar.cpp @@ -24,16 +24,29 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CLemonOnBar, CPlaceHolderItem) + ON_MESSAGE(VisibleMsg) +END_MESSAGE_MAP() + void CLemonOnBar::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writePoint(_pos1, indent); + file->writePoint(_lemonPos, indent); CPlaceHolderItem::save(file, indent); } void CLemonOnBar::load(SimpleFile *file) { file->readNumber(); - _pos1 = file->readPoint(); + _lemonPos = file->readPoint(); CPlaceHolderItem::load(file); } +bool CLemonOnBar::VisibleMsg(CVisibleMsg *msg) { + setVisible(msg->_visible); + if (msg->_visible) + setPosition(_lemonPos); + else + setPosition(Point(0, 0)); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/placeholder/lemon_on_bar.h b/engines/titanic/game/placeholder/lemon_on_bar.h index 92dd54c49b..af5d5e67c8 100644 --- a/engines/titanic/game/placeholder/lemon_on_bar.h +++ b/engines/titanic/game/placeholder/lemon_on_bar.h @@ -28,8 +28,10 @@ namespace Titanic { class CLemonOnBar : public CPlaceHolderItem { + DECLARE_MESSAGE_MAP; + bool VisibleMsg(CVisibleMsg *msg); private: - Point _pos1; + Point _lemonPos; public: CLASSDEF; |
