ScummVM API documentation
fights.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 LURE_FIGHT_H
23 #define LURE_FIGHT_H
24 
25 #include "lure/luredefs.h"
26 #include "lure/hotspots.h"
27 #include "lure/palette.h"
28 
29 #include "common/singleton.h"
30 #include "common/endian.h"
31 #include "common/random.h"
32 
33 namespace Lure {
34 
35 struct FighterRecord {
36  uint16 fwheader_list;
37  uint16 fwweapon;
38  uint16 fwdie_seq;
39  uint16 fwhit_value;
40  uint16 fwhit_rate;
41  int16 fwtrue_x;
42  int16 fwtrue_y;
43  uint16 fwblocking;
44  uint16 fwattack_table;
45  uint16 fwdef_len;
46  uint16 fwdefend_table;
47  uint16 fwnot_near;
48  uint16 fwdefend_adds;
49  uint16 fwseq_no;
50  uint16 fwdist;
51  uint16 fwwalk_roll;
52  uint16 fwmove_number;
53  uint16 fwhits;
54  uint16 fwseq_ad;
55  uint16 fwenemy_ad;
56 };
57 
58 // Constant references into the fight data
59 #define FIGHT_TBL_1 0x8b8
60 #define FIGHT_PLAYER_MOVE_TABLE 0xDAA
61 #define FIGHT_PLAYER_INIT 0xDC8
62 #define FIGHT_PLAYER_DIES 0xF46
63 
64 #define FIGHT_DISTANCE 32
65 
66 enum KeyStatus {KS_UP, KS_KEYDOWN_1, KS_KEYDOWN_2};
67 
69 private:
70  MemoryBlock *_fightData;
72  uint8 _mouseFlags;
73  KeyStatus _keyDown;
74  FighterRecord _fighterList[3];
75 
76  FighterRecord &getDetails(uint16 hotspotId);
77  uint16 fetchFighterDistance(FighterRecord &f1, FighterRecord &f2);
78  void removeWeapon(uint16 weaponId);
79  void enemyKilled();
80  uint16 getFighterMove(FighterRecord &rec, uint16 baseOffset);
81  void checkEvents();
82  void fightHandler(Hotspot &h, uint16 moveOffset);
83 
84  inline uint16 getWord(uint16 offset) {
85  if (!_fightData)
86  _fightData = Disk::getReference().getEntry(FIGHT_DATA_RESOURCE_ID);
87  if (offset >= _fightData->size() - 1) error("Invalid fight data index");
88  return READ_LE_UINT16(_fightData->data() + offset);
89  }
90  inline uint8 getByte(uint16 offset) {
91  if (!_fightData)
92  _fightData = Disk::getReference().getEntry(FIGHT_DATA_RESOURCE_ID);
93  if (offset >= _fightData->size()) error("Invalid fight data index");
94  return _fightData->data()[offset];
95  }
96 public:
97  FightsManager();
98  ~FightsManager();
99  static FightsManager &getReference();
100 
101  void setupPigFight();
102  void setupSkorlFight();
103  bool isFighting();
104  void fightLoop();
105  void saveToStream(Common::WriteStream *stream);
106  void loadFromStream(Common::ReadStream *stream);
107  void reset();
108 
109  void fighterAnimHandler(Hotspot &h);
110  void playerAnimHandler(Hotspot &h);
111 };
112 
113 #define Fights FightsManager::getReference()
114 
115 } // End of namespace Lure
116 
117 #endif
Definition: stream.h:77
Definition: random.h:44
Definition: fights.h:68
Definition: hotspots.h:180
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: stream.h:385
Definition: fights.h:35
Definition: animseq.h:27
Definition: memory.h:31