diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/wage/combat.cpp | 60 | ||||
-rw-r--r-- | engines/wage/wage.cpp | 1 | ||||
-rw-r--r-- | engines/wage/wage.h | 3 |
3 files changed, 63 insertions, 1 deletions
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp index be765a8488..5a9426c9c2 100644 --- a/engines/wage/combat.cpp +++ b/engines/wage/combat.cpp @@ -177,8 +177,66 @@ void WageEngine::performCombatAction(Chr *npc, Chr *player) { delete magics; } +const char *targets[] = { "head", "chest", "side" }; + void WageEngine::performAttack(Chr *attacker, Chr *victim, Obj *weapon) { - warning("STUB: performAttack()"); + if (_world->_weaponMenuDisabled) + return; + + // TODO: verify that a player not aiming will always target the chest?? + int targetIndex = -1; + char buf[256]; + + if (weapon->_type != Obj::MAGICAL_OBJECT) { + if (attacker->_playerCharacter) { + targetIndex = _aim; + } else { + targetIndex = _rnd->getRandomNumber(ARRAYSIZE(targets) - 1); + _opponentAim = targetIndex + 1; + } + + if (!attacker->_playerCharacter) { + snprintf(buf, 256, "%s%s %ss %s%s at %s%s's %s.", + attacker->getDefiniteArticle(true), attacker->_name.c_str(), + weapon->_operativeVerb.c_str(), + prependGenderSpecificPronoun(attacker->_gender), weapon->_name.c_str(), + victim->getDefiniteArticle(true), victim->_name.c_str(), + targets[targetIndex]); + appendText(buf); + } + } else if (!attacker->_playerCharacter) { + snprintf(buf, 256, "%s%s %ss %s%s at %s%s.", + attacker->getDefiniteArticle(true), attacker->_name.c_str(), + weapon->_operativeVerb.c_str(), + prependGenderSpecificPronoun(attacker->_gender), weapon->_name.c_str(), + victim->getDefiniteArticle(true), victim->_name.c_str()); + appendText(buf); + } + + playSound(weapon->_sound); + + bool usesDecremented = false; + int chance = _rnd->getRandomNumber(255); + // TODO: what about obj accuracy + if (chance < attacker->_physicalAccuracy) { + usesDecremented = attackHit(attacker, victim, weapon, targetIndex); + } else if (weapon->_type != Obj::MAGICAL_OBJECT) { + appendText((char *)"A miss!"); + } else if (attacker->_playerCharacter) { + appendText((char *)"The spell has no effect."); + } + + if (!usesDecremented) { + decrementUses(weapon); + } +} + +void WageEngine::decrementUses(Obj *obj) { + warning("STUB: decrementUses()"); +} + +bool WageEngine::attackHit(Chr *attacker, Chr *victim, Obj *weapon, int targetIndex) { + warning("STUB: attackHit"); } void WageEngine::performMagic(Chr *attacker, Chr *victim, Obj *magicalObject) { diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp index 620f1b5bb9..7815ee0e06 100644 --- a/engines/wage/wage.cpp +++ b/engines/wage/wage.cpp @@ -64,6 +64,7 @@ WageEngine::WageEngine(OSystem *syst, const ADGameDescription *desc) : Engine(sy _rnd = new Common::RandomSource("wage"); _aim = -1; + _opponentAim = -1; _temporarilyHidden = false; _isGameOver = false; _monster = NULL; diff --git a/engines/wage/wage.h b/engines/wage/wage.h index fa52c2440e..1a0fe765b0 100644 --- a/engines/wage/wage.h +++ b/engines/wage/wage.h @@ -135,6 +135,8 @@ private: void performMove(Chr *chr, int validMoves); void performOffer(Chr *attacker, Chr *victim); void performTake(Chr *npc, Obj *obj); + void decrementUses(Obj *obj); + bool attackHit(Chr *attacker, Chr *victim, Obj *weapon, int targetIndex); void doClose(); @@ -151,6 +153,7 @@ public: Chr *_running; Obj *_offer; int _aim; + int _opponentAim; bool _temporarilyHidden; bool _isGameOver; bool _commandWasQuick; |