Skip to content

Commit

Permalink
EAI: Fix EVENT_T_DEATH not working with two layers deep PCs and fix n…
Browse files Browse the repository at this point in the history
…pcs not being checked against cond
  • Loading branch information
killerwife committed Sep 9, 2023
1 parent 966698d commit 3c0cf8f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion doc/EventAI.txt
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ NOTE: For Repeat Events the Repeat Timer ONLY Re-Check's Event Conditions to see
------------------
6 = EVENT_T_DEATH:
------------------
Parameter 1: ConditionId - condition from Conditions table
Parameter 1: ConditionId - condition from Conditions table - executed on either controlling player or killer

BOTH - This Event Expires upon Death of the Scripted NPC. This is normally only used in combat though.
This is commonly used for NPC's who have a Yell or Spell Cast when they Die.
Expand Down
9 changes: 6 additions & 3 deletions src/game/AI/EventAI/CreatureEventAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,12 @@ bool CreatureEventAI::CheckEvent(CreatureEventAIHolder& holder, Unit* actionInvo
if (!actionInvoker)
return false;

if (Player* player = actionInvoker->GetBeneficiaryPlayer())
if (!sObjectMgr.IsConditionSatisfied(event.death.conditionId, player, player->GetMap(), m_creature, CONDITION_FROM_EVENTAI))
return false;
Unit const* controller = actionInvoker->GetControllingPlayer();
if (!controller) // only allow going forward if we can evaluate condition
controller = actionInvoker;

if (!sObjectMgr.IsConditionSatisfied(event.death.conditionId, controller, controller->GetMap(), m_creature, CONDITION_FROM_EVENTAI))
return false;
}
break;
case EVENT_T_EVADE:
Expand Down

0 comments on commit 3c0cf8f

Please sign in to comment.