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 /*
24  * This code is based on the original source code of Lord Avalot d'Argent version 1.3.
25  * Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman.
26  */
27 
28 /* Original name: TIMEOUT	The scheduling unit. */
29 
30 #ifndef AVALANCHE_TIMER_H
31 #define AVALANCHE_TIMER_H
32 
33 namespace Avalanche {
34 class AvalancheEngine;
35 
36 class Timer {
37 public:
38 	// Reason runs between 1 and 28.
39 	enum Reason {
40 		kReasonDrawbridgeFalls = 2,
41 		kReasonAvariciusTalks = 3,
42 		kReasonGoToToilet = 4,
43 		kReasonExplosion = 5,
44 		kReasonBrummieStairs = 6,
45 		kReasonCardiffsurvey = 7,
46 		kReasonCwytalotInHerts = 8,
47 		kReasonGettingTiedUp = 9,
48 		kReasonHangingAround = 10, // Tied to the tree in Nottingham.
49 		kReasonJacquesWakingUp = 11,
50 		kReasonNaughtyDuke = 12,
51 		kReasonJumping = 13,
52 		kReasonSequencer = 14,
53 		kReasonCrapulusSaysSpludwickOut = 15,
54 		kReasonDawndelay = 16,
55 		kReasonDrinks = 17,
56 		kReasonDuLustieTalks = 18,
57 		kReasonFallingDownOubliette = 19,
58 		kReasonMeetingAvaroid = 20,
59 		kReasonRisingUpOubliette = 21,
60 		kReasonRobinHoodAndGeida = 22,
61 		kReasonSittingDown = 23,
62 		kReasonGhostRoomPhew = 1,
63 		kReasonArkataShouts = 24,
64 		kReasonWinning = 25,
65 		kReasonFallingOver = 26,
66 		kReasonSpludwickWalk = 27,
67 		kReasonGeidaSings = 28
68 	};
69 
70 	// Proc runs between 1 and 41.
71 	enum Proc {
72 		kProcOpenDrawbridge = 3,
73 		kProcAvariciusTalks = 4,
74 		kProcUrinate = 5,
75 		kProcToilet = 6,
76 		kProcBang = 7,
77 		kProcBang2 = 8,
78 		kProcStairs = 9,
79 		kProcCardiffSurvey = 10,
80 		kProcCardiffReturn = 11,
81 		kProcCwytalotInHerts = 12,
82 		kProcGetTiedUp = 13,
83 		kProcGetTiedUp2 = 1,
84 		kProcHangAround = 14,
85 		kProcHangAround2 = 15,
86 		kProcAfterTheShootemup = 32,
87 		kProcJacquesWakesUp = 16,
88 		kProcNaughtyDuke = 17,
89 		kProcNaughtyDuke2 = 18,
90 		kProcNaughtyDuke3 = 38,
91 		kProcJump = 19,
92 		kProcSequence = 20,
93 		kProcCrapulusSpludOut = 21,
94 		kProcDawnDelay = 22,
95 		kProcBuyDrinks = 23,
96 		kProcBuyWine = 24,
97 		kProcCallsGuards = 25,
98 		kProcGreetsMonk = 26,
99 		kProcFallDownOubliette = 27,
100 		kProcMeetAvaroid = 28,
101 		kProcRiseUpOubliette = 29,
102 		kProcRobinHoodAndGeida = 2,
103 		kProcRobinHoodAndGeidaTalk = 30,
104 		kProcAvalotReturns = 31,
105 		kProcAvvySitDown = 33, // In Nottingham.
106 		kProcGhostRoomPhew = 34,
107 		kProcArkataShouts = 35,
108 		kProcWinning = 36,
109 		kProcAvalotFalls = 37,
110 		kProcSpludwickGoesToCauldron = 39,
111 		kProcSpludwickLeavesCauldron = 40,
112 		kProcGiveLuteToGeida = 41
113 	};
114 
115 	struct TimerType {
116 		int32 _timeLeft;
117 		byte _action;
118 		byte _reason;
119 	};
120 
121 	TimerType _times[7];
122 
123 	Timer(AvalancheEngine *vm);
124 
125 	void resetVariables();
126 	void addTimer(int32 duration, byte action, byte reason);
127 	void updateTimer();
128 	void loseTimer(byte which);
129 
130 	// Procedures to do things at the end of amounts of time:
131 	void openDrawbridge();
132 	void avariciusTalks();
133 	void urinate();
134 	void toilet();
135 	void bang();
136 	void bang2();
137 	void stairs();
138 	void cardiffSurvey();
139 	void cardiffReturn();
140 	void cwytalotInHerts();
141 	void getTiedUp();
142 	void getTiedUp2();
143 	void hangAround();
144 	void hangAround2();
145 	void afterTheShootemup();
146 	void jacquesWakesUp();
147 	void naughtyDuke();
148 	void naughtyDuke2();
149 	void naughtyDuke3();
150 	void jump();
151 	void crapulusSaysSpludOut();
152 	void buyDrinks();
153 	void buyWine();
154 	void callsGuards();
155 	void greetsMonk();
156 	void fallDownOubliette();
157 	void meetAvaroid();
158 	void riseUpOubliette();
159 	void robinHoodAndGeida();
160 	void robinHoodAndGeidaTalk();
161 	void avalotReturns();
162 	void avvySitDown();
163 	void ghostRoomPhew();
164 	void arkataShouts();
165 	void winning();
166 	void avalotFalls();
167 	void spludwickGoesToCauldron();
168 	void spludwickLeavesCauldron();
169 	void giveLuteToGeida();
170 
171 private:
172 	AvalancheEngine *_vm;
173 	byte _shootEmUpScore;
174 };
175 
176 } // End of namespace Avalanche.
177 
178 #endif // AVALANCHE_TIMER_H
179