diff --git a/apps/openmw/mwmechanics/combat.cpp b/apps/openmw/mwmechanics/combat.cpp index b013dbb1b..27ef1a00f 100644 --- a/apps/openmw/mwmechanics/combat.cpp +++ b/apps/openmw/mwmechanics/combat.cpp @@ -166,13 +166,11 @@ namespace MWMechanics } void projectileHit(const MWWorld::Ptr &attacker, const MWWorld::Ptr &victim, MWWorld::Ptr weapon, const MWWorld::Ptr &projectile, - const osg::Vec3f& hitPosition) + const osg::Vec3f& hitPosition, float attackStrength) { MWBase::World *world = MWBase::Environment::get().getWorld(); const MWWorld::Store &gmst = world->getStore().get(); - MWMechanics::CreatureStats& attackerStats = attacker.getClass().getCreatureStats(attacker); - if(victim.isEmpty() || !victim.getClass().isActor() || victim.getClass().getCreatureStats(victim).isDead()) // Can't hit non-actors or dead actors { @@ -199,12 +197,12 @@ namespace MWMechanics const unsigned char* attack = weapon.get()->mBase->mData.mChop; - float damage = attack[0] + ((attack[1]-attack[0])*attackerStats.getAttackStrength()); // Bow/crossbow damage + float damage = attack[0] + ((attack[1]-attack[0])*attackStrength); // Bow/crossbow damage // Arrow/bolt damage // NB in case of thrown weapons, we are applying the damage twice since projectile == weapon attack = projectile.get()->mBase->mData.mChop; - damage += attack[0] + ((attack[1]-attack[0])*attackerStats.getAttackStrength()); + damage += attack[0] + ((attack[1]-attack[0])*attackStrength); adjustWeaponDamage(damage, weapon, attacker); reduceWeaponCondition(damage, true, weapon, attacker); diff --git a/apps/openmw/mwmechanics/combat.hpp b/apps/openmw/mwmechanics/combat.hpp index 9412f62e7..1fabc5772 100644 --- a/apps/openmw/mwmechanics/combat.hpp +++ b/apps/openmw/mwmechanics/combat.hpp @@ -14,7 +14,7 @@ void resistNormalWeapon (const MWWorld::Ptr& actor, const MWWorld::Ptr& attacker /// @note for a thrown weapon, \a weapon == \a projectile, for bows/crossbows, \a projectile is the arrow/bolt /// @note \a victim may be empty (e.g. for a hit on terrain), a non-actor (environment objects) or an actor void projectileHit (const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim, MWWorld::Ptr weapon, const MWWorld::Ptr& projectile, - const osg::Vec3f& hitPosition); + const osg::Vec3f& hitPosition, float attackStrength); /// Get the chance (in percent) for \a attacker to successfully hit \a victim with a given weapon skill value float getHitChance (const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim, int skillValue); diff --git a/apps/openmw/mwworld/projectilemanager.cpp b/apps/openmw/mwworld/projectilemanager.cpp index d0a5de5b2..16e1f6f47 100644 --- a/apps/openmw/mwworld/projectilemanager.cpp +++ b/apps/openmw/mwworld/projectilemanager.cpp @@ -123,6 +123,7 @@ namespace MWWorld state.mVelocity = orient * osg::Vec3f(0,1,0) * speed; state.mId = projectile.getCellRef().getRefId(); state.mCasterHandle = actor; + state.mAttackStrength = actor.getClass().getCreatureStats(actor).getAttackStrength(); MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), projectile.getCellRef().getRefId()); MWWorld::Ptr ptr = ref.getPtr(); @@ -245,7 +246,7 @@ namespace MWWorld if (caster.isEmpty()) caster = result.mHitObject; - MWMechanics::projectileHit(caster, result.mHitObject, bow, projectileRef.getPtr(), result.mHitPos); + MWMechanics::projectileHit(caster, result.mHitObject, bow, projectileRef.getPtr(), result.mHitPos, it->mAttackStrength); mParent->removeChild(it->mNode); @@ -286,6 +287,7 @@ namespace MWWorld state.mBowId = it->mBowId; state.mVelocity = it->mVelocity; + state.mAttackStrength = it->mAttackStrength; state.save(writer); @@ -327,6 +329,7 @@ namespace MWWorld state.mBowId = esm.mBowId; state.mVelocity = esm.mVelocity; state.mId = esm.mId; + state.mAttackStrength = esm.mAttackStrength; std::string model; try diff --git a/apps/openmw/mwworld/projectilemanager.hpp b/apps/openmw/mwworld/projectilemanager.hpp index 68e408149..57a6fb6a5 100644 --- a/apps/openmw/mwworld/projectilemanager.hpp +++ b/apps/openmw/mwworld/projectilemanager.hpp @@ -108,6 +108,7 @@ namespace MWWorld std::string mBowId; osg::Vec3f mVelocity; + float mAttackStrength; }; std::vector mMagicBolts; diff --git a/components/esm/projectilestate.cpp b/components/esm/projectilestate.cpp index 85c00025b..70ae4c5ee 100644 --- a/components/esm/projectilestate.cpp +++ b/components/esm/projectilestate.cpp @@ -52,6 +52,7 @@ namespace ESM esm.writeHNString ("BOW_", mBowId); esm.writeHNT ("VEL_", mVelocity); + esm.writeHNT ("STR_", mAttackStrength); } void ProjectileState::load(ESMReader &esm) @@ -60,6 +61,9 @@ namespace ESM mBowId = esm.getHNString ("BOW_"); esm.getHNT (mVelocity, "VEL_"); + + mAttackStrength = 1.f; + esm.getHNOT(mAttackStrength, "STR_"); } } diff --git a/components/esm/projectilestate.hpp b/components/esm/projectilestate.hpp index 38429e459..3471fbfc7 100644 --- a/components/esm/projectilestate.hpp +++ b/components/esm/projectilestate.hpp @@ -45,6 +45,7 @@ namespace ESM { std::string mBowId; Vector3 mVelocity; + float mAttackStrength; void load (ESMReader &esm); void save (ESMWriter &esm) const;