Skip to content

Commit

Permalink
[Core/Spell] To fix hunter spell Stampede #302 #315 (#320)
Browse files Browse the repository at this point in the history
Remaining issues will be handled by PR later
  • Loading branch information
5840174 authored Aug 11, 2024
1 parent 9f94a7a commit 3cd41b3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
13 changes: 10 additions & 3 deletions src/server/game/Entities/Creature/TemporarySummon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ void TempSummon::UnSummon(uint32 msTime)
}

//ASSERT(!IsPet());
if (IsPet())
if (IsPet() && !ToPet()->IsTemporary())
{
ToPet()->Remove(PET_REMOVE_DISMISS, PET_REMOVE_FLAG_RESET_CURRENT);
ASSERT(!IsInWorld());
Expand All @@ -334,6 +334,9 @@ void TempSummon::UnSummon(uint32 msTime)
if (owner && owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled)
owner->ToCreature()->AI()->SummonedCreatureDespawn(this);

if (IsAIEnabled)
AI()->Unsummoned();

AddObjectToRemoveList();
}

Expand Down Expand Up @@ -429,14 +432,18 @@ void Minion::RemoveFromWorld()

bool Minion::IsGuardianPet() const
{
return IsPet() || (m_Properties && m_Properties->Category == SUMMON_CATEGORY_PET);
if (IsPet())
return !ToPet()->IsTemporary();

return m_Properties && m_Properties->Category == SUMMON_CATEGORY_PET;
}

Guardian::Guardian(SummonPropertiesEntry const* properties, Unit* owner, bool isWorldObject) : Minion(properties, owner, isWorldObject), m_bonusSpellDamage(0)
{
memset(m_statFromOwner, 0, sizeof(float)*MAX_STATS);
m_unitTypeMask |= UNIT_MASK_GUARDIAN;
if (properties && properties->Type == SUMMON_TYPE_PET)
if (properties && (properties->Category == SUMMON_CATEGORY_PET ||
(properties->Type == SUMMON_TYPE_PET && properties->Category != SUMMON_CATEGORY_ALLY)))
{
m_unitTypeMask |= UNIT_MASK_CONTROLABLE_GUARDIAN;
InitCharmInfo();
Expand Down
15 changes: 5 additions & 10 deletions src/server/game/Entities/Pet/Pet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,15 +570,7 @@ void Pet::Update(uint32 diff)
m_duration -= diff;
else
{
if (getPetType() != SUMMON_PET)
{
Remove(PET_REMOVE_DISMISS);
}
else
{
Remove(PET_REMOVE_DISMISS, PET_REMOVE_FLAG_RESET_CURRENT);
}

Remove(PET_REMOVE_DISMISS);
return;
}
}
Expand All @@ -591,7 +583,10 @@ void Pet::Update(uint32 diff)

void Pet::Remove(PetRemoveMode mode, int32 flags)
{
GetOwner()->RemovePet(mode, flags);
if (IsTemporary())
UnSummon();
else
GetOwner()->RemovePet(mode, flags);
}

bool Pet::IsAutoCastEnabled(uint32 spellId) const
Expand Down
12 changes: 11 additions & 1 deletion src/server/game/Entities/Unit/Unit.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* This file is part of the Legends of Azeroth Pandaria Project. See THANKS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -13820,6 +13820,16 @@ void Unit::RemoveFromWorld()
}
}

if (GetTypeId() == TYPEID_PLAYER)
{
while (!m_summons.empty())
{
auto summon = m_summons.front();
m_summons.pop_front();
summon->UnSummon();
}
}

getHostileRefManager().clearReferences();

WorldObject::RemoveFromWorld();
Expand Down
1 change: 1 addition & 0 deletions src/server/scripts/Spells/spell_hunter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ class spell_hunt_stampede : public SpellScript
pet->SetDuration(20 * IN_MILLISECONDS);
if (GetExplTargetUnit()->GetCharmerOrOwnerPlayerOrPlayerItself() || pet->GetMap()->IsBattlegroundOrArena())
pet->CastSpell(pet, SPELL_HUNTER_STAMPEDE_DAMAGE_REDUCTION, true);
pet->SetFullHealth();
}

void Register() override
Expand Down

0 comments on commit 3cd41b3

Please sign in to comment.