Move attackStrength to the CharacterController, where it should have been to begin with

Only relevant for actors in active cells, so doesn't belong in CreatureStats. This change should slightly reduce the game's memory usage.
c++11
scrawl 10 years ago
parent beb1086260
commit 882e359008

@ -480,7 +480,7 @@ namespace MWBase
float speed, bool stack, const ESM::EffectList& effects,
const MWWorld::Ptr& caster, const std::string& sourceName, const osg::Vec3f& fallbackDirection) = 0;
virtual void launchProjectile (MWWorld::Ptr actor, MWWorld::Ptr projectile,
const osg::Vec3f& worldPos, const osg::Quat& orient, MWWorld::Ptr bow, float speed) = 0;
const osg::Vec3f& worldPos, const osg::Quat& orient, MWWorld::Ptr bow, float speed, float attackStrength) = 0;
virtual const std::vector<std::string>& getContentFiles() const = 0;

@ -209,7 +209,7 @@ namespace MWClass
}
void Creature::hit(const MWWorld::Ptr& ptr, int type) const
void Creature::hit(const MWWorld::Ptr& ptr, float attackStrength, int type) const
{
MWWorld::LiveCellRef<ESM::Creature> *ref =
ptr.get<ESM::Creature>();
@ -229,7 +229,7 @@ namespace MWClass
weapon = *weaponslot;
}
MWMechanics::applyFatigueLoss(ptr, weapon);
MWMechanics::applyFatigueLoss(ptr, weapon, attackStrength);
// TODO: where is the distance defined?
float dist = 200.f;
@ -276,7 +276,7 @@ namespace MWClass
break;
}
float damage = min + (max - min) * stats.getAttackStrength();
float damage = min + (max - min) * attackStrength;
bool healthdmg = true;
if (!weapon.isEmpty())
{
@ -289,7 +289,7 @@ namespace MWClass
attack = weapon.get<ESM::Weapon>()->mBase->mData.mThrust;
if(attack)
{
damage = attack[0] + ((attack[1]-attack[0])*stats.getAttackStrength());
damage = attack[0] + ((attack[1]-attack[0])*attackStrength);
MWMechanics::adjustWeaponDamage(damage, weapon, ptr);
MWMechanics::reduceWeaponCondition(damage, true, weapon, ptr);
}
@ -310,12 +310,12 @@ namespace MWClass
}
else if (isBipedal(ptr))
{
MWMechanics::getHandToHandDamage(ptr, victim, damage, healthdmg);
MWMechanics::getHandToHandDamage(ptr, victim, damage, healthdmg, attackStrength);
}
MWMechanics::applyElementalShields(ptr, victim);
if (MWMechanics::blockMeleeAttack(ptr, victim, weapon, damage))
if (MWMechanics::blockMeleeAttack(ptr, victim, weapon, damage, attackStrength))
damage = 0;
if (damage > 0)

@ -66,7 +66,7 @@ namespace MWClass
virtual MWMechanics::CreatureStats& getCreatureStats (const MWWorld::Ptr& ptr) const;
///< Return creature stats
virtual void hit(const MWWorld::Ptr& ptr, int type) const;
virtual void hit(const MWWorld::Ptr& ptr, float attackStrength, int type) const;
virtual void block(const MWWorld::Ptr &ptr) const;

