Skip to content

Commit

Permalink
XEEN: Implemented startFalling
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Feb 15, 2015
1 parent a90ad5b commit 74b4d91
Show file tree
Hide file tree
Showing 9 changed files with 249 additions and 16 deletions.
4 changes: 4 additions & 0 deletions engines/xeen/combat.cpp
Expand Up @@ -47,5 +47,9 @@ void Combat::doCombat() {
error("TODO: doCombat");
}

void Combat::giveCharDamage(int damage, int v2, int v3) {
error("TODO: giveCharDamage");
}


} // End of namespace Xeen
2 changes: 2 additions & 0 deletions engines/xeen/combat.h
Expand Up @@ -67,6 +67,8 @@ class Combat {
void clear();

void doCombat();

void giveCharDamage(int damage, int v2, int v3);
};

} // End of namespace Xeen
Expand Down
247 changes: 236 additions & 11 deletions engines/xeen/interface.cpp
Expand Up @@ -569,7 +569,7 @@ void Interface::doStepCode() {
// We can fly, we can.. oh wait, we can't!
damage = 100;
party._damageType = DT_PHYSICAL;
party._falling = true;
_falling = true;
break;
case SURFTYPE_DESERT:
// Without navigation skills, simulate getting lost by adding extra time
Expand All @@ -579,7 +579,7 @@ void Interface::doStepCode() {
case SURFTYPE_CLOUD:
if (!party._levitateActive) {
party._damageType = DT_PHYSICAL;
party._falling = true;
_falling = true;
damage = 100;
}
break;
Expand All @@ -588,10 +588,10 @@ void Interface::doStepCode() {
}

if (_vm->_files->_isDarkCc && party._gameFlags[374]) {
party._falling = false;
_falling = false;
} else {
if (party._falling)
doFalling();
if (_falling)
startFalling(false);

if ((party._mazePosition.x & 16) || (party._mazePosition.y & 16)) {
if (map._isOutdoors)
Expand All @@ -611,17 +611,233 @@ void Interface::doStepCode() {
}
}

void Interface::doFalling() {
// TODO
/**
* Start the party falling
*/
void Interface::startFalling(bool flag) {
Combat &combat = *_vm->_combat;
Map &map = *_vm->_map;
Party &party = *_vm->_party;
Scripts &scripts = *_vm->_scripts;
bool isDarkCc = _vm->_files->_isDarkCc;

if (isDarkCc && party._gameFlags[374]) {
_falling = 0;
return;
}

_falling = false;
draw3d(true);
_falling = 2;
draw3d(false);

if (flag) {
if (!isDarkCc || party._fallMaze != 0) {
party._mazeId = party._fallMaze;
party._mazePosition = party._fallPosition;
}
}

_falling = true;
map.load(party._mazeId);
if (flag) {
if (((party._mazePosition.x & 16) || (party._mazePosition.y & 16)) &&
map._isOutdoors) {
map.getNewMaze();
}
}

if (isDarkCc) {
switch (party._mazeId - 25) {
case 0:
case 26:
case 27:
case 28:
case 29:
party._mazeId = 24;
party._mazePosition = Common::Point(11, 9);
break;
case 1:
case 30:
case 31:
case 32:
case 33:
party._mazeId = 12;
party._mazePosition = Common::Point(6, 15);
break;
case 2:
case 34:
case 35:
case 36:
case 37:
case 51:
case 52:
case 53:
party._mazeId = 15;
party._mazePosition = Common::Point(4, 12);
party._mazeDirection = DIR_SOUTH;
break;
case 40:
case 41:
party._mazeId = 14;
party._mazePosition = Common::Point(8, 3);
break;
case 44:
case 45:
party._mazeId = 1;
party._mazePosition = Common::Point(8, 7);
party._mazeDirection = DIR_NORTH;
break;
case 49:
party._mazeId = 12;
party._mazePosition = Common::Point(11, 13);
party._mazeDirection = DIR_SOUTH;
break;
case 57:
case 58:
case 59:
party._mazeId = 5;
party._mazePosition = Common::Point(12, 7);
party._mazeDirection = DIR_NORTH;
break;
case 60:
party._mazeId = 6;
party._mazePosition = Common::Point(12, 3);
party._mazeDirection = DIR_NORTH;
break;
default:
party._mazeId = 23;
party._mazePosition = Common::Point(12, 10);
party._mazeDirection = DIR_NORTH;
break;
}
} else {
if (party._mazeId > 89 && party._mazeId < 113) {
party._mazeId += 168;
} else {
switch (party._mazeId - 25) {
case 0:
party._mazeId = 89;
party._mazePosition = Common::Point(2, 14);
break;
case 1:
party._mazeId = 109;
party._mazePosition = Common::Point(13, 14);
break;
case 2:
party._mazeId = 112;
party._mazePosition = Common::Point(13, 3);
break;
case 3:
party._mazeId = 92;
party._mazePosition = Common::Point(2, 3);
break;
case 12:
case 13:
party._mazeId = 14;
party._mazePosition = Common::Point(10, 2);
break;
case 16:
case 17:
case 18:
party._mazeId = 4;
party._mazePosition = Common::Point(5, 14);
break;
case 20:
case 21:
case 22:
party._mazeId = 21;
party._mazePosition = Common::Point(9, 11);
break;
case 24:
case 25:
case 26:
party._mazeId = 1;
party._mazePosition = Common::Point(10, 4);
break;
case 28:
case 29:
case 30:
case 31:
party._mazeId = 26;
party._mazePosition = Common::Point(12, 10);
break;
case 32:
case 33:
case 34:
case 35:
party._mazeId = 3;
party._mazePosition = Common::Point(4, 9);
break;
case 36:
case 37:
case 38:
case 39:
party._mazeId = 16;
party._mazePosition = Common::Point(2, 7);
break;
case 40:
case 41:
case 42:
case 43:
party._mazeId = 23;
party._mazePosition = Common::Point(10, 9);
break;
case 44:
case 45:
case 46:
case 47:
party._mazeId = 13;
party._mazePosition = Common::Point(2, 10);
break;
case 103:
case 104:
map._loadDarkSide = false;
party._mazeId = 8;
party._mazePosition = Common::Point(11, 15);
party._mazeDirection = DIR_NORTH;
break;
case 105:
party._mazeId = 24;
party._mazePosition = Common::Point(11, 9);
break;
case 106:
party._mazeId = 12;
party._mazePosition = Common::Point(6, 15);
break;
case 107:
party._mazeId = 15;
party._mazePosition = Common::Point(4, 12);
break;
default:
party._mazeId = 29;
party._mazePosition = Common::Point(25, 21);
party._mazeDirection = DIR_NORTH;
break;
}
}
}

_flipGround ^= 1;
draw3d(true);
int tempVal = scripts._v2;
scripts._v2 = 0;
combat.giveCharDamage(party._fallDamage, 0, 0);
scripts._v2 = tempVal;

_flipGround ^= 1;
}

/**
* Check movement in the given direction
*/
bool Interface::checkMoveDirection(int key) {
Map &map = *_vm->_map;
Party &party = *_vm->_party;
SoundManager &sound = *_vm->_sound;
Direction dir = party._mazeDirection;

switch (_buttonValue) {
switch (key) {
case (Common::KBD_CTRL << 16) | Common::KEYCODE_LEFT:
party._mazeDirection = (party._mazeDirection == DIR_NORTH) ? DIR_WEST :
(Direction)(party._mazeDirection - 1);
Expand Down Expand Up @@ -948,10 +1164,10 @@ void Interface::draw3d(bool updateFlag) {
// Draw the minimap
drawMiniMap();

if (party._falling == 1)
if (_falling == 1)
handleFalling();

if (party._falling == 2) {
if (_falling == 2) {
screen.saveBackground(1);
}

Expand Down Expand Up @@ -991,6 +1207,9 @@ void Interface::draw3d(bool updateFlag) {
events.wait(2);
}

/**
* Handle doing the falling
*/
void Interface::handleFalling() {
Party &party = *_vm->_party;
Screen &screen = *_vm->_screen;
Expand Down Expand Up @@ -1043,17 +1262,23 @@ void Interface::handleFalling() {
}

void Interface::saveFall() {

// TODO
}

void Interface::fall(int v) {

}

/**
* Shake the screen
*/
void Interface::shake(int time) {

}

/**
* Draw the minimap
*/
void Interface::drawMiniMap() {
Map &map = *_vm->_map;
Party &party = *_vm->_party;
Expand Down
3 changes: 2 additions & 1 deletion engines/xeen/interface.h
Expand Up @@ -98,6 +98,7 @@ class Interface: public ButtonContainer, public InterfaceMap, public PartyDrawer
public:
int _intrIndex1;
Common::String _interfaceText;
int _falling;
public:
Interface(XeenEngine *vm);

Expand All @@ -111,7 +112,7 @@ class Interface: public ButtonContainer, public InterfaceMap, public PartyDrawer

void mainIconsPrint();

void doFalling();
void startFalling(bool v);

void perform();

Expand Down
3 changes: 2 additions & 1 deletion engines/xeen/map.cpp
Expand Up @@ -886,11 +886,12 @@ Map::Map(XeenEngine *vm) : _vm(vm), _mobData(vm) {
}

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

if (_vm->_party->_falling) {
if (intf._falling) {
Window &w = screen._windows[9];
w.open();
w.writeString(OOPS);
Expand Down
1 change: 0 additions & 1 deletion engines/xeen/party.cpp
Expand Up @@ -111,7 +111,6 @@ Party::Party(XeenEngine *vm) {
_isNight = false;
_stepped = false;
_damageType = DT_PHYSICAL;
_falling = false;
_fallMaze = 0;
_fallDamage = 0;
_dead = false;
Expand Down
1 change: 0 additions & 1 deletion engines/xeen/party.h
Expand Up @@ -121,7 +121,6 @@ class Party {
bool _newDay;
bool _isNight;
bool _stepped;
int _falling;
Common::Point _fallPosition;
int _fallMaze;
int _fallDamage;
Expand Down
2 changes: 2 additions & 0 deletions engines/xeen/scripts.cpp
Expand Up @@ -804,10 +804,12 @@ void Scripts::cmdExchObj(Common::Array<byte> &params) {
}

void Scripts::cmdFallToMap(Common::Array<byte> &params) {
Interface &intf = *_vm->_interface;
Party &party = *_vm->_party;
party._fallMaze = params[0];
party._fallPosition = Common::Point(params[1], params[2]);
party._fallDamage = params[3];
intf.startFalling(true);

_lineNum = -1;
}
Expand Down

0 comments on commit 74b4d91

Please sign in to comment.