mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-15 10:00:28 +00:00
fix(Core/Leash): Improve leashing behavior and timer handling (#22525)
This commit is contained in:
committed by
GitHub
parent
40c58123b1
commit
67aa022dbf
@@ -4185,6 +4185,15 @@ void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id, bool withI
|
||||
InterruptSpell(CURRENT_CHANNELED_SPELL, true, true, bySelf);
|
||||
}
|
||||
|
||||
Spell* Unit::GetFirstCurrentCastingSpell() const
|
||||
{
|
||||
for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++)
|
||||
if (m_currentSpells[i] && m_currentSpells[i]->GetCastTimeRemaining() > 0)
|
||||
return m_currentSpells[i];
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Spell* Unit::FindCurrentSpellBySpellId(uint32 spell_id) const
|
||||
{
|
||||
for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++)
|
||||
@@ -10412,8 +10421,29 @@ bool Unit::Attack(Unit* victim, bool meleeAttack)
|
||||
if (meleeAttack)
|
||||
AddUnitState(UNIT_STATE_MELEE_ATTACKING);
|
||||
|
||||
Unit* owner = GetCharmerOrOwner();
|
||||
Creature* ownerCreature = owner ? owner->ToCreature() : nullptr;
|
||||
Creature* controlledCreatureWithSameVictim = nullptr;
|
||||
if (creature && !m_Controlled.empty())
|
||||
{
|
||||
for (ControlSet::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
|
||||
{
|
||||
if ((*itr)->ToCreature() && (*itr)->GetVictim() == victim)
|
||||
{
|
||||
controlledCreatureWithSameVictim = (*itr)->ToCreature();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Share leash timer with controlled unit
|
||||
if (controlledCreatureWithSameVictim)
|
||||
creature->SetLastLeashExtensionTimePtr(controlledCreatureWithSameVictim->GetLastLeashExtensionTimePtr());
|
||||
// Share leash timer with owner
|
||||
else if (creature && ownerCreature && ownerCreature->GetVictim() == victim)
|
||||
creature->SetLastLeashExtensionTimePtr(ownerCreature->GetLastLeashExtensionTimePtr());
|
||||
// Update leash timer when attacking creatures
|
||||
if (victim->IsCreature())
|
||||
else if (victim->IsCreature())
|
||||
victim->ToCreature()->UpdateLeashExtensionTime();
|
||||
|
||||
// set position before any AI calls/assistance
|
||||
|
||||
Reference in New Issue
Block a user