diff options
| -rw-r--r-- | engines/titanic/true_talk/bellbot_script.cpp | 142 | ||||
| -rw-r--r-- | engines/titanic/true_talk/bellbot_script.h | 16 | ||||
| -rw-r--r-- | engines/titanic/true_talk/script_support.cpp | 17 | ||||
| -rw-r--r-- | engines/titanic/true_talk/script_support.h | 10 | ||||
| -rw-r--r-- | engines/titanic/true_talk/tt_npc_script.cpp | 2 | ||||
| -rw-r--r-- | engines/titanic/true_talk/tt_npc_script.h | 2 | 
6 files changed, 185 insertions, 4 deletions
diff --git a/engines/titanic/true_talk/bellbot_script.cpp b/engines/titanic/true_talk/bellbot_script.cpp index 573015c943..87bdb9373d 100644 --- a/engines/titanic/true_talk/bellbot_script.cpp +++ b/engines/titanic/true_talk/bellbot_script.cpp @@ -23,10 +23,14 @@  #include "common/textconsole.h"  #include "titanic/true_talk/bellbot_script.h"  #include "titanic/true_talk/true_talk_manager.h" +#include "titanic/pet_control/pet_control.h"  #include "titanic/core/node_item.h" +#include "titanic/titanic.h"  namespace Titanic { +int BellbotScript::_oldId; +  BellbotScript::BellbotScript(int val1, const char *charClass, int v2,  		const char *charName, int v3, int val2) :  		TTnpcScript(val1, charClass, v2, charName, v3, val2, -1, -1, -1, 0), @@ -183,8 +187,115 @@ int BellbotScript::handleQuote(TTroomScript *roomScript, TTsentence *sentence,  }  int BellbotScript::updateState(int oldId, int newId, int index) { -	warning("TODO"); -	return 0; +	if (!getValue(25)) { +		newId = 202043 - getValue(1) <= 2 ? 994 : 0; +		CTrueTalkManager::setFlags(25, 1); +	} + +	if (oldId == _oldId && _rangeResetCtr >= 3) { +		TTscriptRange *range = findRange(oldId); +		if (range) +			range->_priorIndex = 0; + +		_rangeResetCtr = 0; +		return getRangeValue(200370); +	} + +	if (oldId != _oldId) { +		_oldId = oldId; +		_rangeResetCtr = 0; +	} + +	if (oldId >= 201709 && oldId <= 201754) { +		addResponse(getDialogueId(201705)); +		addResponse(getDialogueId(201706)); +		newId = getRangeValue(201707); +	} + +	if (newId == 202276) +		newId = addLocation(); +	if (newId == 202275) +		newId = getStateDialogueId(); + +	if (getValue(1) >= 2) { +		if (newId == 200840 || newId == 200845 || newId == 200846 || newId == 200851) { +			if (getValue(1) == 2) { +				newId = 202047; +			} else { +				newId = getRangeValue(202848); +			} +		} +	} + +	if (getValue(1) >= 3) { +		if (newId == 200841 || newId == 200842 || newId == 200843 || +				newId == 200847 || newId == 200848 || newId == 200854) { +			newId = getRangeValue(202038); +		} +	} + +	if (newId == 200264 && getValue(1) == 1) +		newId = 200267; +	if (newId == 202231 && getValue(1) == 1) +		newId = 200848; + +	int v4 = getValue(4); +	if (newId == 200187 && v4) { +		return 200188; +	} else if (newId == 200188 && !v4) { +		return 200187; +	} else if (newId == 200014 && (v4 == 1 || v4 == 2)) { +		return 200011; +	} else if (newId == 200011 && !v4) { +		return 200014; +	} + +	if (oldId == 200612) { +		CTrueTalkManager::setFlags(25, 2); +		CTrueTalkManager::setFlags(5, 1); +	} + +	if (newId == 200423 || newId == 200424 || newId == 200425) { +		if (getValue(5)) { +			CTrueTalkManager::triggerAction(16, 0); +		} else { +			newId = 200611; +		} +	} + +	if (oldId == 200261 && getRandomNumber(10) == 1) { +		if (getValue(1) >= 3) +			newId = getRangeValue(200283); +		else if (getValue(1) == 2) +			newId = getRangeValue(200279); +	} + +	if (oldId == 200962) { +		if (getValue(1) == 2) +			return 200963; +		if (getValue(1) == 1) +			return 200964; +	} +	if (oldId == 200989 && getValue(1) <= 2) +		return 200990; + +	if (oldId == 201760) { +		CGameManager *gameManager = g_vm->_trueTalkManager->getGameManager(); +		CPetControl *pet = getPetControl(gameManager); + +		if (pet) { +			bool canSummon = pet->canSummonBot("DoorBot"); +			if (canSummon) { +				CTrueTalkManager::_v9 = 101; +				CTrueTalkManager::triggerAction(5, 0); +			} else { +				newId = 201857; +			} +		} +	} + +	setValue25(newId); +	return newId;  }  int BellbotScript::proc22(int id) const { @@ -289,4 +400,31 @@ int BellbotScript::proc36(int id) const {  	return 0;  } +int BellbotScript::addLocation() { +	addResponse(getDialogueId(202228)); +	int roomNum, floorNum, elevatorNum; +	getAssignedRoom(&roomNum, &floorNum, &elevatorNum); + +	addResponse(getDialogueId(202071 + roomNum)); +	addResponse(getDialogueId(201933 + floorNum)); +	addResponse(getDialogueId(201916 + elevatorNum)); + +	return 200858; +} + +int BellbotScript::getStateDialogueId() const { +	switch (getValue(1)) { +	case 1: +		return 201253; +	case 2: +		return 200282; +	default: +		return 201246; +	} +} + +void BellbotScript::setValue25(int id) { +	// TODO +} +  } // End of namespace Titanic diff --git a/engines/titanic/true_talk/bellbot_script.h b/engines/titanic/true_talk/bellbot_script.h index 235076832f..e3cea8bc54 100644 --- a/engines/titanic/true_talk/bellbot_script.h +++ b/engines/titanic/true_talk/bellbot_script.h @@ -29,6 +29,7 @@ namespace Titanic {  class BellbotScript : public TTnpcScript {  private: +	static int _oldId;  	int _array[150];  	int _field2D0;  	int _field2D4; @@ -39,6 +40,21 @@ private:  	 * Setup sentence data  	 */  	void setupSentences(); + +	/** +	 * Add the current location to the response +	 */ +	int addLocation(); + +	/** +	 * Get a dialogue Id based on the state +	 */ +	int getStateDialogueId() const; + +	/** +	 * Sets the state value 25 based on the passed Id +	 */ +	void setValue25(int id);  public:  	BellbotScript(int val1, const char *charClass, int v2,  		const char *charName, int v3, int val2); diff --git a/engines/titanic/true_talk/script_support.cpp b/engines/titanic/true_talk/script_support.cpp index dd20edd23d..3a7c33ead4 100644 --- a/engines/titanic/true_talk/script_support.cpp +++ b/engines/titanic/true_talk/script_support.cpp @@ -162,4 +162,21 @@ void TThandleQuoteEntries::load(const char *name) {  	delete r;  } +/*------------------------------------------------------------------------*/ + +void TTupdateStateEntries::load(const char *name) { +	Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name); + +	while (r->pos() < r->size()) { +		TTupdateStateEntry ue; +		ue._v1 = r->readUint32LE(); +		ue._v2 = r->readUint32LE(); +		ue._v3 = r->readUint32LE(); + +		push_back(ue); +	} + +	delete r; +} +  } // End of namespace Titanic diff --git a/engines/titanic/true_talk/script_support.h b/engines/titanic/true_talk/script_support.h index 625ae3fed3..915b9ebb11 100644 --- a/engines/titanic/true_talk/script_support.h +++ b/engines/titanic/true_talk/script_support.h @@ -142,6 +142,16 @@ public:  	void load(const char *name);  }; +struct TTupdateStateEntry { +	uint _v1; +	uint _v2; +	uint _v3; +}; + +class TTupdateStateEntries : public Common::Array<TTupdateStateEntry> { +public: +	void load(const char *name); +};  } // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_npc_script.cpp b/engines/titanic/true_talk/tt_npc_script.cpp index 1c133bd7c8..f21111134e 100644 --- a/engines/titanic/true_talk/tt_npc_script.cpp +++ b/engines/titanic/true_talk/tt_npc_script.cpp @@ -559,7 +559,7 @@ int TTnpcScript::getRoom54(int roomId) {  	return room ? room->_field54 : 0;  } -int TTnpcScript::getValue(int testNum) { +int TTnpcScript::getValue(int testNum) const {  	switch (testNum) {  	case 0:  		return CTrueTalkManager::_v2; diff --git a/engines/titanic/true_talk/tt_npc_script.h b/engines/titanic/true_talk/tt_npc_script.h index 1353dcdfe8..833262deb8 100644 --- a/engines/titanic/true_talk/tt_npc_script.h +++ b/engines/titanic/true_talk/tt_npc_script.h @@ -121,7 +121,7 @@ protected:  	/**  	 * Perform test on various state values  	 */ -	int getValue(int testNum); +	int getValue(int testNum) const;  	/**  	 * Gets a random number between 1 and a given max  | 
