mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
Lots of cmangos commirs applied
This commit is contained in:
parent
8431568536
commit
18dd18780d
44 changed files with 677 additions and 323 deletions
|
|
@ -669,9 +669,13 @@ void Unit::Update(uint32 update_diff, uint32 p_time)
|
|||
// update abilities available only for fraction of time
|
||||
UpdateReactives(update_diff);
|
||||
|
||||
ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, GetHealth() < GetMaxHealth() * 0.20f);
|
||||
ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, GetHealth() < GetMaxHealth() * 0.35f);
|
||||
ModifyAuraState(AURA_STATE_HEALTH_ABOVE_75_PERCENT, GetHealth() > GetMaxHealth() * 0.75f);
|
||||
if (IsAlive())
|
||||
{
|
||||
ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, GetHealth() < GetMaxHealth() * 0.20f);
|
||||
ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, GetHealth() < GetMaxHealth() * 0.35f);
|
||||
ModifyAuraState(AURA_STATE_HEALTH_ABOVE_75_PERCENT, GetHealth() > GetMaxHealth() * 0.75f);
|
||||
}
|
||||
|
||||
UpdateSplineMovement(p_time);
|
||||
i_motionMaster.UpdateMotion(p_time);
|
||||
}
|
||||
|
|
@ -734,7 +738,7 @@ bool Unit::UpdateMeleeAttackingState()
|
|||
player->SwingErrorMsg(swingError);
|
||||
}
|
||||
|
||||
return swingError == 0;
|
||||
return swingError;
|
||||
}
|
||||
|
||||
bool Unit::haveOffhandWeapon() const
|
||||
|
|
@ -1089,6 +1093,8 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa
|
|||
|
||||
player_tap->SendDirectMessage(&data);
|
||||
}
|
||||
else if (GetTypeId() == TYPEID_UNIT && this != pVictim)
|
||||
ProcDamageAndSpell(pVictim, PROC_FLAG_KILL, PROC_FLAG_KILLED, PROC_EX_NONE, 0);
|
||||
|
||||
// Reward player, his pets, and group/raid members
|
||||
if (player_tap != pVictim)
|
||||
|
|
@ -1538,7 +1544,7 @@ void Unit::CastSpell(Unit* Victim, SpellEntry const* spellInfo, bool triggered,
|
|||
targets.setSource(caster->GetPositionX(), caster->GetPositionY(), caster->GetPositionZ());
|
||||
|
||||
spell->m_CastItem = castItem;
|
||||
spell->prepare(&targets, triggeredByAura);
|
||||
spell->SpellStart(&targets, triggeredByAura);
|
||||
}
|
||||
|
||||
void Unit::CastCustomSpell(Unit* Victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem, Aura* triggeredByAura, ObjectGuid originalCaster, SpellEntry const* triggeredBy)
|
||||
|
|
@ -1600,7 +1606,7 @@ void Unit::CastCustomSpell(Unit* Victim, SpellEntry const* spellInfo, int32 cons
|
|||
if (WorldObject* caster = spell->GetCastingObject())
|
||||
{ targets.setSource(caster->GetPositionX(), caster->GetPositionY(), caster->GetPositionZ()); }
|
||||
|
||||
spell->prepare(&targets, triggeredByAura);
|
||||
spell->SpellStart(&targets, triggeredByAura);
|
||||
}
|
||||
|
||||
// used for scripting
|
||||
|
|
@ -1657,7 +1663,7 @@ void Unit::CastSpell(float x, float y, float z, SpellEntry const* spellInfo, boo
|
|||
{ targets.setDestination(x, y, z); }
|
||||
|
||||
spell->m_CastItem = castItem;
|
||||
spell->prepare(&targets, triggeredByAura);
|
||||
spell->SpellStart(&targets, triggeredByAura);
|
||||
}
|
||||
|
||||
// Obsolete func need remove, here only for comotability vs another patches
|
||||
|
|
@ -1897,6 +1903,11 @@ void Unit::CalculateMeleeDamage(Unit* pVictim, CalcDamageInfo* damageInfo, Weapo
|
|||
damageInfo->procEx |= PROC_EX_CRITICAL_HIT;
|
||||
// Crit bonus calc
|
||||
damageInfo->damage += damageInfo->damage;
|
||||
|
||||
// Apply SPELL_AURA_MOD_CRIT_DAMAGE_BONUS modifier first
|
||||
const int32 bonus = GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_CRIT_DAMAGE_BONUS, SPELL_SCHOOL_MASK_NORMAL);
|
||||
damageInfo->damage += int32((damageInfo->damage) * float(bonus / 100.0f));
|
||||
|
||||
int32 mod = 0;
|
||||
// Apply SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE or SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE
|
||||
if (damageInfo->attackType == RANGED_ATTACK)
|
||||
|
|
@ -1904,8 +1915,6 @@ void Unit::CalculateMeleeDamage(Unit* pVictim, CalcDamageInfo* damageInfo, Weapo
|
|||
else
|
||||
mod += damageInfo->target->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE);
|
||||
|
||||
mod += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_CRIT_DAMAGE_BONUS, SPELL_SCHOOL_MASK_NORMAL);
|
||||
|
||||
if (mod != 0)
|
||||
damageInfo->damage = int32((damageInfo->damage) * float((100.0f + mod) / 100.0f));
|
||||
|
||||
|
|
@ -2917,6 +2926,8 @@ void Unit::AttackerStateUpdate(Unit* pVictim, WeaponAttackType attType, bool ext
|
|||
return;
|
||||
}
|
||||
|
||||
RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MELEE_ATTACK);
|
||||
|
||||
// attack can be redirected to another target
|
||||
pVictim = SelectMagnetTarget(pVictim);
|
||||
|
||||
|
|
@ -2934,6 +2945,22 @@ void Unit::AttackerStateUpdate(Unit* pVictim, WeaponAttackType attType, bool ext
|
|||
else
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "AttackerStateUpdate: (NPC) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.",
|
||||
GetGUIDLow(), pVictim->GetGUIDLow(), pVictim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist);
|
||||
|
||||
if (Unit* owner = GetOwner())
|
||||
if (owner->GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
owner->SetInCombatWith(pVictim);
|
||||
owner->AddThreat(pVictim);
|
||||
pVictim->SetInCombatWith(owner);
|
||||
}
|
||||
|
||||
for (GuidSet::const_iterator itr = m_guardianPets.begin(); itr != m_guardianPets.end(); ++itr)
|
||||
if (Unit* pet = (Unit*)GetMap()->GetPet(*itr))
|
||||
{
|
||||
pet->SetInCombatWith(pVictim);
|
||||
pet->AddThreat(pVictim);
|
||||
pVictim->SetInCombatWith(pet);
|
||||
}
|
||||
|
||||
// if damage pVictim call AI reaction
|
||||
pVictim->AttackedBy(this);
|
||||
|
|
@ -3101,25 +3128,19 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit* pVictim, WeaponAttackT
|
|||
}
|
||||
|
||||
// mobs can score crushing blows if they're 4 or more levels above victim
|
||||
if (GetLevelForTarget(pVictim) >= pVictim->GetLevelForTarget(this) + 4 &&
|
||||
// can be from by creature (if can) or from controlled player that considered as creature
|
||||
((GetTypeId() != TYPEID_PLAYER && !((Creature*)this)->IsPet() &&
|
||||
!(((Creature*)this)->GetCreatureInfo()->ExtraFlags & CREATURE_EXTRA_FLAG_NO_CRUSH)) ||
|
||||
GetTypeId() == TYPEID_PLAYER && GetCharmerOrOwnerGuid()))
|
||||
// having defense above your maximum (from items, talents etc.) has no effect
|
||||
// mob's level * 5 - player's current defense skill - add 2% chance per lacking skill point, min. is 20%
|
||||
if ((getLevel() - 4) >= pVictim->getLevel() && !IsNonMeleeSpellCasted(false) /* It should have been !spellCasted but wrath doesn't have that? */
|
||||
&& roll < (tmp = (((attackerMaxSkillValueForLevel - tmp) * 200) - 2000)))
|
||||
{
|
||||
// when their weapon skill is 15 or more above victim's defense skill
|
||||
tmp = victimMaxSkillValueForLevel;
|
||||
// tmp = mob's level * 5 - player's current defense skill
|
||||
tmp = attackerMaxSkillValueForLevel - tmp;
|
||||
if (tmp >= 15)
|
||||
uint32 typeId = GetTypeId();
|
||||
/* It should have been !(((Creature*)this)->GetCreatureInfo()->ExtraFlags & CREATURE_EXTRA_FLAG_NO_CRUSH) but wrath doesn't have that? */
|
||||
if ((typeId == TYPEID_UNIT && !(GetOwnerGuid() && GetOwner()->GetTypeId() == TYPEID_PLAYER)
|
||||
&& !(static_cast<Creature const*>(this)->GetCreatureInfo()->ExtraFlags & CREATURE_EXTRA_FLAG_NO_CRUSH))
|
||||
|| (typeId == TYPEID_PLAYER && GetCharmerGuid() && GetCharmer()->GetTypeId() == TYPEID_UNIT))
|
||||
{
|
||||
// add 2% chance per lacking skill point, min. is 15%
|
||||
tmp = tmp * 200 - 1500;
|
||||
if (roll < (sum += tmp))
|
||||
{
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: CRUSHING <%d, %d)", sum - tmp, sum);
|
||||
return MELEE_HIT_CRUSHING;
|
||||
}
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: CRUSHING %d)", tmp);
|
||||
return MELEE_HIT_CRUSHING;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3848,7 +3869,7 @@ void Unit::_UpdateAutoRepeatSpell()
|
|||
|
||||
// we want to shoot
|
||||
Spell* spell = new Spell(this, m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo, true);
|
||||
spell->prepare(&(m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_targets));
|
||||
spell->SpellStart(&(m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_targets));
|
||||
|
||||
// all went good, reset attack
|
||||
resetAttackTimer(RANGED_ATTACK);
|
||||
|
|
@ -4557,31 +4578,9 @@ bool Unit::RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder* holder)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (i_spellId == spellId) continue;
|
||||
|
||||
bool is_triggered_by_spell = false;
|
||||
// prevent triggering aura of removing aura that triggered it
|
||||
for(int j = 0; j < MAX_EFFECT_INDEX; ++j)
|
||||
{
|
||||
SpellEffectEntry const* iSpellEffect = i_spellProto->GetSpellEffect(SpellEffectIndex(j));
|
||||
if(!iSpellEffect)
|
||||
continue;
|
||||
|
||||
if (iSpellEffect->EffectTriggerSpell == spellId)
|
||||
is_triggered_by_spell = true;
|
||||
}
|
||||
|
||||
// prevent triggered aura of removing aura that triggering it (triggered effect early some aura of parent spell
|
||||
for(int j = 0; j < MAX_EFFECT_INDEX; ++j)
|
||||
{
|
||||
SpellEffectEntry const* spellEffect = i_spellProto->GetSpellEffect(SpellEffectIndex(j));
|
||||
if(!spellEffect)
|
||||
continue;
|
||||
if (spellEffect->EffectTriggerSpell == i_spellId)
|
||||
is_triggered_by_spell = true;
|
||||
}
|
||||
|
||||
if (is_triggered_by_spell)
|
||||
if (((*i).second->GetTriggeredBy() && (*i).second->GetTriggeredBy()->Id == spellId)
|
||||
|| (holder->GetTriggeredBy() && holder->GetTriggeredBy()->Id == i_spellId))
|
||||
continue;
|
||||
|
||||
SpellSpecific i_spellId_spec = GetSpellSpecific(i_spellId);
|
||||
|
|
@ -4982,6 +4981,46 @@ void Unit::RemoveAurasWithAttribute(uint32 flags)
|
|||
}
|
||||
}
|
||||
|
||||
void Unit::RemoveAurasOnCast(SpellEntry const* castedSpellEntry)
|
||||
{
|
||||
for (SpellAuraHolderMap::iterator iter = m_spellAuraHolders.begin(); iter != m_spellAuraHolders.end();)
|
||||
{
|
||||
SpellAuraHolder* holder = iter->second;
|
||||
SpellEntry const* spellEntry = holder->GetSpellProto();
|
||||
bool removeThisHolder = false;
|
||||
|
||||
if (spellEntry->GetAuraInterruptFlags() & AURA_INTERRUPT_FLAG_UNK2)
|
||||
{
|
||||
if (castedSpellEntry->HasAttribute(SPELL_ATTR_EX_NOT_BREAK_STEALTH))
|
||||
{
|
||||
bool foundStealth = false;
|
||||
for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
|
||||
{
|
||||
if (Aura* aura = holder->m_auras[i])
|
||||
{
|
||||
if (aura->GetModifier()->m_auraname == SPELL_AURA_MOD_STEALTH)
|
||||
{
|
||||
foundStealth = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
removeThisHolder = !foundStealth;
|
||||
}
|
||||
else
|
||||
removeThisHolder = true;
|
||||
}
|
||||
|
||||
if (removeThisHolder)
|
||||
{
|
||||
RemoveSpellAuraHolder(iter->second);
|
||||
iter = m_spellAuraHolders.begin();
|
||||
}
|
||||
else
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::RemoveNotOwnTrackedTargetAuras(uint32 newPhase)
|
||||
{
|
||||
// tracked aura targets from other casters are removed if the phase does no more fit
|
||||
|
|
@ -5882,7 +5921,7 @@ bool Unit::IsHostileTo(Unit const* unit) const
|
|||
return false;
|
||||
|
||||
// Sanctuary
|
||||
if (pTarget->HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_SUPPORTABLE) && pTester->HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_SUPPORTABLE))
|
||||
if (pTarget->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_SANCTUARY) && pTester->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_SANCTUARY))
|
||||
return false;
|
||||
|
||||
// PvP FFA state
|
||||
|
|
@ -5994,7 +6033,7 @@ bool Unit::IsFriendlyTo(Unit const* unit) const
|
|||
return true;
|
||||
|
||||
// Sanctuary
|
||||
if (pTarget->HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_SUPPORTABLE) && pTester->HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_SUPPORTABLE))
|
||||
if (pTarget->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_SANCTUARY) && pTester->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_SANCTUARY))
|
||||
return true;
|
||||
|
||||
// PvP FFA state
|
||||
|
|
@ -6115,10 +6154,13 @@ bool Unit::Attack(Unit* victim, bool meleeAttack)
|
|||
if (m_attacking == victim)
|
||||
{
|
||||
// switch to melee attack from ranged/magic
|
||||
if (meleeAttack && !hasUnitState(UNIT_STAT_MELEE_ATTACKING))
|
||||
if (meleeAttack)
|
||||
{
|
||||
addUnitState(UNIT_STAT_MELEE_ATTACKING);
|
||||
SendMeleeAttackStart(victim);
|
||||
if (!hasUnitState(UNIT_STAT_MELEE_ATTACKING))
|
||||
{
|
||||
addUnitState(UNIT_STAT_MELEE_ATTACKING);
|
||||
SendMeleeAttackStart(victim);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -7237,6 +7279,14 @@ bool Unit::IsSpellCrit(Unit* pVictim, SpellEntry const* spellProto, SpellSchoolM
|
|||
if (spellProto->HasAttribute(SPELL_ATTR_EX2_CANT_CRIT))
|
||||
return false;
|
||||
|
||||
// Creatures do not crit with their spells or abilities, unless it is owned by a player (pet, totem, etc)
|
||||
if (GetTypeId() != TYPEID_PLAYER)
|
||||
{
|
||||
Unit* owner = GetOwner();
|
||||
if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
|
||||
return false;
|
||||
}
|
||||
|
||||
float crit_chance = 0.0f;
|
||||
switch(spellProto->GetDmgClass())
|
||||
{
|
||||
|
|
@ -7420,6 +7470,10 @@ uint32 Unit::SpellCriticalDamageBonus(SpellEntry const* spellProto, uint32 damag
|
|||
break;
|
||||
}
|
||||
|
||||
// Apply SPELL_AURA_MOD_CRIT_DAMAGE_BONUS modifier first
|
||||
const int32 pctBonus = GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_CRIT_DAMAGE_BONUS, GetSpellSchoolMask(spellProto));
|
||||
crit_bonus += int32((damage + crit_bonus) * float(pctBonus / 100.0f));
|
||||
|
||||
// adds additional damage to crit_bonus (from talents)
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CRIT_DAMAGE_BONUS, crit_bonus);
|
||||
|
|
@ -7438,8 +7492,6 @@ uint32 Unit::SpellCriticalDamageBonus(SpellEntry const* spellProto, uint32 damag
|
|||
else
|
||||
critPctDamageMod += pVictim->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_DAMAGE, GetSpellSchoolMask(spellProto));
|
||||
|
||||
critPctDamageMod += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_CRIT_DAMAGE_BONUS, GetSpellSchoolMask(spellProto));
|
||||
|
||||
if (critPctDamageMod != 0)
|
||||
crit_bonus = int32(crit_bonus * float((100.0f + critPctDamageMod) / 100.0f));
|
||||
|
||||
|
|
@ -7535,9 +7587,9 @@ uint32 Unit::SpellHealingBonusDone(Unit* pVictim, SpellEntry const* spellProto,
|
|||
int ownHotCount = 0; // counted HoT types amount, not stacks
|
||||
|
||||
Unit::AuraList const& RejorRegr = pVictim->GetAurasByType(SPELL_AURA_PERIODIC_HEAL);
|
||||
for(Unit::AuraList::const_iterator i = RejorRegr.begin(); i != RejorRegr.end(); ++i)
|
||||
if ((*i)->GetSpellProto()->GetSpellFamilyName() == SPELLFAMILY_DRUID &&
|
||||
(*i)->GetCasterGuid() == GetObjectGuid())
|
||||
for (Unit::AuraList::const_iterator itr = RejorRegr.begin(); itr != RejorRegr.end(); ++itr)
|
||||
if ((*itr)->GetSpellProto()->GetSpellFamilyName() == SPELLFAMILY_DRUID &&
|
||||
(*itr)->GetCasterGuid() == GetObjectGuid())
|
||||
++ownHotCount;
|
||||
|
||||
if (ownHotCount)
|
||||
|
|
@ -8274,13 +8326,11 @@ void Unit::Mount(uint32 mount, uint32 spellId)
|
|||
// Normal case (Unsummon only permanent pet)
|
||||
else if (Pet* pet = GetPet())
|
||||
{
|
||||
if (pet->IsPermanentPetFor((Player*)this) && !((Player*)this)->InArena() &&
|
||||
sWorld.getConfig(CONFIG_BOOL_PET_UNSUMMON_AT_MOUNT))
|
||||
{
|
||||
if (pet->isControlled() && (!(pet->isTemporarySummoned() || ((Player*)this)->InArena())
|
||||
|| sWorld.getConfig(CONFIG_BOOL_PET_UNSUMMON_AT_MOUNT)))
|
||||
((Player*)this)->UnsummonPetTemporaryIfAny();
|
||||
}
|
||||
else
|
||||
pet->ApplyModeFlags(PET_MODE_DISABLE_ACTIONS, true);
|
||||
pet->SetModeFlags(PET_MODE_DISABLE_ACTIONS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue