Skip to content

Commit

Permalink
XEEN: Added Combat class and further map loading sprite setting
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jan 14, 2015
1 parent 1a0a597 commit a856e58
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 10 deletions.
37 changes: 37 additions & 0 deletions engines/xeen/combat.cpp
@@ -0,0 +1,37 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* 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.
*
*/

#include "xeen/combat.h"
#include "common/algorithm.h"

namespace Xeen {

Combat::Combat(XeenEngine *vm): _vm(vm) {
_attackMon1 = _attackMon2 = _attackMon3 = 0;
Common::fill(&_charsArray1[0], &_charsArray1[12], 0);
Common::fill(&_monPow[0], &_monPow[12], 0);
Common::fill(&_monsterScale[0], &_monsterScale[12], 0);
Common::fill(&_elemPow[0], &_elemPow[12], 0);
Common::fill(&_elemScale[0], &_elemScale[12], 0);
}

} // End of namespace Xeen
48 changes: 48 additions & 0 deletions engines/xeen/combat.h
@@ -0,0 +1,48 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* 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.
*
*/

#ifndef XEEN_COMBAT_H
#define XEEN_COMBAT_H

#include "common/scummsys.h"

namespace Xeen {

class XeenEngine;

class Combat {
private:
XeenEngine *_vm;
public:
int _charsArray1[12];
bool _monPow[12];
int _monsterScale[12];
int _elemPow[12];
int _elemScale[12];
int _attackMon1, _attackMon2, _attackMon3;
public:
Combat(XeenEngine *vm);
};

} // End of namespace Xeen

#endif /* XEEN_COMBAT_H */
5 changes: 3 additions & 2 deletions engines/xeen/interface.h
Expand Up @@ -98,8 +98,6 @@ class Interface: public ButtonContainer {
SpriteResource *_partyFaces[MAX_ACTIVE_PARTY];
DrawStruct _faceDrawStructs[4];
DrawStruct _mainList[16];
OutdoorDrawList _outdoorList;
IndoorDrawList _indoorList;
int _combatCharIds[8];

int _batUIFrame;
Expand Down Expand Up @@ -166,6 +164,9 @@ class Interface: public ButtonContainer {
void setMazeBits();

void updateAutoMap();
public:
OutdoorDrawList _outdoorList;
IndoorDrawList _indoorList;
public:
Interface(XeenEngine *vm);

Expand Down
94 changes: 89 additions & 5 deletions engines/xeen/map.cpp
Expand Up @@ -22,6 +22,7 @@

#include "common/serializer.h"
#include "xeen/map.h"
#include "xeen/interface.h"
#include "xeen/resources.h"
#include "xeen/saves.h"
#include "xeen/screen.h"
Expand Down Expand Up @@ -866,6 +867,9 @@ Map::Map(XeenEngine *vm) : _vm(vm), _mobData(vm) {

void Map::load(int mapId) {
Screen &screen = *_vm->_screen;
IndoorDrawList &indoorList = _vm->_interface->_indoorList;
OutdoorDrawList &outdoorList = _vm->_interface->_outdoorList;

if (_vm->_falling) {
Window &w = screen._windows[9];
w.open();
Expand Down Expand Up @@ -1010,8 +1014,9 @@ void Map::load(int mapId) {
// TODO: Switch setting flags that don't seem to ever be used

// Reload the monster data for the main maze that we're loading
mapId = _vm->_party._mazeId;
Common::String filename = Common::String::format("maze%c%03d.mob",
(_vm->_party._mazeId >= 100) ? 'x' : '0', _vm->_party._mazeId);
(mapId >= 100) ? 'x' : '0', mapId);
File mobFile(filename, *_vm->_saves);
XeenSerializer sMob(&mobFile, nullptr);
_mobData.synchronize(sMob, _monsterData);
Expand All @@ -1020,9 +1025,9 @@ void Map::load(int mapId) {
// Load sprites for the objects
for (uint i = 0; i < _mobData._objectSprites.size(); ++i) {
if (_vm->_party._cloudsEnd && _mobData._objectSprites[i]._spriteId == 85 &&
_vm->_party._mazeId == 27 && isDarkCc) {
mapId == 27 && isDarkCc) {
// TODO: Flags set that don't seem to be used
} else if (_vm->_party._mazeId == 12 && _vm->_party._gameFlags[43] &&
} else if (mapId == 12 && _vm->_party._gameFlags[43] &&
_mobData._objectSprites[i]._spriteId == 118 && !isDarkCc) {
filename = "085.obj";
_mobData._objectSprites[0]._spriteId = 85;
Expand Down Expand Up @@ -1053,7 +1058,25 @@ void Map::load(int mapId) {

// Handle loading miscellaneous sprites for the map
if (_isOutdoors) {
warning("TODO");
warning("TODO"); // Sound loading

_skySprites.load(isDarkCc ? "sky.sky" : "night.sky");
_groundSprites.load("water.out");
_tileSprites.load("outdoor.til");
outdoorList._skySprite._sprites = &_skySprites;
outdoorList._groundSprite._sprites = &_groundSprites;

for (int i = 0; i < TOTAL_SURFACES; ++i) {
_wallSprites._surfaces[i].clear();
if (_mazeData[0]._wallTypes[i] != 0) {
_wallSprites._surfaces[i].load(Common::String::format("%s.wal",
SURFACE_TYPE_NAMES[i]));
}

_surfaceSprites[i].clear();
if (i != 0 && _mazeData[0]._wallTypes[i] != 0)
_surfaceSprites[i].load(OUTDOOR_SURFACES[_mazeData[0]._surfaceTypes[i]]);
}
} else {
warning("TODO"); // Sound loading

Expand All @@ -1072,7 +1095,7 @@ void Map::load(int mapId) {
_surfaceSprites[i].load(OUTDOOR_SURFACES[i]);
}

_wallSprites._wal.clear();
_wallSprites._surfaces[0].clear();
Common::String fwlName = Common::String::format("%s.til",
TERRAIN_TYPES[_mazeData[0]._wallKind]);
_wallSprites._fwl1.load(fwlName);
Expand All @@ -1082,7 +1105,68 @@ void Map::load(int mapId) {
_wallSprites._swl.load(Common::String::format("s%s.swl",
TERRAIN_TYPES[_mazeData[0]._wallKind]));

// Set entries in the indoor draw list to the correct sprites
// for drawing various parts of the background
indoorList._swl_0F1R._sprites = &_wallSprites._swl;
indoorList._swl_0F1L._sprites = &_wallSprites._swl;
indoorList._swl_1F1R._sprites = &_wallSprites._swl;
indoorList._swl_1F1L._sprites = &_wallSprites._swl;
indoorList._swl_2F2R._sprites = &_wallSprites._swl;
indoorList._swl_2F1R._sprites = &_wallSprites._swl;
indoorList._swl_2F1L._sprites = &_wallSprites._swl;
indoorList._swl_2F2L._sprites = &_wallSprites._swl;

indoorList._swl_3F1R._sprites = &_wallSprites._swl;
indoorList._swl_3F2R._sprites = &_wallSprites._swl;
indoorList._swl_3F3R._sprites = &_wallSprites._swl;
indoorList._swl_3F4R._sprites = &_wallSprites._swl;
indoorList._swl_3F1L._sprites = &_wallSprites._swl;
indoorList._swl_3F2L._sprites = &_wallSprites._swl;
indoorList._swl_3F3L._sprites = &_wallSprites._swl;
indoorList._swl_3F4L._sprites = &_wallSprites._swl;

indoorList._swl_4F4R._sprites = &_wallSprites._swl;
indoorList._swl_4F3R._sprites = &_wallSprites._swl;
indoorList._swl_4F2R._sprites = &_wallSprites._swl;
indoorList._swl_4F1R._sprites = &_wallSprites._swl;
indoorList._swl_4F1L._sprites = &_wallSprites._swl;
indoorList._swl_4F2L._sprites = &_wallSprites._swl;
indoorList._swl_4F3L._sprites = &_wallSprites._swl;
indoorList._swl_4F4L._sprites = &_wallSprites._swl;

indoorList._fwl_4F4R._sprites = &_wallSprites._fwl4;
indoorList._fwl_4F3R._sprites = &_wallSprites._fwl4;
indoorList._fwl_4F2R._sprites = &_wallSprites._fwl4;
indoorList._fwl_4F1R._sprites = &_wallSprites._fwl4;
indoorList._fwl_4F._sprites = &_wallSprites._fwl4;
indoorList._fwl_4F1L._sprites = &_wallSprites._fwl4;
indoorList._fwl_4F2L._sprites = &_wallSprites._fwl4;
indoorList._fwl_4F3L._sprites = &_wallSprites._fwl4;
indoorList._fwl_4F4L._sprites = &_wallSprites._fwl4;

indoorList._fwl_2F1R._sprites = &_wallSprites._fwl3;
indoorList._fwl_2F._sprites = &_wallSprites._fwl3;
indoorList._fwl_2F1L._sprites = &_wallSprites._fwl3;
indoorList._fwl_3F2R._sprites = &_wallSprites._fwl3;
indoorList._fwl_3F1R._sprites = &_wallSprites._fwl3;
indoorList._fwl_3F._sprites = &_wallSprites._fwl3;
indoorList._fwl_3F1L._sprites = &_wallSprites._fwl3;
indoorList._fwl_3F2L._sprites = &_wallSprites._fwl3;

indoorList._fwl_1F._sprites = &_wallSprites._fwl1;
indoorList._fwl_1F1R._sprites = &_wallSprites._fwl1;
indoorList._fwl_1F1L._sprites = &_wallSprites._fwl1;

indoorList._horizon._sprites = &_groundSprites;

// Down show horizon for certain maps
if (_vm->_files->_isDarkCc) {
if ((mapId >= 89 && mapId <= 112) || mapId == 128 || mapId == 129)
indoorList._horizon._sprites = nullptr;
} else {
if (mapId >= 25 && mapId <= 27)
indoorList._horizon._sprites = nullptr;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion engines/xeen/map.h
Expand Up @@ -271,7 +271,7 @@ class MazeWallItem {
};

struct WallSprites {
SpriteResource _wal;
SpriteResource _surfaces[TOTAL_SURFACES];
SpriteResource _fwl1;
SpriteResource _fwl2;
SpriteResource _fwl3;
Expand Down
2 changes: 1 addition & 1 deletion engines/xeen/resources.cpp
Expand Up @@ -70,7 +70,7 @@ const char *const TERRAIN_TYPES[6] = {
"town", "cave", "towr", "cstl", "dung", "scfi"
};

const char *const OUTDOOR_WALLS[15] = {
const char *const SURFACE_TYPE_NAMES[15] = {
nullptr, "mount", "ltree", "dtree", "grass", "snotree", "snomnt",
"dedltree", "mount", "lavamnt", "palm", "dmount", "dedltree",
"dedltree", "dedltree"
Expand Down
2 changes: 1 addition & 1 deletion engines/xeen/resources.h
Expand Up @@ -34,7 +34,7 @@ extern const char *const OPTIONS_TITLE;

extern const char *const TERRAIN_TYPES[6];

extern const char *const OUTDOOR_WALLS[15];
extern const char *const SURFACE_TYPE_NAMES[15];

extern const char *const OUTDOOR_SURFACES[16];

Expand Down

0 comments on commit a856e58

Please sign in to comment.