remove CreatureStats::mAttackType, set/getAttackType()

actorid
mrcheko 11 years ago
parent fe0268062d
commit e50e94af0b

@ -39,17 +39,17 @@
namespace
{
int getBestAttack (const ESM::Weapon* weapon)
std::string getBestAttack (const ESM::Weapon* weapon)
{
int slash = (weapon->mData.mSlash[0] + weapon->mData.mSlash[1])/2;
int chop = (weapon->mData.mChop[0] + weapon->mData.mChop[1])/2;
int thrust = (weapon->mData.mThrust[0] + weapon->mData.mThrust[1])/2;
if (slash >= chop && slash >= thrust)
return MWMechanics::CreatureStats::AT_Slash;
return "slash";
else if (chop >= slash && chop >= thrust)
return MWMechanics::CreatureStats::AT_Chop;
return "chop";
else
return MWMechanics::CreatureStats::AT_Thrust;
return "thrust";
}
}
@ -691,9 +691,8 @@ bool CharacterController::updateWeaponState()
mAttackType = "shoot";
else
{
int attackType;
if(isWeapon && Settings::Manager::getBool("best attack", "Game"))
attackType = getBestAttack(weapon->get<ESM::Weapon>()->mBase);
mAttackType = getBestAttack(weapon->get<ESM::Weapon>()->mBase);
else
determineAttackType();
}
@ -1299,27 +1298,21 @@ void CharacterController::determineAttackType()
{
float * move = mPtr.getClass().getMovementSettings(mPtr).mPosition;
if (move[0] && !move[1]) //sideway
if(mPtr.getClass().hasInventoryStore(mPtr))
{
mPtr.getClass().getCreatureStats(mPtr).setAttackType(MWMechanics::CreatureStats::AT_Slash);
if(mPtr.getClass().hasInventoryStore(mPtr))
if (move[0] && !move[1]) //sideway
mAttackType = "slash";
else
mCurrentWeapon = "attack2";
}
else if (move[1]) //forward
{
mPtr.getClass().getCreatureStats(mPtr).setAttackType(MWMechanics::CreatureStats::AT_Thrust);
if(mPtr.getClass().hasInventoryStore(mPtr))
else if (move[1]) //forward
mAttackType = "thrust";
else
mCurrentWeapon = "attack3";
mAttackType = "chop";
}
else
{
mPtr.getClass().getCreatureStats(mPtr).setAttackType(MWMechanics::CreatureStats::AT_Chop);
if(mPtr.getClass().hasInventoryStore(mPtr))
mAttackType = "chop";
if (move[0] && !move[1]) //sideway
mCurrentWeapon = "attack2";
else if (move[1]) //forward
mCurrentWeapon = "attack3";
else
mCurrentWeapon = "attack1";
}

@ -13,7 +13,7 @@ namespace MWMechanics
: mLevel (0), mLevelHealthBonus(0.f), mDead (false), mDied (false), mFriendlyHits (0),
mTalkedTo (false), mAlarmed (false),
mAttacked (false), mHostile (false),
mAttackingOrSpell(false), mAttackType(AT_Chop),
mAttackingOrSpell(false),
mIsWerewolf(false),
mFallHeight(0), mRecalcDynamicStats(false), mKnockdown(false), mHitRecovery(false), mBlock(false),
mMovementFlags(0), mDrawState (DrawState_Nothing), mAttackStrength(0.f)

@ -45,14 +45,11 @@ namespace MWMechanics
float mFallHeight;
int mAttackType;
std::string mLastHitObject; // The last object to hit this actor
// Do we need to recalculate stats derived from attributes or other factors?
bool mRecalcDynamicStats;
std::map<std::string, MWWorld::TimeStamp> mUsedPowers;
protected:
bool mIsWerewolf;
@ -125,15 +122,6 @@ namespace MWMechanics
void setAttackingOrSpell(bool attackingOrSpell);
enum AttackType
{
AT_Chop,
AT_Slash,
AT_Thrust
};
void setAttackType(int attackType) { mAttackType = attackType; }
int getAttackType() { return mAttackType; }
void setLevel(int level);
enum AiSetting

@ -686,19 +686,19 @@ void Animation::handleTextKey(AnimState &state, const std::string &groupname, co
else if(evt.compare(off, len, "unequip detach") == 0)
showWeapons(false);
else if(evt.compare(off, len, "chop hit") == 0)
mPtr.getClass().hit(mPtr, MWMechanics::CreatureStats::AT_Chop);
mPtr.getClass().hit(mPtr, ESM::Weapon::AT_Chop);
else if(evt.compare(off, len, "slash hit") == 0)
mPtr.getClass().hit(mPtr, MWMechanics::CreatureStats::AT_Slash);
mPtr.getClass().hit(mPtr, ESM::Weapon::AT_Slash);
else if(evt.compare(off, len, "thrust hit") == 0)
mPtr.getClass().hit(mPtr, MWMechanics::CreatureStats::AT_Thrust);
mPtr.getClass().hit(mPtr, ESM::Weapon::AT_Thrust);
else if(evt.compare(off, len, "hit") == 0)
{
if (groupname == "attack1")
mPtr.getClass().hit(mPtr, MWMechanics::CreatureStats::AT_Chop);
mPtr.getClass().hit(mPtr, ESM::Weapon::AT_Chop);
else if (groupname == "attack2")
mPtr.getClass().hit(mPtr, MWMechanics::CreatureStats::AT_Slash);
mPtr.getClass().hit(mPtr, ESM::Weapon::AT_Slash);
else if (groupname == "attack3")
mPtr.getClass().hit(mPtr, MWMechanics::CreatureStats::AT_Thrust);
mPtr.getClass().hit(mPtr, ESM::Weapon::AT_Thrust);
else
mPtr.getClass().hit(mPtr);
}

@ -35,6 +35,13 @@ struct Weapon
Bolt = 13
};
enum AttackType
{
AT_Chop,
AT_Slash,
AT_Thrust
};
enum Flags
{
Magical = 0x01,

Loading…
Cancel
Save