1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-21 09:53:50 +00:00

Improve weapon attack logic to better handle picks, probes, and h2h

This commit is contained in:
Chris Robinson 2013-07-23 02:28:58 -07:00
parent ef17fdeb15
commit 0240efa6cf

View file

@ -538,25 +538,26 @@ void CharacterController::update(float duration, Movement &movement)
} }
} }
if(weaptype != WeapType_PickProbe && weaptype != WeapType_BowAndArrow if(1)
&& weaptype != WeapType_Crossbow && weaptype != WeapType_ThowWeapon)
{ {
bool isWeapon = (weapon != inv.end() && weapon->getTypeName() == typeid(ESM::Weapon).name());
float weapSpeed = 1.0f;
if(isWeapon)
weapSpeed = weapon->get<ESM::Weapon>()->mBase->mData.mSpeed;
std::string weapgroup; std::string weapgroup;
getWeaponGroup(mWeaponType, weapgroup); getWeaponGroup(mWeaponType, weapgroup);
float weapSpeed = 1;
if(weapon != inv.end()) weapSpeed = weapon->get<ESM::Weapon>()->mBase->mData.mSpeed;
std::string start;
std::string stop;
float complete; float complete;
float speedMult; bool animPlaying = mAnimation->getInfo(weapgroup, &complete);
bool animPlaying = mAnimation->getInfo(weapgroup,&complete,&speedMult,&start,&stop);
if(cls.getCreatureStats(mPtr).getAttackingOrSpell()) if(cls.getCreatureStats(mPtr).getAttackingOrSpell())
{ {
if(mUpperBodyState == UpperCharState_WeapEquiped) if(mUpperBodyState == UpperCharState_WeapEquiped && mWeaponType != WeapType_Crossbow &&
mWeaponType != WeapType_BowAndArrow && mWeaponType != WeapType_ThowWeapon &&
mWeaponType != WeapType_PickProbe)
{ {
int attackType = cls.getCreatureStats(mPtr).getAttackType(); int attackType = cls.getCreatureStats(mPtr).getAttackType();
if (Settings::Manager::getBool("best attack", "Game") && weapon != inv.end()) if(isWeapon && Settings::Manager::getBool("best attack", "Game"))
attackType = getBestAttack(weapon->get<ESM::Weapon>()->mBase); attackType = getBestAttack(weapon->get<ESM::Weapon>()->mBase);
if (attackType == MWMechanics::CreatureStats::AT_Chop) if (attackType == MWMechanics::CreatureStats::AT_Chop)
@ -590,11 +591,13 @@ void CharacterController::update(float duration, Movement &movement)
mUpperBodyState = UpperCharState_MaxAttackToMinHit; mUpperBodyState = UpperCharState_MaxAttackToMinHit;
} }
if(mUpperBodyState == UpperCharState_EquipingWeap && !animPlaying) mUpperBodyState = UpperCharState_WeapEquiped; if(mUpperBodyState == UpperCharState_EquipingWeap && !animPlaying)
if(mUpperBodyState == UpperCharState_UnEquipingWeap && !animPlaying) mUpperBodyState = UpperCharState_Nothing; mUpperBodyState = UpperCharState_WeapEquiped;
if(animPlaying) else if(mUpperBodyState == UpperCharState_UnEquipingWeap && !animPlaying)
mUpperBodyState = UpperCharState_Nothing;
else if(animPlaying)
{ {
if(mUpperBodyState == UpperCharState_StartToMinAttack && complete == 1) if(mUpperBodyState == UpperCharState_StartToMinAttack && complete == 1.0f)
{ {
mAnimation->disable(weapgroup); mAnimation->disable(weapgroup);
mAnimation->play(weapgroup, Priority_Weapon, mAnimation->play(weapgroup, Priority_Weapon,
@ -602,7 +605,7 @@ void CharacterController::update(float duration, Movement &movement)
weapSpeed, mAttackType+" min attack", mAttackType+" max attack",0, 0); weapSpeed, mAttackType+" min attack", mAttackType+" max attack",0, 0);
mUpperBodyState = UpperCharState_MinAttackToMaxAttack; mUpperBodyState = UpperCharState_MinAttackToMaxAttack;
} }
else if(mUpperBodyState == UpperCharState_MaxAttackToMinHit && complete == 1) else if(mUpperBodyState == UpperCharState_MaxAttackToMinHit && complete == 1.0f)
{ {
mAnimation->disable(weapgroup); mAnimation->disable(weapgroup);
mAnimation->play(weapgroup, Priority_Weapon, mAnimation->play(weapgroup, Priority_Weapon,
@ -610,7 +613,7 @@ void CharacterController::update(float duration, Movement &movement)
weapSpeed, mAttackType+" min hit", mAttackType+" hit",0, 0); weapSpeed, mAttackType+" min hit", mAttackType+" hit",0, 0);
mUpperBodyState = UpperCharState_MinHitToHit; mUpperBodyState = UpperCharState_MinHitToHit;
} }
else if(mUpperBodyState == UpperCharState_MinHitToHit && complete == 1) else if(mUpperBodyState == UpperCharState_MinHitToHit && complete == 1.0f)
{ {
mAnimation->disable(weapgroup); mAnimation->disable(weapgroup);
mAnimation->play(weapgroup, Priority_Weapon, mAnimation->play(weapgroup, Priority_Weapon,
@ -618,8 +621,9 @@ void CharacterController::update(float duration, Movement &movement)
weapSpeed, mAttackType+" large follow start", mAttackType+" large follow stop",0, 0); weapSpeed, mAttackType+" large follow start", mAttackType+" large follow stop",0, 0);
mUpperBodyState = UpperCharState_LargeFollowStartToLargeFollowStop; mUpperBodyState = UpperCharState_LargeFollowStartToLargeFollowStop;
} }
else if(mUpperBodyState == UpperCharState_LargeFollowStartToLargeFollowStop && complete == 1) else if(mUpperBodyState == UpperCharState_LargeFollowStartToLargeFollowStop && complete == 1.0f)
{ {
mAnimation->disable(weapgroup);
mUpperBodyState = UpperCharState_WeapEquiped; mUpperBodyState = UpperCharState_WeapEquiped;
} }
} }