@ -470,7 +470,7 @@ namespace MWClass
}
void Npc::hit(const MWWorld::Ptr& ptr, int type) const
void Npc::hit(const MWWorld::Ptr& ptr, float attackStrength, int type) const
{
MWBase::World *world = MWBase::Environment::get().getWorld();
@ -483,7 +483,7 @@ namespace MWClass
if(!weapon.isEmpty() && weapon.getTypeName() != typeid(ESM::Weapon).name())
weapon = MWWorld::Ptr();
MWMechanics::applyFatigueLoss(ptr, weapon);
MWMechanics::applyFatigueLoss(ptr, weapon, attackStrength);
const float fCombatDistance = store.find("fCombatDistance")->getFloat();
float dist = fCombatDistance * (!weapon.isEmpty() ?
@ -522,7 +522,6 @@ namespace MWClass
bool healthdmg;
float damage = 0.0f;
MWMechanics::NpcStats &stats = getNpcStats(ptr);
if(!weapon.isEmpty())
{
const unsigned char *attack = NULL;
@ -534,7 +533,7 @@ namespace MWClass
attack = weapon.get<ESM::Weapon>()->mBase->mData.mThrust;
if(attack)
{
damage = attack[0] + ((attack[1]-attack[0])*stats.getAttackStrength());
damage = attack[0] + ((attack[1]-attack[0])*attackStrength);
}
MWMechanics::adjustWeaponDamage(damage, weapon, ptr);
MWMechanics::reduceWeaponCondition(damage, true, weapon, ptr);
@ -542,7 +541,7 @@ namespace MWClass
}
else
{
MWMechanics::getHandToHandDamage(ptr, victim, damage, healthdmg);
MWMechanics::getHandToHandDamage(ptr, victim, damage, healthdmg, attackStrength);
}
if(ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
{
@ -579,7 +578,7 @@ namespace MWClass
MWMechanics::applyElementalShields(ptr, victim);
if (MWMechanics::blockMeleeAttack(ptr, victim, weapon, damage))
if (MWMechanics::blockMeleeAttack(ptr, victim, weapon, damage, attackStrength))
damage = 0;
if (healthdmg && damage > 0)

@ -81,7 +81,7 @@ namespace MWClass
virtual bool hasInventoryStore(const MWWorld::Ptr &ptr) const { return true; }
virtual void hit(const MWWorld::Ptr& ptr, int type) const;
virtual void hit(const MWWorld::Ptr& ptr, float attackStrength, int type) const;
virtual void onHit(const MWWorld::Ptr &ptr, float damage, bool ishealth, const MWWorld::Ptr &object, const MWWorld::Ptr &attacker, bool successful) const;

@ -649,6 +649,7 @@ CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Anim
, mUpperBodyState(UpperCharState_Nothing)
, mJumpState(JumpState_None)
, mWeaponType(WeapType_None)
, mAttackStrength(0.f)
, mSkipAnim(false)
, mSecondsOfSwimming(0)
, mSecondsOfRunning(0)
@ -782,21 +783,21 @@ void CharacterController::handleTextKey(const std::string &groupname, const std:
else if(evt.compare(off, len, "unequip detach") == 0)
mAnimation->showWeapons(false);
else if(evt.compare(off, len, "chop hit") == 0)
mPtr.getClass().hit(mPtr, ESM::Weapon::AT_Chop);
mPtr.getClass().hit(mPtr, mAttackStrength, ESM::Weapon::AT_Chop);
else if(evt.compare(off, len, "slash hit") == 0)
mPtr.getClass().hit(mPtr, ESM::Weapon::AT_Slash);
mPtr.getClass().hit(mPtr, mAttackStrength, ESM::Weapon::AT_Slash);
else if(evt.compare(off, len, "thrust hit") == 0)
mPtr.getClass().hit(mPtr, ESM::Weapon::AT_Thrust);
mPtr.getClass().hit(mPtr, mAttackStrength, ESM::Weapon::AT_Thrust);
else if(evt.compare(off, len, "hit") == 0)
{
if (groupname == "attack1")
mPtr.getClass().hit(mPtr, ESM::Weapon::AT_Chop);
mPtr.getClass().hit(mPtr, mAttackStrength, ESM::Weapon::AT_Chop);
else if (groupname == "attack2")
mPtr.getClass().hit(mPtr, ESM::Weapon::AT_Slash);
mPtr.getClass().hit(mPtr, mAttackStrength, ESM::Weapon::AT_Slash);
else if (groupname == "attack3")
mPtr.getClass().hit(mPtr, ESM::Weapon::AT_Thrust);
mPtr.getClass().hit(mPtr, mAttackStrength, ESM::Weapon::AT_Thrust);
else
mPtr.getClass().hit(mPtr);
mPtr.getClass().hit(mPtr, mAttackStrength);
}
else if (!groupname.empty() && groupname.compare(0, groupname.size()-1, "attack") == 0
&& evt.compare(off, len, "start") == 0)
@ -819,17 +820,17 @@ void CharacterController::handleTextKey(const std::string &groupname, const std:
if (!hasHitKey)
{
if (groupname == "attack1")
mPtr.getClass().hit(mPtr, ESM::Weapon::AT_Chop);
mPtr.getClass().hit(mPtr, mAttackStrength, ESM::Weapon::AT_Chop);
else if (groupname == "attack2")
mPtr.getClass().hit(mPtr, ESM::Weapon::AT_Slash);
mPtr.getClass().hit(mPtr, mAttackStrength, ESM::Weapon::AT_Slash);
else if (groupname == "attack3")
mPtr.getClass().hit(mPtr, ESM::Weapon::AT_Thrust);
mPtr.getClass().hit(mPtr, mAttackStrength, ESM::Weapon::AT_Thrust);
}
}
else if (evt.compare(off, len, "shoot attach") == 0)
mAnimation->attachArrow();
else if (evt.compare(off, len, "shoot release") == 0)
mAnimation->releaseArrow();
mAnimation->releaseArrow(mAttackStrength);
else if (evt.compare(off, len, "shoot follow attach") == 0)
mAnimation->attachArrow();
@ -992,7 +993,7 @@ bool CharacterController::updateCreatureState()
0.0f, 0);
mUpperBodyState = UpperCharState_StartToMinAttack;
stats.setAttackStrength(std::min(1.f, 0.1f + Misc::Rng::rollClosedProbability()));
mAttackStrength = std::min(1.f, 0.1f + Misc::Rng::rollClosedProbability());
}
}
@ -1294,7 +1295,7 @@ bool CharacterController::updateWeaponState()
sndMgr->playSound3D(mPtr, sound, 1.0f, 1.2f); //Strong attack
}
}
stats.setAttackStrength(attackStrength);
mAttackStrength = attackStrength;
mAnimation->disable(mCurrentWeapon);
mAnimation->play(mCurrentWeapon, Priority_Weapon,
@ -1418,7 +1419,7 @@ bool CharacterController::updateWeaponState()
}
else
{
float str = stats.getAttackStrength();
float str = mAttackStrength;
start = mAttackType+((str < 0.5f) ? " small follow start"
: (str < 1.0f) ? " medium follow start"
: " large follow start");

@ -167,6 +167,8 @@ class CharacterController : public MWRender::Animation::TextKeyListener
WeaponType mWeaponType;
std::string mCurrentWeapon;
float mAttackStrength;
bool mSkipAnim;
// counted for skill increase

@ -51,7 +51,7 @@ bool applyEnchantment (const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim,
namespace MWMechanics
{
bool blockMeleeAttack(const MWWorld::Ptr &attacker, const MWWorld::Ptr &blocker, const MWWorld::Ptr &weapon, float damage)
bool blockMeleeAttack(const MWWorld::Ptr &attacker, const MWWorld::Ptr &blocker, const MWWorld::Ptr &weapon, float damage, float attackStrength)
{
if (!blocker.getClass().hasInventoryStore(blocker))
return false;
@ -90,7 +90,7 @@ namespace MWMechanics
float blockTerm = blocker.getClass().getSkill(blocker, ESM::Skill::Block) + 0.2f * blockerStats.getAttribute(ESM::Attribute::Agility).getModified()
+ 0.1f * blockerStats.getAttribute(ESM::Attribute::Luck).getModified();
float enemySwing = attackerStats.getAttackStrength();
float enemySwing = attackStrength;
float swingTerm = enemySwing * gmst.find("fSwingBlockMult")->getFloat() + gmst.find("fSwingBlockBase")->getFloat();
float blockerTerm = blockTerm * swingTerm;
@ -131,7 +131,7 @@ namespace MWMechanics
normalizedEncumbrance = std::min(1.f, normalizedEncumbrance);
float fatigueLoss = fFatigueBlockBase + normalizedEncumbrance * fFatigueBlockMult;
if (!weapon.isEmpty())
fatigueLoss += weapon.getClass().getWeight(weapon) * attackerStats.getAttackStrength() * fWeaponFatigueBlockMult;
fatigueLoss += weapon.getClass().getWeight(weapon) * attackStrength * fWeaponFatigueBlockMult;
fatigue.setCurrent(fatigue.getCurrent() - fatigueLoss);
blockerStats.setFatigue(fatigue);
@ -363,7 +363,7 @@ namespace MWMechanics
(attacker.getClass().getCreatureStats(attacker).getAttribute(ESM::Attribute::Strength).getModified() * fDamageStrengthMult * 0.1f);
}
void getHandToHandDamage(const MWWorld::Ptr &attacker, const MWWorld::Ptr &victim, float &damage, bool &healthdmg)
void getHandToHandDamage(const MWWorld::Ptr &attacker, const MWWorld::Ptr &victim, float &damage, bool &healthdmg, float attackStrength)
{
// Note: MCP contains an option to include Strength in hand-to-hand damage
// calculations. Some mods recommend using it, so we may want to include an
@ -372,7 +372,7 @@ namespace MWMechanics
float minstrike = store.get<ESM::GameSetting>().find("fMinHandToHandMult")->getFloat();
float maxstrike = store.get<ESM::GameSetting>().find("fMaxHandToHandMult")->getFloat();
damage = static_cast<float>(attacker.getClass().getSkill(attacker, ESM::Skill::HandToHand));
damage *= minstrike + ((maxstrike-minstrike)*attacker.getClass().getCreatureStats(attacker).getAttackStrength());
damage *= minstrike + ((maxstrike-minstrike)*attackStrength);
MWMechanics::CreatureStats& otherstats = victim.getClass().getCreatureStats(victim);
healthdmg = (otherstats.getMagicEffects().get(ESM::MagicEffect::Paralyze).getMagnitude() > 0)
@ -398,7 +398,7 @@ namespace MWMechanics
sndMgr->playSound3D(victim, "Hand To Hand Hit", 1.0f, 1.0f);
}
void applyFatigueLoss(const MWWorld::Ptr &attacker, const MWWorld::Ptr &weapon)
void applyFatigueLoss(const MWWorld::Ptr &attacker, const MWWorld::Ptr &weapon, float attackStrength)
{
// somewhat of a guess, but using the weapon weight makes sense
const MWWorld::Store<ESM::GameSetting>& store = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
@ -410,7 +410,7 @@ namespace MWMechanics
const float normalizedEncumbrance = attacker.getClass().getNormalizedEncumbrance(attacker);
float fatigueLoss = fFatigueAttackBase + normalizedEncumbrance * fFatigueAttackMult;
if (!weapon.isEmpty())
fatigueLoss += weapon.getClass().getWeight(weapon) * stats.getAttackStrength() * fWeaponFatigueMult;
fatigueLoss += weapon.getClass().getWeight(weapon) * attackStrength * fWeaponFatigueMult;
fatigue.setCurrent(fatigue.getCurrent() - fatigueLoss);
stats.setFatigue(fatigue);
}

@ -7,7 +7,7 @@ namespace MWMechanics
{
/// @return can we block the attack?
bool blockMeleeAttack (const MWWorld::Ptr& attacker, const MWWorld::Ptr& blocker, const MWWorld::Ptr& weapon, float damage);
bool blockMeleeAttack (const MWWorld::Ptr& attacker, const MWWorld::Ptr& blocker, const MWWorld::Ptr& weapon, float damage, float attackStrength);
void resistNormalWeapon (const MWWorld::Ptr& actor, const MWWorld::Ptr& attacker, const MWWorld::Ptr& weapon, float& damage);
@ -31,10 +31,10 @@ void reduceWeaponCondition (float damage, bool hit, MWWorld::Ptr& weapon, const
/// Adjust weapon damage based on its condition. A used weapon will be less effective.
void adjustWeaponDamage (float& damage, const MWWorld::Ptr& weapon, const MWWorld::Ptr& attacker);
void getHandToHandDamage (const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim, float& damage, bool& healthdmg);
void getHandToHandDamage (const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim, float& damage, bool& healthdmg, float attackStrength);
/// Apply the fatigue loss incurred by attacking with the given weapon (weapon may be empty = hand-to-hand)
void applyFatigueLoss(const MWWorld::Ptr& attacker, const MWWorld::Ptr& weapon);
void applyFatigueLoss(const MWWorld::Ptr& attacker, const MWWorld::Ptr& weapon, float attackStrength);
/// Can attacker operate in victim's environment?
/// e.g. If attacker is a fish, is victim in water? Or, if attacker can't swim, is victim on land?

@ -18,7 +18,7 @@ namespace MWMechanics
: mDrawState (DrawState_Nothing), mDead (false), mDied (false), mMurdered(false), mFriendlyHits (0),
mTalkedTo (false), mAlarmed (false), mAttacked (false), mAttackingOrSpell(false),
mKnockdown(false), mKnockdownOneFrame(false), mKnockdownOverOneFrame(false),
mHitRecovery(false), mBlock(false), mMovementFlags(0), mAttackStrength(0.f),
mHitRecovery(false), mBlock(false), mMovementFlags(0),
mFallHeight(0), mRecalcMagicka(false), mLastRestock(0,0), mGoldPool(0), mActorId(-1),
mDeathAnimation(0), mLevel (0)
{
@ -466,16 +466,6 @@ namespace MWMechanics
mDrawState = state;
}
float CreatureStats::getAttackStrength() const
{
return mAttackStrength;
}
void CreatureStats::setAttackStrength(float value)
{
mAttackStrength = value;
}
void CreatureStats::writeState (ESM::CreatureStats& state) const
{
for (int i=0; i<ESM::Attribute::Length; ++i)
@ -505,7 +495,6 @@ namespace MWMechanics
state.mHitRecovery = mHitRecovery;
state.mBlock = mBlock;
state.mMovementFlags = mMovementFlags;
state.mAttackStrength = mAttackStrength;
state.mFallHeight = mFallHeight; // TODO: vertical velocity (move from PhysicActor to CreatureStats?)
state.mLastHitObject = mLastHitObject;
state.mLastHitAttemptObject = mLastHitAttemptObject;
@ -553,7 +542,6 @@ namespace MWMechanics
mHitRecovery = state.mHitRecovery;
mBlock = state.mBlock;
mMovementFlags = state.mMovementFlags;
mAttackStrength = state.mAttackStrength;
mFallHeight = state.mFallHeight;
mLastHitObject = state.mLastHitObject;
mLastHitAttemptObject = state.mLastHitAttemptObject;

@ -47,7 +47,6 @@ namespace MWMechanics
bool mHitRecovery;
bool mBlock;
unsigned int mMovementFlags;
float mAttackStrength; // Note only some creatures attack with weapons
float mFallHeight;
@ -85,10 +84,6 @@ namespace MWMechanics
DrawState_ getDrawState() const;
void setDrawState(DrawState_ state);
/// When attacking, stores how strong the attack should be (0 = weakest, 1 = strongest)
float getAttackStrength() const;
void setAttackStrength(float value);
bool needToRecalcDynamicStats();
void setNeedRecalcDynamicStats(bool val);

@ -372,7 +372,7 @@ public:
virtual void setAlpha(float alpha) {}
virtual void setPitchFactor(float factor) {}
virtual void attachArrow() {}
virtual void releaseArrow() {}
virtual void releaseArrow(float attackStrength) {}
virtual void enableHeadAnimation(bool enable) {}
// TODO: move outside of this class
/// Makes this object glow, by placing a Light in its center.

@ -146,9 +146,9 @@ void CreatureWeaponAnimation::attachArrow()
WeaponAnimation::attachArrow(mPtr);
}
void CreatureWeaponAnimation::releaseArrow()
void CreatureWeaponAnimation::releaseArrow(float attackStrength)
{
WeaponAnimation::releaseArrow(mPtr);
WeaponAnimation::releaseArrow(mPtr, attackStrength);
}
osg::Group *CreatureWeaponAnimation::getArrowBone()

@ -38,7 +38,7 @@ namespace MWRender
void updatePart(PartHolderPtr& scene, int slot);
virtual void attachArrow();
virtual void releaseArrow();
virtual void releaseArrow(float attackStrength);
// WeaponAnimation
virtual osg::Group* getArrowBone();
virtual osg::Node* getWeaponNode();

@ -930,9 +930,9 @@ void NpcAnimation::attachArrow()
WeaponAnimation::attachArrow(mPtr);
}
void NpcAnimation::releaseArrow()
void NpcAnimation::releaseArrow(float attackStrength)
{
WeaponAnimation::releaseArrow(mPtr);
WeaponAnimation::releaseArrow(mPtr, attackStrength);
}
osg::Group* NpcAnimation::getArrowBone()

@ -115,7 +115,7 @@ public:
virtual void showCarriedLeft(bool show);
virtual void attachArrow();
virtual void releaseArrow();
virtual void releaseArrow(float attackStrength);
virtual osg::Group* getArrowBone();
virtual osg::Node* getWeaponNode();

@ -90,7 +90,7 @@ void WeaponAnimation::attachArrow(MWWorld::Ptr actor)
}
}
void WeaponAnimation::releaseArrow(MWWorld::Ptr actor)
void WeaponAnimation::releaseArrow(MWWorld::Ptr actor, float attackStrength)
{
MWWorld::InventoryStore& inv = actor.getClass().getInventoryStore(actor);
MWWorld::ContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
@ -106,7 +106,7 @@ void WeaponAnimation::releaseArrow(MWWorld::Ptr actor)
const MWWorld::Store<ESM::GameSetting> &gmst =
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
MWMechanics::applyFatigueLoss(actor, *weapon);
MWMechanics::applyFatigueLoss(actor, *weapon, attackStrength);
if (weapon->get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::MarksmanThrown)
{
@ -121,10 +121,9 @@ void WeaponAnimation::releaseArrow(MWWorld::Ptr actor)
float fThrownWeaponMinSpeed = gmst.find("fThrownWeaponMinSpeed")->getFloat();
float fThrownWeaponMaxSpeed = gmst.find("fThrownWeaponMaxSpeed")->getFloat();
float speed = fThrownWeaponMinSpeed + (fThrownWeaponMaxSpeed - fThrownWeaponMinSpeed) *
actor.getClass().getCreatureStats(actor).getAttackStrength();
float speed = fThrownWeaponMinSpeed + (fThrownWeaponMaxSpeed - fThrownWeaponMinSpeed) * attackStrength;
MWBase::Environment::get().getWorld()->launchProjectile(actor, *weapon, launchPos, orient, *weapon, speed);
MWBase::Environment::get().getWorld()->launchProjectile(actor, *weapon, launchPos, orient, *weapon, speed, attackStrength);
showWeapon(false);
@ -148,9 +147,9 @@ void WeaponAnimation::releaseArrow(MWWorld::Ptr actor)
float fProjectileMinSpeed = gmst.find("fProjectileMinSpeed")->getFloat();
float fProjectileMaxSpeed = gmst.find("fProjectileMaxSpeed")->getFloat();
float speed = fProjectileMinSpeed + (fProjectileMaxSpeed - fProjectileMinSpeed) * actor.getClass().getCreatureStats(actor).getAttackStrength();
float speed = fProjectileMinSpeed + (fProjectileMaxSpeed - fProjectileMinSpeed) * attackStrength;
MWBase::Environment::get().getWorld()->launchProjectile(actor, *ammo, launchPos, orient, *weapon, speed);
MWBase::Environment::get().getWorld()->launchProjectile(actor, *ammo, launchPos, orient, *weapon, speed, attackStrength);
inv.remove(*ammo, 1, actor);
mAmmunition.reset();

@ -36,7 +36,7 @@ namespace MWRender
void attachArrow(MWWorld::Ptr actor);
/// @note If no weapon (or an invalid weapon) is equipped, this function is a no-op.
void releaseArrow(MWWorld::Ptr actor);
void releaseArrow(MWWorld::Ptr actor, float attackStrength);
/// Add WeaponAnimation-related controllers to \a nodes and store the added controllers in \a map.
void addControllers(const std::map<std::string, osg::ref_ptr<osg::MatrixTransform> >& nodes,

@ -94,7 +94,7 @@ namespace MWWorld
throw std::runtime_error ("class does not have item health");
}
void Class::hit(const Ptr& ptr, int type) const
void Class::hit(const Ptr& ptr, float attackStrength, int type) const
{
throw std::runtime_error("class cannot hit");
}

@ -118,9 +118,10 @@ namespace MWWorld
///< Return item max health or throw an exception, if class does not have item health
/// (default implementation: throw an exception)
virtual void hit(const Ptr& ptr, int type=-1) const;
virtual void hit(const Ptr& ptr, float attackStrength, int type=-1) const;
///< Execute a melee hit, using the current weapon. This will check the relevant skills
/// of the given attacker, and whoever is hit.
/// \param attackStrength how long the attack was charged for, a value in 0-1 range.
/// \param type - type of attack, one of the MWMechanics::CreatureStats::AttackType
/// enums. ignored for creature attacks.
/// (default implementation: throw an exception)

@ -115,7 +115,7 @@ namespace MWWorld
mMagicBolts.push_back(state);
}
void ProjectileManager::launchProjectile(Ptr actor, Ptr projectile, const osg::Vec3f &pos, const osg::Quat &orient, Ptr bow, float speed)
void ProjectileManager::launchProjectile(Ptr actor, Ptr projectile, const osg::Vec3f &pos, const osg::Quat &orient, Ptr bow, float speed, float attackStrength)
{
ProjectileState state;
state.mActorId = actor.getClass().getCreatureStats(actor).getActorId();
@ -123,7 +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();
state.mAttackStrength = attackStrength;
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), projectile.getCellRef().getRefId());
MWWorld::Ptr ptr = ref.getPtr();

@ -52,7 +52,7 @@ namespace MWWorld
const MWWorld::Ptr& caster, const std::string& sourceName, const osg::Vec3f& fallbackDirection);
void launchProjectile (MWWorld::Ptr actor, MWWorld::Ptr projectile,
const osg::Vec3f& pos, const osg::Quat& orient, MWWorld::Ptr bow, float speed);
const osg::Vec3f& pos, const osg::Quat& orient, MWWorld::Ptr bow, float speed, float attackStrength);
void update(float dt);

