Scripts/AreaTrigger: Added CanCaptureFlag and CaptureFlag hooks
Port From (https://github.com/TrinityCore/TrinityCore/commit/30f57de184fb96dfb6c548201e7717fa293682e1)
This commit is contained in:
@@ -46,6 +46,9 @@ namespace Game.Maps
|
|||||||
|
|
||||||
public virtual void OnFlagStateChange(GameObject flagInBase, FlagState oldValue, FlagState newValue, Player player) { }
|
public virtual void OnFlagStateChange(GameObject flagInBase, FlagState oldValue, FlagState newValue, Player player) { }
|
||||||
|
|
||||||
|
public virtual bool CanCaptureFlag(AreaTrigger areaTrigger, Player player) { return false; }
|
||||||
|
public virtual void OnCaptureFlag(AreaTrigger areaTrigger, Player player) { }
|
||||||
|
|
||||||
protected EventMap _events = new();
|
protected EventMap _events = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,13 @@
|
|||||||
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
using Framework.Constants;
|
using Framework.Constants;
|
||||||
|
using Game.AI;
|
||||||
using Game.DataStorage;
|
using Game.DataStorage;
|
||||||
using Game.Entities;
|
using Game.Entities;
|
||||||
|
using Game.Maps;
|
||||||
using Game.Scripting;
|
using Game.Scripting;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Game.AI;
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Scripts.World.Areatriggers
|
namespace Scripts.World.Areatriggers
|
||||||
{
|
{
|
||||||
@@ -433,4 +434,21 @@ namespace Scripts.World.Areatriggers
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Script]
|
||||||
|
class areatrigger_action_capture_flag : AreaTriggerAI
|
||||||
|
{
|
||||||
|
public areatrigger_action_capture_flag(AreaTrigger areatrigger) : base(areatrigger) { }
|
||||||
|
|
||||||
|
public override void OnUnitEnter(Unit unit)
|
||||||
|
{
|
||||||
|
if (!unit.IsPlayer())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player player = unit.ToPlayer();
|
||||||
|
ZoneScript zoneScript = at.GetZoneScript();
|
||||||
|
if (zoneScript != null && zoneScript.CanCaptureFlag(at, player))
|
||||||
|
zoneScript.OnCaptureFlag(at, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user