aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/titanic/carry/carry_parrot.cpp116
-rw-r--r--engines/titanic/carry/carry_parrot.h4
-rw-r--r--engines/titanic/core/game_object.cpp52
-rw-r--r--engines/titanic/core/game_object.h27
-rw-r--r--engines/titanic/core/movie_clip.cpp12
-rw-r--r--engines/titanic/core/movie_clip.h4
-rw-r--r--engines/titanic/game_manager.h5
-rw-r--r--engines/titanic/pet_control/pet_control.cpp39
-rw-r--r--engines/titanic/pet_control/pet_control.h18
-rw-r--r--engines/titanic/pet_control/pet_inventory.cpp4
-rw-r--r--engines/titanic/pet_control/pet_inventory.h5
-rw-r--r--engines/titanic/true_talk/true_talk_manager.cpp5
-rw-r--r--engines/titanic/true_talk/true_talk_manager.h3
13 files changed, 252 insertions, 42 deletions
diff --git a/engines/titanic/carry/carry_parrot.cpp b/engines/titanic/carry/carry_parrot.cpp
index 1081980121..4b2b637fa1 100644
--- a/engines/titanic/carry/carry_parrot.cpp
+++ b/engines/titanic/carry/carry_parrot.cpp
@@ -21,8 +21,12 @@
*/
#include "titanic/carry/carry_parrot.h"
+#include "titanic/core/project_item.h"
+#include "titanic/core/room_item.h"
#include "titanic/game/cage.h"
#include "titanic/npcs/parrot.h"
+#include "titanic/npcs/succubus.h"
+#include "titanic/pet_control/pet_control.h"
namespace Titanic {
@@ -39,14 +43,14 @@ BEGIN_MESSAGE_MAP(CCarryParrot, CCarry)
END_MESSAGE_MAP()
CCarryParrot::CCarryParrot() : CCarry(), _string6("PerchedParrot"),
- _field138(0), _field13C(0), _field140(0), _field144(10),
+ _timerId(0), _field13C(0), _field140(false), _field144(10),
_field148(25), _field14C(0), _field150(8) {
}
void CCarryParrot::save(SimpleFile *file, int indent) const {
file->writeNumberLine(1, indent);
file->writeQuotedLine(_string6, indent);
- file->writeNumberLine(_field138, indent);
+ file->writeNumberLine(_timerId, indent);
file->writeNumberLine(_field13C, indent);
file->writeNumberLine(_field140, indent);
@@ -56,7 +60,7 @@ void CCarryParrot::save(SimpleFile *file, int indent) const {
void CCarryParrot::load(SimpleFile *file) {
file->readNumber();
_string6 = file->readString();
- _field138 = file->readNumber();
+ _timerId = file->readNumber();
_field13C = file->readNumber();
_field140 = file->readNumber();
@@ -109,34 +113,124 @@ bool CCarryParrot::MouseDragEndMsg(CMouseDragEndMsg *msg) {
if (msg->_mousePos.x >= 75 && msg->_mousePos.x <= 565 &&
!CParrot::_v2 && !CCage::_v2) {
setVisible(false);
- // TODO
+ _fieldE0 = 0;
+ CTreeItem *perchedParrot = findUnder(getRoot(), "PerchedParrot");
+ detach();
+ addUnder(perchedParrot);
+ sound8(true);
+
+ CPutParrotBackMsg backMsg(msg->_mousePos.x);
+ backMsg.execute(perchedParrot);
} else {
- // TODO
+ setVisible(false);
+ _fieldE0 = 0;
+ CParrot::_v4 = 2;
+ playSound("z#475.wav", 100, 0, 0);
+ sound8(true);
+ moveUnder(findRoom());
+
+ CActMsg actMsg("Shut");
+ actMsg.execute("ParrotCage");
}
} else {
- // TODO
+ CCharacter *character = static_cast<CCharacter *>(msg->_dropTarget);
+ if (character) {
+ CUseWithCharMsg charMsg(character);
+ charMsg.execute(this, nullptr, 0);
+ } else {
+ setVisible(false);
+ _fieldE0 = 0;
+ playSound("z#475.wav", 100, 0, 0);
+ sound8(true);
+ moveUnder(findRoom());
+ }
}
return true;
}
bool CCarryParrot::PassOnDragStartMsg(CPassOnDragStartMsg *msg) {
- // TODO
+ if (CParrot::_v4 != 3) {
+ moveToView();
+ setPosition(Point(0, 0));
+ setVisible(true);
+ playClip("Pick Up", 2);
+ playClip("Flapping", 1);
+
+ stopTimer(_timerId);
+ _timerId = addTimer(1000, 1000);
+
+ _field13C = 0;
+ CParrot::_v4 = 1;
+ msg->_value3 = 1;
+
+ return CCarry::PassOnDragStartMsg(msg);
+ }
+
+ CTreeItem *treeItem = getRoot()->findByName(_string6);
+ if (treeItem)
+ trueTalkFn1(treeItem, 0x446BF, 0);
+
+ _fieldE0 = 0;
+ playSound("z#475.wav", 100, 0, 0);
+ moveUnder(findRoom());
+ msg->_value4 = 1;
+
return true;
}
bool CCarryParrot::PreEnterViewMsg(CPreEnterViewMsg *msg) {
- // TODO
+ loadSurface();
+ CCarryParrot *parrot = static_cast<CCarryParrot *>(getRoot()->findByName("CarryParrot"));
+ if (parrot)
+ parrot->_fieldE0 = 0;
+
return true;
}
bool CCarryParrot::UseWithCharMsg(CUseWithCharMsg *msg) {
- // TODO
- return true;
+ CSuccUBus *succubus = static_cast<CSuccUBus *>(msg->_character);
+ if (succubus)
+ CParrot::_v4 = 3;
+
+ return CCarry::UseWithCharMsg(msg);
}
bool CCarryParrot::ActMsg(CActMsg *msg) {
- // TODO
+ if (msg->_action == "FreeParrot" && (CParrot::_v4 == 4 || CParrot::_v4 == 1)) {
+ CTreeItem *treeItem = getRoot()->findByName(_string6);
+ if (treeItem)
+ trueTalkFn1(treeItem, 0x446BF, 0);
+
+ setVisible(false);
+ _fieldE0 = 0;
+
+ if (CParrot::_v4 == 4) {
+ CActMsg actMsg("Shut");
+ actMsg.execute("ParrotCage");
+ } else {
+ playSound("z#475.wav", 100, 0, 0);
+
+ if (!_field140) {
+ CCarry *feathers = static_cast<CCarry *>(getRoot()->findByName("Feathers"));
+ if (feathers) {
+ feathers->setVisible(true);
+ feathers->dropOnPet();
+ }
+
+ _field140 = true;
+ }
+
+ getPetControl()->removeFromInventory(this);
+ getPetControl()->setC8(true);
+ moveUnder(getRoom());
+ }
+
+ CParrot::_v4 = 2;
+ stopTimer(_timerId);
+ _timerId = 0;
+ }
+
return true;
}
diff --git a/engines/titanic/carry/carry_parrot.h b/engines/titanic/carry/carry_parrot.h
index fc1bbba255..1c5cc2e890 100644
--- a/engines/titanic/carry/carry_parrot.h
+++ b/engines/titanic/carry/carry_parrot.h
@@ -43,9 +43,9 @@ class CCarryParrot : public CCarry {
bool ActMsg(CActMsg *msg);
private:
CString _string6;
- int _field138;
+ int _timerId;
int _field13C;
- int _field140;
+ bool _field140;
int _field144;
int _field148;
int _field14C;
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index 362dbfe0c8..016903b95c 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -377,6 +377,13 @@ void CGameObject::playMovie(uint startFrame, uint endFrame, int val3) {
}
}
+void CGameObject::playClip(const CString &name, uint flags) {
+ _frameNumber = -1;
+ CMovieClip *clip = _clipList1.findByName(name);
+ if (clip)
+ playMovie(clip->_startFrame, clip->_endFrame, flags);
+}
+
void CGameObject::playMovie(uint flags) {
_frameNumber = -1;
if (!_surface && !_resource.empty()) {
@@ -473,6 +480,18 @@ int CGameObject::addTimer(int endVal, uint firstDuration, uint duration) {
return timer->_id;
}
+int CGameObject::addTimer(uint firstDuration, uint duration) {
+ CTimeEventInfo *timer = new CTimeEventInfo(g_vm->_events->getTicksCount(),
+ duration != 0, firstDuration, duration, this, 0, CString());
+
+ getGameManager()->addTimer(timer);
+ return timer->_id;
+}
+
+void CGameObject::stopTimer(int id) {
+ getGameManager()->stopTimer(id);
+}
+
void CGameObject::gotoView(const CString &viewName, const CString &clipName) {
CViewItem *newView = parseView(viewName);
CGameManager *gameManager = getGameManager();
@@ -588,6 +607,20 @@ CGameObject *CGameObject::findRoomObject(const CString &name) const {
return static_cast<CGameObject *>(findRoom()->findByName(name));
}
+CGameObject *CGameObject::findUnder(CTreeItem *parent, const CString &name) {
+ if (!parent)
+ return nullptr;
+
+ for (CTreeItem *treeItem = parent->getFirstChild(); treeItem;
+ treeItem = treeItem->scan(parent)) {
+ if (!treeItem->getName().compareTo(name)) {
+ return dynamic_cast<CGameObject *>(treeItem);
+ }
+ }
+
+ return nullptr;
+}
+
Found CGameObject::find(const CString &name, CGameObject **item, int findAreas) {
CGameObject *go;
*item = nullptr;
@@ -648,4 +681,23 @@ void CGameObject::incState38() {
getGameManager()->_gameState.inc38();
}
+void CGameObject::trueTalkFn1(CTreeItem *item, int val2, int val3) {
+ CGameManager *gameManager = getGameManager();
+ if (gameManager) {
+ CTrueTalkManager *talkManager = gameManager->getTalkManager();
+ if (talkManager)
+ talkManager->fn1(item, val2, val3);
+ }
+}
+
+void CGameObject::loadSurface() {
+ if (!_surface && !_resource.empty()) {
+ loadResource(_resource);
+ _resource.clear();
+ }
+
+ if (_surface)
+ _surface->loadIfReady();
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index 653230a74f..6047203c9e 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -150,6 +150,16 @@ protected:
int addTimer(int endVal, uint firstDuration, uint duration);
/**
+ * Adds a timer
+ */
+ int addTimer(uint firstDuration, uint duration);
+
+ /**
+ * Stops a timer
+ */
+ void stopTimer(int id);
+
+ /**
* Causes the game to sleep for the specified time
*/
void sleep(uint milli);
@@ -191,6 +201,11 @@ protected:
Found find(const CString &name, CGameObject **item, int findAreas);
/**
+ * Scan the specified room for an item by name
+ */
+ static CGameObject *findUnder(CTreeItem *parent, const CString &name);
+
+ /**
* Moves the item from it's original position to be under the hidden room
*/
void moveToHiddenRoom();
@@ -199,6 +214,13 @@ protected:
* Moves the item from it's original position to be under the current view
*/
void moveToView();
+
+ void trueTalkFn1(CTreeItem *item, int val2, int val3);
+
+ /**
+ * Load the surface
+ */
+ void loadSurface();
public:
int _field60;
CursorId _cursorId;
@@ -272,6 +294,11 @@ public:
void playMovie(uint startFrame, uint endFrame, int val3);
/**
+ * Play an arbitrary clip
+ */
+ void playClip(const CString &name, uint flags);
+
+ /**
* Return the current view/node/room as a single string
*/
CString getViewFullName() const;
diff --git a/engines/titanic/core/movie_clip.cpp b/engines/titanic/core/movie_clip.cpp
index 9a787e2aa9..fdf329ac13 100644
--- a/engines/titanic/core/movie_clip.cpp
+++ b/engines/titanic/core/movie_clip.cpp
@@ -31,8 +31,8 @@ void CMovieClip::save(SimpleFile *file, int indent) const {
file->writeNumberLine(2, indent);
file->writeQuotedLine("Clip", indent);
file->writeQuotedLine(_name, indent);
- file->writeNumberLine(_field18, indent);
- file->writeNumberLine(_field1C, indent);
+ file->writeNumberLine(_startFrame, indent);
+ file->writeNumberLine(_endFrame, indent);
ListItem::save(file, indent);
}
@@ -43,8 +43,8 @@ void CMovieClip::load(SimpleFile *file) {
switch (val) {
case 1:
_name = file->readString();
- _field18 = file->readNumber();
- _field1C = file->readNumber();
+ _startFrame = file->readNumber();
+ _endFrame = file->readNumber();
_field20 = file->readNumber();
_field24 = file->readNumber();
_field28 = file->readNumber();
@@ -55,8 +55,8 @@ void CMovieClip::load(SimpleFile *file) {
case 2:
file->readString();
_name = file->readString();
- _field18 = file->readNumber();
- _field1C = file->readNumber();
+ _startFrame = file->readNumber();
+ _endFrame = file->readNumber();
break;
default:
diff --git a/engines/titanic/core/movie_clip.h b/engines/titanic/core/movie_clip.h
index 0abda9453f..7eccc47bea 100644
--- a/engines/titanic/core/movie_clip.h
+++ b/engines/titanic/core/movie_clip.h
@@ -32,8 +32,6 @@ namespace Titanic {
*/
class CMovieClip : public ListItem {
private:
- int _field18;
- int _field1C;
int _field20;
int _field24;
int _field28;
@@ -43,6 +41,8 @@ private:
CString _string3;
public:
CString _name;
+ int _startFrame;
+ int _endFrame;
public:
CLASSDEF
CMovieClip();
diff --git a/engines/titanic/game_manager.h b/engines/titanic/game_manager.h
index 6e5782fb1d..102cc40316 100644
--- a/engines/titanic/game_manager.h
+++ b/engines/titanic/game_manager.h
@@ -181,6 +181,11 @@ public:
void stopTimer(uint id) { _timers.stop(id); }
void setTimer44(uint id, uint val) { _timers.set44(id, val); }
+
+ /**
+ * Return the true talk manager
+ */
+ CTrueTalkManager *getTalkManager() { return &_trueTalkManager; }
};
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp
index a955b085cc..bb320f29f4 100644
--- a/engines/titanic/pet_control/pet_control.cpp
+++ b/engines/titanic/pet_control/pet_control.cpp
@@ -21,7 +21,9 @@
*/
#include "titanic/pet_control/pet_control.h"
+#include "titanic/carry/carry.h"
#include "titanic/core/project_item.h"
+#include "titanic/messages/pet_messages.h"
#include "titanic/game_manager.h"
#include "titanic/game_state.h"
@@ -217,24 +219,9 @@ CRoomItem *CPetControl::getHiddenRoom() {
return _hiddenRoom;
}
-CGameObject *CPetControl::findItemInRoom(CRoomItem *room,
- const CString &name) const {
- if (!room)
- return nullptr;
-
- for (CTreeItem *treeItem = room->getFirstChild(); treeItem;
- treeItem = treeItem->scan(room)) {
- if (!treeItem->getName().compareTo(name)) {
- return dynamic_cast<CGameObject *>(treeItem);
- }
- }
-
- return nullptr;
-}
-
CGameObject *CPetControl::getHiddenObject(const CString &name) {
CRoomItem *room = getHiddenRoom();
- return room ? findItemInRoom(room, name) : nullptr;
+ return room ? findUnder(room, name) : nullptr;
}
bool CPetControl::containsPt(const Common::Point &pt) const {
@@ -369,6 +356,26 @@ void CPetControl::addToInventory(CCarry *item) {
_inventory.addItem(item);
}
+void CPetControl::removeFromInventory(CCarry *item, CTreeItem *newParent,
+ bool refreshUI, bool sendMsg) {
+ if (item && newParent) {
+ item->detach();
+ item->addUnder(newParent);
+
+ if (refreshUI)
+ _inventory.itemRemoved(item);
+ if (sendMsg) {
+ CPETLostObjectMsg lostMsg;
+ lostMsg.execute(item);
+ }
+ }
+}
+
+void CPetControl::removeFromInventory(CCarry *item, bool refreshUI, bool sendMsg) {
+ CViewItem *view = getGameManager()->getView();
+ removeFromInventory(item, view, refreshUI, sendMsg);
+}
+
void CPetControl::moveToHiddenRoom(CTreeItem *item) {
CRoomItem *room = getHiddenRoom();
if (room) {
diff --git a/engines/titanic/pet_control/pet_control.h b/engines/titanic/pet_control/pet_control.h
index 88a738f2d8..27b0a2ba6f 100644
--- a/engines/titanic/pet_control/pet_control.h
+++ b/engines/titanic/pet_control/pet_control.h
@@ -83,11 +83,6 @@ private:
void loaded();
/**
- * Scan the specified room for an item by name
- */
- CGameObject *findItemInRoom(CRoomItem *room, const CString &name) const;
-
- /**
* Returns true if the draw bounds contains the specified point
*/
bool containsPt(const Common::Point &pt) const;
@@ -219,9 +214,22 @@ public:
void addToInventory(CCarry *item);
/**
+ * Remove an item from the inventory
+ */
+ void removeFromInventory(CCarry *item, CTreeItem *newParent,
+ bool refreshUI = true, bool sendMsg = true);
+
+ /**
+ * Remove an item from the inventory
+ */
+ void removeFromInventory(CCarry *item, bool refreshUI = true, bool sendMsg = true);
+
+ /**
* Moves a tree item from it's original position to be under the hidden room
*/
void moveToHiddenRoom(CTreeItem *item);
+
+ void setC8(int val) { _fieldC8 = val; }
};
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_inventory.cpp b/engines/titanic/pet_control/pet_inventory.cpp
index a073a376de..6ea844a3d7 100644
--- a/engines/titanic/pet_control/pet_inventory.cpp
+++ b/engines/titanic/pet_control/pet_inventory.cpp
@@ -106,4 +106,8 @@ void CPetInventory::addItem(CCarry *item) {
warning("TODO: CPetInventory::addItem");
}
+void CPetInventory::itemRemoved(CCarry *item) {
+ warning("TODO: CPetInventory::itemRemoved");
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_inventory.h b/engines/titanic/pet_control/pet_inventory.h
index 3700854b8e..8f40200dfa 100644
--- a/engines/titanic/pet_control/pet_inventory.h
+++ b/engines/titanic/pet_control/pet_inventory.h
@@ -95,6 +95,11 @@ public:
* Add an item to the inventory
*/
void addItem(CCarry *item);
+
+ /**
+ * Called when an item has been removed from the PET
+ */
+ void itemRemoved(CCarry *item);
};
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/true_talk_manager.cpp b/engines/titanic/true_talk/true_talk_manager.cpp
index 68818dbbef..03f8ac5b3e 100644
--- a/engines/titanic/true_talk/true_talk_manager.cpp
+++ b/engines/titanic/true_talk/true_talk_manager.cpp
@@ -21,6 +21,7 @@
*/
#include "titanic/true_talk/true_talk_manager.h"
+#include "titanic/core/tree_item.h"
#define MKTAG_BE(a3,a2,a1,a0) ((uint32)((a3) | ((a2) << 8) | ((a1) << 16) | ((a0) << 24)))
@@ -190,4 +191,8 @@ void CTrueTalkManager::update2() {
//warning("CTrueTalkManager::update2");
}
+void CTrueTalkManager::fn1(CTreeItem *item, int val2, int val3) {
+ warning("CTrueTalkManager::fn1");
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/true_talk_manager.h b/engines/titanic/true_talk/true_talk_manager.h
index 4cd892c3ba..2e366a6a35 100644
--- a/engines/titanic/true_talk/true_talk_manager.h
+++ b/engines/titanic/true_talk/true_talk_manager.h
@@ -30,6 +30,7 @@
namespace Titanic {
class CGameManager;
+class CTreeItem;
class CTrueTalkManager {
private:
@@ -110,6 +111,8 @@ public:
void update1();
void update2();
+
+ void fn1(CTreeItem *item, int val2, int val3);
};
} // End of namespace Titanic