@ -2677,9 +2677,9 @@ namespace MWWorld
}
void World::launchProjectile (MWWorld::Ptr actor, MWWorld::Ptr projectile,
const osg::Vec3f& worldPos, const osg::Quat& orient, MWWorld::Ptr bow, float speed)
const osg::Vec3f& worldPos, const osg::Quat& orient, MWWorld::Ptr bow, float speed, float attackStrength)
{
mProjectileManager->launchProjectile(actor, projectile, worldPos, orient, bow, speed);
mProjectileManager->launchProjectile(actor, projectile, worldPos, orient, bow, speed, attackStrength);
}
void World::launchMagicBolt (const std::string& model, const std::string &sound, const std::string &spellId,

@ -569,7 +569,7 @@ namespace MWWorld
float speed, bool stack, const ESM::EffectList& effects,
const MWWorld::Ptr& caster, const std::string& sourceName, const osg::Vec3f& fallbackDirection);
virtual void launchProjectile (MWWorld::Ptr actor, MWWorld::Ptr projectile,
const osg::Vec3f& worldPos, const osg::Quat& orient, MWWorld::Ptr bow, float speed);
const osg::Vec3f& worldPos, const osg::Quat& orient, MWWorld::Ptr bow, float speed, float attackStrength);
virtual const std::vector<std::string>& getContentFiles() const;

