aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/carry/carry_parrot.cpp12
-rw-r--r--engines/titanic/core/game_object.cpp7
-rw-r--r--engines/titanic/core/game_object.h2
-rw-r--r--engines/titanic/true_talk/true_talk_manager.cpp14
-rw-r--r--engines/titanic/true_talk/true_talk_manager.h14
5 files changed, 37 insertions, 12 deletions
diff --git a/engines/titanic/carry/carry_parrot.cpp b/engines/titanic/carry/carry_parrot.cpp
index 598393bb08..6bf536ea7a 100644
--- a/engines/titanic/carry/carry_parrot.cpp
+++ b/engines/titanic/carry/carry_parrot.cpp
@@ -167,9 +167,9 @@ bool CCarryParrot::PassOnDragStartMsg(CPassOnDragStartMsg *msg) {
return CCarry::PassOnDragStartMsg(msg);
}
- CTreeItem *treeItem = getRoot()->findByName(_string6);
- if (treeItem)
- trueTalkFn1(treeItem, 0x446BF, 0);
+ CGameObject *npc = static_cast<CGameObject *>(getRoot()->findByName(_string6));
+ if (npc)
+ trueTalkFn1(npc, 0x446BF, 0);
_fieldE0 = 0;
playSound("z#475.wav", 100, 0, 0);
@@ -198,9 +198,9 @@ bool CCarryParrot::UseWithCharMsg(CUseWithCharMsg *msg) {
bool CCarryParrot::ActMsg(CActMsg *msg) {
if (msg->_action == "FreeParrot" && (CParrot::_v4 == 4 || CParrot::_v4 == 1)) {
- CTreeItem *treeItem = getRoot()->findByName(_string6);
- if (treeItem)
- trueTalkFn1(treeItem, 0x446BF, 0);
+ CGameObject *npc = static_cast<CGameObject *>(getRoot()->findByName(_string6));
+ if (npc)
+ trueTalkFn1(npc, 0x446BF, 0);
setVisible(false);
_fieldE0 = 0;
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index 3406de6902..1b76ec1960 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -699,15 +699,16 @@ void CGameObject::incState38() {
}
void CGameObject::trueTalkFn1(const CString &name, int val2, int val3) {
- trueTalkFn1(getRoot()->findByName(name), val2, val3);
+ CGameObject *npc = static_cast<CGameObject *>(getRoot()->findByName(name));
+ trueTalkFn1(npc, val2, val3);
}
-void CGameObject::trueTalkFn1(CTreeItem *item, int val2, int val3) {
+void CGameObject::trueTalkFn1(CGameObject *npc, int val2, int val3) {
CGameManager *gameManager = getGameManager();
if (gameManager) {
CTrueTalkManager *talkManager = gameManager->getTalkManager();
if (talkManager)
- talkManager->fn1(item, val2, val3);
+ talkManager->fn1(npc, val2, val3);
}
}
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index 8a56945d13..40492676b0 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -218,7 +218,7 @@ protected:
void trueTalkFn1(const CString &name, int val2, int val3);
- void trueTalkFn1(CTreeItem *item, int val2, int val3);
+ void trueTalkFn1(CGameObject *npc, int val2, int val3);
/**
* Load the surface
diff --git a/engines/titanic/true_talk/true_talk_manager.cpp b/engines/titanic/true_talk/true_talk_manager.cpp
index 827cda99ec..a07f7fa242 100644
--- a/engines/titanic/true_talk/true_talk_manager.cpp
+++ b/engines/titanic/true_talk/true_talk_manager.cpp
@@ -192,7 +192,7 @@ void CTrueTalkManager::update2() {
//warning("CTrueTalkManager::update2");
}
-void CTrueTalkManager::fn1(CTreeItem *npc, int val2, int val3) {
+void CTrueTalkManager::fn1(CGameObject *npc, int val2, int val3) {
warning("CTrueTalkManager::fn1");
}
@@ -219,4 +219,16 @@ TTNamedScript *CTrueTalkManager::getTalker(const CString &name) {
return nullptr;
}
+TTNamedScript *CTrueTalkManager::getNpcScript(CGameObject *npc) {
+ CString npcName = npc->getName();
+ TTNamedScript *script = getTalker(npcName);
+
+ if (!script) {
+ // Fall back on the default NPC script
+ script = _scripts.getNamedScript(101);
+ }
+
+ return script;
+}
+
} // 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 8d2ea65667..5d5f67958d 100644
--- a/engines/titanic/true_talk/true_talk_manager.h
+++ b/engines/titanic/true_talk/true_talk_manager.h
@@ -31,6 +31,7 @@ namespace Titanic {
class CGameManager;
class CTreeItem;
+class CGameObject;
class CTrueTalkManager {
private:
@@ -48,9 +49,20 @@ private:
*/
static void saveStatics(SimpleFile *file);
+ /**
+ * Loads an NPC from file
+ */
void loadNPC(SimpleFile *file, int charId);
+ /**
+ * Saves the specified NPC to file
+ */
void saveNPC(SimpleFile *file, int charId) const;
+
+ /**
+ * Gets the script associated with an NPC game object
+ */
+ TTNamedScript *getNpcScript(CGameObject *npc);
public:
static int _v1;
static int _v2;
@@ -112,7 +124,7 @@ public:
void update2();
- void fn1(CTreeItem *npc, int val2, int val3);
+ void fn1(CGameObject *npc, int val2, int val3);
/**
* Return a TrueTalk talker/script