From 8fcc1911d98dbd4d041418591592cad2c7998ca5 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 10 Jun 2016 23:29:41 +0200 Subject: [PATCH] Use fCombatDistance as the creature attack range --- apps/openmw/mwclass/creature.cpp | 9 +++------ apps/openmw/mwmechanics/aicombat.cpp | 5 +++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 182177d52..c111fce36 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -242,13 +242,10 @@ namespace MWClass MWMechanics::applyFatigueLoss(ptr, weapon, attackStrength); - // TODO: where is the distance defined? - float dist = 200.f; + float dist = gmst.find("fCombatDistance")->getFloat(); if (!weapon.isEmpty()) - { - const float fCombatDistance = gmst.find("fCombatDistance")->getFloat(); - dist = fCombatDistance * weapon.get()->mBase->mData.mReach; - } + dist *= weapon.get()->mBase->mData.mReach; + std::pair result = MWBase::Environment::get().getWorld()->getHitContact(ptr, dist); if (result.first.isEmpty()) return; // Didn't hit anything diff --git a/apps/openmw/mwmechanics/aicombat.cpp b/apps/openmw/mwmechanics/aicombat.cpp index b1821d64a..196ef1c3f 100644 --- a/apps/openmw/mwmechanics/aicombat.cpp +++ b/apps/openmw/mwmechanics/aicombat.cpp @@ -261,6 +261,7 @@ namespace MWMechanics // Get weapon characteristics MWBase::World* world = MWBase::Environment::get().getWorld(); + static const float fCombatDistance = world->getStore().get().find("fCombatDistance")->getFloat(); if (actorClass.hasInventoryStore(actor)) { //Get weapon range @@ -279,12 +280,12 @@ namespace MWMechanics weapon = weaponSlot->get()->mBase; weapRange = weapon->mData.mReach; } - weapRange *= 100.0f; + weapRange *= fCombatDistance; } else //is creature { weaptype = actorClass.getCreatureStats(actor).getDrawState() == DrawState_Spell ? WeapType_Spell : WeapType_HandToHand; - weapRange = 150.0f; //TODO: use true attack range (the same problem in Creature::hit) + weapRange = fCombatDistance; } bool distantCombat = false;