@ -60,8 +60,8 @@ void ESM::CreatureStats::load (ESMReader &esm)
mMovementFlags = 0;
esm.getHNOT (mMovementFlags, "MOVE");
mAttackStrength = 0;
esm.getHNOT (mAttackStrength, "ASTR");
if (esm.isNextSub("ASTR"))
esm.skipHSub(); // attackStrength, no longer used
mFallHeight = 0;
esm.getHNOT (mFallHeight, "FALL");
@ -170,9 +170,6 @@ void ESM::CreatureStats::save (ESMWriter &esm) const
if (mMovementFlags)
esm.writeHNT ("MOVE", mMovementFlags);
if (mAttackStrength)
esm.writeHNT ("ASTR", mAttackStrength);
if (mFallHeight)
esm.writeHNT ("FALL", mFallHeight);
@ -242,7 +239,6 @@ void ESM::CreatureStats::blank()
mHitRecovery = false;
mBlock = false;
mMovementFlags = 0;
mAttackStrength = 0.f;
mFallHeight = 0.f;
mRecalcDynamicStats = false;
mDrawState = 0;

@ -52,7 +52,6 @@ namespace ESM
bool mHitRecovery;
bool mBlock;
unsigned int mMovementFlags;
float mAttackStrength;
float mFallHeight;
std::string mLastHitObject;
std::string mLastHitAttemptObject;

@ -86,7 +86,7 @@ void ESM::NpcStats::load (ESMReader &esm)
if (esm.isNextSub("PROF"))
esm.skipHSub(); // int profit
// No longer used. Now part of CreatureStats.
// No longer used
if (esm.isNextSub("ASTR"))
esm.skipHSub(); // attackStrength

Loading…
Cancel
Save