remove CreatureStats::mAttackType, set/getAttackType()

actorid
mrcheko 11 years ago
parent fe0268062d
commit e50e94af0b

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

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

@ -45,14 +45,11 @@ namespace MWMechanics
float mFallHeight; float mFallHeight;
int mAttackType;
std::string mLastHitObject; // The last object to hit this actor std::string mLastHitObject; // The last object to hit this actor
// Do we need to recalculate stats derived from attributes or other factors? // Do we need to recalculate stats derived from attributes or other factors?
bool mRecalcDynamicStats; bool mRecalcDynamicStats;
std::map<std::string, MWWorld::TimeStamp> mUsedPowers; std::map<std::string, MWWorld::TimeStamp> mUsedPowers;
protected: protected:
bool mIsWerewolf; bool mIsWerewolf;
@ -125,15 +122,6 @@ namespace MWMechanics
void setAttackingOrSpell(bool attackingOrSpell); 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); void setLevel(int level);
enum AiSetting 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) else if(evt.compare(off, len, "unequip detach") == 0)
showWeapons(false); showWeapons(false);
else if(evt.compare(off, len, "chop hit") == 0) 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) 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) 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) else if(evt.compare(off, len, "hit") == 0)
{ {
if (groupname == "attack1") if (groupname == "attack1")
mPtr.getClass().hit(mPtr, MWMechanics::CreatureStats::AT_Chop); mPtr.getClass().hit(mPtr, ESM::Weapon::AT_Chop);
else if (groupname == "attack2") else if (groupname == "attack2")
mPtr.getClass().hit(mPtr, MWMechanics::CreatureStats::AT_Slash); mPtr.getClass().hit(mPtr, ESM::Weapon::AT_Slash);
else if (groupname == "attack3") else if (groupname == "attack3")
mPtr.getClass().hit(mPtr, MWMechanics::CreatureStats::AT_Thrust); mPtr.getClass().hit(mPtr, ESM::Weapon::AT_Thrust);
else else
mPtr.getClass().hit(mPtr); mPtr.getClass().hit(mPtr);
} }

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

Loading…
Cancel
Save