mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-06 09:48:39 +00:00
XEEN: Implementing combat methods
This commit is contained in:
parent
ef2a4595c2
commit
75a070de17
@ -20,12 +20,64 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "xeen/combat.h"
|
||||
#include "common/algorithm.h"
|
||||
#include "common/textconsole.h"
|
||||
#include "common/rect.h"
|
||||
#include "xeen/combat.h"
|
||||
#include "xeen/interface.h"
|
||||
#include "xeen/xeen.h"
|
||||
|
||||
namespace Xeen {
|
||||
|
||||
static const int MONSTER_GRID_X[48] = {
|
||||
1, 1, 1, 0, -1, -1, -1, 1, 1, 1, 0, -1,
|
||||
-1, -1, 1, 1, 1, 0, -1, -1, -1, 1, 1, 1,
|
||||
0, -1, -1, -1, 1, 1, 1, 0, -1, -1, -1, 1,
|
||||
1, 1, 0, -1, -1, -1, 1, 1, 1, 0, -1, -1
|
||||
};
|
||||
|
||||
static const int MONSTER_GRID_Y[48] = {
|
||||
0, 0, 0, -1, 0, 0, 0, 0, 0, 0, -1, 0,
|
||||
0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
|
||||
0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0
|
||||
};
|
||||
|
||||
static const int MONSTER_GRID3[48] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
- 1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1,
|
||||
0, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
|
||||
};
|
||||
|
||||
static const int MONSTER_GRID_BITINDEX1[48] = {
|
||||
1, 1, 1, 2, 3, 3, 3, 1, 1, 1, 2, 3,
|
||||
3, 3, 1, 1, 1, 2, 3, 3, 3, 1, 1, 1,
|
||||
0, 3, 3, 3, 1, 1, 1, 0, 3, 3, 3, 1,
|
||||
1, 1, 0, 3, 3, 3, 1, 1, 1, 0, 3, 3
|
||||
};
|
||||
|
||||
static const int MONSTER_GRID_BITINDEX2[48] = {
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1,
|
||||
0, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
static const int MONSTER_GRID_BITMASK[12] = {
|
||||
0xC, 8, 4, 0, 0xF, 0xF000, 0xF00, 0xF0, 0xF00, 0xF0, 0x0F, 0xF000
|
||||
};
|
||||
|
||||
static const int ATTACK_TYPE_FX[23] = {
|
||||
49, 18, 13, 14, 15, 17, 16, 0, 6, 1, 2, 3,
|
||||
4, 5, 4, 9, 27, 29, 44, 51, 53, 61, 71
|
||||
};
|
||||
|
||||
static const int MONSTER_SHOOT_POW[7] = { 12, 14, 0, 4, 8, 10, 13 };
|
||||
|
||||
static const int COMBAT_SHOOTING[4] = { 1, 1, 2, 3 };
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
Combat::Combat(XeenEngine *vm): _vm(vm) {
|
||||
Common::fill(&_attackMonsters[0], &_attackMonsters[26], 0);
|
||||
Common::fill(&_charsArray1[0], &_charsArray1[12], 0);
|
||||
@ -34,9 +86,14 @@ Combat::Combat(XeenEngine *vm): _vm(vm) {
|
||||
Common::fill(&_elemPow[0], &_elemPow[12], 0);
|
||||
Common::fill(&_elemScale[0], &_elemScale[12], 0);
|
||||
Common::fill(&_shooting[0], &_shooting[8], 0);
|
||||
Common::fill(&_monsterMap[0][0], &_monsterMap[32][32], 0);
|
||||
Common::fill(&_monsterMoved[0], &_monsterMoved[MAX_NUM_MONSTERS], false);
|
||||
Common::fill(&_rangeAttacking[0], &_rangeAttacking[MAX_NUM_MONSTERS], false);
|
||||
Common::fill(&_gmonHit[0], &_gmonHit[36], 0);
|
||||
_globalCombat = 0;
|
||||
_whosTurn = -1;
|
||||
_itemFlag = false;
|
||||
_monstersAttacking = false;
|
||||
}
|
||||
|
||||
void Combat::clear() {
|
||||
@ -51,5 +108,345 @@ void Combat::giveCharDamage(int damage, int v2, int v3) {
|
||||
error("TODO: giveCharDamage");
|
||||
}
|
||||
|
||||
void Combat::moveMonsters() {
|
||||
Interface &intf = *_vm->_interface;
|
||||
Map &map = *_vm->_map;
|
||||
Party &party = *_vm->_party;
|
||||
|
||||
if (!_vm->_moveMonsters)
|
||||
return;
|
||||
|
||||
intf._tillMove = 0;
|
||||
if (intf._charsShooting)
|
||||
return;
|
||||
|
||||
Common::fill(&_monsterMap[0][0], &_monsterMap[32][32], 0);
|
||||
Common::fill(&_monsterMoved[0], &_monsterMoved[MAX_NUM_MONSTERS], false);
|
||||
Common::fill(&_rangeAttacking[0], &_rangeAttacking[MAX_NUM_MONSTERS], false);
|
||||
Common::fill(&_gmonHit[0], &_gmonHit[36], -1);
|
||||
_vm->_dangerSenseAllowed = false;
|
||||
|
||||
for (uint idx = 0; idx < map._mobData._monsters.size(); ++idx) {
|
||||
MazeMonster &monster = map._mobData._monsters[idx];
|
||||
if (monster._position.y < 32) {
|
||||
_monsterMap[monster._position.y][monster._position.x]++;
|
||||
}
|
||||
}
|
||||
|
||||
for (int loopNum = 0; loopNum < 2; ++loopNum) {
|
||||
int arrIndex = -1;
|
||||
for (int yDiff = 3; yDiff >= -3; --yDiff) {
|
||||
for (int xDiff = 3; xDiff >= -3; --xDiff) {
|
||||
Common::Point pt = party._mazePosition + Common::Point(xDiff, yDiff);
|
||||
++arrIndex;
|
||||
|
||||
for (int idx = 0; idx < (int)map._mobData._monsters.size(); ++idx) {
|
||||
MazeMonster &monster = map._mobData._monsters[idx];
|
||||
MonsterStruct &monsterData = map._monsterData[monster._spriteId];
|
||||
|
||||
if (pt == monster._position) {
|
||||
_vm->_dangerSenseAllowed = true;
|
||||
if ((monster._isAttacking || _vm->_mode == MODE_SLEEPING)
|
||||
&& !_monsterMoved[idx]) {
|
||||
if (party._mazePosition.x == pt.x || party._mazePosition.y == pt.y) {
|
||||
// Check for range attacks
|
||||
if (monsterData._rangeAttack && !_rangeAttacking[idx]
|
||||
&& _attackMonsters[0] != idx && _attackMonsters[1] != idx
|
||||
&& _attackMonsters[2] != idx && !monster._field7) {
|
||||
// Setup monster for attacking
|
||||
setupMonsterAttack(monster._spriteId, pt);
|
||||
_rangeAttacking[idx] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (party._mazeDirection) {
|
||||
case DIR_NORTH:
|
||||
case DIR_SOUTH:
|
||||
if (monsterCanMove(pt, MONSTER_GRID_BITMASK[MONSTER_GRID_BITINDEX1[arrIndex]],
|
||||
MONSTER_GRID_X[arrIndex], MONSTER_GRID_Y[arrIndex], idx)) {
|
||||
// Move the monster
|
||||
moveMonster(idx, Common::Point(MONSTER_GRID_X[arrIndex], MONSTER_GRID_Y[arrIndex]));
|
||||
} else {
|
||||
if (monsterCanMove(pt, MONSTER_GRID_BITMASK[MONSTER_GRID_BITINDEX2[arrIndex]],
|
||||
arrIndex >= 21 && arrIndex <= 27 ? MONSTER_GRID3[arrIndex] : 0,
|
||||
arrIndex >= 21 && arrIndex <= 27 ? 0 : MONSTER_GRID3[arrIndex],
|
||||
idx))
|
||||
if (arrIndex >= 21 && arrIndex <= 27) {
|
||||
moveMonster(idx, Common::Point(MONSTER_GRID3[arrIndex], 0));
|
||||
} else {
|
||||
moveMonster(idx, Common::Point(0, MONSTER_GRID3[arrIndex]));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case DIR_EAST:
|
||||
case DIR_WEST:
|
||||
if (monsterCanMove(pt, MONSTER_GRID_BITMASK[MONSTER_GRID_BITINDEX2[arrIndex]],
|
||||
arrIndex >= 21 && arrIndex <= 27 ? MONSTER_GRID3[arrIndex] : 0,
|
||||
arrIndex >= 21 && arrIndex <= 27 ? 0 : MONSTER_GRID3[arrIndex],
|
||||
idx)) {
|
||||
if (arrIndex >= 21 && arrIndex <= 27) {
|
||||
moveMonster(idx, Common::Point(MONSTER_GRID3[arrIndex], 0));
|
||||
} else {
|
||||
moveMonster(idx, Common::Point(0, MONSTER_GRID3[arrIndex]));
|
||||
}
|
||||
} else if (monsterCanMove(pt, MONSTER_GRID_BITMASK[MONSTER_GRID_BITINDEX1[arrIndex]],
|
||||
MONSTER_GRID_X[arrIndex], MONSTER_GRID_Y[arrIndex], idx)) {
|
||||
moveMonster(idx, Common::Point(MONSTER_GRID_X[arrIndex], MONSTER_GRID_Y[arrIndex]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
monsterOvercome();
|
||||
if (_monstersAttacking)
|
||||
monstersAttack();
|
||||
}
|
||||
|
||||
void Combat::monstersAttack() {
|
||||
EventsManager &events = *_vm->_events;
|
||||
Interface &intf = *_vm->_interface;
|
||||
Map &map = *_vm->_map;
|
||||
Party &party = *_vm->_party;
|
||||
SoundManager &sound = *_vm->_sound;
|
||||
int powNum = -1;
|
||||
MonsterStruct *monsterData = nullptr;
|
||||
OutdoorDrawList &outdoorList = intf._outdoorList;
|
||||
IndoorDrawList &indoorList = intf._indoorList;
|
||||
|
||||
for (int idx = 0; idx < 36; ++idx) {
|
||||
if (_gmonHit[idx] != -1) {
|
||||
monsterData = &map._monsterData[_gmonHit[idx]];
|
||||
powNum = MONSTER_SHOOT_POW[monsterData->_attackType];
|
||||
if (powNum != 12)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_powSprites.load(Common::String::format("pow%d.icn", powNum));
|
||||
sound.playFX(ATTACK_TYPE_FX[monsterData->_attackType]);
|
||||
|
||||
for (int charNum = 0; charNum < MAX_PARTY_COUNT; ++charNum) {
|
||||
if (!_shooting[charNum])
|
||||
continue;
|
||||
|
||||
if (map._isOutdoors) {
|
||||
outdoorList._attackImgs1[charNum]._scale = 3;
|
||||
outdoorList._attackImgs2[charNum]._scale = 7;
|
||||
outdoorList._attackImgs3[charNum]._scale = 11;
|
||||
outdoorList._attackImgs4[charNum]._scale = 15;
|
||||
outdoorList._attackImgs1[charNum]._sprites = nullptr;
|
||||
outdoorList._attackImgs2[charNum]._sprites = nullptr;
|
||||
outdoorList._attackImgs3[charNum]._sprites = nullptr;
|
||||
outdoorList._attackImgs4[charNum]._sprites = nullptr;
|
||||
|
||||
switch (_shooting[charNum]) {
|
||||
case 1:
|
||||
outdoorList._attackImgs1[charNum]._sprites = &_powSprites;
|
||||
break;
|
||||
case 2:
|
||||
outdoorList._attackImgs2[charNum]._sprites = &_powSprites;
|
||||
break;
|
||||
default:
|
||||
outdoorList._attackImgs3[charNum]._sprites = &_powSprites;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
indoorList._attackImgs1[charNum]._scale = 3;
|
||||
indoorList._attackImgs2[charNum]._scale = 7;
|
||||
indoorList._attackImgs3[charNum]._scale = 11;
|
||||
indoorList._attackImgs4[charNum]._scale = 15;
|
||||
indoorList._attackImgs1[charNum]._sprites = nullptr;
|
||||
indoorList._attackImgs2[charNum]._sprites = nullptr;
|
||||
indoorList._attackImgs3[charNum]._sprites = nullptr;
|
||||
indoorList._attackImgs4[charNum]._sprites = nullptr;
|
||||
|
||||
switch (_shooting[charNum]) {
|
||||
case 1:
|
||||
indoorList._attackImgs1[charNum]._sprites = &_powSprites;
|
||||
break;
|
||||
case 2:
|
||||
indoorList._attackImgs2[charNum]._sprites = &_powSprites;
|
||||
break;
|
||||
default:
|
||||
indoorList._attackImgs3[charNum]._sprites = &_powSprites;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Wait whilst the attacking effect is done
|
||||
do {
|
||||
intf.draw3d(true);
|
||||
events.pollEventsAndWait();
|
||||
} while (!_vm->shouldQuit() && intf._isAttacking);
|
||||
|
||||
endAttack();
|
||||
|
||||
if (_vm->_mode != MODE_COMBAT) {
|
||||
// Combat wasn't previously active, but it is now. Set up
|
||||
// the combat party from the currently active party
|
||||
party._combatParty.clear();
|
||||
for (uint idx = 0; idx < party._activeParty.size(); ++idx)
|
||||
party._combatParty.push_back(&party._activeParty[idx]);
|
||||
}
|
||||
|
||||
for (int idx = 0; idx < 36; ++idx) {
|
||||
if (_gmonHit[idx] != -1)
|
||||
attackMonster(_gmonHit[idx]);
|
||||
}
|
||||
|
||||
_monstersAttacking = false;
|
||||
|
||||
if (_vm->_mode != MODE_SLEEPING) {
|
||||
for (uint charNum = 0; charNum < party._activeParty.size(); ++charNum) {
|
||||
Condition condition = party._activeParty[charNum].worstCondition();
|
||||
|
||||
if (condition != ASLEEP && (condition < PARALYZED || condition == NO_CONDITION)) {
|
||||
_vm->_mode = MODE_1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Combat::setupMonsterAttack(int monsterDataIndex, const Common::Point &pt) {
|
||||
Party &party = *_vm->_party;
|
||||
|
||||
for (int idx = 0; idx < 36; ++idx) {
|
||||
if (_gmonHit[idx] != -1) {
|
||||
int result = stopAttack(pt - party._mazePosition);
|
||||
if (result) {
|
||||
_monstersAttacking = true;
|
||||
_gmonHit[idx] = monsterDataIndex;
|
||||
|
||||
if (result != 1) {
|
||||
for (int charNum = 0; charNum < MAX_PARTY_COUNT; ++charNum) {
|
||||
if (!_shooting[charNum]) {
|
||||
_shooting[charNum] = COMBAT_SHOOTING[result - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Combat::monsterCanMove(const Common::Point &pt, int wallShift,
|
||||
int xDiff, int yDiff, int monsterId) {
|
||||
Map &map = *_vm->_map;
|
||||
MazeMonster &monster = map._mobData._monsters[monsterId];
|
||||
MonsterStruct &monsterData = map._monsterData[monster._spriteId];
|
||||
|
||||
Common::Point tempPos = pt;
|
||||
if (map._isOutdoors) {
|
||||
tempPos += Common::Point(xDiff, yDiff);
|
||||
wallShift = 4;
|
||||
}
|
||||
int v = map.mazeLookup(tempPos, wallShift);
|
||||
|
||||
if (!map._isOutdoors) {
|
||||
return v <= map.mazeData()._difficulties._wallNoPass;
|
||||
} else {
|
||||
SurfaceType surfaceType;
|
||||
switch (v) {
|
||||
case 0:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 8:
|
||||
case 11:
|
||||
case 13:
|
||||
case 14:
|
||||
surfaceType = (SurfaceType)map.mazeData()._surfaceTypes[map._currentSurfaceId];
|
||||
if (surfaceType == SURFTYPE_WATER || surfaceType == SURFTYPE_DWATER) {
|
||||
return monsterData._flying || monster._spriteId == 59;
|
||||
} else if (surfaceType == SURFTYPE_SPACE) {
|
||||
return monsterData._flying;
|
||||
} else {
|
||||
return _vm->_files->_isDarkCc || monster._spriteId != 59;
|
||||
}
|
||||
default:
|
||||
return v <= map.mazeData()._difficulties._wallNoPass;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Combat::moveMonster(int monsterId, const Common::Point &pt) {
|
||||
Map &map = *_vm->_map;
|
||||
MazeMonster &monster = map._mobData._monsters[monsterId];
|
||||
|
||||
if (_monsterMap[pt.y][pt.x] < 3 && !monster._field7 && _vm->_moveMonsters) {
|
||||
++_monsterMap[pt.y][pt.x];
|
||||
--_monsterMap[monster._position.y][monster._position.x];
|
||||
monster._position = pt;
|
||||
_monsterMoved[monsterId] = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Combat::endAttack() {
|
||||
Interface &intf = *_vm->_interface;
|
||||
Map &map = *_vm->_map;
|
||||
Party &party = *_vm->_party;
|
||||
intf._isAttacking = false;
|
||||
IndoorDrawList &indoorList = intf._indoorList;
|
||||
OutdoorDrawList &outdoorList = intf._outdoorList;
|
||||
|
||||
for (uint idx = 0; idx < party._activeParty.size(); ++idx) {
|
||||
Character &c = party._activeParty[idx];
|
||||
|
||||
if (map._isOutdoors) {
|
||||
outdoorList._attackImgs1[idx]._scale = 0;
|
||||
outdoorList._attackImgs2[idx]._scale = 0;
|
||||
outdoorList._attackImgs3[idx]._scale = 0;
|
||||
outdoorList._attackImgs4[idx]._scale = 0;
|
||||
outdoorList._attackImgs1[idx]._sprites = nullptr;
|
||||
outdoorList._attackImgs2[idx]._sprites = nullptr;
|
||||
outdoorList._attackImgs3[idx]._sprites = nullptr;
|
||||
outdoorList._attackImgs4[idx]._sprites = nullptr;
|
||||
} else {
|
||||
indoorList._attackImgs1[idx]._scale = 0;
|
||||
indoorList._attackImgs2[idx]._scale = 0;
|
||||
indoorList._attackImgs3[idx]._scale = 0;
|
||||
indoorList._attackImgs4[idx]._scale = 0;
|
||||
indoorList._attackImgs1[idx]._sprites = nullptr;
|
||||
indoorList._attackImgs2[idx]._sprites = nullptr;
|
||||
indoorList._attackImgs3[idx]._sprites = nullptr;
|
||||
indoorList._attackImgs4[idx]._sprites = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Common::fill(&_shooting[0], &_shooting[MAX_PARTY_COUNT], false);
|
||||
}
|
||||
|
||||
void Combat::monsterOvercome() {
|
||||
Map &map = *_vm->_map;
|
||||
|
||||
for (uint idx = 0; idx < map._mobData._monsters.size(); ++idx) {
|
||||
MazeMonster &monster = map._mobData._monsters[idx];
|
||||
int dataIndex = monster._spriteId;
|
||||
|
||||
if (monster._field7 != 0 && monster._field7 != 13) {
|
||||
// Do a saving throw for monster
|
||||
if (dataIndex <= _vm->getRandomNumber(1, dataIndex + 50))
|
||||
monster._field7 = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Combat::attackMonster(int monsterId) {
|
||||
|
||||
}
|
||||
|
||||
bool Combat::stopAttack(const Common::Point &diffPt) {
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
} // End of namespace Xeen
|
||||
|
@ -24,9 +24,13 @@
|
||||
#define XEEN_COMBAT_H
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "common/rect.h"
|
||||
#include "xeen/sprites.h"
|
||||
|
||||
namespace Xeen {
|
||||
|
||||
#define MAX_NUM_MONSTERS 107
|
||||
|
||||
enum DamageType {
|
||||
DT_PHYSICAL = 0, DT_MAGICAL = 1, DT_FIRE = 2, DT_ELECTRICAL = 3,
|
||||
DT_COLD = 4, DT_POISON = 5, DT_ENERGY = 6, DT_SLEEP = 7,
|
||||
@ -51,16 +55,39 @@ class Combat {
|
||||
private:
|
||||
XeenEngine *_vm;
|
||||
public:
|
||||
SpriteResource _powSprites;
|
||||
int _attackMonsters[26];
|
||||
int _charsArray1[12];
|
||||
bool _monPow[12];
|
||||
int _monsterScale[12];
|
||||
int _elemPow[12];
|
||||
int _elemScale[12];
|
||||
bool _shooting[8];
|
||||
int _shooting[8];
|
||||
int _globalCombat;
|
||||
int _whosTurn;
|
||||
bool _itemFlag;
|
||||
int _monsterMap[32][32];
|
||||
bool _monsterMoved[MAX_NUM_MONSTERS];
|
||||
bool _rangeAttacking[MAX_NUM_MONSTERS];
|
||||
int _gmonHit[36];
|
||||
bool _monstersAttacking;
|
||||
|
||||
void monstersAttack();
|
||||
|
||||
void setupMonsterAttack(int monsterDataIndex, const Common::Point &pt);
|
||||
|
||||
bool monsterCanMove(const Common::Point &pt, int wallShift,
|
||||
int v1, int v2, int monsterId);
|
||||
|
||||
void moveMonster(int monsterId, const Common::Point &pt);
|
||||
|
||||
void attackMonster(int monsterId);
|
||||
|
||||
void endAttack();
|
||||
|
||||
void monsterOvercome();
|
||||
|
||||
bool stopAttack(const Common::Point &diffPt);
|
||||
public:
|
||||
Combat(XeenEngine *vm);
|
||||
|
||||
@ -69,6 +96,8 @@ public:
|
||||
void doCombat();
|
||||
|
||||
void giveCharDamage(int damage, int v2, int v3);
|
||||
|
||||
void moveMonsters();
|
||||
};
|
||||
|
||||
} // End of namespace Xeen
|
||||
|
@ -1052,7 +1052,7 @@ int ItemsDialog::doItemOptions(Character &c, int actionIndex, int itemIndex, Ite
|
||||
}
|
||||
|
||||
intf._charsShooting = false;
|
||||
intf.moveMonsters();
|
||||
combat.moveMonsters();
|
||||
combat._whosTurn = -1;
|
||||
return true;
|
||||
}
|
||||
|
@ -142,7 +142,6 @@ Interface::Interface(XeenEngine *vm) : ButtonContainer(), InterfaceMap(vm),
|
||||
_upDoorText = false;
|
||||
_tillMove = 0;
|
||||
|
||||
Common::fill(&_combatCharIds[0], &_combatCharIds[8], 0);
|
||||
initDrawStructs();
|
||||
}
|
||||
|
||||
@ -244,6 +243,7 @@ void Interface::setMainButtons() {
|
||||
* be animated.
|
||||
*/
|
||||
void Interface::perform() {
|
||||
Combat &combat = *_vm->_combat;
|
||||
EventsManager &events = *_vm->_events;
|
||||
Map &map = *_vm->_map;
|
||||
Party &party = *_vm->_party;
|
||||
@ -314,7 +314,7 @@ void Interface::perform() {
|
||||
case Common::KEYCODE_w:
|
||||
// Wait one turn
|
||||
chargeStep();
|
||||
moveMonsters();
|
||||
combat.moveMonsters();
|
||||
_upDoorText = false;
|
||||
_flipDefaultGround = !_flipDefaultGround;
|
||||
_flipGround = !_flipGround;
|
||||
@ -456,7 +456,7 @@ void Interface::perform() {
|
||||
if (_buttonValue < (int)party._activeParty.size()) {
|
||||
CharacterInfo::show(_vm, _buttonValue);
|
||||
if (party._stepped)
|
||||
moveMonsters();
|
||||
combat.moveMonsters();
|
||||
}
|
||||
break;
|
||||
|
||||
@ -533,7 +533,7 @@ void Interface::chargeStep() {
|
||||
if (_vm->_party->_partyDead) {
|
||||
_vm->_party->changeTime(_vm->_map->_isOutdoors ? 10 : 1);
|
||||
if (!_tillMove) {
|
||||
moveMonsters();
|
||||
_vm->_combat->moveMonsters();
|
||||
}
|
||||
|
||||
_tillMove = 3;
|
||||
@ -1181,9 +1181,9 @@ void Interface::draw3d(bool updateFlag) {
|
||||
if (_flipUIFrame == 0)
|
||||
_flipWater = !_flipWater;
|
||||
if (_tillMove && (_vm->_mode == MODE_1 || _vm->_mode == MODE_COMBAT) &&
|
||||
!_flag1 && _vm->_moveMonsters) {
|
||||
!combat._monstersAttacking && _vm->_moveMonsters) {
|
||||
if (--_tillMove == 0)
|
||||
moveMonsters();
|
||||
combat.moveMonsters();
|
||||
}
|
||||
|
||||
// Draw the map
|
||||
@ -1213,8 +1213,8 @@ void Interface::draw3d(bool updateFlag) {
|
||||
|
||||
if (combat._attackMonsters[0] != -1 || combat._attackMonsters[1] != -1
|
||||
|| combat._attackMonsters[2] != -1) {
|
||||
if ((_vm->_mode == MODE_1 || _vm->_mode == MODE_SLEEPING) && !_flag1
|
||||
&& !_charsShooting && _vm->_moveMonsters) {
|
||||
if ((_vm->_mode == MODE_1 || _vm->_mode == MODE_SLEEPING) &&
|
||||
!combat._monstersAttacking && !_charsShooting && _vm->_moveMonsters) {
|
||||
combat.doCombat();
|
||||
if (scripts._eventSkipped)
|
||||
scripts.checkEvents();
|
||||
@ -1795,8 +1795,4 @@ void Interface::assembleBorder() {
|
||||
screen._windows[12].frame();
|
||||
}
|
||||
|
||||
void Interface::moveMonsters() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
} // End of namespace Xeen
|
||||
|
@ -69,7 +69,6 @@ private:
|
||||
SpriteResource _fecpSprites;
|
||||
SpriteResource _blessSprites;
|
||||
DrawStruct _mainList[16];
|
||||
int _combatCharIds[8];
|
||||
|
||||
bool _buttonsLoaded;
|
||||
int _steppingFX;
|
||||
@ -140,8 +139,6 @@ public:
|
||||
void draw3d(bool updateFlag);
|
||||
|
||||
void assembleBorder();
|
||||
|
||||
void moveMonsters();
|
||||
};
|
||||
|
||||
} // End of namespace Xeen
|
||||
|
@ -30,8 +30,8 @@ namespace Xeen {
|
||||
static bool debugFlag = false;
|
||||
|
||||
OutdoorDrawList::OutdoorDrawList() : _sky1(_data[0]), _sky2(_data[1]),
|
||||
_groundSprite(_data[2]), _combatImgs1(&_data[124]), _combatImgs2(&_data[95]),
|
||||
_combatImgs3(&_data[76]), _combatImgs4(&_data[53]), _groundTiles(&_data[3]) {
|
||||
_groundSprite(_data[2]), _attackImgs1(&_data[124]), _attackImgs2(&_data[95]),
|
||||
_attackImgs3(&_data[76]), _attackImgs4(&_data[53]), _groundTiles(&_data[3]) {
|
||||
_data[0] = DrawStruct(0, 8, 8);
|
||||
_data[1] = DrawStruct(1, 8, 25);
|
||||
_data[2] = DrawStruct(0, 8, 67);
|
||||
@ -190,8 +190,8 @@ IndoorDrawList::IndoorDrawList() :
|
||||
_objects3(_data[127]), _objects4(_data[97]), _objects5(_data[98]),
|
||||
_objects6(_data[99]), _objects7(_data[55]), _objects8(_data[56]),
|
||||
_objects9(_data[58]), _objects10(_data[57]), _objects11(_data[59]),
|
||||
_combatImgs1(&_data[162]), _combatImgs2(&_data[135]),
|
||||
_combatImgs3(&_data[111]), _combatImgs4(&_data[79]) {
|
||||
_attackImgs1(&_data[162]), _attackImgs2(&_data[135]),
|
||||
_attackImgs3(&_data[111]), _attackImgs4(&_data[79]) {
|
||||
// Setup draw structure positions
|
||||
_data[0] = DrawStruct(0, 8, 8);
|
||||
_data[1] = DrawStruct(1, 8, 25);
|
||||
@ -375,13 +375,12 @@ InterfaceMap::InterfaceMap(XeenEngine *vm): _vm(vm) {
|
||||
_flipGround = false;
|
||||
_flipSky = false;
|
||||
_flipDefaultGround = false;
|
||||
_isShooting = false;
|
||||
_isAttacking = false;
|
||||
_charsShooting = false;
|
||||
_objNumber = 0;
|
||||
_combatFloatCounter = 0;
|
||||
_thinWall = false;
|
||||
_isAnimReset = false;
|
||||
_flag1 = false;
|
||||
_overallFrame = 0;
|
||||
_openDoor = false;
|
||||
}
|
||||
@ -430,27 +429,27 @@ void InterfaceMap::drawMap() {
|
||||
for (int idx = 0; idx < 44; ++idx)
|
||||
_outdoorList[OUTDOOR_DRAWSTRCT_INDEXES[idx]]._frame = -1;
|
||||
|
||||
if (_flag1) {
|
||||
if (combat._monstersAttacking) {
|
||||
for (int idx = 0; idx < 8; ++idx) {
|
||||
if (_outdoorList._combatImgs4[idx]._sprites)
|
||||
_outdoorList._combatImgs4[idx]._frame = 0;
|
||||
else if (_outdoorList._combatImgs3[idx]._sprites)
|
||||
_outdoorList._combatImgs3[idx]._frame = 1;
|
||||
else if (_outdoorList._combatImgs2[idx]._sprites)
|
||||
_outdoorList._combatImgs2[idx]._frame = 2;
|
||||
else if (_outdoorList._combatImgs1[idx]._sprites)
|
||||
_outdoorList._combatImgs1[idx]._frame = 0;
|
||||
if (_outdoorList._attackImgs4[idx]._sprites)
|
||||
_outdoorList._attackImgs4[idx]._frame = 0;
|
||||
else if (_outdoorList._attackImgs3[idx]._sprites)
|
||||
_outdoorList._attackImgs3[idx]._frame = 1;
|
||||
else if (_outdoorList._attackImgs2[idx]._sprites)
|
||||
_outdoorList._attackImgs2[idx]._frame = 2;
|
||||
else if (_outdoorList._attackImgs1[idx]._sprites)
|
||||
_outdoorList._attackImgs1[idx]._frame = 0;
|
||||
}
|
||||
} else if (_charsShooting) {
|
||||
for (int idx = 0; idx < 8; ++idx) {
|
||||
if (_outdoorList._combatImgs1[idx]._sprites)
|
||||
_outdoorList._combatImgs1[idx]._frame = 0;
|
||||
else if (_outdoorList._combatImgs2[idx]._sprites)
|
||||
_outdoorList._combatImgs2[idx]._frame = 1;
|
||||
else if (_outdoorList._combatImgs3[idx]._sprites)
|
||||
_outdoorList._combatImgs3[idx]._frame = 2;
|
||||
else if (_outdoorList._combatImgs4[idx]._sprites)
|
||||
_outdoorList._combatImgs1[idx]._frame = 0;
|
||||
if (_outdoorList._attackImgs1[idx]._sprites)
|
||||
_outdoorList._attackImgs1[idx]._frame = 0;
|
||||
else if (_outdoorList._attackImgs2[idx]._sprites)
|
||||
_outdoorList._attackImgs2[idx]._frame = 1;
|
||||
else if (_outdoorList._attackImgs3[idx]._sprites)
|
||||
_outdoorList._attackImgs3[idx]._frame = 2;
|
||||
else if (_outdoorList._attackImgs4[idx]._sprites)
|
||||
_outdoorList._attackImgs1[idx]._frame = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -557,7 +556,7 @@ void InterfaceMap::drawMap() {
|
||||
for (int idx = 3; idx < _indoorList.size(); ++idx)
|
||||
_indoorList[idx]._frame = -1;
|
||||
|
||||
if (_flag1) {
|
||||
if (combat._monstersAttacking) {
|
||||
for (int idx = 0; idx < 96; ++idx) {
|
||||
if (_indoorList[79 + idx]._sprites != nullptr) {
|
||||
_indoorList[79 + idx]._frame = 0;
|
||||
@ -762,12 +761,12 @@ void InterfaceMap::animate3d() {
|
||||
}
|
||||
}
|
||||
|
||||
DrawStruct *combatImgs1 = map._isOutdoors ? _outdoorList._combatImgs1 : _indoorList._combatImgs1;
|
||||
DrawStruct *combatImgs2 = map._isOutdoors ? _outdoorList._combatImgs2 : _indoorList._combatImgs2;
|
||||
DrawStruct *combatImgs3 = map._isOutdoors ? _outdoorList._combatImgs3 : _indoorList._combatImgs3;
|
||||
DrawStruct *combatImgs4 = map._isOutdoors ? _outdoorList._combatImgs4 : _indoorList._combatImgs4;
|
||||
DrawStruct *combatImgs1 = map._isOutdoors ? _outdoorList._attackImgs1 : _indoorList._attackImgs1;
|
||||
DrawStruct *combatImgs2 = map._isOutdoors ? _outdoorList._attackImgs2 : _indoorList._attackImgs2;
|
||||
DrawStruct *combatImgs3 = map._isOutdoors ? _outdoorList._attackImgs3 : _indoorList._attackImgs3;
|
||||
DrawStruct *combatImgs4 = map._isOutdoors ? _outdoorList._attackImgs4 : _indoorList._attackImgs4;
|
||||
|
||||
if (_flag1) {
|
||||
if (combat._monstersAttacking) {
|
||||
for (int idx = 0; idx < 8; ++idx) {
|
||||
if (combatImgs1[idx]._sprites) {
|
||||
combatImgs1[idx]._sprites = nullptr;
|
||||
@ -4326,13 +4325,13 @@ void InterfaceMap::drawIndoors() {
|
||||
_vm->_screen->_windows[3].drawList(&_indoorList[0], _indoorList.size());
|
||||
|
||||
// Check for any character shooting
|
||||
_isShooting = false;
|
||||
_isAttacking = false;
|
||||
for (uint idx = 0; idx < _vm->_party->_activeParty.size(); ++idx) {
|
||||
if (_vm->_combat->_shooting[idx])
|
||||
_isShooting = true;
|
||||
_isAttacking = true;
|
||||
}
|
||||
|
||||
_charsShooting = _isShooting;
|
||||
_charsShooting = _isAttacking;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4404,13 +4403,13 @@ void InterfaceMap::drawOutdoors() {
|
||||
screen._windows[3].drawList(&_outdoorList[0], _outdoorList.size());
|
||||
|
||||
// Check for any character shooting
|
||||
_isShooting = false;
|
||||
_isAttacking = false;
|
||||
for (uint idx = 0; idx < _vm->_party->_activeParty.size(); ++idx) {
|
||||
if (_vm->_combat->_shooting[idx])
|
||||
_isShooting = true;
|
||||
_isAttacking = true;
|
||||
}
|
||||
|
||||
_charsShooting = _isShooting;
|
||||
_charsShooting = _isAttacking;
|
||||
}
|
||||
|
||||
} // End of namespace Xeen
|
||||
|
@ -37,10 +37,10 @@ public:
|
||||
DrawStruct &_sky1, &_sky2;
|
||||
DrawStruct &_groundSprite;
|
||||
DrawStruct * const _groundTiles;
|
||||
DrawStruct * const _combatImgs1;
|
||||
DrawStruct * const _combatImgs2;
|
||||
DrawStruct * const _combatImgs3;
|
||||
DrawStruct * const _combatImgs4;
|
||||
DrawStruct * const _attackImgs1;
|
||||
DrawStruct * const _attackImgs2;
|
||||
DrawStruct * const _attackImgs3;
|
||||
DrawStruct * const _attackImgs4;
|
||||
public:
|
||||
OutdoorDrawList();
|
||||
|
||||
@ -73,10 +73,10 @@ public:
|
||||
DrawStruct &_objects0, &_objects1, &_objects2, &_objects3;
|
||||
DrawStruct &_objects4, &_objects5, &_objects6, &_objects7;
|
||||
DrawStruct &_objects8, &_objects9, &_objects10, &_objects11;
|
||||
DrawStruct * const _combatImgs1;
|
||||
DrawStruct * const _combatImgs2;
|
||||
DrawStruct * const _combatImgs3;
|
||||
DrawStruct * const _combatImgs4;
|
||||
DrawStruct * const _attackImgs1;
|
||||
DrawStruct * const _attackImgs2;
|
||||
DrawStruct * const _attackImgs3;
|
||||
DrawStruct * const _attackImgs4;
|
||||
public:
|
||||
IndoorDrawList();
|
||||
|
||||
@ -104,10 +104,8 @@ protected:
|
||||
bool _flipGround;
|
||||
bool _flipSky;
|
||||
bool _flipDefaultGround;
|
||||
bool _isShooting;
|
||||
bool _thinWall;
|
||||
bool _isAnimReset;
|
||||
bool _flag1;
|
||||
|
||||
void setMazeBits();
|
||||
|
||||
@ -122,6 +120,7 @@ public:
|
||||
int _overallFrame;
|
||||
bool _charsShooting;
|
||||
bool _openDoor;
|
||||
bool _isAttacking;
|
||||
public:
|
||||
InterfaceMap(XeenEngine *vm);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user