aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra/sequences_v3.cpp
blob: 16fd9910220e55f9187bb0eb0812a6e1c01b1153 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * $URL$
 * $Id$
 *
 */

#include "kyra/kyra_v3.h"

namespace Kyra {

void KyraEngine_v3::showBadConscience() {
	debugC(9, kDebugLevelMain, "KyraEngine_v3::showBadConscience()");
	if (_badConscienceShown)
		return;

	_badConscienceShown = true;
	_badConscienceAnim = _rnd.getRandomNumberRng(0, 2);
	if (_curChapter == 2)
		_badConscienceAnim = 5;
	else if (_curChapter == 3)
		_badConscienceAnim = 3;
	else if (_curChapter == 4 && _rnd.getRandomNumberRng(1, 100) <= 25)
		_badConscienceAnim = 6;
	else if (_curChapter == 5 && _rnd.getRandomNumberRng(1, 100) <= 25)
		_badConscienceAnim = 7;
	else if (_malcolmShapes == 9)
		_badConscienceAnim = 4;

	_badConsciencePosition = (_mainCharacter.x1 <= 160);

	//if (_goodConscienceShown)
	//	_badConsciencePosition = !_goodConsciencePosition;
	
	int anim = _badConscienceAnim + (_badConsciencePosition ? 0 : 8);
	TalkObject &talkObject = _talkObjectList[1];

	if (_badConsciencePosition)
		talkObject.x = 290;
	else
		talkObject.x = 30;
	talkObject.y = 30;

	static const char *animFilenames[] = {
		"GUNFL00.WSA", "GUNFL01.WSA", "GUNFL02.WSA", "GUNFL03.WSA", "GUNFL04.WSA", "GUNFL05.WSA", "GUNFL06.WSA", "GUNFL07.WSA",
		"GUNFR00.WSA", "GUNFR01.WSA", "GUNFR02.WSA", "GUNFR03.WSA", "GUNFR04.WSA", "GUNFR05.WSA", "GUNFR06.WSA", "GUNFR07.WSA"
	};

	setupSceneAnimObject(0x0E, 9, 0, 187, -1, -1, -1, -1, 0, 0, 0, -1, animFilenames[anim]);
	for (uint i = 0; i <= _badConscienceFrameTable[_badConscienceAnim]; ++i) {
		if (i == 8)
			playSoundEffect(0x1B, 0xC8);
		updateSceneAnim(0x0E, i);
		delay(3*_tickLength, true);
	}

	if (_mainCharacter.animFrame < 50 || _mainCharacter.animFrame > 87)
		return;

	if (_mainCharacter.y1 == -1 || (_mainCharacter.x1 != -1 && _mainCharacter.animFrame == 87) || _mainCharacter.animFrame == 87) {
		_mainCharacter.animFrame = 87;
	} else {
		if (_badConsciencePosition)
			_mainCharacter.facing = 3;
		else
			_mainCharacter.facing = 5;
		_mainCharacter.animFrame = _characterFrameTable[_mainCharacter.facing];
	}

	updateCharacterAnim(0);
	refreshAnimObjectsIfNeed();
}

void KyraEngine_v3::hideBadConscience() {
	debugC(9, kDebugLevelMain, "KyraEngine_v3::hideBadConscience()");
	if (!_badConscienceShown)
		return;

	_badConscienceShown = false;
	for (int frame = _badConscienceFrameTable[_badConscienceAnim+8]; frame >= 0; --frame) {
		if (frame == 15)
			playSoundEffect(0x31, 0xC8);
		updateSceneAnim(0x0E, frame);
		delay(1*_tickLength, true);
	}

	updateSceneAnim(0x0E, -1);
	update();
	removeSceneAnimObject(0x0E, 1);
	//setNextIdleAnimTimer();
}

} // end of namespace Kyra