corrected things connected to determining attack type

actorid
mrcheko 11 years ago
parent 87e83a92f8
commit 45b3aa3d93

@ -163,9 +163,7 @@ namespace MWMechanics
float rangeMelee;
float rangeCloseUp;
bool distantCombat = false;
int attackType = actor.getClass().getCreatureStats(actor).getAttackType();
if (weaptype==WeapType_BowAndArrow || weaptype==WeapType_Crossbow || weaptype==WeapType_ThowWeapon
|| attackType==MWMechanics::CreatureStats::AT_Target )
if (weaptype==WeapType_BowAndArrow || weaptype==WeapType_Crossbow || weaptype==WeapType_ThowWeapon)
{
rangeMelee = 1000; // TODO: should depend on archer skill
rangeCloseUp = 0; //doesn't needed when attacking from distance

@ -644,7 +644,12 @@ bool CharacterController::updateNpcState()
mAnimation->addEffect("meshes\\" + castStatic->mModel, -1, false, "Left Hand", effect->mParticle);
mAnimation->addEffect("meshes\\" + castStatic->mModel, -1, false, "Right Hand", effect->mParticle);
determineAttackType(effectentry.mRange);
switch(effectentry.mRange)
{
case 0: mAttackType = "self"; break;
case 1: mAttackType = "touch"; break;
case 2: mAttackType = "target"; break;
}
mAnimation->play(mCurrentWeapon, Priority_Weapon,
MWRender::Animation::Group_UpperBody, true,
@ -698,7 +703,7 @@ bool CharacterController::updateNpcState()
mAttackType = "shoot";
else
{
int attackType = stats.getAttackType();
int attackType;
if(isWeapon && Settings::Manager::getBool("best attack", "Game"))
attackType = getBestAttack(weapon->get<ESM::Weapon>()->mBase);
else
@ -1302,57 +1307,34 @@ void CharacterController::updateVisibility()
mAnimation->setAlpha(alpha);
}
void CharacterController::determineAttackType(int spellRange)
void CharacterController::determineAttackType()
{
if(spellRange == -1)
{
float * move = mPtr.getClass().getMovementSettings(mPtr).mPosition;
float * move = mPtr.getClass().getMovementSettings(mPtr).mPosition;
if (move[0] && !move[1]) //sideway
{
mPtr.getClass().getCreatureStats(mPtr).setAttackType(MWMechanics::CreatureStats::AT_Slash);
if(mPtr.getClass().isNpc())
mAttackType = "slash";
else
mCurrentWeapon = "attack2";
}
else if (move[1]) //forward
{
mPtr.getClass().getCreatureStats(mPtr).setAttackType(MWMechanics::CreatureStats::AT_Thrust);
if(mPtr.getClass().isNpc())
mAttackType = "thrust";
else
mCurrentWeapon = "attack3";
}
if (move[0] && !move[1]) //sideway
{
mPtr.getClass().getCreatureStats(mPtr).setAttackType(MWMechanics::CreatureStats::AT_Slash);
if(mPtr.getClass().isNpc())
mAttackType = "slash";
else
{
mPtr.getClass().getCreatureStats(mPtr).setAttackType(MWMechanics::CreatureStats::AT_Chop);
if(mPtr.getClass().isNpc())
mAttackType = "chop";
else
mCurrentWeapon = "attack1";
}
mCurrentWeapon = "attack2";
}
else if (move[1]) //forward
{
mPtr.getClass().getCreatureStats(mPtr).setAttackType(MWMechanics::CreatureStats::AT_Thrust);
if(mPtr.getClass().isNpc())
mAttackType = "thrust";
else
mCurrentWeapon = "attack3";
}
else
{
switch(spellRange)
{
case 0:
mAttackType = "self";
mPtr.getClass().getCreatureStats(mPtr).setAttackType(MWMechanics::CreatureStats::AT_Self);
break;
case 1:
mAttackType = "touch";
mPtr.getClass().getCreatureStats(mPtr).setAttackType(MWMechanics::CreatureStats::AT_Touch);
break;
case 2:
mAttackType = "target";
mPtr.getClass().getCreatureStats(mPtr).setAttackType(MWMechanics::CreatureStats::AT_Target);
break;
}
mPtr.getClass().getCreatureStats(mPtr).setAttackType(MWMechanics::CreatureStats::AT_Chop);
if(mPtr.getClass().isNpc())
mAttackType = "chop";
else
mCurrentWeapon = "attack1";
}
}
}

@ -165,7 +165,7 @@ class CharacterController
float mSecondsOfRunning;
std::string mAttackType; // slash, chop or thrust
void determineAttackType(int spellRange = -1);
void determineAttackType();
void refreshCurrentAnims(CharacterState idle, CharacterState movement, bool force=false);

@ -118,11 +118,7 @@ namespace MWMechanics
{
AT_Chop,
AT_Slash,
AT_Thrust,
AT_Self,
AT_Touch,
AT_Target,
AT_Thrust
};
void setAttackType(int attackType) { mAttackType = attackType; }
int getAttackType() { return mAttackType; }

Loading…
Cancel
Save