Core/GameObject: Implemented OnFlagTaken/OnFlagDropped hooks for GAMEOBJECT_TYPE_FLAGSTAND
Port From (https://github.com/TrinityCore/TrinityCore/commit/0535a61cb7c9da97f05e5867ce181d91e3dd92eb)
This commit is contained in:
@@ -2632,8 +2632,22 @@ namespace Game.Entities
|
||||
SpellCastResult castResult = CastSpell(user, spellId);
|
||||
if (castResult == SpellCastResult.Success)
|
||||
{
|
||||
if (GetGoType() == GameObjectTypes.NewFlag)
|
||||
HandleCustomTypeCommand(new GameObjectType.SetNewFlagState(FlagState.Taken, user.ToPlayer()));
|
||||
switch (GetGoType())
|
||||
{
|
||||
case GameObjectTypes.NewFlag:
|
||||
HandleCustomTypeCommand(new GameObjectType.SetNewFlagState(FlagState.Taken, user.ToPlayer()));
|
||||
break;
|
||||
case GameObjectTypes.FlagStand:
|
||||
SetFlag(GameObjectFlags.InUse);
|
||||
ZoneScript zonescript = GetZoneScript();
|
||||
if (zonescript != null)
|
||||
zonescript.OnFlagTaken(this, user?.ToPlayer());
|
||||
|
||||
Delete();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,11 @@ namespace Game.Maps
|
||||
|
||||
public virtual bool CanCaptureFlag(AreaTrigger areaTrigger, Player player) { return false; }
|
||||
public virtual void OnCaptureFlag(AreaTrigger areaTrigger, Player player) { }
|
||||
|
||||
// This hook is used with GAMEOBJECT_TYPE_FLAGSTAND. Newer gameobjects use GAMEOBJECT_TYPE_NEW_FLAG and should use `OnFlagStateChange`
|
||||
public virtual void OnFlagTaken(GameObject flag, Player player) { }
|
||||
// This hook is used with GAMEOBJECT_TYPE_FLAGSTAND. Newer gameobjects use GAMEOBJECT_TYPE_NEW_FLAG and should use `OnFlagStateChange`. The GameObject doesn't exist anymore, but the ObjectGuid does
|
||||
public virtual void OnFlagDropped(ObjectGuid flagGuid, Player player) { }
|
||||
}
|
||||
|
||||
public class ControlZoneHandler
|
||||
|
||||
@@ -6004,15 +6004,28 @@ namespace Game.Spells
|
||||
|
||||
if (!apply && aurApp.GetRemoveMode() != AuraRemoveMode.Default)
|
||||
{
|
||||
GameObject gameObjectCaster = target.GetMap().GetGameObject(GetCasterGUID());
|
||||
if (gameObjectCaster != null)
|
||||
if (GetCasterGUID().IsGameObject())
|
||||
{
|
||||
if (gameObjectCaster.GetGoType() == GameObjectTypes.NewFlag)
|
||||
GameObjectTemplate gobTemplate = Global.ObjectMgr.GetGameObjectTemplate(GetCasterGUID().GetEntry());
|
||||
if (gobTemplate != null)
|
||||
{
|
||||
gameObjectCaster.HandleCustomTypeCommand(new SetNewFlagState(FlagState.Dropped, target));
|
||||
GameObject droppedFlag = gameObjectCaster.SummonGameObject(gameObjectCaster.GetGoInfo().NewFlag.FlagDrop, target.GetPosition(), Quaternion.CreateFromRotationMatrix(Extensions.fromEulerAnglesZYX(target.GetOrientation(), 0.0f, 0.0f)), TimeSpan.FromSeconds(gameObjectCaster.GetGoInfo().NewFlag.ExpireDuration / 1000), GameObjectSummonType.TimedDespawn);
|
||||
if (droppedFlag != null)
|
||||
droppedFlag.SetOwnerGUID(gameObjectCaster.GetGUID());
|
||||
if (gobTemplate.type == GameObjectTypes.NewFlag)
|
||||
{
|
||||
GameObject gameObjectCaster = target.GetMap().GetGameObject(GetCasterGUID());
|
||||
if (gameObjectCaster != null)
|
||||
{
|
||||
gameObjectCaster.HandleCustomTypeCommand(new SetNewFlagState(FlagState.Dropped, target));
|
||||
GameObject droppedFlag = gameObjectCaster.SummonGameObject(gameObjectCaster.GetGoInfo().NewFlag.FlagDrop, target.GetPosition(), Quaternion.CreateFromRotationMatrix(Extensions.fromEulerAnglesZYX(target.GetOrientation(), 0.0f, 0.0f)), TimeSpan.FromSeconds(gameObjectCaster.GetGoInfo().NewFlag.ExpireDuration / 1000), GameObjectSummonType.TimedDespawn);
|
||||
if (droppedFlag != null)
|
||||
droppedFlag.SetOwnerGUID(gameObjectCaster.GetGUID());
|
||||
}
|
||||
}
|
||||
else if (gobTemplate.type == GameObjectTypes.FlagStand)
|
||||
{
|
||||
ZoneScript zonescript = target.FindZoneScript();
|
||||
if (zonescript != null)
|
||||
zonescript.OnFlagDropped(GetCasterGUID(), target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user