Core/Scripts: Implemented OnlyOnceAreaTriggerScript
Port From (https://github.com/TrinityCore/TrinityCore/commit/fe938b99f843df3f6c120695db38f327bd55ea94)
This commit is contained in:
@@ -872,11 +872,16 @@ namespace Game.Maps
|
|||||||
public uint GetCompletedEncounterMask() { return completedEncounters; }
|
public uint GetCompletedEncounterMask() { return completedEncounters; }
|
||||||
|
|
||||||
// Sets a temporary entrance that does not get saved to db
|
// Sets a temporary entrance that does not get saved to db
|
||||||
void SetTemporaryEntranceLocation(uint worldSafeLocationId) { _temporaryEntranceId = worldSafeLocationId; }
|
public void SetTemporaryEntranceLocation(uint worldSafeLocationId) { _temporaryEntranceId = worldSafeLocationId; }
|
||||||
|
|
||||||
// Get's the current entrance id
|
// Get's the current entrance id
|
||||||
public uint GetEntranceLocation() { return _temporaryEntranceId != 0 ? _temporaryEntranceId : _entranceId; }
|
public uint GetEntranceLocation() { return _temporaryEntranceId != 0 ? _temporaryEntranceId : _entranceId; }
|
||||||
|
|
||||||
|
// Only used by areatriggers that inherit from OnlyOnceAreaTriggerScript
|
||||||
|
public void MarkAreaTriggerDone(uint id) { _activatedAreaTriggers.Add(id); }
|
||||||
|
public void ResetAreaTriggerDone(uint id) { _activatedAreaTriggers.Remove(id); }
|
||||||
|
public bool IsAreaTriggerDone(uint id) { return _activatedAreaTriggers.Contains(id); }
|
||||||
|
|
||||||
public virtual void FillInitialWorldStates(InitWorldStates data) { }
|
public virtual void FillInitialWorldStates(InitWorldStates data) { }
|
||||||
|
|
||||||
public int GetEncounterCount() { return bosses.Count; }
|
public int GetEncounterCount() { return bosses.Count; }
|
||||||
@@ -909,6 +914,7 @@ namespace Game.Maps
|
|||||||
Dictionary<uint, ObjectGuid> _objectGuids = new Dictionary<uint, ObjectGuid>();
|
Dictionary<uint, ObjectGuid> _objectGuids = new Dictionary<uint, ObjectGuid>();
|
||||||
uint completedEncounters;
|
uint completedEncounters;
|
||||||
List<InstanceSpawnGroupInfo> _instanceSpawnGroups = new List<InstanceSpawnGroupInfo>();
|
List<InstanceSpawnGroupInfo> _instanceSpawnGroups = new List<InstanceSpawnGroupInfo>();
|
||||||
|
List<uint> _activatedAreaTriggers = new List<uint>();
|
||||||
uint _entranceId;
|
uint _entranceId;
|
||||||
uint _temporaryEntranceId;
|
uint _temporaryEntranceId;
|
||||||
uint _combatResurrectionTimer;
|
uint _combatResurrectionTimer;
|
||||||
|
|||||||
@@ -366,6 +366,39 @@ namespace Game.Scripting
|
|||||||
public virtual bool OnTrigger(Player player, AreaTriggerRecord trigger, bool entered) { return false; }
|
public virtual bool OnTrigger(Player player, AreaTriggerRecord trigger, bool entered) { return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class OnlyOnceAreaTriggerScript : AreaTriggerScript
|
||||||
|
{
|
||||||
|
public OnlyOnceAreaTriggerScript(string name) : base(name) { }
|
||||||
|
|
||||||
|
public override bool OnTrigger(Player player, AreaTriggerRecord trigger, bool entered)
|
||||||
|
{
|
||||||
|
uint triggerId = trigger.Id;
|
||||||
|
InstanceScript instance = player.GetInstanceScript();
|
||||||
|
if (instance != null)
|
||||||
|
{
|
||||||
|
if (instance.IsAreaTriggerDone(triggerId))
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
instance.MarkAreaTriggerDone(triggerId);
|
||||||
|
}
|
||||||
|
return _OnTrigger(player, trigger, entered);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResetAreaTriggerDone(InstanceScript script, uint triggerId)
|
||||||
|
{
|
||||||
|
script.ResetAreaTriggerDone(triggerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResetAreaTriggerDone(Player player, AreaTriggerRecord trigger)
|
||||||
|
{
|
||||||
|
InstanceScript instance = player.GetInstanceScript();
|
||||||
|
if (instance != null)
|
||||||
|
ResetAreaTriggerDone(instance, trigger.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool _OnTrigger(Player player, AreaTriggerRecord trigger, bool entered) { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
public class BattlegroundScript : ScriptObject
|
public class BattlegroundScript : ScriptObject
|
||||||
{
|
{
|
||||||
public BattlegroundScript(string name) : base(name)
|
public BattlegroundScript(string name) : base(name)
|
||||||
|
|||||||
@@ -186,9 +186,9 @@ namespace Scripts.Northrend.AzjolNerub.AzjolNerub.KrikthirTheGatewatcher
|
|||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case -ANInstanceMisc.ActionGatewatcherGreet:
|
case -ANInstanceMisc.ActionGatewatcherGreet:
|
||||||
if (!_hadGreet && me.IsAlive() && !me.IsInCombat() && !_petsInCombat)
|
if (instance.GetData(ANDataTypes.GatewatcherGreet) == 0 && me.IsAlive() && !me.IsInCombat() && !_petsInCombat)
|
||||||
{
|
{
|
||||||
_hadGreet = true;
|
instance.SetData(ANDataTypes.GatewatcherGreet, 1);
|
||||||
Talk(TextIds.SayPrefight);
|
Talk(TextIds.SayPrefight);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -277,7 +277,6 @@ namespace Scripts.Northrend.AzjolNerub.AzjolNerub.KrikthirTheGatewatcher
|
|||||||
Talk(TextIds.SaySendGroup);
|
Talk(TextIds.SaySendGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _hadGreet;
|
|
||||||
bool _hadFrenzy;
|
bool _hadFrenzy;
|
||||||
bool _petsInCombat;
|
bool _petsInCombat;
|
||||||
byte _watchersActive;
|
byte _watchersActive;
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ namespace Scripts.Northrend.AzjolNerub.AzjolNerub
|
|||||||
public const uint WatcherSilthik = 5;
|
public const uint WatcherSilthik = 5;
|
||||||
public const uint AnubarakWall = 6;
|
public const uint AnubarakWall = 6;
|
||||||
public const uint AnubarakWall2 = 7;
|
public const uint AnubarakWall2 = 7;
|
||||||
|
public const uint GatewatcherGreet = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ANCreatureIds
|
struct ANCreatureIds
|
||||||
@@ -103,6 +104,8 @@ namespace Scripts.Northrend.AzjolNerub.AzjolNerub
|
|||||||
|
|
||||||
class instance_azjol_nerub_InstanceScript : InstanceScript
|
class instance_azjol_nerub_InstanceScript : InstanceScript
|
||||||
{
|
{
|
||||||
|
uint _gateWatcherGreet;
|
||||||
|
|
||||||
public instance_azjol_nerub_InstanceScript(InstanceMap map) : base(map)
|
public instance_azjol_nerub_InstanceScript(InstanceMap map) : base(map)
|
||||||
{
|
{
|
||||||
SetHeaders(ANInstanceMisc.DataHeader);
|
SetHeaders(ANInstanceMisc.DataHeader);
|
||||||
@@ -134,7 +137,30 @@ namespace Scripts.Northrend.AzjolNerub.AzjolNerub
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public override uint GetData(uint dataId)
|
||||||
|
{
|
||||||
|
switch (dataId)
|
||||||
|
{
|
||||||
|
case ANDataTypes.GatewatcherGreet:
|
||||||
|
return _gateWatcherGreet;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetData(uint dataId, uint value)
|
||||||
|
{
|
||||||
|
switch (dataId)
|
||||||
|
{
|
||||||
|
case ANDataTypes.GatewatcherGreet:
|
||||||
|
_gateWatcherGreet = value;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override InstanceScript GetInstanceScript(InstanceMap map)
|
public override InstanceScript GetInstanceScript(InstanceMap map)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user