Merge branch 'master' into Playerbot

This commit is contained in:
Yunfan Li
2024-10-10 23:13:20 +08:00
15 changed files with 100 additions and 34 deletions

View File

@@ -1893,6 +1893,23 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss)
Unit::DealDamage(this, victim, damageInfo->damages[i].damage, &cleanDamage, DIRECT_DAMAGE, SpellSchoolMask(damageInfo->damages[i].damageSchoolMask), nullptr, durabilityLoss);
}
// gain rage if attack is fully blocked, dodged or parried
if (HasActivePowerType(POWER_RAGE) && (damageInfo->TargetState == VICTIMSTATE_BLOCKS || damageInfo->TargetState == VICTIMSTATE_DODGE || damageInfo->TargetState == VICTIMSTATE_PARRY))
{
switch (damageInfo->attackType)
{
case BASE_ATTACK:
case OFF_ATTACK:
{
uint32 weaponSpeedHitFactor = uint32(GetAttackTime(damageInfo->attackType) / 1000.0f * (damageInfo->attackType == BASE_ATTACK ? 3.5f : 1.75f));
RewardRage(damageInfo->cleanDamage, weaponSpeedHitFactor, true);
break;
}
default:
break;
}
}
// If this is a creature and it attacks from behind it has a probability to daze it's victim
if ((damageInfo->damages[0].damage + damageInfo->damages[1].damage) && ((damageInfo->hitOutCome == MELEE_HIT_CRIT || damageInfo->hitOutCome == MELEE_HIT_CRUSHING || damageInfo->hitOutCome == MELEE_HIT_NORMAL || damageInfo->hitOutCome == MELEE_HIT_GLANCING) &&
!IsPlayer() && !ToCreature()->IsControlledByPlayer() && !victim->HasInArc(M_PI, this)
@@ -8970,9 +8987,9 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg
if (GetStat(STAT_AGILITY) > stat) { trigger_spell_id = 67772; }
break;
}
// Mana Drain Trigger
case 27522:
case 40336:
case 27522: // Mana Drain Trigger
case 40336: // Mana Drain Trigger
case 46939: // Black Bow of the Betrayer
{
// On successful melee or ranged attack gain $29471s1 mana and if possible drain $27526s1 mana from the target.
if (IsAlive())
@@ -14535,6 +14552,7 @@ void Unit::setDeathState(DeathState s, bool despawn)
{
// death state needs to be updated before RemoveAllAurasOnDeath() calls HandleChannelDeathItem(..) so that
// it can be used to check creation of death items (such as soul shards).
m_deathState = s;
if (s != DeathState::Alive && s != DeathState::JustRespawned)
{
@@ -14584,8 +14602,6 @@ void Unit::setDeathState(DeathState s, bool despawn)
{
RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); // clear skinnable for creature and player (at battleground)
}
m_deathState = s;
}
/*########################################
@@ -14593,14 +14609,14 @@ void Unit::setDeathState(DeathState s, bool despawn)
######## AGGRO SYSTEM ########
######## ########
########################################*/
bool Unit::CanHaveThreatList() const
bool Unit::CanHaveThreatList(bool skipAliveCheck) const
{
// only creatures can have threat list
if (!IsCreature())
return false;
// only alive units can have threat list
if (!IsAlive() || isDying())
if (!skipAliveCheck && !IsAlive())
return false;
// totems can not have threat list
@@ -20144,6 +20160,7 @@ void Unit::SendRemoveFromThreatListOpcode(HostileReference* pHostileReference)
void Unit::RewardRage(uint32 damage, uint32 weaponSpeedHitFactor, bool attacker)
{
// Rage formulae https://wowwiki-archive.fandom.com/wiki/Rage#Formulae
float addRage;
float rageconversion = ((0.0091107836f * GetLevel() * GetLevel()) + 3.225598133f * GetLevel()) + 4.2652911f;
@@ -20154,9 +20171,10 @@ void Unit::RewardRage(uint32 damage, uint32 weaponSpeedHitFactor, bool attacker)
if (attacker)
{
addRage = (damage / rageconversion * 7.5f + weaponSpeedHitFactor) / 2;
// talent who gave more rage on attack
// see Bornak's bluepost explanation (05/29/2009)
float rageFromDamageDealt = damage / rageconversion * 7.5f;
addRage = (rageFromDamageDealt + weaponSpeedHitFactor) / 2.0f;
addRage = std::min(addRage, rageFromDamageDealt * 2.0f);
AddPct(addRage, GetTotalAuraModifier(SPELL_AURA_MOD_RAGE_FROM_DAMAGE_DEALT));
}
else