Core/Players: PlayerChoice improvements

Port From (https://github.com/TrinityCore/TrinityCore/commit/e59059e1bd2f67691e2da0105771b0cb55b123a4)
This commit is contained in:
Hondacrx
2025-08-18 16:57:28 -04:00
parent 1f6f9013c7
commit cd0ffc6975
9 changed files with 284 additions and 212 deletions
+12 -3
View File
@@ -703,9 +703,6 @@ namespace Game.Scripting
// Called when a player completes a movie
public virtual void OnMovieComplete(Player player, uint movieId) { }
// Called when a player choose a response from a PlayerChoice
public virtual void OnPlayerChoiceResponse(Player player, uint choiceId, uint responseId) { }
}
public class AccountScript : ScriptObject
@@ -892,4 +889,16 @@ namespace Game.Scripting
// Called when a game event is triggered
public virtual void OnTrigger(WorldObject obj, WorldObject invoker, uint eventId) { }
}
public class PlayerChoiceScript : ScriptObject
{
public PlayerChoiceScript(string name) : base(name)
{
Global.ScriptMgr.AddScript(this);
}
public override bool IsDatabaseBound() { return true; }
public virtual void OnResponse(WorldObject obj, Player player, PlayerChoice choice, PlayerChoiceResponse response, ushort clientIdentifier) { }
}
}
+5 -2
View File
@@ -915,9 +915,12 @@ namespace Game.Scripting
{
ForEach<PlayerScript>(p => p.OnMovieComplete(player, movieId));
}
public void OnPlayerChoiceResponse(Player player, uint choiceId, uint responseId)
public void OnPlayerChoiceResponse(WorldObject obj, Player player, PlayerChoice choice, PlayerChoiceResponse response, ushort clientIdentifier)
{
ForEach<PlayerScript>(p => p.OnPlayerChoiceResponse(player, choiceId, responseId));
Cypher.Assert(choice != null);
Cypher.Assert(response != null);
ForEach<PlayerChoiceScript>(p => p.OnResponse(obj, player, choice, response, clientIdentifier));
}
// Account