Core/Player: Added PlayerCreateMode field to playercreateinfo_cast_spell to only cast spells based on related mode

Port From (https://github.com/TrinityCore/TrinityCore/commit/8a61024cfad05279791badf33fcdb5a608ad6e94)
This commit is contained in:
hondacrx
2022-02-25 19:43:04 -05:00
parent fcc371968a
commit 5720b89b7e
4 changed files with 23 additions and 8 deletions
+3 -1
View File
@@ -794,7 +794,9 @@ namespace Framework.Constants
public enum PlayerCreateMode
{
Normal = 0,
NPE = 1
NPE = 1,
Max
}
public enum DuelState
+7 -1
View File
@@ -269,7 +269,7 @@ namespace Game.Entities
public List<PlayerCreateInfoItem> item = new();
public List<uint> customSpells = new();
public List<uint> castSpells = new();
public List<uint>[] castSpells = new List<uint>[(int)PlayerCreateMode.Max];
public List<PlayerCreateInfoAction> action = new();
public List<SkillRaceClassInfoRecord> skills = new();
@@ -279,6 +279,12 @@ namespace Game.Entities
public PlayerLevelInfo[] levelInfo = new PlayerLevelInfo[WorldConfig.GetIntValue(WorldCfg.MaxPlayerLevel)];
public PlayerInfo()
{
for (var i = 0; i < castSpells.Length; ++i)
castSpells[i] = new List<uint>();
}
public struct CreatePosition
{
public WorldLocation Loc;
+12 -5
View File
@@ -6123,7 +6123,7 @@ namespace Game
{
uint oldMSTime = Time.GetMSTime();
SQLResult result = DB.World.Query("SELECT raceMask, classMask, spell FROM playercreateinfo_cast_spell");
SQLResult result = DB.World.Query("SELECT raceMask, classMask, spell, createMode FROM playercreateinfo_cast_spell");
if (result.IsEmpty())
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 player create cast spells. DB table `playercreateinfo_cast_spell` is empty.");
@@ -6136,16 +6136,23 @@ namespace Game
ulong raceMask = result.Read<ulong>(0);
uint classMask = result.Read<uint>(1);
uint spellId = result.Read<uint>(2);
sbyte playerCreateMode = result.Read<sbyte>(3);
if (raceMask != 0 && (raceMask & SharedConst.RaceMaskAllPlayable) == 0)
{
Log.outError(LogFilter.Sql, "Wrong race mask {0} in `playercreateinfo_cast_spell` table, ignoring.", raceMask);
Log.outError(LogFilter.Sql, $"Wrong race mask {raceMask} in `playercreateinfo_cast_spell` table, ignoring.");
continue;
}
if (classMask != 0 && !classMask.HasAnyFlag<uint>((uint)Class.ClassMaskAllPlayable))
if (classMask != 0 && !classMask.HasAnyFlag((uint)Class.ClassMaskAllPlayable))
{
Log.outError(LogFilter.Sql, "Wrong class mask {0} in `playercreateinfo_cast_spell` table, ignoring.", classMask);
Log.outError(LogFilter.Sql, $"Wrong class mask {classMask} in `playercreateinfo_cast_spell` table, ignoring.");
continue;
}
if (playerCreateMode < 0 || playerCreateMode >= (sbyte)PlayerCreateMode.Max)
{
Log.outError(LogFilter.Sql, $"Uses invalid createMode {playerCreateMode} in `playercreateinfo_cast_spell` table, ignoring.");
continue;
}
@@ -6160,7 +6167,7 @@ namespace Game
PlayerInfo info = _playerInfo[(int)raceIndex][classIndex];
if (info != null)
{
info.castSpells.Add(spellId);
info.castSpells[playerCreateMode].Add(spellId);
++count;
}
}
+1 -1
View File
@@ -963,7 +963,7 @@ namespace Game
pCurrChar.RemoveAtLoginFlag(AtLoginFlags.FirstLogin);
PlayerInfo info = Global.ObjectMgr.GetPlayerInfo(pCurrChar.GetRace(), pCurrChar.GetClass());
foreach (var spellId in info.castSpells)
foreach (var spellId in info.castSpells[(int)pCurrChar.GetCreateMode()])
pCurrChar.CastSpell(pCurrChar, spellId, new CastSpellExtraArgs(true));
// start with every map explored