2007-06-22 12:30:18 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
*
|
|
|
|
* 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
|
2008-01-05 12:45:14 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2007-06-22 12:30:18 +00:00
|
|
|
* 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$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LURE_FIGHT_H
|
|
|
|
#define LURE_FIGHT_H
|
|
|
|
|
|
|
|
#include "lure/luredefs.h"
|
|
|
|
#include "lure/hotspots.h"
|
|
|
|
#include "lure/palette.h"
|
|
|
|
#include "common/singleton.h"
|
|
|
|
#include "common/endian.h"
|
|
|
|
|
|
|
|
namespace Lure {
|
|
|
|
|
|
|
|
struct FighterRecord {
|
|
|
|
uint16 fwheader_list;
|
|
|
|
uint16 fwweapon;
|
|
|
|
uint16 fwdie_seq;
|
|
|
|
uint16 fwhit_value;
|
|
|
|
uint16 fwhit_rate;
|
|
|
|
int16 fwtrue_x;
|
|
|
|
int16 fwtrue_y;
|
|
|
|
uint16 fwblocking;
|
|
|
|
uint16 fwattack_table;
|
|
|
|
uint16 fwdef_len;
|
|
|
|
uint16 fwdefend_table;
|
|
|
|
uint16 fwnot_near;
|
|
|
|
uint16 fwdefend_adds;
|
|
|
|
uint16 fwseq_no;
|
|
|
|
uint16 fwdist;
|
|
|
|
uint16 fwwalk_roll;
|
|
|
|
uint16 fwmove_number;
|
|
|
|
uint16 fwhits;
|
|
|
|
uint16 fwseq_ad;
|
|
|
|
uint16 fwenemy_ad;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Constant references into the fight data
|
|
|
|
#define FIGHT_TBL_1 0x8b8
|
|
|
|
#define FIGHT_PLAYER_MOVE_TABLE 0xDAA
|
|
|
|
#define FIGHT_PLAYER_INIT 0xDC8
|
|
|
|
#define FIGHT_PLAYER_DIES 0xF46
|
|
|
|
|
|
|
|
#define FIGHT_DISTANCE 32
|
|
|
|
|
2007-12-03 12:26:45 +00:00
|
|
|
enum KeyStatus {KS_UP, KS_KEYDOWN_1, KS_KEYDOWN_2};
|
|
|
|
|
2007-06-22 12:30:18 +00:00
|
|
|
class FightsManager {
|
|
|
|
private:
|
|
|
|
MemoryBlock *_fightData;
|
2009-08-24 23:04:25 +00:00
|
|
|
Common::RandomSource &_rnd;
|
2007-06-22 12:30:18 +00:00
|
|
|
uint8 _mouseFlags;
|
2007-12-03 12:26:45 +00:00
|
|
|
KeyStatus _keyDown;
|
2007-11-17 06:53:13 +00:00
|
|
|
FighterRecord _fighterList[3];
|
2007-06-22 12:30:18 +00:00
|
|
|
|
|
|
|
FighterRecord &getDetails(uint16 hotspotId);
|
|
|
|
uint16 fetchFighterDistance(FighterRecord &f1, FighterRecord &f2);
|
|
|
|
void removeWeapon(uint16 weaponId);
|
|
|
|
void enemyKilled();
|
|
|
|
uint16 getFighterMove(FighterRecord &rec, uint16 baseOffset);
|
|
|
|
void checkEvents();
|
|
|
|
void fightHandler(Hotspot &h, uint16 moveOffset);
|
|
|
|
|
|
|
|
inline uint16 getWord(uint16 offset) {
|
|
|
|
if (!_fightData)
|
|
|
|
_fightData = Disk::getReference().getEntry(FIGHT_DATA_RESOURCE_ID);
|
|
|
|
if (offset >= _fightData->size() - 1) error("Invalid fight data index");
|
|
|
|
return READ_LE_UINT16(_fightData->data() + offset);
|
|
|
|
}
|
|
|
|
inline uint8 getByte(uint16 offset) {
|
|
|
|
if (!_fightData)
|
|
|
|
_fightData = Disk::getReference().getEntry(FIGHT_DATA_RESOURCE_ID);
|
|
|
|
if (offset >= _fightData->size()) error("Invalid fight data index");
|
|
|
|
return _fightData->data()[offset];
|
|
|
|
}
|
|
|
|
public:
|
|
|
|
FightsManager();
|
|
|
|
~FightsManager();
|
|
|
|
static FightsManager &getReference();
|
|
|
|
|
|
|
|
void setupPigFight();
|
|
|
|
void setupSkorlFight();
|
|
|
|
bool isFighting();
|
|
|
|
void fightLoop();
|
|
|
|
void saveToStream(Common::WriteStream *stream);
|
|
|
|
void loadFromStream(Common::ReadStream *stream);
|
2007-11-17 06:53:13 +00:00
|
|
|
void reset();
|
2007-06-22 12:30:18 +00:00
|
|
|
|
|
|
|
void fighterAnimHandler(Hotspot &h);
|
|
|
|
void playerAnimHandler(Hotspot &h);
|
|
|
|
};
|
|
|
|
|
|
|
|
#define Fights FightsManager::getReference()
|
|
|
|
|
|
|
|
} // End of namespace Lure
|
|
|
|
|
|
|
|
#endif
|