aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2016-04-30 22:14:22 -0400
committerPaul Gilbert2016-07-10 16:37:53 -0400
commit6691dfa408b05d2cb01fb879bc1b2466bf757738 (patch)
treee6cf169f00310c4e2dbcb976dd79c4ef597568bc
parent2a107eb540d2058ee105b8a362d9288c1e463bfe (diff)
downloadscummvm-rg350-6691dfa408b05d2cb01fb879bc1b2466bf757738.tar.gz
scummvm-rg350-6691dfa408b05d2cb01fb879bc1b2466bf757738.tar.bz2
scummvm-rg350-6691dfa408b05d2cb01fb879bc1b2466bf757738.zip
TITANIC: Implement PET Conversations dial logic
-rw-r--r--engines/titanic/pet_control/pet_conversations.cpp61
-rw-r--r--engines/titanic/pet_control/pet_conversations.h19
-rw-r--r--engines/titanic/pet_control/pet_section.cpp7
-rw-r--r--engines/titanic/pet_control/pet_section.h2
-rw-r--r--engines/titanic/true_talk/tt_named_script.cpp2
-rw-r--r--engines/titanic/true_talk/tt_named_script.h7
6 files changed, 89 insertions, 9 deletions
diff --git a/engines/titanic/pet_control/pet_conversations.cpp b/engines/titanic/pet_control/pet_conversations.cpp
index bffcb6ddd2..a62de341a0 100644
--- a/engines/titanic/pet_control/pet_conversations.cpp
+++ b/engines/titanic/pet_control/pet_conversations.cpp
@@ -47,7 +47,7 @@ CPetConversations::CPetConversations() : CPetSection(),
_textInput.setColor(getColor(0));
_textInput.setup();
- _valArray3[0] = _valArray3[1] = _valArray3[2] = 0;
+ _npcLevels[0] = _npcLevels[1] = _npcLevels[2] = 0;
}
bool CPetConversations::setup(CPetControl *petControl) {
@@ -217,7 +217,7 @@ void CPetConversations::load(SimpleFile *file, int param) {
_log.load(file, param);
for (int idx = 0; idx < 3; ++idx)
- _valArray3[idx] = file->readNumber();
+ _npcLevels[idx] = file->readNumber();
}
void CPetConversations::postLoad() {
@@ -229,7 +229,7 @@ void CPetConversations::save(SimpleFile *file, int indent) const {
_log.save(file, indent);
for (int idx = 0; idx < 3; ++idx)
- file->writeNumberLine(_valArray3[idx], indent);
+ file->writeNumberLine(_npcLevels[idx], indent);
}
void CPetConversations::enter(PetArea oldArea) {
@@ -246,6 +246,19 @@ void CPetConversations::leave() {
stopNPCTimer();
}
+void CPetConversations::proc25(int val) {
+ if (val == 1) {
+ proc25(val);
+ } else {
+ CString name = _field418 ? _npcName : getActiveNPCName();
+
+ for (int idx = 0; idx < 3; ++idx) {
+ if (!_dials[idx].hasActiveMovie())
+ updateDial(idx, name);
+ }
+ }
+}
+
void CPetConversations::displayNPCName(CGameObject *npc) {
if (npc) {
displayMessage(CString());
@@ -491,4 +504,46 @@ void CPetConversations::copyColors(uint tableNum, uint colors[5]) {
Common::copy(src, src + 5, colors);
}
+void CPetConversations::updateDial(uint dialNum, const CString &npcName) {
+ TTNamedScript *script = getNPCScript(npcName);
+ uint newLevel = getDialLevel(dialNum, script);
+ npcDialChange(dialNum, _npcLevels[dialNum], newLevel);
+ _npcLevels[dialNum] = newLevel;
+}
+
+uint CPetConversations::getDialLevel(uint dialNum, TTNamedScript *script, int v) {
+ bool flag = v != 0;
+
+ if (!script)
+ return 0;
+ else
+ return MAX(script->getDialLevel(dialNum), 15);
+}
+
+void CPetConversations::npcDialChange(uint dialNum, int oldLevel, int newLevel) {
+ const uint range1[2] = { 0, 21 };
+ const uint range2[2] = { 22, 43 };
+
+ if (newLevel != oldLevel) {
+ uint src = range1[0], dest = range1[1];
+ if (oldLevel < newLevel) {
+ src = range2[0];
+ dest = range2[1];
+ }
+
+ int64 val1 = (oldLevel * dest) + (100 - oldLevel) * src;
+ val1 *= 0x51EB851F;
+ val1 >>= 37;
+ uint startFrame = val1 + (val1 >> 31);
+
+ int64 val2 = (newLevel * dest) + (100 - newLevel) * src;
+ val2 *= 0x51EB851F;
+ val2 >>= 37;
+ uint endFrame = val2 + (val2 >> 31);
+
+ if (startFrame != endFrame)
+ _dials[dialNum].playMovie(startFrame, endFrame);
+ }
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_conversations.h b/engines/titanic/pet_control/pet_conversations.h
index 57c7fbd9b2..6e8ffbee41 100644
--- a/engines/titanic/pet_control/pet_conversations.h
+++ b/engines/titanic/pet_control/pet_conversations.h
@@ -47,7 +47,7 @@ private:
int _npcNum;
CPetText _log;
CPetText _textInput;
- int _valArray3[3];
+ uint _npcLevels[3];
bool _logChanged;
int _field418;
CString _npcName;
@@ -131,6 +131,21 @@ private:
* Create a color table
*/
void copyColors(uint tableNum, uint colors[5]);
+
+ /**
+ * Updates one of the dials with data from a given NPC
+ */
+ void updateDial(uint dialNum, const CString &npcName);
+
+ /**
+ * Get a dial level
+ */
+ uint getDialLevel(uint dialNum, TTNamedScript *script, int v = 1);
+
+ /**
+ * Called when the dial for an NPC is being changed
+ */
+ void npcDialChange(uint dialNum, int oldLevel, int newLevel);
public:
CPetConversations();
virtual ~CPetConversations() {}
@@ -199,6 +214,8 @@ public:
*/
virtual void leave();
+ virtual void proc25(int val);
+
/**
* Display a title for an NPC
*/
diff --git a/engines/titanic/pet_control/pet_section.cpp b/engines/titanic/pet_control/pet_section.cpp
index 8cd9207316..7f0a0005e5 100644
--- a/engines/titanic/pet_control/pet_section.cpp
+++ b/engines/titanic/pet_control/pet_section.cpp
@@ -42,8 +42,11 @@ void CPetSection::displayMessage(const CString &msg) {
error("TODO");
}
-void CPetSection::proc25() {
- error("TODO");
+void CPetSection::proc25(int val) {
+ if (!val) {
+ proc28();
+ _petControl->makeDirty();
+ }
}
void CPetSection::proc27(int duration) {
diff --git a/engines/titanic/pet_control/pet_section.h b/engines/titanic/pet_control/pet_section.h
index 0d7ede6230..2a70b1dabb 100644
--- a/engines/titanic/pet_control/pet_section.h
+++ b/engines/titanic/pet_control/pet_section.h
@@ -142,7 +142,7 @@ public:
*/
virtual void enterRoom(CRoomItem *room) {}
- virtual void proc25();
+ virtual void proc25(int val);
/**
* Get a reference to the tooltip text associated with the section
diff --git a/engines/titanic/true_talk/tt_named_script.cpp b/engines/titanic/true_talk/tt_named_script.cpp
index 7f4bb5b201..9d253206e2 100644
--- a/engines/titanic/true_talk/tt_named_script.cpp
+++ b/engines/titanic/true_talk/tt_named_script.cpp
@@ -218,7 +218,7 @@ int TTNamedScript::proc34() {
return 0;
}
-int TTNamedScript::proc35(int v1, int v2) {
+int TTNamedScript::getDialLevel(uint dialNum, bool flag) {
warning("TODO");
return 0;
}
diff --git a/engines/titanic/true_talk/tt_named_script.h b/engines/titanic/true_talk/tt_named_script.h
index ec5c35c843..8174f64c53 100644
--- a/engines/titanic/true_talk/tt_named_script.h
+++ b/engines/titanic/true_talk/tt_named_script.h
@@ -103,7 +103,12 @@ public:
virtual void proc32();
virtual void proc33(int v1, int v2);
virtual int proc34();
- virtual int proc35(int v1, int v2);
+
+ /**
+ * Get the NPC's dial level
+ */
+ virtual int getDialLevel(uint dialNum, bool flag = true);
+
virtual int proc36() const;
virtual int proc37() const;