Skip to content

Commit

Permalink
Creature: Add function to CallAssistance explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
insunaa authored and killerwife committed Oct 6, 2024
1 parent f5c57fb commit 74d69d4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/game/Entities/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2174,9 +2174,14 @@ bool Creature::IsVisibleInGridForPlayer(Player* pl) const
}

void Creature::CallAssistance()
{
CallAssistance(GetVictim());
}

void Creature::CallAssistance(Unit* enemy)
{
// FIXME: should player pets call for assistance?
if (!m_AlreadyCallAssistance && GetVictim() && !HasCharmer())
if (!m_AlreadyCallAssistance && enemy && !HasCharmer())
{
MANGOS_ASSERT(AI());

Expand All @@ -2188,7 +2193,7 @@ void Creature::CallAssistance()
float radius = sWorld.getConfig(CONFIG_FLOAT_CREATURE_FAMILY_ASSISTANCE_RADIUS);
if (GetCreatureInfo()->CallForHelp > 0)
radius = GetCreatureInfo()->CallForHelp;
AI()->SendAIEventAround(AI_EVENT_CALL_ASSISTANCE, GetVictim(), sWorld.getConfig(CONFIG_UINT32_CREATURE_FAMILY_ASSISTANCE_DELAY), radius);
AI()->SendAIEventAround(AI_EVENT_CALL_ASSISTANCE, enemy, sWorld.getConfig(CONFIG_UINT32_CREATURE_FAMILY_ASSISTANCE_DELAY), radius);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/game/Entities/Creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ class Creature : public Unit

void CallForHelp(float radius);
void CallAssistance();
void CallAssistance(Unit* enemy);
void SetNoCallAssistance(bool val) { m_AlreadyCallAssistance = val; }
bool CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction = true) const;
bool CanInitiateAttack() const;
Expand Down
2 changes: 1 addition & 1 deletion src/game/Entities/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9034,7 +9034,7 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy)
if (InstanceData* mapInstance = GetInstanceData())
mapInstance->OnCreatureEnterCombat(creature);

creature->CallAssistance();
creature->CallAssistance(enemy);

creature->SetCanCheckForHelp(false);
creature->m_events.AddEvent(new UnitLambdaEvent(*creature, [](Unit& unit)
Expand Down

0 comments on commit 74d69d4

Please sign in to comment.