Skip to content

Commit

Permalink
TITANIC: Renamings for MaitreDScript
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Aug 22, 2017
1 parent 3596fa9 commit 3e3e0e9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
52 changes: 26 additions & 26 deletions engines/titanic/true_talk/maitred_script.cpp
Expand Up @@ -78,7 +78,7 @@ int MaitreDScript::process(const TTroomScript *roomScript, const TTsentence *sen
setState(0);

if (getValue(12) == 0) {
trigger12(false);
stopFighting(false);
_answerCtr = 0;

if (sentence->contains("restaurant at the end of the universe")
Expand Down Expand Up @@ -113,13 +113,13 @@ int MaitreDScript::process(const TTroomScript *roomScript, const TTsentence *sen
|| sentence->contains("i give up") || sentence->contains("i give in")
|| sentence->contains("i surrender") || sentence->contains("i submit")) {
_answerCtr = 0;
trigger12(false);
stopFighting(false);
addResponse(getDialogueId(260063));
} else if (sentence->localWord("not") && sentence->localWord("fight") &&
(sentence->localWord("feel") || sentence->localWord("want")
|| sentence->localWord("do") || sentence->localWord("will"))) {
_answerCtr = 0;
trigger12(false);
stopFighting(false);
addResponse(getDialogueId(260678));
} else if (sentence->contains("touche") || sentence->contains("toushe")) {
addResponse(getDialogueId(260098));
Expand Down Expand Up @@ -165,7 +165,7 @@ ScriptChangedResult MaitreDScript::scriptChanged(const TTroomScript *roomScript,
case 110:
addResponse(getDialogueId(260118));
applyResponse();
trigger12(true);
stopFighting(true);
CTrueTalkManager::setFlags(8, 1);
CTrueTalkManager::setFlags(9, 1);
break;
Expand Down Expand Up @@ -207,7 +207,7 @@ ScriptChangedResult MaitreDScript::scriptChanged(const TTroomScript *roomScript,
case 117:
CTrueTalkManager::setFlags(8, 0);
CTrueTalkManager::setFlags(9, 0);
setFlags12();
startFighting();
break;

case 132:
Expand Down Expand Up @@ -291,7 +291,7 @@ ScriptChangedResult MaitreDScript::scriptChanged(const TTroomScript *roomScript,
break;

case 13:
setFlags12();
startFighting();
addResponse(getDialogueId(260131));
applyResponse();
break;
Expand Down Expand Up @@ -533,7 +533,7 @@ int MaitreDScript::updateState(uint oldId, uint newId, int index) {

if (newId == 260076 || newId == 260181 || newId == 261010) {
CTrueTalkManager::setFlags(14, 1);
trigger12(true);
stopFighting(true);
setFlags10(newId, index);
return newId;
}
Expand All @@ -547,7 +547,7 @@ int MaitreDScript::updateState(uint oldId, uint newId, int index) {

for (uint idx = 0; FLAG_IDS[idx]; ++idx) {
if (FLAG_IDS[idx] == newId) {
setFlags12();
startFighting();
break;
}
}
Expand Down Expand Up @@ -634,12 +634,11 @@ uint MaitreDScript::getStateDialogueId(uint oldId, uint newId) {
}
}


void MaitreDScript::setFlags12() {
int val = getValue(12);
void MaitreDScript::startFighting() {
bool isFighting = getValue(12);
CTrueTalkManager::setFlags(12, 1);

if (!val) {
if (!isFighting) {
CTrueTalkManager::triggerAction(8, 0);
resetRange(260121);
resetRange(260122);
Expand All @@ -650,6 +649,16 @@ void MaitreDScript::setFlags12() {
}
}

void MaitreDScript::stopFighting(bool flag) {
bool isFighting = getValue(12);
CTrueTalkManager::setFlags(12, 0);

if (isFighting) {
// Surrender
CTrueTalkManager::triggerAction(flag ? 10 : 9, 0);
}
}

void MaitreDScript::setFlags10(uint newId, uint index) {
int val = 28;
for (uint idx = 0; idx < _states.size(); ++idx) {
Expand All @@ -663,15 +672,6 @@ void MaitreDScript::setFlags10(uint newId, uint index) {
CTrueTalkManager::setFlags(10, val);
}

void MaitreDScript::trigger12(bool flag) {
int val = getValue(12);
CTrueTalkManager::setFlags(12, 0);

if (val) {
CTrueTalkManager::triggerAction(flag ? 10 : 9, 0);
}
}

int MaitreDScript::preprocess(const TTroomScript *roomScript, const TTsentence *sentence) {
if (!roomScript || !sentence || getValue(8))
return 1;
Expand Down Expand Up @@ -739,18 +739,18 @@ int MaitreDScript::preprocess(const TTroomScript *roomScript, const TTsentence *

case 8:
if (sentence->_category == 11 || sentence->_category == 13) {
trigger12(false);
stopFighting(false);
addResponse(getDialogueId(260094));
CTrueTalkManager::setFlags(11, 1);
} else {
setFlags12();
startFighting();
addResponse(getDialogueId(260131));
}
applyFlag = true;
break;

case 9:
setFlags12();
startFighting();
break;

case 11:
Expand Down Expand Up @@ -835,7 +835,7 @@ int MaitreDScript::preprocess(const TTroomScript *roomScript, const TTsentence *
applyFlag = true;
stateFlag = false;
} else {
setFlags12();
startFighting();
addResponse(getDialogueId(260221));
applyFlag = true;
stateFlag = false;
Expand Down Expand Up @@ -1026,7 +1026,7 @@ int MaitreDScript::preprocess(const TTroomScript *roomScript, const TTsentence *

case 29:
if (sentence->_category == 11) {
setFlags12();
startFighting();
addResponse(getDialogueId(260131));
} else {
addResponse(getDialogueId(260966));
Expand Down
14 changes: 7 additions & 7 deletions engines/titanic/true_talk/maitred_script.h
Expand Up @@ -44,20 +44,20 @@ class MaitreDScript : public TTnpcScript {
uint getStateDialogueId(uint oldId, uint newId);

/**
* Sets flags 12 and resets some ranges
* Starts the MaitreD fighting, if he isn't already
*/
void setFlags12();
void startFighting();

/**
* Sets flags 10 to different values based on the passed
* dialogue Id
* Stops the MaitreD fighting
*/
void setFlags10(uint newId, uint index);
void stopFighting(bool flag);

/**
* Trigers 12
* Sets flags 10 to different values based on the passed
* dialogue Id
*/
void trigger12(bool flag);
void setFlags10(uint newId, uint index);

/**
* Does preprocessing for the sentence
Expand Down

0 comments on commit 3e3e0e9

Please sign in to comment.