More work on scripts.

This commit is contained in:
hondacrx
2023-10-13 20:25:10 -04:00
parent b2ac8035f2
commit 50cda96b45
16 changed files with 1073 additions and 732 deletions
+27 -1
View File
@@ -653,7 +653,7 @@ namespace Game.Scripting
public virtual void OnSpellCast(Player player, Spell spell, bool skipCheck) { }
// Called when a player logs in.
public virtual void OnLogin(Player player) { }
public virtual void OnLogin(Player player, bool firstLogin) { }
// Called when a player logs out.
public virtual void OnLogout(Player player) { }
@@ -692,6 +692,32 @@ namespace Game.Scripting
public virtual void OnPlayerChoiceResponse(Player player, uint choiceId, uint responseId) { }
}
public class AccountScript : ScriptObject
{
public AccountScript(string name) : base(name)
{
Global.ScriptMgr.AddScript(this);
}
// Called when an account logged in succesfully
public virtual void OnAccountLogin(uint accountId) { }
// Called when an account login failed
public virtual void OnFailedAccountLogin(uint accountId) { }
// Called when Email is successfully changed for Account
public virtual void OnEmailChange(uint accountId) { }
// Called when Email failed to change for Account
public virtual void OnFailedEmailChange(uint accountId) { }
// Called when Password is successfully changed for Account
public virtual void OnPasswordChange(uint accountId) { }
// Called when Password failed to change for Account
public virtual void OnFailedPasswordChange(uint accountId) { }
}
public class GuildScript : ScriptObject
{
public GuildScript(string name) : base(name)
+32 -5
View File
@@ -147,6 +147,7 @@ namespace Game.Scripting
case "TransportScript":
case "AchievementCriteriaScript":
case "PlayerScript":
case "AccountScript":
case "GuildScript":
case "GroupScript":
case "AreaTriggerEntityScript":
@@ -267,7 +268,7 @@ namespace Game.Scripting
{
UnitAI.FillAISpellInfo();
}
public List<SplineChainLink> GetSplineChain(Creature who, ushort chainId)
{
return GetSplineChain(who.GetEntry(), chainId);
@@ -762,7 +763,7 @@ namespace Game.Scripting
RunScript<AchievementScript>(p => p.OnCompleted(player, achievement), Global.AchievementMgr.GetAchievementScriptId(achievement.Id));
}
// AchievementCriteriaScript
public bool OnCriteriaCheck(uint ScriptId, Player source, Unit target)
{
@@ -855,9 +856,9 @@ namespace Game.Scripting
{
ForEach<PlayerScript>(p => p.OnSpellCast(player, spell, skipCheck));
}
public void OnPlayerLogin(Player player)
public void OnPlayerLogin(Player player, bool firstLogin)
{
ForEach<PlayerScript>(p => p.OnLogin(player));
ForEach<PlayerScript>(p => p.OnLogin(player, firstLogin));
}
public void OnPlayerLogout(Player player)
{
@@ -904,6 +905,32 @@ namespace Game.Scripting
ForEach<PlayerScript>(p => p.OnPlayerChoiceResponse(player, choiceId, responseId));
}
// Account
public void OnAccountLogin(uint accountId)
{
ForEach<AccountScript>(script => script.OnAccountLogin(accountId));
}
public void OnFailedAccountLogin(uint accountId)
{
ForEach<AccountScript>(script => script.OnFailedAccountLogin(accountId));
}
public void OnEmailChange(uint accountId)
{
ForEach<AccountScript>(script => script.OnEmailChange(accountId));
}
public void OnFailedEmailChange(uint accountId)
{
ForEach<AccountScript>(script => script.OnFailedEmailChange(accountId));
}
public void OnPasswordChange(uint accountId)
{
ForEach<AccountScript>(script => script.OnPasswordChange(accountId));
}
public void OnFailedPasswordChange(uint accountId)
{
ForEach<AccountScript>(script => script.OnFailedPasswordChange(accountId));
}
// GuildScript
public void OnGuildAddMember(Guild guild, Player player, byte plRank)
{
@@ -1172,7 +1199,7 @@ namespace Game.Scripting
uint _ScriptCount;
public Dictionary<uint, SpellSummary> spellSummaryStorage = new();
Hashtable ScriptStorage = new();
// creature entry + chain ID
MultiMap<Tuple<uint, ushort>, SplineChainLink> m_mSplineChainsMap = new(); // spline chains
}