ScummVM API documentation
game_bountyhunter.h
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 modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef ALG_GAME_BOUNTYHUNTER_H
23 #define ALG_GAME_BOUNTYHUNTER_H
24 
25 #include "common/hashmap.h"
26 #include "common/rect.h"
27 
28 #include "gui/debugger.h"
29 
30 #include "alg/game.h"
31 #include "alg/scene.h"
32 
33 namespace Alg {
34 
35 typedef Common::Functor1Mem<Scene *, void, GameBountyHunter> BHScriptFunctionScene;
36 typedef Common::Functor1Mem<Rect *, void, GameBountyHunter> BHScriptFunctionRect;
38 typedef Common::HashMap<Common::String, BHScriptFunctionScene *> BHScriptFunctionSceneMap;
39 typedef Common::HashMap<Common::String, BHScriptFunctionRect *> BHScriptFunctionRectMap;
40 typedef Common::HashMap<Common::String, BHScriptFunctionPoint *> BHScriptFunctionPointMap;
41 
42 class GameBountyHunter : public Game {
43 
44  enum SceneFuncType {
45  PREOP = 1,
46  SHOWMSG = 2,
47  INSOP = 3,
48  WEPDWN = 4,
49  SCNSCR = 5,
50  NXTFRM = 6,
51  NXTSCN = 7
52  };
53 
54 public:
56  ~GameBountyHunter() override;
57  Common::Error run() override;
58  void debugWarpTo(int val);
59 
60 private:
61  void init() override;
62  void registerScriptFunctions();
63  void verifyScriptFunctions();
64  BHScriptFunctionRect getScriptFunctionRectHit(Common::String name);
65  BHScriptFunctionScene getScriptFunctionScene(SceneFuncType type, Common::String name);
66  void callScriptFunctionRectHit(Common::String name, Rect *rect);
67  void callScriptFunctionScene(SceneFuncType type, Common::String name, Scene *scene);
68 
69  BHScriptFunctionRectMap _rectHitFuncs;
70  BHScriptFunctionSceneMap _scenePreOps;
71  BHScriptFunctionSceneMap _sceneShowMsg;
72  BHScriptFunctionSceneMap _sceneInsOps;
73  BHScriptFunctionSceneMap _sceneWepDwn;
74  BHScriptFunctionSceneMap _sceneScnScr;
75  BHScriptFunctionSceneMap _sceneNxtFrm;
76  BHScriptFunctionSceneMap _sceneNxtScn;
77 
78  // images
79  Graphics::Surface *_shotIcon;
80  Graphics::Surface *_emptyIcon;
81  Graphics::Surface *_liveIcon;
82  Graphics::Surface *_deadIcon;
83  Graphics::Surface *_diffIcon;
84  Graphics::Surface *_bulletholeIcon;
85  Graphics::Surface *_playersIcon1;
86  Graphics::Surface *_playersIcon2;
87  Graphics::Surface *_textScoreIcon;
88  Graphics::Surface *_textMenuIcon;
89  Graphics::Surface *_textBlackBarIcon;
92 
93  // sounds
94  Audio::SeekableAudioStream *_shotgunSound = nullptr;
95 
96  // constants
97  uint16 _randomHarry1[7] = {0x01B9, 0x01B7, 0x01B5, 0x01B3, 0x01AF, 0x01AD, 0};
98  uint16 _randomHarry2[6] = {0x0194, 0x0190, 0x018E, 0x018C, 0};
99  uint16 _randomDan1[5] = {0x0173, 0x0171, 0x016F, 0x016D, 0};
100  uint16 _randomDan1TwoPlayer[6] = {0x0173, 0x0171, 0x016F, 0x016D, 0x016B, 0};
101  uint16 _randomDan2[7] = {0x0165, 0x0163, 0x0161, 0x015F, 0x015D, 0x015B, 0};
102  uint16 _randomLoco1[4] = {0xF7, 0xF5, 0xF3, 0};
103  uint16 _randomLoco2[3] = {0xED, 0xEB, 0};
104  uint16 _randomKid1[4] = {0xBA, 0xB7, 0xB5, 0};
105  uint16 _randomKid2[4] = {0xB1, 0xAE, 0xAC, 0};
106 
107  uint16 *_randomScenes[8] = {_randomHarry1, _randomHarry2, _randomDan1, _randomDan2, _randomLoco1, _randomLoco2, _randomKid1, _randomKid2};
108  const uint8 _randomScenesPicks[8] = {6, 6, 4, 7, 3, 2, 5, 5};
109 
110  const uint8 _subLevelOrder[96] = {0, 1, 2, 4, 0, 0, 0, 1, 3, 4, 0, 0, 0, 2, 3, 4, 0, 0, 0, 1, 2, 3, 4, 0,
111  0, 1, 2, 4, 0, 0, 0, 1, 3, 4, 0, 0, 0, 2, 3, 4, 0, 0, 0, 1, 2, 3, 4, 0,
112  0, 1, 3, 4, 0, 0, 0, 2, 3, 4, 0, 0, 1, 2, 3, 4, 0, 0, 0, 1, 2, 3, 4, 0,
113  0, 1, 2, 3, 4, 0, 0, 1, 2, 3, 4, 0, 0, 1, 2, 3, 4, 0, 0, 1, 2, 3, 4, 0};
114  const uint16 _subLevelSceneIds[20] = {0x01BE, 0x017A, 0x01A2, 0x0198, 0x0183, 0x0178, 0x0167, 0x0159, 0x014B, 0x0147,
115  0xF1, 0xE1, 0xFF, 0xD8, 0xD0, 0x9B, 0xA8, 0x86, 0xBF, 0x74};
116 
117  const uint16 _clueLevels[4] = {0x017A, 0x013B, 0xC2, 0x68};
118  const uint8 _mainLevelMasks[5] = {2, 4, 8, 0x10, 0x80};
119  const uint8 _gunfightCountDown[15] = {5, 4, 3, 3, 3, 4, 3, 3, 2, 1, 3, 2, 2, 2, 1};
120 
121  // const uint16 _firstSceneInScenario[4] = {4, 0x36, 0x36, 0x66};
122  const uint16 _moneyScenes[4] = {0x017D, 0x013C, 0xC3, 0x69};
123  const uint16 _gunfightScenarios[18] = {0x0116, 0x0118, 0x011B, 0x011D, 0x011F, 0x0121, 0x0123, 0x0125, 0x0127,
124  0x0129, 0x012B, 0x012D, 0x012F, 0x0131, 0x0133, 0x0135, 0x0137, 0x0139};
125  const uint16 _innocentScenarios[5] = {0x0110, 0x010F, 0x010C, 0x010B, 0};
126  const uint16 _deathScenarios[9] = {0x0100, 0x0101, 0x0102, 0x0103, 0x0104, 0x0105, 0x0106, 0x0107, 0};
127  const uint16 _onePlayerOfTwoDead[2] = {0x0109, 0x010A};
128  const uint16 _allPlayersDead = 0x108;
129 
130  // gamestate
131  uint16 _restartScene = 0;
132  uint8 _numPlayers = 1;
133  uint8 _player = 0;
134  uint8 _playerLives[2] = {0, 0};
135  uint8 _playerGun[2] = {1, 1};
136  uint8 _playerShots[2] = {0, 0};
137  uint32 _playerScore[2] = {0, 0};
138 
139  uint8 _currentLevel = 0;
140  uint16 _currentSubLevelSceneId = 0;
141  uint8 _numLevelsDone = 0;
142  uint8 _levelDoneMask = 0;
143  uint8 _numSubLevelsDone = 0;
144 
145  // uint16 _usedScenes = 0;
146  // int16 _lastPick = -1;
147  // int16 _initted = 0;
148  // int16 _sceneCount = 0;
149 
150  uint16 *_randomSceneList;
151  uint8 _randomMax = 0;
152  uint16 _randomMask = 0;
153  int16 _randomPicked = 0;
154  uint8 _randomSceneCount = 0;
155  bool _gunfightInitialized = false;
156  uint16 _gunfightMask = 0;
157  int16 _gunfightPicked = 0;
158  uint8 _gunfightSceneCount = 0;
159  bool _innocentInitialized = false;
160  uint16 _innocentMask = 0;
161  int16 _innocentPicked = 0;
162  uint8 _innocentSceneCount = 0;
163  bool _deathInitialized = false;
164  uint16 _deathMask = 0;
165  int16 _deathPicked = 0;
166  uint8 _deathSceneCount = 0;
167 
168  uint8 _continuesUsed = 0;
169  bool _wounded = false;
170  uint16 _mainWounds = 0;
171  int8 _gunfightCount = 0;
172  bool _given = false;
173  uint32 _firstDrawFrame = 0;
174  uint8 _count = 0;
175 
176  uint8 _unk_2ADA6 = 0;
177 
178  // base functions
179  void newGame();
180  void doMenu();
181  void updateCursor();
182  void updateMouse();
183  void moveMouse();
184  void displayLivesLeft(uint8 player);
185  void displayScores(uint8 player);
186  void displayShotsLeft(uint8 player);
187  bool weaponDown();
188  bool saveState();
189  bool loadState();
190 
191  // misc game functions
192  void setNextScene(uint16 sceneId);
193  void displayShotFiredImage(Common::Point *point);
194  void enableVideoFadeIn();
195  void iconShotgun();
196  void iconReset();
197  uint16 beginLevel(uint8 levelNumber);
198  uint16 pickRandomScene(uint16 *sceneList, uint8 max);
199  uint16 pickGunfightScene();
200  uint16 pickInnocentScene();
201  uint16 pickDeathScene();
202  uint16 timeForGunfight();
203  void waitingForShootout(uint32 drawFrame);
204  void doShotgunSound();
205 
206  // Script functions: RectHit
207  void rectShotMenu(Rect *rect);
208  void rectSave(Rect *rect);
209  void rectLoad(Rect *rect);
210  void rectContinue(Rect *rect);
211  void rectStart(Rect *rect);
212  void rectTogglePlayers(Rect *rect);
213  void rectHitIconJug(Rect *rect);
214  void rectHitIconLantern(Rect *rect);
215  void rectHitIconSkull(Rect *rect);
216  void rectHitIconWheel(Rect *rect);
217  void rectHitSelectHarry(Rect *rect);
218  void rectHitSelectDan(Rect *rect);
219  void rectHitSelectLoco(Rect *rect);
220  void rectHitSelectKid(Rect *rect);
221  void rectHitKillMan(Rect *rect);
222  void rectHitGiveShotgun(Rect *rect);
223  void rectHitKill3(Rect *rect);
224  void rectHitCheckShotgun(Rect *rect);
225  void rectHitCheater(Rect *rect);
226 
227  // Script functions: Scene PreOps
228  void scenePsoShootout(Scene *scene);
229  void scenePsoWoundedMain(Scene *scene);
230  void scenePsoGunfightSetup(Scene *scene);
231  void scenePsoLoseALife(Scene *scene);
232  void scenePsoSetupNdRandom1(Scene *scene);
233  void scenePsoSetCurrentScene(Scene *scene);
234 
235  // Script functions: Scene InsOps
236  void sceneIsoShootout(Scene *scene);
237  void sceneIsoGivemoney(Scene *scene);
238 
239  // Script functions: Scene NxtScn
240  void sceneNxtscnLoseALife(Scene *scene);
241  void sceneNxtscnContinueGame(Scene *scene);
242  void sceneNxtscnDidNotContinue(Scene *scene);
243  void sceneNxtscnKillInnocentMan(Scene *scene);
244  void sceneNxtscnKillInnocentWoman(Scene *scene);
245  void sceneNxtscnAfterDie(Scene *scene);
246  void sceneNxtscnGotoLevelSelect(Scene *scene);
247  void sceneNxtscnContinueRandom(Scene *scene);
248  void sceneNxtscnInitRandomHarry1(Scene *scene);
249  void sceneNxtscnInitRandomHarry2(Scene *scene);
250  void sceneNxtscnInitRandomDan1(Scene *scene);
251  void sceneNxtscnInitRandomDan2(Scene *scene);
252  void sceneNxtscnInitRandomLoco1(Scene *scene);
253  void sceneNxtscnInitRandomLoco2(Scene *scene);
254  void sceneNxtscnInitRandomKid1(Scene *scene);
255  void sceneNxtscnInitRandomKid2(Scene *scene);
256  void sceneNxtscnNextSubLevel(Scene *scene);
257  void sceneNxtscnGotoBadGuy(Scene *scene);
258  void sceneNxtscnAutoSelectLevel(Scene *scene);
259  void sceneNxtscnSelectScenario(Scene *scene);
260  void sceneNxtscnFinishScenario(Scene *scene);
261  void sceneNxtscnGameWon(Scene *scene);
262  void sceneNxtscnKilledMain(Scene *scene);
263  void sceneNxtscnWoundedMain(Scene *scene);
264  void sceneNxtscnEndLevel(Scene *scene);
265  void sceneNxtscnEndGame(Scene *scene);
266  void sceneNxtscnDoBreakoutMains(Scene *scene);
267  void sceneNxtscnDiedRefed(Scene *scene);
268  void sceneNxtscnGiveShotgun(Scene *scene);
269  void sceneNxtscnCheck2Players(Scene *scene);
270 
271  // Script functions: Scene WepDwn
272  void sceneDefaultWepdwn(Scene *scene);
273 };
274 
276 public:
278  bool cmdWarpTo(int argc, const char **argv);
279  bool cmdDumpLib(int argc, const char **argv);
280 
281 private:
282  GameBountyHunter *_game;
283 };
284 
285 } // End of namespace Alg
286 
287 #endif
Definition: scene.h:72
Definition: scene.h:102
Definition: str.h:59
Definition: surface.h:67
Definition: error.h:81
Definition: debugger.h:41
Definition: game_bountyhunter.h:275
Definition: audiostream.h:212
Definition: alg.h:30
Definition: func.h:452
Definition: rect.h:144
Definition: game.h:36
Definition: alg.h:46
Definition: game_bountyhunter.h:42
Definition: detection.h:39