[Core] Implement CREATURE_FLAG_EXTRA_NO_PARRY_HASTEN [cz2664]

This commit is contained in:
fgreinus 2015-07-08 21:46:56 +01:00 committed by Antz
parent 93c77682bf
commit fa303fb829

View File

@ -1657,36 +1657,40 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss)
// This seems to reduce the victims time until next attack if your attack was parried // This seems to reduce the victims time until next attack if your attack was parried
if (damageInfo->TargetState == VICTIMSTATE_PARRY) if (damageInfo->TargetState == VICTIMSTATE_PARRY)
{ {
// Get attack timers if (pVictim->GetTypeId() != TYPEID_UNIT ||
float offtime = float(pVictim->getAttackTimer(OFF_ATTACK)); !(((Creature*)pVictim)->GetCreatureInfo()->ExtraFlags & CREATURE_EXTRA_FLAG_NO_PARRY_HASTEN))
float basetime = float(pVictim->getAttackTimer(BASE_ATTACK));
// Reduce attack time
if (pVictim->haveOffhandWeapon() && offtime < basetime)
{ {
float percent20 = pVictim->GetAttackTime(OFF_ATTACK) * 0.20f; // Get attack timers
float percent60 = 3.0f * percent20; float offtime = float(pVictim->getAttackTimer(OFF_ATTACK));
if (offtime > percent20 && offtime <= percent60) float basetime = float(pVictim->getAttackTimer(BASE_ATTACK));
// Reduce attack time
if (pVictim->haveOffhandWeapon() && offtime < basetime)
{ {
pVictim->setAttackTimer(OFF_ATTACK, uint32(percent20)); float percent20 = pVictim->GetAttackTime(OFF_ATTACK) * 0.20f;
float percent60 = 3.0f * percent20;
if (offtime > percent20 && offtime <= percent60)
{
pVictim->setAttackTimer(OFF_ATTACK, uint32(percent20));
}
else if (offtime > percent60)
{
offtime -= 2.0f * percent20;
pVictim->setAttackTimer(OFF_ATTACK, uint32(offtime));
}
} }
else if (offtime > percent60) else
{ {
offtime -= 2.0f * percent20; float percent20 = pVictim->GetAttackTime(BASE_ATTACK) * 0.20f;
pVictim->setAttackTimer(OFF_ATTACK, uint32(offtime)); float percent60 = 3.0f * percent20;
} if (basetime > percent20 && basetime <= percent60)
} {
else pVictim->setAttackTimer(BASE_ATTACK, uint32(percent20));
{ }
float percent20 = pVictim->GetAttackTime(BASE_ATTACK) * 0.20f; else if (basetime > percent60)
float percent60 = 3.0f * percent20; {
if (basetime > percent20 && basetime <= percent60) basetime -= 2.0f * percent20;
{ pVictim->setAttackTimer(BASE_ATTACK, uint32(basetime));
pVictim->setAttackTimer(BASE_ATTACK, uint32(percent20)); }
}
else if (basetime > percent60)
{
basetime -= 2.0f * percent20;
pVictim->setAttackTimer(BASE_ATTACK, uint32(basetime));
} }
} }
} }