1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #include "titanic/true_talk/parrot_script.h"
24 #include "titanic/true_talk/true_talk_manager.h"
25 #include "titanic/titanic.h"
26 #include "common/textconsole.h"
27 
28 namespace Titanic {
29 
ParrotScript(int val1,const char * charClass,int v2,const char * charName,int v3,int val2,int v4,int v5,int v6,int v7)30 ParrotScript::ParrotScript(int val1, const char *charClass, int v2,
31 		const char *charName, int v3, int val2, int v4, int v5, int v6, int v7) :
32 		TTnpcScript(val1, charClass, v2, charName, v3, val2, v4, v5, v6, v7) {
33 
34 	loadRanges("Ranges/Parrot");
35 	setupSentences();
36 }
37 
setupSentences()38 void ParrotScript::setupSentences() {
39 	_mappings.load("Mappings/Parrot", 1);
40 	_entries.load("Sentences/Parrot");
41 	_field68 = 0;
42 	_entryCount = 0;
43 }
44 
chooseResponse(const TTroomScript * roomScript,const TTsentence * sentence,uint tag)45 int ParrotScript::chooseResponse(const TTroomScript *roomScript, const TTsentence *sentence, uint tag) {
46 	if (tag == MKTAG('B', 'Y', 'Z', 'A')) {
47 		addResponse(getDialogueId(280246));
48 		applyResponse();
49 		return 2;
50 	} else {
51 		return 1;
52 	}
53 }
54 
process(const TTroomScript * roomScript,const TTsentence * sentence)55 int ParrotScript::process(const TTroomScript *roomScript, const TTsentence *sentence) {
56 	if (processEntries(roomScript, sentence) != 2) {
57 		int tagId = g_vm->_trueTalkManager->_quotes.find(sentence->_normalizedLine);
58 		if (!tagId || chooseResponse(roomScript, sentence, tagId) != 2) {
59 			addResponse(getDialogueId(sentence->checkCategory() ? 280248 : 280235));
60 			applyResponse();
61 		}
62 	}
63 
64 	return 2;
65 }
66 
scriptChanged(const TTroomScript * roomScript,uint id)67 ScriptChangedResult ParrotScript::scriptChanged(const TTroomScript *roomScript, uint id) {
68 	if (id >= 280000 && id <= 280276) {
69 		if (id == 280258) {
70 			if (CTrueTalkManager::_currentNPC) {
71 				CGameObject *chicken;
72 				if (CTrueTalkManager::_currentNPC->find("Chicken", &chicken, FIND_PET))
73 					id = 280147 - getRandomBit();
74 			}
75 
76 			id = getDialogueId(id);
77 		} else {
78 			if ((id == 280146 || id == 280147) && CTrueTalkManager::_currentNPC) {
79 				CGameObject *chicken;
80 				if (!CTrueTalkManager::_currentNPC->find("Chicken", &chicken, FIND_PET))
81 					id = 280142;
82 			}
83 
84 			addResponse(getDialogueId(id));
85 			if (id == 280192)
86 				addResponse(getDialogueId(280222));
87 			applyResponse();
88 		}
89 	}
90 
91 	if (id >= 80000 && id <= 80244) {
92 		if ((id == 80155 || id == 80156) && CTrueTalkManager::_currentNPC) {
93 			CGameObject *chicken;
94 			if (!CTrueTalkManager::_currentNPC->find("Chicken", &chicken, FIND_PET))
95 				id = 80151;
96 		}
97 
98 		addResponse(id);
99 		if (id == 80201)
100 			addResponse(getDialogueId(280222));
101 		applyResponse();
102 	}
103 
104 	return (id == 3) ? SCR_2 : SCR_1;
105 }
106 
doSentenceEntry(int val1,const int * srcIdP,const TTroomScript * roomScript,const TTsentence * sentence)107 int ParrotScript::doSentenceEntry(int val1, const int *srcIdP, const TTroomScript *roomScript, const TTsentence *sentence) {
108 	return 0;
109 }
110 
111 } // End of namespace Titanic
112