From b378709478fc689de8a1a0b455deb12e6aee5fb2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 28 Feb 2015 13:00:35 -0500 Subject: XEEN: Implement shoot action --- engines/xeen/combat.cpp | 9 +++++++++ engines/xeen/combat.h | 2 ++ engines/xeen/interface.cpp | 25 +++++++++++++++++++++++++ engines/xeen/party.cpp | 9 +++++++++ engines/xeen/party.h | 2 ++ 5 files changed, 47 insertions(+) (limited to 'engines') diff --git a/engines/xeen/combat.cpp b/engines/xeen/combat.cpp index 763daa7d03..74e098cdd4 100644 --- a/engines/xeen/combat.cpp +++ b/engines/xeen/combat.cpp @@ -2083,4 +2083,13 @@ done: party.giveTreasure(); } +/** + * Fires off a ranged attack at all oncoming monsters + */ +void Combat::shootRangedWeapon() { + _rangeType = RT_ALL; + _damageType = DT_PHYSICAL; + multiAttack(11); +} + } // End of namespace Xeen diff --git a/engines/xeen/combat.h b/engines/xeen/combat.h index 9831f90f25..cff9261b05 100644 --- a/engines/xeen/combat.h +++ b/engines/xeen/combat.h @@ -172,6 +172,8 @@ public: int stopAttack(const Common::Point &diffPt); void multiAttack(int powNum); + + void shootRangedWeapon(); }; } // End of namespace Xeen diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp index 7339e1014f..cc027b8676 100644 --- a/engines/xeen/interface.cpp +++ b/engines/xeen/interface.cpp @@ -268,6 +268,7 @@ void Interface::perform() { Map &map = *_vm->_map; Party &party = *_vm->_party; Scripts &scripts = *_vm->_scripts; + SoundManager &sound = *_vm->_sound; Spells &spells = *_vm->_spells; const Common::Rect WAIT_BOUNDS(8, 8, 224, 140); @@ -571,6 +572,30 @@ void Interface::perform() { rest(); break; + case Common::KEYCODE_s: + // Shoot + if (!party.canShoot()) { + sound.playFX(21); + } else { + if (_tillMove) { + combat.moveMonsters(); + draw3d(true); + } + + if (combat._attackMonsters[0] != -1 || combat._attackMonsters[1] != -1 + || combat._attackMonsters[2] != -1) { + if ((_vm->_mode == MODE_1 || _vm->_mode == MODE_SLEEPING) + && !combat._monstersAttacking && !_charsShooting) { + doCombat(); + } + } + + combat.shootRangedWeapon(); + chargeStep(); + doStepCode(); + } + break; + case Common::KEYCODE_v: // Show the quests dialog Quests::show(_vm); diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp index 268dfcce15..5e111e61b4 100644 --- a/engines/xeen/party.cpp +++ b/engines/xeen/party.cpp @@ -735,4 +735,13 @@ void Party::giveTreasureToCharacter(Character &c, ItemCategory category, int ite events.ipause(5); } +bool Party::canShoot() const { + for (uint idx = 0; idx < _activeParty.size(); ++idx) { + if (_activeParty[idx].hasMissileWeapon()) + return true; + } + + return false; +} + } // End of namespace Xeen diff --git a/engines/xeen/party.h b/engines/xeen/party.h index b5e31f9405..483c3f43ec 100644 --- a/engines/xeen/party.h +++ b/engines/xeen/party.h @@ -173,6 +173,8 @@ public: void giveTreasure(); bool arePacksFull() const; + + bool canShoot() const; }; } // End of namespace Xeen -- cgit v1.2.3