Updated all spell scripts

This commit is contained in:
Hondacrx
2025-10-13 13:23:31 -04:00
parent 3c4602e4a1
commit 3e028633ba
46 changed files with 33364 additions and 26554 deletions
+2 -2
View File
@@ -663,7 +663,7 @@ namespace Framework.Constants
Hunter = 3, Hunter = 3,
Rogue = 4, Rogue = 4,
Priest = 5, Priest = 5,
Deathknight = 6, DeathKnight = 6,
Shaman = 7, Shaman = 7,
Mage = 8, Mage = 8,
Warlock = 9, Warlock = 9,
@@ -675,7 +675,7 @@ namespace Framework.Constants
Max = 15, Max = 15,
ClassMaskAllPlayable = ((1 << (Warrior - 1)) | (1 << (Paladin - 1)) | (1 << (Hunter - 1)) | ClassMaskAllPlayable = ((1 << (Warrior - 1)) | (1 << (Paladin - 1)) | (1 << (Hunter - 1)) |
(1 << (Rogue - 1)) | (1 << (Priest - 1)) | (1 << (Deathknight - 1)) | (1 << (Shaman - 1)) | (1 << (Rogue - 1)) | (1 << (Priest - 1)) | (1 << (DeathKnight - 1)) | (1 << (Shaman - 1)) |
(1 << (Mage - 1)) | (1 << (Warlock - 1)) | (1 << (Monk - 1)) | (1 << (Druid - 1)) | (1 << (DemonHunter - 1)) | (1 << (Evoker - 1))), (1 << (Mage - 1)) | (1 << (Warlock - 1)) | (1 << (Monk - 1)) | (1 << (Druid - 1)) | (1 << (DemonHunter - 1)) | (1 << (Evoker - 1))),
ClassMaskAllCreatures = ((1 << (Warrior - 1)) | (1 << (Paladin - 1)) | (1 << (Rogue - 1)) | (1 << (Mage - 1))), ClassMaskAllCreatures = ((1 << (Warrior - 1)) | (1 << (Paladin - 1)) | (1 << (Rogue - 1)) | (1 << (Mage - 1))),
@@ -203,6 +203,33 @@ namespace System.Collections.Generic
while (list.Count <= index) while (list.Count <= index)
list.Add(defaultValue); list.Add(defaultValue);
} }
public static void PartitionInPlace<T>(this IList<T> list, Func<T, bool> predicate)
{
int left = 0;
int right = list.Count - 1;
while (left <= right)
{
while (left <= right && predicate(list[left]))
{
left++;
}
while (left <= right && !predicate(list[right]))
{
right--;
}
if (left < right)
{
T temp = list[left];
list[left] = list[right];
list[right] = temp;
left++;
right--;
}
}
}
} }
public interface ICheck<in T> public interface ICheck<in T>
+2 -2
View File
@@ -845,7 +845,7 @@ namespace Game.DataStorage
return row.Rogue; return row.Rogue;
case Class.Priest: case Class.Priest:
return row.Priest; return row.Priest;
case Class.Deathknight: case Class.DeathKnight:
return row.DeathKnight; return row.DeathKnight;
case Class.Shaman: case Class.Shaman:
return row.Shaman; return row.Shaman;
@@ -884,7 +884,7 @@ namespace Game.DataStorage
return row.Rogue; return row.Rogue;
case (int)Class.Priest: case (int)Class.Priest:
return row.Priest; return row.Priest;
case (int)Class.Deathknight: case (int)Class.DeathKnight:
return row.DeathKnight; return row.DeathKnight;
case (int)Class.Shaman: case (int)Class.Shaman:
return row.Shaman; return row.Shaman;
+2 -2
View File
@@ -1842,7 +1842,7 @@ namespace Game.DataStorage
{ {
return playerClass switch return playerClass switch
{ {
Class.Deathknight => numTalentsAtLevel.NumTalentsDeathKnight, Class.DeathKnight => numTalentsAtLevel.NumTalentsDeathKnight,
Class.DemonHunter => numTalentsAtLevel.NumTalentsDemonHunter, Class.DemonHunter => numTalentsAtLevel.NumTalentsDemonHunter,
_ => numTalentsAtLevel.NumTalents, _ => numTalentsAtLevel.NumTalents,
}; };
@@ -1897,7 +1897,7 @@ namespace Game.DataStorage
{ {
switch (class_) switch (class_)
{ {
case Class.Deathknight: case Class.DeathKnight:
return _pvpTalentSlotUnlock[slot].DeathKnightLevelRequired; return _pvpTalentSlotUnlock[slot].DeathKnightLevelRequired;
case Class.DemonHunter: case Class.DemonHunter:
return _pvpTalentSlotUnlock[slot].DemonHunterLevelRequired; return _pvpTalentSlotUnlock[slot].DemonHunterLevelRequired;
@@ -637,7 +637,7 @@ namespace Game.Entities
var conditions = Global.ConditionMgr.GetConditionsForAreaTrigger(GetTemplate().Id.Id, GetTemplate().Id.IsCustom); var conditions = Global.ConditionMgr.GetConditionsForAreaTrigger(GetTemplate().Id.Id, GetTemplate().Id.IsCustom);
targetList.RemoveAll(target => targetList.RemoveAll(target =>
{ {
if (GetCasterGuid() == target.GetGUID()) if (GetCasterGUID() == target.GetGUID())
{ {
if (HasActionSetFlag(AreaTriggerActionSetFlag.NotTriggeredbyCaster)) if (HasActionSetFlag(AreaTriggerActionSetFlag.NotTriggeredbyCaster))
return true; return true;
@@ -921,7 +921,7 @@ namespace Game.Entities
public Unit GetCaster() public Unit GetCaster()
{ {
return Global.ObjAccessor.GetUnit(this, GetCasterGuid()); return Global.ObjAccessor.GetUnit(this, GetCasterGUID());
} }
Unit GetTarget() Unit GetTarget()
@@ -1015,7 +1015,7 @@ namespace Game.Entities
} }
} }
float GetMaxSearchRadius() public float GetMaxSearchRadius()
{ {
return m_areaTriggerData.BoundsRadius2D * CalcCurrentScale(); return m_areaTriggerData.BoundsRadius2D * CalcCurrentScale();
} }
@@ -1161,7 +1161,7 @@ namespace Game.Entities
case AreaTriggerActionTypes.Cast: case AreaTriggerActionTypes.Cast:
goto case AreaTriggerActionTypes.AddAura; goto case AreaTriggerActionTypes.AddAura;
case AreaTriggerActionTypes.AddAura: case AreaTriggerActionTypes.AddAura:
unit.RemoveAurasDueToSpell(action.Param, GetCasterGuid()); unit.RemoveAurasDueToSpell(action.Param, GetCasterGUID());
break; break;
case AreaTriggerActionTypes.Tavern: case AreaTriggerActionTypes.Tavern:
Player player = unit.ToPlayer(); Player player = unit.ToPlayer();
@@ -1574,9 +1574,9 @@ namespace Game.Entities
public AreaTriggerCreateProperties GetCreateProperties() { return _areaTriggerCreateProperties; } public AreaTriggerCreateProperties GetCreateProperties() { return _areaTriggerCreateProperties; }
public override ObjectGuid GetCreatorGUID() { return GetCasterGuid(); } public override ObjectGuid GetCreatorGUID() { return GetCasterGUID(); }
public override ObjectGuid GetOwnerGUID() { return GetCasterGuid(); } public override ObjectGuid GetOwnerGUID() { return GetCasterGUID(); }
public ObjectGuid GetCasterGuid() { return m_areaTriggerData.Caster; } public ObjectGuid GetCasterGUID() { return m_areaTriggerData.Caster; }
public bool HasSplines() { return _spline != null && !_spline.Empty(); } public bool HasSplines() { return _spline != null && !_spline.Empty(); }
public Spline<float> GetSpline() { return _spline; } public Spline<float> GetSpline() { return _spline; }
+13 -1
View File
@@ -3902,6 +3902,18 @@ namespace Game.Entities
command.Execute(m_goTypeImpl); command.Execute(m_goTypeImpl);
} }
public int GetControllingTeam()
{
if (GetGoType() != GameObjectTypes.ControlZone)
return BattleGroundTeamId.Neutral;
var controlZone = (ControlZone)m_goTypeImpl;
if (controlZone == null)
return BattleGroundTeamId.Neutral;
return controlZone.GetControllingTeam();
}
public void CreateModel() public void CreateModel()
{ {
m_model = GameObjectModel.Create(new GameObjectModelOwnerImpl(this)); m_model = GameObjectModel.Create(new GameObjectModelOwnerImpl(this));
@@ -4600,7 +4612,7 @@ namespace Game.Entities
} }
} }
int GetControllingTeam() public int GetControllingTeam()
{ {
if (_value < GetMaxHordeValue()) if (_value < GetMaxHordeValue())
return BattleGroundTeamId.Horde; return BattleGroundTeamId.Horde;
+2 -2
View File
@@ -2454,7 +2454,7 @@ namespace Game.Entities
return spell.Prepare(targets.Targets, args.TriggeringAura); return spell.Prepare(targets.Targets, args.TriggeringAura);
} }
void SendPlayOrphanSpellVisual(Position sourceLocation, ObjectGuid target, uint spellVisualId, float travelSpeed, bool speedAsTime = false, bool withSourceOrientation = false) public void SendPlayOrphanSpellVisual(Position sourceLocation, ObjectGuid target, uint spellVisualId, float travelSpeed, bool speedAsTime = false, bool withSourceOrientation = false)
{ {
PlayOrphanSpellVisual playOrphanSpellVisual = new(); PlayOrphanSpellVisual playOrphanSpellVisual = new();
playOrphanSpellVisual.SourceLocation = sourceLocation; playOrphanSpellVisual.SourceLocation = sourceLocation;
@@ -2479,7 +2479,7 @@ namespace Game.Entities
SendMessageToSet(playOrphanSpellVisual, true); SendMessageToSet(playOrphanSpellVisual, true);
} }
void SendPlayOrphanSpellVisual(Position sourceLocation, Position targetLocation, uint spellVisualId, float travelSpeed, bool speedAsTime = false, bool withSourceOrientation = false) public void SendPlayOrphanSpellVisual(Position sourceLocation, Position targetLocation, uint spellVisualId, float travelSpeed, bool speedAsTime = false, bool withSourceOrientation = false)
{ {
PlayOrphanSpellVisual playOrphanSpellVisual = new(); PlayOrphanSpellVisual playOrphanSpellVisual = new();
playOrphanSpellVisual.SourceLocation = sourceLocation; playOrphanSpellVisual.SourceLocation = sourceLocation;
+1 -1
View File
@@ -1325,7 +1325,7 @@ namespace Game.Entities
{ {
case Class.Warlock: case Class.Warlock:
return GetCreatureTemplate().CreatureType == CreatureType.Demon; return GetCreatureTemplate().CreatureType == CreatureType.Demon;
case Class.Deathknight: case Class.DeathKnight:
return GetCreatureTemplate().CreatureType == CreatureType.Undead; return GetCreatureTemplate().CreatureType == CreatureType.Undead;
case Class.Mage: case Class.Mage:
return GetCreatureTemplate().CreatureType == CreatureType.Elemental; return GetCreatureTemplate().CreatureType == CreatureType.Elemental;
+1 -1
View File
@@ -472,7 +472,7 @@ namespace Game.Entities
opponent.UpdateCriteria(CriteriaType.WinDuel, 1); opponent.UpdateCriteria(CriteriaType.WinDuel, 1);
// Credit for quest Death's Challenge // Credit for quest Death's Challenge
if (GetClass() == Class.Deathknight && opponent.GetQuestStatus(12733) == QuestStatus.Incomplete) if (GetClass() == Class.DeathKnight && opponent.GetQuestStatus(12733) == QuestStatus.Incomplete)
opponent.CastSpell(duel.Opponent, 52994, true); opponent.CastSpell(duel.Opponent, 52994, true);
// Honor points after duel (the winner) - ImpConfig // Honor points after duel (the winner) - ImpConfig
+1 -1
View File
@@ -4276,7 +4276,7 @@ namespace Game.Entities
// Define the required variables // Define the required variables
uint charDeleteMinLvl; uint charDeleteMinLvl;
if (characterInfo.ClassId == Class.Deathknight) if (characterInfo.ClassId == Class.DeathKnight)
charDeleteMinLvl = WorldConfig.GetUIntValue(WorldCfg.ChardeleteDeathKnightMinLevel); charDeleteMinLvl = WorldConfig.GetUIntValue(WorldCfg.ChardeleteDeathKnightMinLevel);
else if (characterInfo.ClassId == Class.DemonHunter) else if (characterInfo.ClassId == Class.DemonHunter)
charDeleteMinLvl = WorldConfig.GetUIntValue(WorldCfg.ChardeleteDemonHunterMinLevel); charDeleteMinLvl = WorldConfig.GetUIntValue(WorldCfg.ChardeleteDemonHunterMinLevel);
+4 -4
View File
@@ -2088,7 +2088,7 @@ namespace Game.Entities
ushort maxValue = GetMaxSkillValueForLevel(); ushort maxValue = GetMaxSkillValueForLevel();
if (rcInfo.HasFlag(SkillRaceClassInfoFlags.AlwaysMaxValue)) if (rcInfo.HasFlag(SkillRaceClassInfoFlags.AlwaysMaxValue))
skillValue = maxValue; skillValue = maxValue;
else if (GetClass() == Class.Deathknight) else if (GetClass() == Class.DeathKnight)
skillValue = (ushort)Math.Min(Math.Max(1, (GetLevel() - 1) * 5), maxValue); skillValue = (ushort)Math.Min(Math.Max(1, (GetLevel() - 1) * 5), maxValue);
SetSkill(skillId, 0, skillValue, maxValue); SetSkill(skillId, 0, skillValue, maxValue);
@@ -2104,7 +2104,7 @@ namespace Game.Entities
ushort skillValue = 1; ushort skillValue = 1;
if (rcInfo.HasFlag(SkillRaceClassInfoFlags.AlwaysMaxValue)) if (rcInfo.HasFlag(SkillRaceClassInfoFlags.AlwaysMaxValue))
skillValue = maxValue; skillValue = maxValue;
else if (GetClass() == Class.Deathknight) else if (GetClass() == Class.DeathKnight)
skillValue = (ushort)Math.Min(Math.Max(1, (GetLevel() - 1) * 5), maxValue); skillValue = (ushort)Math.Min(Math.Max(1, (GetLevel() - 1) * 5), maxValue);
SetSkill(skillId, 1, skillValue, maxValue); SetSkill(skillId, 1, skillValue, maxValue);
@@ -3394,7 +3394,7 @@ namespace Game.Entities
public void InitRunes() public void InitRunes()
{ {
if (GetClass() != Class.Deathknight) if (GetClass() != Class.DeathKnight)
return; return;
uint runeIndex = GetPowerIndex(PowerType.Runes); uint runeIndex = GetPowerIndex(PowerType.Runes);
@@ -3414,7 +3414,7 @@ namespace Game.Entities
public void UpdateAllRunesRegen() public void UpdateAllRunesRegen()
{ {
if (GetClass() != Class.Deathknight) if (GetClass() != Class.DeathKnight)
return; return;
uint runeIndex = GetPowerIndex(PowerType.Runes); uint runeIndex = GetPowerIndex(PowerType.Runes);
+4 -4
View File
@@ -2072,7 +2072,7 @@ namespace Game.Entities
} }
else else
{ {
if (GetClass() == Class.Deathknight && GetMapId() == 609 && !IsGameMaster() && !HasSpell(50977)) if (GetClass() == Class.DeathKnight && GetMapId() == 609 && !IsGameMaster() && !HasSpell(50977))
{ {
SendTransferAborted(teleportLocation.Location.GetMapId(), TransferAbortReason.UniqueMessage, 1); SendTransferAborted(teleportLocation.Location.GetMapId(), TransferAbortReason.UniqueMessage, 1);
return false; return false;
@@ -2230,7 +2230,7 @@ namespace Game.Entities
if (CliDB.ChrRacesStorage.LookupByKey(race).HasFlag(ChrRacesFlag.IsAlliedRace)) if (CliDB.ChrRacesStorage.LookupByKey(race).HasFlag(ChrRacesFlag.IsAlliedRace))
startLevel = WorldConfig.GetUIntValue(WorldCfg.StartAlliedRaceLevel); startLevel = WorldConfig.GetUIntValue(WorldCfg.StartAlliedRaceLevel);
if (playerClass == Class.Deathknight) if (playerClass == Class.DeathKnight)
{ {
if (race == Race.PandarenAlliance || race == Race.PandarenHorde) if (race == Race.PandarenAlliance || race == Race.PandarenHorde)
startLevel = Math.Max(WorldConfig.GetUIntValue(WorldCfg.StartAlliedRaceLevel), startLevel); startLevel = Math.Max(WorldConfig.GetUIntValue(WorldCfg.StartAlliedRaceLevel), startLevel);
@@ -3587,7 +3587,7 @@ namespace Game.Entities
Regenerate(power); Regenerate(power);
// Runes act as cooldowns, and they don't need to send any data // Runes act as cooldowns, and they don't need to send any data
if (GetClass() == Class.Deathknight) if (GetClass() == Class.DeathKnight)
{ {
uint regeneratedRunes = 0; uint regeneratedRunes = 0;
int regenIndex = 0; int regenIndex = 0;
@@ -7393,7 +7393,7 @@ namespace Game.Entities
if (node.HasFlag(TaxiNodeFlags.UsePlayerFavoriteMount) && preferredMountDisplay != 0) if (node.HasFlag(TaxiNodeFlags.UsePlayerFavoriteMount) && preferredMountDisplay != 0)
mount_display_id = preferredMountDisplay; mount_display_id = preferredMountDisplay;
else else
mount_display_id = ObjectMgr.GetTaxiMountDisplayId(sourcenode, GetTeam(), npc == null || (sourcenode == 315 && GetClass() == Class.Deathknight)); mount_display_id = ObjectMgr.GetTaxiMountDisplayId(sourcenode, GetTeam(), npc == null || (sourcenode == 315 && GetClass() == Class.DeathKnight));
// in spell case allow 0 model // in spell case allow 0 model
if ((mount_display_id == 0 && spellid == 0) || sourcepath == 0) if ((mount_display_id == 0 && spellid == 0) || sourcepath == 0)
+1 -1
View File
@@ -22,7 +22,7 @@ namespace Game.Entities
m_taximask = new byte[((CliDB.TaxiNodesStorage.GetNumRows() - 1) / (1 * 64) + 1) * 8]; m_taximask = new byte[((CliDB.TaxiNodesStorage.GetNumRows() - 1) / (1 * 64) + 1) * 8];
// class specific initial known nodes // class specific initial known nodes
if (chrClass == Class.Deathknight) if (chrClass == Class.DeathKnight)
{ {
var factionMask = Player.TeamForRace(race) == Team.Horde ? DB2Manager.HordeTaxiNodesMask : DB2Manager.AllianceTaxiNodesMask; var factionMask = Player.TeamForRace(race) == Team.Horde ? DB2Manager.HordeTaxiNodesMask : DB2Manager.AllianceTaxiNodesMask;
m_taximask = new byte[factionMask.Length]; m_taximask = new byte[factionMask.Length];
+2 -2
View File
@@ -917,7 +917,7 @@ namespace Game.Entities
return Math.Max(missChance, 0f); return Math.Max(missChance, 0f);
} }
float GetUnitCriticalChanceDone(WeaponAttackType attackType) public float GetUnitCriticalChanceDone(WeaponAttackType attackType)
{ {
float chance = 0.0f; float chance = 0.0f;
Player thisPlayer = ToPlayer(); Player thisPlayer = ToPlayer();
@@ -1585,7 +1585,7 @@ namespace Game.Entities
ApplyAttackTimePercentMod(WeaponAttackType.OffAttack, oldVal, false); ApplyAttackTimePercentMod(WeaponAttackType.OffAttack, oldVal, false);
ApplyAttackTimePercentMod(WeaponAttackType.BaseAttack, newVal, true); ApplyAttackTimePercentMod(WeaponAttackType.BaseAttack, newVal, true);
ApplyAttackTimePercentMod(WeaponAttackType.OffAttack, newVal, true); ApplyAttackTimePercentMod(WeaponAttackType.OffAttack, newVal, true);
if (GetClass() == Class.Deathknight) if (GetClass() == Class.DeathKnight)
UpdateAllRunesRegen(); UpdateAllRunesRegen();
break; break;
case CombatRating.HasteRanged: case CombatRating.HasteRanged:
+1 -1
View File
@@ -623,7 +623,7 @@ namespace Game.Entities
{ {
if (GetOwner().GetClass() == Class.Warlock if (GetOwner().GetClass() == Class.Warlock
|| GetOwner().GetClass() == Class.Shaman // Fire Elemental || GetOwner().GetClass() == Class.Shaman // Fire Elemental
|| GetOwner().GetClass() == Class.Deathknight) // Risen Ghoul || GetOwner().GetClass() == Class.DeathKnight) // Risen Ghoul
{ {
petType = PetType.Summon; petType = PetType.Summon;
} }
+25 -2
View File
@@ -312,11 +312,23 @@ namespace Game.Entities
m_hitMask |= ProcFlagsHit.Absorb; m_hitMask |= ProcFlagsHit.Absorb;
} }
public void ModifyDamage(ref int amount)
{
amount = Math.Max(amount, -((int)GetDamage()));
m_damage += (uint)amount;
}
public void ModifyDamage(int amount) public void ModifyDamage(int amount)
{ {
amount = Math.Max(amount, -((int)GetDamage())); amount = Math.Max(amount, -((int)GetDamage()));
m_damage += (uint)amount; m_damage += (uint)amount;
} }
public void AbsorbDamage(ref uint amount)
{
amount = Math.Min(amount, GetDamage());
m_absorb += amount;
m_damage -= amount;
m_hitMask |= ProcFlagsHit.Absorb;
}
public void AbsorbDamage(uint amount) public void AbsorbDamage(uint amount)
{ {
amount = Math.Min(amount, GetDamage()); amount = Math.Min(amount, GetDamage());
@@ -324,7 +336,7 @@ namespace Game.Entities
m_damage -= amount; m_damage -= amount;
m_hitMask |= ProcFlagsHit.Absorb; m_hitMask |= ProcFlagsHit.Absorb;
} }
public void ResistDamage(uint amount) public void ResistDamage(ref uint amount)
{ {
amount = Math.Min(amount, GetDamage()); amount = Math.Min(amount, GetDamage());
m_resist += amount; m_resist += amount;
@@ -335,7 +347,18 @@ namespace Game.Entities
m_hitMask &= ~(ProcFlagsHit.Normal | ProcFlagsHit.Critical); m_hitMask &= ~(ProcFlagsHit.Normal | ProcFlagsHit.Critical);
} }
} }
void BlockDamage(uint amount) public void ResistDamage(uint amount)
{
amount = Math.Min(amount, GetDamage());
m_resist += amount;
m_damage -= amount;
if (m_damage == 0)
{
m_hitMask |= ProcFlagsHit.FullResist;
m_hitMask &= ~(ProcFlagsHit.Normal | ProcFlagsHit.Critical);
}
}
public void BlockDamage(ref uint amount)
{ {
amount = Math.Min(amount, GetDamage()); amount = Math.Min(amount, GetDamage());
m_block += amount; m_block += amount;
+5 -2
View File
@@ -528,14 +528,17 @@ namespace Game.Entities
} }
} }
public void GetAllMinionsByEntry(List<TempSummon> Minions, uint entry) public List<TempSummon> GetAllMinionsByEntry(uint entry)
{ {
List<TempSummon> minions = new();
for (var i = 0; i < m_Controlled.Count; ++i) for (var i = 0; i < m_Controlled.Count; ++i)
{ {
Unit unit = m_Controlled[i]; Unit unit = m_Controlled[i];
if (unit.GetEntry() == entry && unit.IsSummon()) // minion, actually if (unit.GetEntry() == entry && unit.IsSummon()) // minion, actually
Minions.Add(unit.ToTempSummon()); minions.Add(unit.ToTempSummon());
} }
return minions;
} }
public void RemoveAllMinionsByEntry(uint entry) public void RemoveAllMinionsByEntry(uint entry)
+5
View File
@@ -2685,6 +2685,11 @@ namespace Game.Entities
return m_appliedAuras.KeyValueList; return m_appliedAuras.KeyValueList;
} }
public List<AuraApplication> GetAppliedAuras(uint key)
{
return m_appliedAuras.LookupByKey(key);
}
public Aura AddAura(uint spellId, Unit target) public Aura AddAura(uint spellId, Unit target)
{ {
if (target == null) if (target == null)
+5 -4
View File
@@ -3568,7 +3568,7 @@ namespace Game.Entities
if (spell != null) if (spell != null)
spell.CallScriptOnResistAbsorbCalculateHandlers(damageInfo, ref resistedDamage, ref absorbIgnoringDamage); spell.CallScriptOnResistAbsorbCalculateHandlers(damageInfo, ref resistedDamage, ref absorbIgnoringDamage);
damageInfo.ResistDamage(resistedDamage); damageInfo.ResistDamage(ref resistedDamage);
// We're going to call functions which can modify content of the list during iteration over it's elements // We're going to call functions which can modify content of the list during iteration over it's elements
// Let's copy the list so we can prevent iterator invalidation // Let's copy the list so we can prevent iterator invalidation
@@ -3608,9 +3608,10 @@ namespace Game.Entities
// absorb must be smaller than the damage itself // absorb must be smaller than the damage itself
currentAbsorb = MathFunctions.RoundToInterval(ref currentAbsorb, 0, damageInfo.GetDamage()); currentAbsorb = MathFunctions.RoundToInterval(ref currentAbsorb, 0, damageInfo.GetDamage());
damageInfo.AbsorbDamage((uint)currentAbsorb); uint temp = (uint)currentAbsorb;
damageInfo.AbsorbDamage(ref temp);
tempAbsorb = temp;
tempAbsorb = (uint)currentAbsorb;
absorbAurEff.GetBase().CallScriptEffectAfterAbsorbHandlers(absorbAurEff, aurApp, damageInfo, ref tempAbsorb); absorbAurEff.GetBase().CallScriptEffectAfterAbsorbHandlers(absorbAurEff, aurApp, damageInfo, ref tempAbsorb);
// Check if our aura is using amount to count heal // Check if our aura is using amount to count heal
@@ -3625,7 +3626,7 @@ namespace Game.Entities
} }
if (!absorbAurEff.GetSpellInfo().HasAttribute(SpellAttr6.AbsorbCannotBeIgnore)) if (!absorbAurEff.GetSpellInfo().HasAttribute(SpellAttr6.AbsorbCannotBeIgnore))
damageInfo.ModifyDamage(absorbIgnoringDamage); damageInfo.ModifyDamage(ref absorbIgnoringDamage);
if (currentAbsorb != 0) if (currentAbsorb != 0)
{ {
+2 -2
View File
@@ -6139,7 +6139,7 @@ namespace Game
switch ((SpellCategories)itemTemplate.Effects[0].SpellCategoryID) switch ((SpellCategories)itemTemplate.Effects[0].SpellCategoryID)
{ {
case SpellCategories.Food: // food case SpellCategories.Food: // food
count = characterLoadout.ChrClassID == (int)Class.Deathknight ? 10 : 4u; count = characterLoadout.ChrClassID == (int)Class.DeathKnight ? 10 : 4u;
break; break;
case SpellCategories.Drink: // drink case SpellCategories.Drink: // drink
count = 2; count = 2;
@@ -6502,7 +6502,7 @@ namespace Game
continue; continue;
// skip expansion classes if not playing with expansion // skip expansion classes if not playing with expansion
if (WorldConfig.GetIntValue(WorldCfg.Expansion) < (int)Expansion.WrathOfTheLichKing && _class == Class.Deathknight) if (WorldConfig.GetIntValue(WorldCfg.Expansion) < (int)Expansion.WrathOfTheLichKing && _class == Class.DeathKnight)
continue; continue;
if (WorldConfig.GetIntValue(WorldCfg.Expansion) < (int)Expansion.MistsOfPandaria && (race == Race.PandarenNeutral || race == Race.PandarenHorde || race == Race.PandarenAlliance)) if (WorldConfig.GetIntValue(WorldCfg.Expansion) < (int)Expansion.MistsOfPandaria && (race == Race.PandarenNeutral || race == Race.PandarenHorde || race == Race.PandarenAlliance))
+1 -1
View File
@@ -2018,7 +2018,7 @@ namespace Game
{ {
// i = (315 - 1) / 8 = 39 // i = (315 - 1) / 8 = 39
// m = 1 << ((315 - 1) % 8) = 4 // m = 1 << ((315 - 1) % 8) = 4
int deathKnightExtraNode = playerClass != Class.Deathknight || i != 39 ? 0 : 4; int deathKnightExtraNode = playerClass != Class.DeathKnight || i != 39 ? 0 : 4;
taximaskstream += (uint)(factionMask[i] | deathKnightExtraNode) + ' '; taximaskstream += (uint)(factionMask[i] | deathKnightExtraNode) + ' ';
} }
+1 -1
View File
@@ -630,7 +630,7 @@ namespace Game
if (target == null) if (target == null)
return; return;
if (target.GetCasterGuid() != _player.GetGUID()) if (target.GetCasterGUID() != _player.GetGUID())
return; return;
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(target.m_areaTriggerData.SpellForVisuals, _player.GetMap().GetDifficultyID()); SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(target.m_areaTriggerData.SpellForVisuals, _player.GetMap().GetDifficultyID());
+21
View File
@@ -687,6 +687,7 @@ namespace Game.Maps
WorldObjectSearcherContinuation ShouldContinue(); WorldObjectSearcherContinuation ShouldContinue();
void Insert(T obj); void Insert(T obj);
T GetResult(); T GetResult();
bool HasResult();
} }
class SearcherFirstObjectResult<T>() : IResultInserter<T> class SearcherFirstObjectResult<T>() : IResultInserter<T>
@@ -703,6 +704,11 @@ namespace Game.Maps
result = obj; result = obj;
} }
public bool HasResult()
{
return result != null;
}
public T GetResult() public T GetResult()
{ {
return result; return result;
@@ -723,6 +729,11 @@ namespace Game.Maps
result = obj; result = obj;
} }
public bool HasResult()
{
return result != null;
}
public T GetResult() public T GetResult()
{ {
return result; return result;
@@ -743,6 +754,11 @@ namespace Game.Maps
container.Add(obj); container.Add(obj);
} }
public bool HasResult()
{
return !container.Empty();
}
public T GetResult() public T GetResult()
{ {
return default; return default;
@@ -876,6 +892,11 @@ namespace Game.Maps
} }
} }
public bool HasResult()
{
return resultInserter.HasResult();
}
public T GetResult() public T GetResult()
{ {
return resultInserter.GetResult(); return resultInserter.GetResult();
@@ -152,7 +152,7 @@ namespace Game.Networking.Packets
FirstLogin = atLoginFlags.HasAnyFlag(AtLoginFlags.FirstLogin); FirstLogin = atLoginFlags.HasAnyFlag(AtLoginFlags.FirstLogin);
// show pet at selection character in character list only for non-ghost character // show pet at selection character in character list only for non-ghost character
if (!playerFlags.HasAnyFlag(PlayerFlags.Ghost) && (ClassId == Class.Warlock || ClassId == Class.Hunter || ClassId == Class.Deathknight)) if (!playerFlags.HasAnyFlag(PlayerFlags.Ghost) && (ClassId == Class.Warlock || ClassId == Class.Hunter || ClassId == Class.DeathKnight))
{ {
CreatureTemplate creatureInfo = Global.ObjectMgr.GetCreatureTemplate(fields.Read<uint>(14)); CreatureTemplate creatureInfo = Global.ObjectMgr.GetCreatureTemplate(fields.Read<uint>(14));
if (creatureInfo != null) if (creatureInfo != null)
+10 -11
View File
@@ -74,7 +74,7 @@ namespace Game.Scripting
var constructors = type.GetConstructors(); var constructors = type.GetConstructors();
if (constructors.Length == 0) if (constructors.Length == 0)
{ {
Log.outError(LogFilter.Scripts, "Script: {0} contains no Public Constructors. Can't load script.", type.Name); Log.outError(LogFilter.Scripts, $"Script: {type.Name} contains no Public Constructors. Can't load script.");
continue; continue;
} }
@@ -84,16 +84,15 @@ namespace Game.Scripting
string name = type.Name; string name = type.Name;
bool validArgs = true; bool validArgs = true;
int i = 0;
foreach (var constructor in constructors) foreach (var constructor in constructors)
{ {
var parameters = constructor.GetParameters(); var parameters = constructor.GetParameters();
if (parameters.Length != attribute.Args.Length) if (parameters.Length != attribute.Args.Length)
continue; continue;
foreach (var arg in constructor.GetParameters()) for (var i = 0; i < parameters.Length; ++i)
{ {
if (arg.ParameterType != attribute.Args[i++].GetType()) if (attribute.Args[i] != null && attribute.Args[i].GetType() != parameters[i].ParameterType)
{ {
validArgs = false; validArgs = false;
break; break;
@@ -110,6 +109,9 @@ namespace Game.Scripting
continue; continue;
} }
if (!attribute.Name.IsEmpty())
name = attribute.Name;
switch (type.BaseType.Name) switch (type.BaseType.Name)
{ {
case nameof(SpellScript): case nameof(SpellScript):
@@ -129,6 +131,9 @@ namespace Game.Scripting
case nameof(ConversationAI): case nameof(ConversationAI):
genericType = typeof(GenericConversationScript<>).MakeGenericType(type); genericType = typeof(GenericConversationScript<>).MakeGenericType(type);
break; break;
case nameof(BattlegroundScript):
genericType = typeof(GenericBattlegroundMapScript<>).MakeGenericType(type);
break;
case "SpellScriptLoader": case "SpellScriptLoader":
case "AuraScriptLoader": case "AuraScriptLoader":
case "WorldScript": case "WorldScript":
@@ -161,22 +166,16 @@ namespace Game.Scripting
case "AchievementScript": case "AchievementScript":
case "BattlefieldScript": case "BattlefieldScript":
case "EventScript": case "EventScript":
if (!attribute.Name.IsEmpty())
name = attribute.Name;
if (attribute.Args.Empty()) if (attribute.Args.Empty())
Activator.CreateInstance(genericType); Activator.CreateInstance(genericType);
else else
Activator.CreateInstance(genericType, new object[] { name }.Combine(attribute.Args)); Activator.CreateInstance(genericType, name, attribute.Args);
continue; continue;
default: default:
genericType = typeof(GenericCreatureScript<>).MakeGenericType(type); genericType = typeof(GenericCreatureScript<>).MakeGenericType(type);
break; break;
} }
if (!attribute.Name.IsEmpty())
name = attribute.Name;
Activator.CreateInstance(genericType, name, attribute.Args); Activator.CreateInstance(genericType, name, attribute.Args);
} }
} }
+3 -3
View File
@@ -30,7 +30,7 @@ namespace Game.Scripting
return true; return true;
} }
public bool ValidateSpellInfo(params uint[] spellIds) public static bool ValidateSpellInfo(params uint[] spellIds)
{ {
bool allValid = true; bool allValid = true;
foreach (uint spellId in spellIds) foreach (uint spellId in spellIds)
@@ -45,7 +45,7 @@ namespace Game.Scripting
return allValid; return allValid;
} }
public bool ValidateSpellEffect(params (uint spellId, uint effectIndex)[] pairs) public static bool ValidateSpellEffect(params (uint spellId, uint effectIndex)[] pairs)
{ {
bool allValid = true; bool allValid = true;
foreach (var (spellId, effectIndex) in pairs) foreach (var (spellId, effectIndex) in pairs)
@@ -56,7 +56,7 @@ namespace Game.Scripting
return allValid; return allValid;
} }
public bool ValidateSpellEffect(uint spellId, uint effectIndex) public static bool ValidateSpellEffect(uint spellId, uint effectIndex)
{ {
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, Difficulty.None); SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, Difficulty.None);
if (spellInfo == null) if (spellInfo == null)
+6 -6
View File
@@ -4047,7 +4047,7 @@ namespace Game.Spells
if ((m_caster.IsPlayer() || (m_caster.IsTypeId(TypeId.Unit) && m_caster.ToCreature().IsPet())) && m_powerCost.Any(cost => cost.Power != PowerType.Health)) if ((m_caster.IsPlayer() || (m_caster.IsTypeId(TypeId.Unit) && m_caster.ToCreature().IsPet())) && m_powerCost.Any(cost => cost.Power != PowerType.Health))
castFlags |= SpellCastFlags.PowerLeftSelf; castFlags |= SpellCastFlags.PowerLeftSelf;
if (m_caster.IsPlayer() && m_caster.ToPlayer().GetClass() == Class.Deathknight && if (m_caster.IsPlayer() && m_caster.ToPlayer().GetClass() == Class.DeathKnight &&
HasPowerTypeCost(PowerType.Runes) && !_triggeredCastFlags.HasAnyFlag(TriggerCastFlags.IgnorePowerCost)) HasPowerTypeCost(PowerType.Runes) && !_triggeredCastFlags.HasAnyFlag(TriggerCastFlags.IgnorePowerCost))
{ {
castFlags |= SpellCastFlags.NoGCD; // not needed, but it's being sent according to sniffs castFlags |= SpellCastFlags.NoGCD; // not needed, but it's being sent according to sniffs
@@ -4820,7 +4820,7 @@ namespace Game.Spells
if (player == null) if (player == null)
return SpellCastResult.SpellCastOk; return SpellCastResult.SpellCastOk;
if (player.GetClass() != Class.Deathknight) if (player.GetClass() != Class.DeathKnight)
return SpellCastResult.SpellCastOk; return SpellCastResult.SpellCastOk;
int readyRunes = 0; int readyRunes = 0;
@@ -4836,7 +4836,7 @@ namespace Game.Spells
void TakeRunePower(bool didHit) void TakeRunePower(bool didHit)
{ {
if (!m_caster.IsTypeId(TypeId.Player) || m_caster.ToPlayer().GetClass() != Class.Deathknight) if (!m_caster.IsTypeId(TypeId.Player) || m_caster.ToPlayer().GetClass() != Class.DeathKnight)
return; return;
Player player = m_caster.ToPlayer(); Player player = m_caster.ToPlayer();
@@ -4858,7 +4858,7 @@ namespace Game.Spells
void RefundRunePower() void RefundRunePower()
{ {
if (!m_caster.IsPlayer() || m_caster.ToPlayer().GetClass() != Class.Deathknight) if (!m_caster.IsPlayer() || m_caster.ToPlayer().GetClass() != Class.DeathKnight)
return; return;
Player player = m_caster.ToPlayer(); Player player = m_caster.ToPlayer();
@@ -6578,7 +6578,7 @@ namespace Game.Spells
return unit.HasUnitMovementFlag(MovementFlag.Forward | MovementFlag.StrafeLeft | MovementFlag.StrafeRight | MovementFlag.Falling) && !unit.IsWalking(); return unit.HasUnitMovementFlag(MovementFlag.Forward | MovementFlag.StrafeLeft | MovementFlag.StrafeRight | MovementFlag.Falling) && !unit.IsWalking();
} }
(float minRange, float maxRange) GetMinMaxRange(bool strict) public (float minRange, float maxRange) GetMinMaxRange(bool strict)
{ {
float rangeMod = 0.0f; float rangeMod = 0.0f;
float minRange = 0.0f; float minRange = 0.0f;
@@ -8421,7 +8421,7 @@ namespace Game.Spells
return SpellCastResult.SpellCastOk; return SpellCastResult.SpellCastOk;
} }
int CalculateDamage(SpellEffectInfo spellEffectInfo, Unit target) public int CalculateDamage(SpellEffectInfo spellEffectInfo, Unit target)
{ {
return CalculateDamage(spellEffectInfo, target, out _); return CalculateDamage(spellEffectInfo, target, out _);
} }
+9 -2
View File
@@ -857,7 +857,7 @@ namespace Game.Spells
_categoryCharges.Add(chargeCategoryId, new ChargeEntry(recoveryStart, TimeSpan.FromMilliseconds(chargeRecovery))); _categoryCharges.Add(chargeCategoryId, new ChargeEntry(recoveryStart, TimeSpan.FromMilliseconds(chargeRecovery)));
} }
void ModifyChargeRecoveryTime(uint chargeCategoryId, TimeSpan cooldownMod) public void ModifyChargeRecoveryTime(uint chargeCategoryId, TimeSpan cooldownMod)
{ {
var chargeCategoryEntry = CliDB.SpellCategoryStorage.LookupByKey(chargeCategoryId); var chargeCategoryEntry = CliDB.SpellCategoryStorage.LookupByKey(chargeCategoryId);
if (chargeCategoryEntry == null) if (chargeCategoryEntry == null)
@@ -1119,12 +1119,19 @@ namespace Game.Spells
} }
} }
void GetCooldownDurations(SpellInfo spellInfo, uint itemId, ref uint categoryId) public static void GetCooldownDurations(SpellInfo spellInfo, uint itemId, ref uint categoryId)
{ {
TimeSpan notUsed = TimeSpan.Zero; TimeSpan notUsed = TimeSpan.Zero;
GetCooldownDurations(spellInfo, itemId, ref notUsed, ref categoryId, ref notUsed); GetCooldownDurations(spellInfo, itemId, ref notUsed, ref categoryId, ref notUsed);
} }
public static void GetCooldownDurations(SpellInfo spellInfo, uint itemId, ref TimeSpan cooldown)
{
TimeSpan notUsed = TimeSpan.Zero;
uint notUsedId = 0;
GetCooldownDurations(spellInfo, itemId, ref cooldown, ref notUsedId, ref notUsed);
}
public static void GetCooldownDurations(SpellInfo spellInfo, uint itemId, ref TimeSpan cooldown, ref uint categoryId, ref TimeSpan categoryCooldown) public static void GetCooldownDurations(SpellInfo spellInfo, uint itemId, ref TimeSpan cooldown, ref uint categoryId, ref TimeSpan categoryCooldown)
{ {
TimeSpan tmpCooldown = TimeSpan.MinValue; TimeSpan tmpCooldown = TimeSpan.MinValue;
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+4269 -4097
View File
File diff suppressed because it is too large Load Diff
+1619 -1311
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+189 -1458
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff