Core/Scripts: Fix EventScript assert for GameObject::SetDestructibleState

Port From (https://github.com/TrinityCore/TrinityCore/commit/3aa264d0c74d0425fd335d69e1890bef6dfa1838)
This commit is contained in:
hondacrx
2023-09-04 07:31:01 -04:00
parent 15fe47e0cb
commit 9ba60f66f8
3 changed files with 70 additions and 18 deletions
@@ -2809,7 +2809,7 @@ namespace Game.Entities
break;
case GameObjectDestructibleState.Damaged:
{
if (GetGoInfo().DestructibleBuilding.DamagedEvent != 0)
if (GetGoInfo().DestructibleBuilding.DamagedEvent != 0 && attackerOrHealer != null)
GameEvents.Trigger(GetGoInfo().DestructibleBuilding.DamagedEvent, attackerOrHealer, this);
GetAI().Damaged(attackerOrHealer, m_goInfo.DestructibleBuilding.DamagedEvent);
@@ -2836,7 +2836,7 @@ namespace Game.Entities
}
case GameObjectDestructibleState.Destroyed:
{
if (GetGoInfo().DestructibleBuilding.DestroyedEvent != 0)
if (GetGoInfo().DestructibleBuilding.DestroyedEvent != 0 && attackerOrHealer != null)
GameEvents.Trigger(GetGoInfo().DestructibleBuilding.DestroyedEvent, attackerOrHealer, this);
GetAI().Destroyed(attackerOrHealer, m_goInfo.DestructibleBuilding.DestroyedEvent);
@@ -2868,7 +2868,7 @@ namespace Game.Entities
}
case GameObjectDestructibleState.Rebuilding:
{
if (GetGoInfo().DestructibleBuilding.RebuildingEvent != 0)
if (GetGoInfo().DestructibleBuilding.RebuildingEvent != 0 && attackerOrHealer != null)
GameEvents.Trigger(GetGoInfo().DestructibleBuilding.RebuildingEvent, attackerOrHealer, this);
RemoveFlag(GameObjectFlags.Damaged | GameObjectFlags.Destroyed);