Core/Scripts: Added script hook to execute actions after completing an achievement
Port From (https://github.com/TrinityCore/TrinityCore/commit/27cba3f52309dad5be964fec11d80cd8cad128cf)
This commit is contained in:
@@ -586,6 +586,19 @@ namespace Game.Scripting
|
||||
public virtual void OnUpdate(Transport obj, uint diff) { }
|
||||
}
|
||||
|
||||
public class AchievementScript : ScriptObject
|
||||
{
|
||||
public AchievementScript(string name) : base(name)
|
||||
{
|
||||
Global.ScriptMgr.AddScript(this);
|
||||
}
|
||||
|
||||
public override bool IsDatabaseBound() { return true; }
|
||||
|
||||
// Called when an achievement is completed.
|
||||
public virtual void OnCompleted(Player player, AchievementRecord achievement) { }
|
||||
}
|
||||
|
||||
public class AchievementCriteriaScript : ScriptObject
|
||||
{
|
||||
public AchievementCriteriaScript(string name) : base(name)
|
||||
@@ -593,7 +606,7 @@ namespace Game.Scripting
|
||||
Global.ScriptMgr.AddScript(this);
|
||||
}
|
||||
|
||||
public override bool IsDatabaseBound() { return false; }
|
||||
public override bool IsDatabaseBound() { return true; }
|
||||
|
||||
// Called when an additional criteria is checked.
|
||||
public virtual bool OnCheck(Player source, Unit target) { return false; }
|
||||
|
||||
@@ -866,6 +866,15 @@ namespace Game.Scripting
|
||||
RunScript<TransportScript>(p => p.OnRelocate(transport, waypointId, mapId, x, y, z), transport.GetScriptId());
|
||||
}
|
||||
|
||||
// Achievement
|
||||
public void OnAchievementCompleted(Player player, AchievementRecord achievement)
|
||||
{
|
||||
Cypher.Assert(player != null);
|
||||
Cypher.Assert(achievement != null);
|
||||
|
||||
RunScript<AchievementScript>(p => p.OnCompleted(player, achievement), Global.AchievementMgr.GetAchievementScriptId(achievement.Id));
|
||||
}
|
||||
|
||||
// AchievementCriteriaScript
|
||||
public bool OnCriteriaCheck(uint ScriptId, Player source, Unit target)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user