Some cleanups. (might break build for scripts as they are a WIP)

This commit is contained in:
hondacrx
2023-10-08 10:35:31 -04:00
parent fa10b981bd
commit cda53c8e7f
208 changed files with 2266 additions and 2329 deletions
+11 -11
View File
@@ -336,12 +336,12 @@ namespace Game.Spells
m_castItemGuid = createInfo.CastItemGUID;
m_castItemId = createInfo.CastItemId;
m_castItemLevel = createInfo.CastItemLevel;
m_spellVisual = new SpellCastVisual(createInfo.Caster ? createInfo.Caster.GetCastSpellXSpellVisualId(createInfo._spellInfo) : createInfo._spellInfo.GetSpellXSpellVisualId(), 0);
m_spellVisual = new SpellCastVisual(createInfo.Caster != null ? createInfo.Caster.GetCastSpellXSpellVisualId(createInfo._spellInfo) : createInfo._spellInfo.GetSpellXSpellVisualId(), 0);
m_applyTime = GameTime.GetGameTime();
m_owner = createInfo._owner;
m_timeCla = 0;
m_updateTargetMapInterval = 0;
m_casterLevel = createInfo.Caster ? createInfo.Caster.GetLevel() : m_spellInfo.SpellLevel;
m_casterLevel = createInfo.Caster != null ? createInfo.Caster.GetLevel() : m_spellInfo.SpellLevel;
m_procCharges = 0;
m_stackAmount = 1;
m_isRemoved = false;
@@ -452,7 +452,7 @@ namespace Game.Spells
if (app == null)
{
Log.outError(LogFilter.Spells, "Aura._UnapplyForTarget, target: {0}, caster: {1}, spell: {2} was not found in owners application map!",
target.GetGUID().ToString(), caster ? caster.GetGUID().ToString() : "", auraApp.GetBase().GetSpellInfo().Id);
target.GetGUID().ToString(), caster != null ? caster.GetGUID().ToString() : "", auraApp.GetBase().GetSpellInfo().Id);
Cypher.Assert(false);
}
@@ -773,10 +773,10 @@ namespace Game.Spells
if (withMods)
{
Unit caster = GetCaster();
if (caster)
if (caster != null)
{
Player modOwner = caster.GetSpellModOwner();
if (modOwner)
if (modOwner != null)
modOwner.ApplySpellMod(GetSpellInfo(), SpellModOp.Duration, ref duration);
}
}
@@ -788,7 +788,7 @@ namespace Game.Spells
public void RefreshDuration(bool withMods = false)
{
Unit caster = GetCaster();
if (withMods && caster)
if (withMods && caster != null)
{
int duration = m_spellInfo.GetMaxDuration();
// Calculate duration of periodics affected by haste.
@@ -872,7 +872,7 @@ namespace Game.Spells
// only units have events
Unit owner = m_owner.ToUnit();
if (!owner)
if (owner == null)
return;
m_dropEvent = new ChargeDropEvent(this, removeMode);
@@ -1589,10 +1589,10 @@ namespace Game.Spells
if (HasEffectType(AuraType.ControlVehicle) && existingAura.HasEffectType(AuraType.ControlVehicle))
{
Vehicle veh = null;
if (GetOwner().ToUnit())
if (GetOwner().ToUnit() != null)
veh = GetOwner().ToUnit().GetVehicleKit();
if (!veh) // We should probably just let it stack. Vehicle system will prevent undefined behaviour later
if (veh == null) // We should probably just let it stack. Vehicle system will prevent undefined behaviour later
return true;
if (veh.GetAvailableSeatCount() == 0)
@@ -1803,7 +1803,7 @@ namespace Game.Spells
item = target.ToPlayer().GetUseableItemByPos(InventorySlots.Bag0, EquipmentSlot.OffHand);
}
if (!item || item.IsBroken() || !item.IsFitToSpellRequirements(GetSpellInfo()))
if (item == null || item.IsBroken() || !item.IsFitToSpellRequirements(GetSpellInfo()))
return 0;
}
}
@@ -2717,7 +2717,7 @@ namespace Game.Spells
if (target == null && targetPair.Key == GetUnitOwner().GetGUID())
target = GetUnitOwner();
if (target)
if (target != null)
targets.Add(target, targetPair.Value);
}
+27 -27
View File
@@ -96,7 +96,7 @@ namespace Game.Spells
amount = (int)mountCapability.Id;
break;
case AuraType.ShowConfirmationPromptWithDifficulty:
if (caster)
if (caster != null)
amount = (int)caster.GetMap().GetDifficultyID();
m_canBeRecalculated = false;
break;
@@ -144,7 +144,7 @@ namespace Game.Spells
public float? CalculateEstimatedAmount(Unit caster, int amount)
{
if (!caster || GetBase().GetAuraType() != AuraObjectType.Unit)
if (caster == null || GetBase().GetAuraType() != AuraObjectType.Unit)
return null;
return CalculateEstimatedAmount(caster, GetBase().GetUnitOwner(), GetSpellInfo(), GetSpellEffectInfo(), amount, GetBase().GetStackAmount(), this);
@@ -2422,7 +2422,7 @@ namespace Game.Spells
Unit caster = GetCaster();
Unit target = aurApp.GetTarget();
if (!caster || !caster.IsAlive() || !target.IsAlive() || !caster.CanHaveThreatList())
if (caster == null || !caster.IsAlive() || !target.IsAlive() || !caster.CanHaveThreatList())
return;
caster.GetThreatManager().TauntUpdate();
@@ -2863,7 +2863,7 @@ namespace Game.Spells
if (player.InBattleground())
{
Battleground bg = player.GetBattleground();
if (bg)
if (bg != null)
bg.EventPlayerDroppedFlag(player);
}
else
@@ -3228,7 +3228,7 @@ namespace Game.Spells
return;
Player player = aurApp.GetTarget().ToPlayer();
if (player)
if (player != null)
player.UpdateHealingDonePercentMod();
}
@@ -3300,7 +3300,7 @@ namespace Game.Spells
// only players have primary stats
Player player = aurApp.GetTarget().ToPlayer();
if (!player)
if (player == null)
return;
player.UpdateArmor();
@@ -3359,7 +3359,7 @@ namespace Game.Spells
return;
Player target = aurApp.GetTarget().ToPlayer();
if (!target)
if (target == null)
return;
target.ApplyModOverrideSpellPowerByAPPercent(GetAmount(), apply);
@@ -3373,7 +3373,7 @@ namespace Game.Spells
return;
Player target = aurApp.GetTarget().ToPlayer();
if (!target)
if (target == null)
return;
target.ApplyModOverrideAPBySpellPowerPercent(GetAmount(), apply);
@@ -3388,7 +3388,7 @@ namespace Game.Spells
return;
Player target = aurApp.GetTarget().ToPlayer();
if (target)
if (target != null)
{
target.SetVersatilityBonus(target.GetTotalAuraModifier(AuraType.ModVersatility));
target.UpdateHealingDonePercentMod();
@@ -3790,7 +3790,7 @@ namespace Game.Spells
return;
Player target = aurApp.GetTarget().ToPlayer();
if (!target)
if (target == null)
return;
target.UpdateAllWeaponDependentCritAuras();
@@ -4116,7 +4116,7 @@ namespace Game.Spells
}
Guardian pet = playerTarget.GetGuardianPet();
if (pet)
if (pet != null)
pet.UpdateAttackPowerAndDamage();
}
}
@@ -4177,7 +4177,7 @@ namespace Game.Spells
return;
Player target = aurApp.GetTarget().ToPlayer();
if (!target)
if (target == null)
return;
if (apply)
@@ -4463,7 +4463,7 @@ namespace Game.Spells
case 57821: // Champion of the Kirin Tor
case 57822: // Wyrmrest Champion
{
if (!caster || !caster.IsTypeId(TypeId.Player))
if (caster == null || !caster.IsTypeId(TypeId.Player))
break;
uint FactionID = 0;
@@ -4724,7 +4724,7 @@ namespace Game.Spells
return;
Unit caster = triggeredSpellInfo.NeedsToBeTriggeredByCaster(m_spellInfo) ? GetCaster() : target;
if (!caster)
if (caster == null)
return;
if (mode.HasAnyFlag(AuraEffectHandleModes.Real))
@@ -4861,7 +4861,7 @@ namespace Game.Spells
target.m_invisibilityDetect.AddValue(InvisibilityType.Drunk, GetAmount());
Player playerTarget = target.ToPlayer();
if (playerTarget)
if (playerTarget != null)
playerTarget.ApplyModFakeInebriation(GetAmount(), true);
}
else
@@ -5189,7 +5189,7 @@ namespace Game.Spells
// ignore negative values (can be result apply spellmods to aura damage
uint damage = (uint)Math.Max(GetAmount(), 0);
if (caster)
if (caster != null)
damage = (uint)caster.SpellDamageBonusDone(target, GetSpellInfo(), (int)damage, DamageEffectType.DOT, GetSpellEffectInfo(), stackAmountForBonuses, null, this);
damage = (uint)target.SpellDamageBonusTaken(caster, GetSpellInfo(), (int)damage, DamageEffectType.DOT);
@@ -5249,7 +5249,7 @@ namespace Game.Spells
Unit.ProcSkillsAndAuras(caster, target, procAttacker, procVictim, ProcFlagsSpellType.Damage, ProcFlagsSpellPhase.Hit, hitMask, null, damageInfo, null);
// process caster heal from now on (must be in world)
if (!caster || !caster.IsAlive())
if (caster == null || !caster.IsAlive())
return;
float gainMultiplier = GetSpellEffectInfo().CalcValueMultiplier(caster);
@@ -5533,11 +5533,11 @@ namespace Game.Spells
float CalcPeriodicCritChance(Unit caster)
{
if (!caster || !CanPeriodicTickCrit())
if (caster == null || !CanPeriodicTickCrit())
return 0.0f;
Player modOwner = caster.GetSpellModOwner();
if (!modOwner)
if (modOwner == null)
return 0.0f;
float critChance = modOwner.SpellCritChanceDone(null, this, GetSpellInfo().GetSchoolMask(), GetSpellInfo().GetAttackType());
@@ -5678,7 +5678,7 @@ namespace Game.Spells
return;
Player player = aurApp.GetTarget().ToPlayer();
if (!player)
if (player == null)
return;
if (apply)
@@ -5694,14 +5694,14 @@ namespace Game.Spells
return;
Player player = aurApp.GetTarget().ToPlayer();
if (!player)
if (player == null)
return;
if (player.GetClass() != Class.Hunter)
return;
Pet pet = player.GetPet();
if (!pet)
if (pet == null)
return;
ChrSpecializationRecord currSpec = CliDB.ChrSpecializationStorage.LookupByKey(pet.GetSpecialization());
@@ -5734,7 +5734,7 @@ namespace Game.Spells
return;
Player player = aurApp.GetTarget().ToPlayer();
if (!player)
if (player == null)
return;
if (apply)
@@ -5758,7 +5758,7 @@ namespace Game.Spells
else
{
Unit caster = GetCaster();
if (caster)
if (caster != null)
caster.RemoveAreaTrigger(this);
}
}
@@ -5770,7 +5770,7 @@ namespace Game.Spells
return;
Player target = auraApp.GetTarget().ToPlayer();
if (target)
if (target != null)
{
if (apply)
target.TogglePvpTalents(true);
@@ -5827,7 +5827,7 @@ namespace Game.Spells
else
{
TempSummon tempSummon = creature.ToTempSummon();
if (tempSummon)
if (tempSummon != null)
{
if (tempSummon.GetSummonerGUID() == target.GetGUID())
{
@@ -5848,7 +5848,7 @@ namespace Game.Spells
return;
Player target = aurApp.GetTarget().ToPlayer();
if (!target)
if (target == null)
return;
target.UpdatePvPState(true);
+95 -95
View File
@@ -114,7 +114,7 @@ namespace Game.Spells
m_selfContainer = null;
}
if (m_caster && m_caster.GetTypeId() == TypeId.Player)
if (m_caster != null && m_caster.GetTypeId() == TypeId.Player)
Cypher.Assert(m_caster.ToPlayer().m_spellModTakingSpell != this);
}
@@ -132,7 +132,7 @@ namespace Game.Spells
{
// check if object target is valid with needed target flags
// for unit case allow corpse target mask because player with not released corpse is a unit target
if ((target.ToUnit() && !neededTargets.HasAnyFlag(SpellCastTargetFlags.UnitMask | SpellCastTargetFlags.CorpseMask))
if ((target.ToUnit() != null && !neededTargets.HasAnyFlag(SpellCastTargetFlags.UnitMask | SpellCastTargetFlags.CorpseMask))
|| (target.IsTypeId(TypeId.GameObject) && !neededTargets.HasFlag(SpellCastTargetFlags.GameobjectMask))
|| (target.IsTypeId(TypeId.Corpse) && !neededTargets.HasFlag(SpellCastTargetFlags.CorpseMask)))
m_targets.RemoveObjectTarget();
@@ -513,8 +513,8 @@ namespace Game.Spells
WorldObject target = Global.ObjAccessor.GetUnit(m_caster, channelTarget);
CallScriptObjectTargetSelectHandlers(ref target, spellEffectInfo.EffectIndex, targetType);
// unit target may be no longer avalible - teleported out of map for example
Unit unitTarget = target ? target.ToUnit() : null;
if (unitTarget)
Unit unitTarget = target?.ToUnit();
if (unitTarget != null)
AddUnitTarget(unitTarget, 1u << (int)spellEffectInfo.EffectIndex);
else
Log.outDebug(LogFilter.Spells, "SPELL: cannot find channel spell target for spell ID {0}, effect {1}", m_spellInfo.Id, spellEffectInfo.EffectIndex);
@@ -532,7 +532,7 @@ namespace Game.Spells
if (target != null)
{
CallScriptObjectTargetSelectHandlers(ref target, spellEffectInfo.EffectIndex, targetType);
if (target)
if (target != null)
{
SpellDestination dest = new(target);
if (m_spellInfo.HasAttribute(SpellAttr4.UseFacingFromSpell))
@@ -684,7 +684,7 @@ namespace Game.Spells
}
CallScriptObjectTargetSelectHandlers(ref target, spellEffectInfo.EffectIndex, targetType);
if (!target)
if (target == null)
{
Log.outDebug(LogFilter.Spells, $"Spell.SelectImplicitNearbyTargets: OnObjectTargetSelect script hook for spell Id {m_spellInfo.Id} set NULL target, effect {spellEffectInfo.EffectIndex}");
SendCastResult(SpellCastResult.BadImplicitTargets);
@@ -971,7 +971,7 @@ namespace Game.Spells
{
Log.outDebug(LogFilter.Spells, "SPELL: unknown target coordinates for spell ID {0}", m_spellInfo.Id);
WorldObject target = m_targets.GetObjectTarget();
if (target)
if (target != null)
dest = new SpellDestination(target);
}
break;
@@ -1286,7 +1286,7 @@ namespace Game.Spells
CallScriptObjectTargetSelectHandlers(ref target, spellEffectInfo.EffectIndex, targetType);
if (target)
if (target != null)
{
if (target.IsUnit())
AddUnitTarget(target.ToUnit(), 1u << (int)spellEffectInfo.EffectIndex, checkIfValid);
@@ -1324,7 +1324,7 @@ namespace Game.Spells
{
int maxTargets = spellEffectInfo.ChainTargets;
Player modOwner = m_caster.GetSpellModOwner();
if (modOwner)
if (modOwner != null)
modOwner.ApplySpellMod(m_spellInfo, SpellModOp.ChainTargets, ref maxTargets, this);
if (maxTargets > 1)
@@ -1347,7 +1347,7 @@ namespace Game.Spells
foreach (var obj in targets)
{
Unit unitTarget = obj.ToUnit();
if (unitTarget)
if (unitTarget != null)
AddUnitTarget(unitTarget, effMask, false, true, losPosition);
if (!m_spellInfo.HasAttribute(SpellAttr2.ChainFromCaster) && !spellEffectInfo.EffectAttributes.HasFlag(SpellEffectAttributes.ChainFromInitialTarget))
@@ -1407,15 +1407,15 @@ namespace Game.Spells
continue;
Unit unitTarget = obj.ToUnit();
if (unitTarget)
if (unitTarget != null)
{
if (unitCaster == obj || unitCaster.IsOnVehicle(unitTarget) || unitTarget.GetVehicle())
if (unitCaster == obj || unitCaster.IsOnVehicle(unitTarget) || unitTarget.GetVehicle() != null)
continue;
Creature creatureTarget = unitTarget.ToCreature();
if (creatureTarget)
if (creatureTarget != null)
{
if (!creatureTarget.GetCreatureDifficulty().TypeFlags.HasFlag(CreatureTypeFlags.CollideWithMissiles))
if (creatureTarget.GetCreatureDifficulty().TypeFlags.HasFlag(CreatureTypeFlags.CollideWithMissiles))
continue;
}
}
@@ -1737,7 +1737,7 @@ namespace Game.Spells
}
Player modOwner = m_caster.GetSpellModOwner();
if (modOwner)
if (modOwner != null)
modOwner.ApplySpellMod(m_spellInfo, SpellModOp.ChainJumpDistance, ref jumpRadius, this);
float searchRadius;
@@ -1908,7 +1908,7 @@ namespace Game.Spells
targetInfo.IsAlive = target.IsAlive();
// Calculate hit result
WorldObject caster = m_originalCaster ? m_originalCaster : m_caster;
WorldObject caster = m_originalCaster != null ? m_originalCaster : m_caster;
targetInfo.MissCondition = caster.SpellHitResult(target, m_spellInfo, m_canReflect && !(IsPositive() && m_caster.IsFriendlyTo(target)));
// Spell have speed - need calculate incoming time
@@ -2170,7 +2170,7 @@ namespace Game.Spells
}
Player casterPlayer = m_caster.ToPlayer();
if (casterPlayer)
if (casterPlayer != null)
{
casterPlayer.StartCriteriaTimer(CriteriaStartEvent.CastSpell, m_spellInfo.Id);
casterPlayer.UpdateCriteria(CriteriaType.LandTargetedSpellOnTarget, m_spellInfo.Id, 0, 0, unit);
@@ -2201,7 +2201,7 @@ namespace Game.Spells
}
}
if (m_originalCaster && unit.IsInCombat() && m_spellInfo.HasInitialAggro())
if (m_originalCaster != null && unit.IsInCombat() && m_spellInfo.HasInitialAggro())
{
if (m_originalCaster.HasUnitFlag(UnitFlags.PlayerControlled)) // only do explicit combat forwarding for PvP enabled units
m_originalCaster.GetCombatManager().InheritCombatStatesFrom(unit); // for creature v creature combat, the threat forward does it for us
@@ -2212,7 +2212,7 @@ namespace Game.Spells
// original caster for auras
WorldObject origCaster = m_caster;
if (m_originalCaster)
if (m_originalCaster != null)
origCaster = m_originalCaster;
// check immunity due to diminishing returns
@@ -2272,7 +2272,7 @@ namespace Game.Spells
if (aura_effmask != 0)
{
WorldObject caster = m_caster;
if (m_originalCaster)
if (m_originalCaster != null)
caster = m_originalCaster;
if (caster != null)
@@ -2495,7 +2495,7 @@ namespace Game.Spells
m_castItemEntry = m_CastItem.GetEntry();
Player owner = m_CastItem.GetOwner();
if (owner)
if (owner != null)
m_castItemLevel = (int)m_CastItem.GetItemLevel(owner);
else if (m_CastItem.GetOwnerGUID() == m_caster.GetGUID())
m_castItemLevel = (int)m_CastItem.GetItemLevel(m_caster.ToPlayer());
@@ -2595,7 +2595,7 @@ namespace Game.Spells
{
// Channeled spells and some triggered spells do not focus a cast target. They face their target later on via channel object guid and via spell attribute or not at all
bool focusTarget = !m_spellInfo.IsChanneled() && !_triggeredCastFlags.HasFlag(TriggerCastFlags.IgnoreSetFacing);
if (focusTarget && m_targets.GetObjectTarget() && m_caster != m_targets.GetObjectTarget())
if (focusTarget && m_targets.GetObjectTarget() != null && m_caster != m_targets.GetObjectTarget())
m_caster.ToCreature().SetSpellFocus(this, m_targets.GetObjectTarget());
else
m_caster.ToCreature().SetSpellFocus(this, null);
@@ -2719,7 +2719,7 @@ namespace Game.Spells
{
Player modOwner = m_caster.GetSpellModOwner();
Spell lastSpellMod = null;
if (modOwner)
if (modOwner != null)
{
lastSpellMod = modOwner.m_spellModTakingSpell;
if (lastSpellMod != null)
@@ -2798,7 +2798,7 @@ namespace Game.Spells
SendCastResult(result, param1, param2);
SendInterrupted(0);
if (modOwner)
if (modOwner != null)
modOwner.SetSpellModTakingSpell(this, false);
Finish(result);
@@ -2817,7 +2817,7 @@ namespace Game.Spells
// if trade not complete then remember it in trade data
if (Convert.ToBoolean(m_targets.GetTargetMask() & SpellCastTargetFlags.TradeItem))
{
if (modOwner)
if (modOwner != null)
{
TradeData my_trade = modOwner.GetTradeData();
if (my_trade != null)
@@ -2849,7 +2849,7 @@ namespace Game.Spells
DiminishingReturnsType type = m_spellInfo.GetDiminishingReturnsGroupType();
if (type == DiminishingReturnsType.All || (type == DiminishingReturnsType.Player && target.IsAffectedByDiminishingReturns()))
{
Unit caster1 = m_originalCaster ? m_originalCaster : m_caster.ToUnit();
Unit caster1 = m_originalCaster != null ? m_originalCaster : m_caster.ToUnit();
if (caster1 != null)
{
if (target.HasStrongerAuraWithDR(m_spellInfo, caster1))
@@ -2868,7 +2868,7 @@ namespace Game.Spells
Creature creatureCaster = m_caster.ToCreature();
if (creatureCaster != null)
{
if (!creatureCaster.GetTarget().IsEmpty() && !creatureCaster.HasUnitFlag(UnitFlags.Possessed))
if (creatureCaster.GetTarget().IsEmpty() && !creatureCaster.HasUnitFlag(UnitFlags.Possessed))
{
WorldObject target = Global.ObjAccessor.GetUnit(creatureCaster, creatureCaster.GetTarget());
if (target != null)
@@ -3008,7 +3008,7 @@ namespace Game.Spells
SetExecutedCurrently(false);
if (!m_originalCaster)
if (m_originalCaster == null)
return;
// Handle procs on cast
@@ -3052,7 +3052,7 @@ namespace Game.Spells
// Call CreatureAI hook OnSpellCast
Creature caster = m_originalCaster.ToCreature();
if (caster)
if (caster != null)
if (caster.IsAIEnabled())
caster.GetAI().OnSpellCast(GetSpellInfo());
}
@@ -3223,7 +3223,7 @@ namespace Game.Spells
FinishTargetProcessing();
if (modOwner)
if (modOwner != null)
modOwner.SetSpellModTakingSpell(this, false);
// All targets passed - need finish phase
@@ -3272,7 +3272,7 @@ namespace Game.Spells
unitCaster.SetLastExtraAttackSpell(m_spellInfo.Id);
// Handle procs on finish
if (!m_originalCaster)
if (m_originalCaster == null)
return;
ProcFlagsInit procAttacker = m_procAttacker;
@@ -3310,7 +3310,7 @@ namespace Game.Spells
if (!m_caster.IsUnit())
return;
if (m_CastItem)
if (m_CastItem != null)
m_caster.ToUnit().GetSpellHistory().HandleCooldowns(m_spellInfo, m_CastItem, this);
else
m_caster.ToUnit().GetSpellHistory().HandleCooldowns(m_spellInfo, m_castItemEntry, this);
@@ -3377,7 +3377,7 @@ namespace Game.Spells
foreach (TargetInfo target in m_UniqueTargetInfo)
{
Unit unit = m_caster.GetGUID() == target.TargetGUID ? m_caster.ToUnit() : Global.ObjAccessor.GetUnit(m_caster, target.TargetGUID);
if (unit)
if (unit != null)
unit.RemoveOwnedAura(m_spellInfo.Id, m_originalCasterGUID, 0, AuraRemoveMode.Cancel);
}
}
@@ -3416,7 +3416,7 @@ namespace Game.Spells
m_spellState = SpellState.Finished;
if (!m_caster)
if (m_caster == null)
return;
Unit unitCaster = m_caster.ToUnit();
@@ -3732,7 +3732,7 @@ namespace Game.Spells
return;
Unit owner = m_caster.GetCharmerOrOwner();
if (!owner || !owner.IsTypeId(TypeId.Player))
if (owner == null || !owner.IsTypeId(TypeId.Player))
return;
if (_triggeredCastFlags.HasAnyFlag(TriggerCastFlags.DontReportCastError))
@@ -3804,7 +3804,7 @@ namespace Game.Spells
SpellStart packet = new();
SpellCastData castData = packet.Cast;
if (m_CastItem)
if (m_CastItem != null)
castData.CasterGUID = m_CastItem.GetGUID();
else
castData.CasterGUID = m_caster.GetGUID();
@@ -3840,7 +3840,7 @@ namespace Game.Spells
//The creature is the mover of a player, so HandleCastSpellOpcode uses it as the caster
Player player = m_caster.ToPlayer();
if (player)
if (player != null)
{
runeData.Start = m_runesState; // runes state before
runeData.Count = player.GetRunesState(); // runes state after
@@ -4020,7 +4020,7 @@ namespace Game.Spells
if (playerCaster != null)
{
Item pItem = playerCaster.GetWeaponForAttack(WeaponAttackType.RangedAttack);
if (pItem)
if (pItem != null)
{
ammoInventoryType = pItem.GetTemplate().GetInventoryType();
if (ammoInventoryType == InventoryType.Thrown)
@@ -4310,7 +4310,7 @@ namespace Game.Spells
Creature creatureCaster = unitCaster.ToCreature();
if (creatureCaster != null)
if (unitCaster.m_unitData.ChannelObjects.Size() == 1 && unitCaster.m_unitData.ChannelObjects[0].IsUnit())
if (!creatureCaster.HasSpellFocus(this))
if (creatureCaster.HasSpellFocus(this))
creatureCaster.SetSpellFocus(this, Global.ObjAccessor.GetWorldObject(creatureCaster, unitCaster.m_unitData.ChannelObjects[0]));
unitCaster.SetChannelSpellId(m_spellInfo.Id);
@@ -4333,7 +4333,7 @@ namespace Game.Spells
resurrectRequest.UseTimer = !m_spellInfo.HasAttribute(SpellAttr3.NoResTimer);
Pet pet = target.GetPet();
if (pet)
if (pet != null)
{
CharmInfo charmInfo = pet.GetCharmInfo();
if (charmInfo != null)
@@ -4416,7 +4416,7 @@ namespace Game.Spells
{
// GameObjects don't use power
Unit unitCaster = m_caster.ToUnit();
if (!unitCaster)
if (unitCaster == null)
return;
if (m_CastItem != null || m_triggeredByAuraSpell != null)
@@ -4485,7 +4485,7 @@ namespace Game.Spells
return SpellCastResult.SpellCastOk;
Player player = m_caster.ToPlayer();
if (!player)
if (player == null)
return SpellCastResult.SpellCastOk;
if (player.GetClass() != Class.Deathknight)
@@ -4578,7 +4578,7 @@ namespace Game.Spells
void HandleThreatSpells()
{
// wild GameObject spells don't cause threat
Unit unitCaster = (m_originalCaster ? m_originalCaster : m_caster.ToUnit());
Unit unitCaster = (m_originalCaster != null ? m_originalCaster : m_caster.ToUnit());
if (unitCaster == null)
return;
@@ -4670,7 +4670,7 @@ namespace Game.Spells
SpellCastResult castResult;
// check death state
if (m_caster.ToUnit() && !m_caster.ToUnit().IsAlive() && !m_spellInfo.IsPassive() && !(m_spellInfo.HasAttribute(SpellAttr0.AllowCastWhileDead) || (IsTriggered() && m_triggeredByAuraSpell == null)))
if (m_caster.ToUnit() != null && !m_caster.ToUnit().IsAlive() && !m_spellInfo.IsPassive() && !(m_spellInfo.HasAttribute(SpellAttr0.AllowCastWhileDead) || (IsTriggered() && m_triggeredByAuraSpell == null)))
return SpellCastResult.CasterDead;
// Prevent cheating in case the player has an immunity effect and tries to interact with a non-allowed gameobject. The error message is handled by the client so we don't report anything here
@@ -4716,7 +4716,7 @@ namespace Game.Spells
}
// check if we are using a potion in combat for the 2nd+ time. Cooldown is added only after caster gets out of combat
if (!IsIgnoringCooldowns() && playerCaster.GetLastPotionId() != 0 && m_CastItem && (m_CastItem.IsPotion() || m_spellInfo.IsCooldownStartedOnEvent()))
if (!IsIgnoringCooldowns() && playerCaster.GetLastPotionId() != 0 && m_CastItem != null && (m_CastItem.IsPotion() || m_spellInfo.IsCooldownStartedOnEvent()))
return SpellCastResult.NotReady;
}
@@ -4749,7 +4749,7 @@ namespace Game.Spells
if (!IsTriggered() && m_caster.IsTypeId(TypeId.Player))
{
Battleground bg = m_caster.ToPlayer().GetBattleground();
if (bg)
if (bg != null)
if (bg.GetStatus() == BattlegroundStatus.WaitLeave)
return SpellCastResult.DontReport;
}
@@ -4907,7 +4907,7 @@ namespace Game.Spells
if (IsTriggered() && m_triggeredByAuraSpell != null)
{
DynamicObject dynObj = m_caster.ToUnit().GetDynObject(m_triggeredByAuraSpell.Id);
if (dynObj)
if (dynObj != null)
losTarget = dynObj;
}
@@ -4989,7 +4989,7 @@ namespace Game.Spells
if (!m_caster.IsUnit() || !m_caster.ToUnit().HasAuraTypeWithMiscvalue(AuraType.ProvideSpellFocus, (int)m_spellInfo.RequiresSpellFocus))
{
focusObject = SearchSpellFocus();
if (!focusObject)
if (focusObject == null)
return SpellCastResult.RequiresSpellFocus;
}
}
@@ -5172,11 +5172,11 @@ namespace Game.Spells
return SpellCastResult.BadTargets;
Item foodItem = m_targets.GetItemTarget();
if (!foodItem)
if (foodItem == null)
return SpellCastResult.BadTargets;
Pet pet = m_caster.ToPlayer().GetPet();
if (!pet)
if (pet == null)
return SpellCastResult.NoPet;
if (!pet.HaveInDiet(foodItem.GetTemplate()))
@@ -5496,7 +5496,7 @@ namespace Game.Spells
if (m_caster.IsTypeId(TypeId.Player))
{
Battleground bg = m_caster.ToPlayer().GetBattleground();
if (bg)
if (bg != null)
if (bg.GetStatus() != BattlegroundStatus.InProgress)
return SpellCastResult.TryAgain;
}
@@ -5537,7 +5537,7 @@ namespace Game.Spells
{
ChrSpecializationRecord spec = CliDB.ChrSpecializationStorage.LookupByKey(m_misc.SpecializationId);
Player playerCaster = m_caster.ToPlayer();
if (!playerCaster)
if (playerCaster == null)
return SpellCastResult.TargetNotPlayer;
if (spec == null || (spec.ClassID != (uint)player.GetClass() && !spec.IsPetSpecialization()))
@@ -5546,13 +5546,13 @@ namespace Game.Spells
if (spec.IsPetSpecialization())
{
Pet pet = player.GetPet();
if (!pet || pet.GetPetType() != PetType.Hunter || pet.GetCharmInfo() == null)
if (pet == null || pet.GetPetType() != PetType.Hunter || pet.GetCharmInfo() == null)
return SpellCastResult.NoPet;
}
// can't change during already started arena/Battleground
Battleground bg = player.GetBattleground();
if (bg)
if (bg != null)
if (bg.GetStatus() == BattlegroundStatus.InProgress)
return SpellCastResult.NotInBattleground;
break;
@@ -5612,7 +5612,7 @@ namespace Game.Spells
case SpellEffectName.GrantBattlepetExperience:
{
Player playerCaster = m_caster.ToPlayer();
if (playerCaster == null || !m_targets.GetUnitTarget() || !m_targets.GetUnitTarget().IsCreature())
if (playerCaster == null || m_targets.GetUnitTarget() == null || !m_targets.GetUnitTarget().IsCreature())
return SpellCastResult.BadTargets;
var battlePetMgr = playerCaster.GetSession().GetBattlePetMgr();
@@ -5694,7 +5694,7 @@ namespace Game.Spells
case AuraType.ModCharm:
case AuraType.AoeCharm:
{
Unit unitCaster1 = (m_originalCaster ? m_originalCaster : m_caster.ToUnit());
Unit unitCaster1 = (m_originalCaster != null ? m_originalCaster : m_caster.ToUnit());
if (unitCaster1 == null)
return SpellCastResult.BadTargets;
@@ -5859,7 +5859,7 @@ namespace Game.Spells
// cooldown
Creature creatureCaster = m_caster.ToCreature();
if (creatureCaster)
if (creatureCaster != null)
if (creatureCaster.GetSpellHistory().HasCooldown(m_spellInfo.Id))
return SpellCastResult.NotReady;
@@ -5873,7 +5873,7 @@ namespace Game.Spells
SpellCastResult CheckCasterAuras(ref int param1)
{
Unit unitCaster = (m_originalCaster ? m_originalCaster : m_caster.ToUnit());
Unit unitCaster = (m_originalCaster != null ? m_originalCaster : m_caster.ToUnit());
if (unitCaster == null)
return SpellCastResult.SpellCastOk;
@@ -5899,7 +5899,7 @@ namespace Game.Spells
/*if (!unitCaster.GetCharmerGUID().IsEmpty())
{
Unit charmer = unitCaster.GetCharmer();
if (charmer)
if (charmer != null)
if (charmer.GetUnitBeingMoved() != unitCaster && !CheckSpellCancelsCharm(ref param1))
result = SpellCastResult.Charmed;
}*/
@@ -6002,7 +6002,7 @@ namespace Game.Spells
bool CheckSpellCancelsAuraEffect(AuraType auraType, ref int param1)
{
Unit unitCaster = (m_originalCaster ? m_originalCaster : m_caster.ToUnit());
Unit unitCaster = (m_originalCaster != null ? m_originalCaster : m_caster.ToUnit());
if (unitCaster == null)
return false;
@@ -6099,7 +6099,7 @@ namespace Game.Spells
public bool CanAutoCast(Unit target)
{
if (!target)
if (target == null)
return (CheckPetCast(target) == SpellCastResult.SpellCastOk);
ObjectGuid targetguid = target.GetGUID();
@@ -6171,7 +6171,7 @@ namespace Game.Spells
maxRange *= maxRange;
Unit target = m_targets.GetUnitTarget();
if (target && target != m_caster)
if (target != null && target != m_caster)
{
if (m_caster.GetExactDistSq(target) > maxRange)
return SpellCastResult.OutOfRange;
@@ -6219,8 +6219,8 @@ namespace Game.Spells
if (m_spellInfo.RangeEntry.Flags.HasAnyFlag(SpellRangeFlag.Melee))
{
// when the target is not a unit, take the caster's combat reach as the target's combat reach.
if (unitCaster)
rangeMod = unitCaster.GetMeleeRange(target ? target : unitCaster);
if (unitCaster != null)
rangeMod = unitCaster.GetMeleeRange(target != null ? target : unitCaster);
}
else
{
@@ -6229,15 +6229,15 @@ namespace Game.Spells
{
// when the target is not a unit, take the caster's combat reach as the target's combat reach.
if (unitCaster != null)
meleeRange = unitCaster.GetMeleeRange(target ? target : unitCaster);
meleeRange = unitCaster.GetMeleeRange(target != null ? target : unitCaster);
}
minRange = m_caster.GetSpellMinRangeForTarget(target, m_spellInfo) + meleeRange;
maxRange = m_caster.GetSpellMaxRangeForTarget(target, m_spellInfo);
if (target || m_targets.GetCorpseTarget())
if (target != null || m_targets.GetCorpseTarget() != null)
{
rangeMod = m_caster.GetCombatReach() + (target ? target.GetCombatReach() : m_caster.GetCombatReach());
rangeMod = m_caster.GetCombatReach() + (target != null ? target.GetCombatReach() : m_caster.GetCombatReach());
if (minRange > 0.0f && !m_spellInfo.RangeEntry.Flags.HasAnyFlag(SpellRangeFlag.Ranged))
minRange += rangeMod;
@@ -6252,12 +6252,12 @@ namespace Game.Spells
if (m_spellInfo.HasAttribute(SpellAttr0.UsesRangedSlot) && m_caster.IsTypeId(TypeId.Player))
{
Item ranged = m_caster.ToPlayer().GetWeaponForAttack(WeaponAttackType.RangedAttack, true);
if (ranged)
if (ranged != null)
maxRange *= ranged.GetTemplate().GetRangedModRange() * 0.01f;
}
Player modOwner = m_caster.GetSpellModOwner();
if (modOwner)
if (modOwner != null)
modOwner.ApplySpellMod(m_spellInfo, SpellModOp.Range, ref maxRange, this);
maxRange += rangeMod;
@@ -6311,7 +6311,7 @@ namespace Game.Spells
SpellCastResult CheckItems(ref int param1, ref int param2)
{
Player player = m_caster.ToPlayer();
if (!player)
if (player == null)
return SpellCastResult.SpellCastOk;
if (m_CastItem == null)
@@ -6675,7 +6675,7 @@ namespace Game.Spells
case SpellEffectName.Disenchant:
{
Item item = m_targets.GetItemTarget();
if (!item)
if (item == null)
return SpellCastResult.CantBeSalvaged;
// prevent disenchanting in trade slot
@@ -6696,7 +6696,7 @@ namespace Game.Spells
case SpellEffectName.Prospecting:
{
Item item = m_targets.GetItemTarget();
if (!item)
if (item == null)
return SpellCastResult.CantBeProspected;
//ensure item is a prospectable ore
if (!item.GetTemplate().HasFlag(ItemFlags.IsProspectable))
@@ -6724,7 +6724,7 @@ namespace Game.Spells
case SpellEffectName.Milling:
{
Item item = m_targets.GetItemTarget();
if (!item)
if (item == null)
return SpellCastResult.CantBeMilled;
//ensure item is a millable herb
if (!item.GetTemplate().HasFlag(ItemFlags.IsMillable))
@@ -6839,7 +6839,7 @@ namespace Game.Spells
Item item = player.ToPlayer().GetWeaponForAttack(attackType);
// skip spell if no weapon in slot or broken
if (!item || item.IsBroken())
if (item == null || item.IsBroken())
return SpellCastResult.EquippedItemClass;
// skip spell if weapon not fit to triggered spell
@@ -6992,7 +6992,7 @@ namespace Game.Spells
m_CastItem = m_caster.ToPlayer().GetItemByGuid(m_castItemGUID);
m_castItemLevel = -1;
// cast item not found, somehow the item is no longer where we expected
if (!m_CastItem)
if (m_CastItem == null)
return false;
// check if the item is really the same, in case it has been wrapped for example
@@ -7059,7 +7059,7 @@ namespace Game.Spells
case AuraType.ModCharm:
case AuraType.ModPossessPet:
case AuraType.AoeCharm:
if (target.GetVehicleKit() && target.GetVehicleKit().IsControllableVehicle())
if (target.GetVehicleKit() != null && target.GetVehicleKit().IsControllableVehicle())
return false;
if (target.IsMounted())
return false;
@@ -7103,7 +7103,7 @@ namespace Game.Spells
}
Corpse corpse = ObjectAccessor.GetCorpse(m_caster, m_targets.GetCorpseTargetGUID());
if (!corpse)
if (corpse == null)
return false;
if (target.GetGUID() != corpse.GetOwnerGUID())
@@ -7125,7 +7125,7 @@ namespace Game.Spells
WorldObject caster = null;
if (m_originalCasterGUID.IsGameObject())
caster = m_caster.GetMap().GetGameObject(m_originalCasterGUID);
if (!caster)
if (caster == null)
caster = m_caster;
if (target != m_caster && !IsWithinLOS(caster, target, true, ModelIgnoreFlags.M2))
@@ -7250,7 +7250,7 @@ namespace Game.Spells
return;
// This will only cause combat - the target will engage once the projectile hits (in Spell::TargetInfo::PreprocessTarget)
if (m_originalCaster && targetInfo.MissCondition != SpellMissInfo.Evade && !m_originalCaster.IsFriendlyTo(targetUnit) && (!m_spellInfo.IsPositive() || m_spellInfo.HasEffect(SpellEffectName.Dispel)) && (m_spellInfo.HasInitialAggro() || targetUnit.IsEngaged()))
if (m_originalCaster != null && targetInfo.MissCondition != SpellMissInfo.Evade && !m_originalCaster.IsFriendlyTo(targetUnit) && (!m_spellInfo.IsPositive() || m_spellInfo.HasEffect(SpellEffectName.Dispel)) && (m_spellInfo.HasInitialAggro() || targetUnit.IsEngaged()))
m_originalCaster.SetInCombatWith(targetUnit, true);
Unit unit = null;
@@ -7264,7 +7264,7 @@ namespace Game.Spells
return;
float critChance = m_spellValue.CriticalChance;
if (m_originalCaster)
if (m_originalCaster != null)
{
if (critChance == 0)
critChance = m_originalCaster.SpellCritChanceDone(this, null, m_spellSchoolMask, m_attackType);
@@ -7284,7 +7284,7 @@ namespace Game.Spells
else if (targetInfo.MissCondition == SpellMissInfo.Reflect && targetInfo.ReflectResult == SpellMissInfo.None)
unit = m_caster.ToUnit();
if (!unit)
if (unit == null)
return;
m_damage = 0;
@@ -7315,7 +7315,7 @@ namespace Game.Spells
}
}
if (m_originalCaster && m_healing > 0)
if (m_originalCaster != null && m_healing > 0)
{
bool isAoeTarget = spellEffectInfo.IsTargetingArea() || spellEffectInfo.IsAreaAuraEffect() || spellEffectInfo.IsEffect(SpellEffectName.PersistentAreaAura);
if (isAoeTarget || m_spellInfo.HasAttribute(SpellAttr5.TreatAsAreaEffect))
@@ -7370,7 +7370,7 @@ namespace Game.Spells
{
// check key item (many fit cases can be)
case LockKeyType.Item:
if (lockInfo.Index[j] != 0 && m_CastItem && m_CastItem.GetEntry() == lockInfo.Index[j])
if (lockInfo.Index[j] != 0 && m_CastItem != null && m_CastItem.GetEntry() == lockInfo.Index[j])
return SpellCastResult.SpellCastOk;
reqKey = true;
break;
@@ -7391,7 +7391,7 @@ namespace Game.Spells
// castitem check: rogue using skeleton keys. the skill values should not be added in this case.
skillValue = 0;
if (!m_CastItem && unitCaster.IsTypeId(TypeId.Player))
if (m_CastItem == null && unitCaster.IsTypeId(TypeId.Player))
skillValue = unitCaster.ToPlayer().GetSkillValue(skillId);
else if (lockInfo.Index[j] == (uint)LockType.Lockpicking)
skillValue = (int)unitCaster.GetLevel() * 5;
@@ -7887,7 +7887,7 @@ namespace Game.Spells
{
// gcd modifier auras are applied only to own spells and only players have such mods
Player modOwner = m_caster.GetSpellModOwner();
if (modOwner)
if (modOwner != null)
{
int intGcd = (int)gcd.TotalMilliseconds;
modOwner.ApplySpellMod(m_spellInfo, SpellModOp.StartCooldown, ref intGcd, this);
@@ -8410,7 +8410,7 @@ namespace Game.Spells
else if (MissCondition == SpellMissInfo.Reflect && ReflectResult == SpellMissInfo.None)
_spellHitTarget = spell.GetCaster().ToUnit();
if (spell.GetOriginalCaster() && MissCondition != SpellMissInfo.Evade && !spell.GetOriginalCaster().IsFriendlyTo(unit) && (!spell.m_spellInfo.IsPositive() || spell.m_spellInfo.HasEffect(SpellEffectName.Dispel)) && (spell.m_spellInfo.HasInitialAggro() || unit.IsEngaged()))
if (spell.GetOriginalCaster() != null && MissCondition != SpellMissInfo.Evade && !spell.GetOriginalCaster().IsFriendlyTo(unit) && (!spell.m_spellInfo.IsPositive() || spell.m_spellInfo.HasEffect(SpellEffectName.Dispel)) && (spell.m_spellInfo.HasInitialAggro() || unit.IsEngaged()))
unit.SetInCombatWith(spell.GetOriginalCaster());
// if target is flagged for pvp also flag caster if a player
@@ -8418,7 +8418,7 @@ namespace Game.Spells
_enablePVP = (MissCondition == SpellMissInfo.None || spell.m_spellInfo.HasAttribute(SpellAttr3.PvpEnabling))
&& unit.IsPvP() && (unit.IsInCombat() || unit.IsCharmedOwnedByPlayerOrPlayer()) && spell.GetCaster().IsPlayer(); // need to check PvP state before spell effects, but act on it afterwards
if (_spellHitTarget)
if (_spellHitTarget != null)
{
SpellMissInfo missInfo = spell.PreprocessSpellHit(_spellHitTarget, this);
if (missInfo != SpellMissInfo.None)
@@ -8459,7 +8459,7 @@ namespace Game.Spells
if (spell.GetState() == SpellState.Delayed && !spell.IsPositive() && (GameTime.GetGameTimeMS() - TimeDelay) <= unit.LastSanctuaryTime)
return; // No missinfo in that case
if (_spellHitTarget)
if (_spellHitTarget != null)
spell.DoSpellEffectHit(_spellHitTarget, spellEffectInfo, this);
// scripts can modify damage/healing for current target, save them
@@ -8475,7 +8475,7 @@ namespace Game.Spells
// other targets executed before this one changed pointer
spell.unitTarget = unit;
if (_spellHitTarget)
if (_spellHitTarget != null)
spell.unitTarget = _spellHitTarget;
// Reset damage/healing counter
@@ -8484,7 +8484,7 @@ namespace Game.Spells
// Get original caster (if exist) and calculate damage/healing from him data
// Skip if m_originalCaster not available
Unit caster = spell.GetOriginalCaster() ? spell.GetOriginalCaster() : spell.GetCaster().ToUnit();
Unit caster = spell.GetOriginalCaster() != null ? spell.GetOriginalCaster() : spell.GetCaster().ToUnit();
if (caster != null)
{
// Fill base trigger info
@@ -8684,7 +8684,7 @@ namespace Game.Spells
spell.m_procSpellType |= procSpellType;
// _spellHitTarget can be null if spell is missed in DoSpellHitOnUnit
if (MissCondition != SpellMissInfo.Evade && _spellHitTarget && !spell.GetCaster().IsFriendlyTo(unit) && (!spell.IsPositive() || spell.m_spellInfo.HasEffect(SpellEffectName.Dispel)))
if (MissCondition != SpellMissInfo.Evade && _spellHitTarget != null && !spell.GetCaster().IsFriendlyTo(unit) && (!spell.IsPositive() || spell.m_spellInfo.HasEffect(SpellEffectName.Dispel)))
{
Unit unitCaster = spell.GetCaster().ToUnit();
if (unitCaster != null)
@@ -8708,7 +8708,7 @@ namespace Game.Spells
caster.CastSpell(unit, 32747, new CastSpellExtraArgs(spell));
}
if (_spellHitTarget)
if (_spellHitTarget != null)
{
//AI functions
Creature cHitTarget = _spellHitTarget.ToCreature();
@@ -8959,7 +8959,7 @@ namespace Game.Spells
return false;
break;
case SpellTargetCheckTypes.RaidClass:
if (!refUnit)
if (refUnit == null)
return false;
if (refUnit.GetClass() != unitTarget.GetClass())
return false;
@@ -9054,7 +9054,7 @@ namespace Game.Spells
public override bool Invoke(WorldObject target)
{
if (target.ToGameObject())
if (target.ToGameObject() != null)
{
// isInRange including the dimension of the GO
bool isInRange = target.ToGameObject().IsInRange(_position.GetPositionX(), _position.GetPositionY(), _position.GetPositionZ(), _range);
@@ -9263,7 +9263,7 @@ namespace Game.Spells
public override bool Execute(ulong e_time, uint p_time)
{
Unit caster = Global.ObjAccessor.GetUnit(_victim, _casterGuid);
if (!caster)
if (caster == null)
return true;
ProcFlags typeMaskActor = ProcFlags.None;
+2 -4
View File
@@ -69,7 +69,7 @@ namespace Game.Spells
if (m_targetMask.HasAnyFlag(SpellCastTargetFlags.Unit | SpellCastTargetFlags.CorpseAlly | SpellCastTargetFlags.Gameobject | SpellCastTargetFlags.CorpseEnemy | SpellCastTargetFlags.UnitMinipet))
data.Unit = m_objectTargetGUID;
if (m_targetMask.HasAnyFlag(SpellCastTargetFlags.Item | SpellCastTargetFlags.TradeItem) && m_itemTarget)
if (m_targetMask.HasAnyFlag(SpellCastTargetFlags.Item | SpellCastTargetFlags.TradeItem) && m_itemTarget != null)
data.Item = m_itemTarget.GetGUID();
if (m_targetMask.HasAnyFlag(SpellCastTargetFlags.SourceLocation))
@@ -110,9 +110,7 @@ namespace Game.Spells
public Unit GetUnitTarget()
{
if (m_objectTarget)
return m_objectTarget.ToUnit();
return null;
return m_objectTarget?.ToUnit();
}
public void SetUnitTarget(Unit target)
+65 -65
View File
@@ -57,9 +57,9 @@ namespace Game.Spells
Player player = null;
if (corpseTarget)
if (corpseTarget != null)
player = Global.ObjAccessor.FindPlayer(corpseTarget.GetOwnerGUID());
else if (unitTarget)
else if (unitTarget != null)
player = unitTarget.ToPlayer();
if (player == null || player.IsAlive() || !player.IsInWorld)
@@ -597,7 +597,7 @@ namespace Game.Spells
if (targetDest.GetMapId() == 0xFFFFFFFF)
targetDest.SetMapId(unitTarget.GetMapId());
if (targetDest.GetOrientation() == 0 && m_targets.GetUnitTarget())
if (targetDest.GetOrientation() == 0 && m_targets.GetUnitTarget() != null)
targetDest.SetOrientation(m_targets.GetUnitTarget().GetOrientation());
Player player = unitTarget.ToPlayer();
@@ -624,7 +624,7 @@ namespace Game.Spells
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
return;
if (!unitTarget)
if (unitTarget == null)
return;
// If not exist data for dest location - return
@@ -639,7 +639,7 @@ namespace Game.Spells
if (targetDest.GetMapId() == 0xFFFFFFFF)
targetDest.SetMapId(unitTarget.GetMapId());
if (targetDest.GetOrientation() == 0 && m_targets.GetUnitTarget())
if (targetDest.GetOrientation() == 0 && m_targets.GetUnitTarget() != null)
targetDest.SetOrientation(m_targets.GetUnitTarget().GetOrientation());
if (effectInfo.MiscValueB != 0)
@@ -852,7 +852,7 @@ namespace Game.Spells
int heal = (int)unitTarget.CountPctFromMaxHealth(damage);
Unit unitCaster = GetUnitCasterForEffectHandlers();
if (unitCaster)
if (unitCaster != null)
{
heal = unitCaster.SpellHealingBonusDone(unitTarget, m_spellInfo, heal, DamageEffectType.Heal, effectInfo, 1, this);
heal = unitTarget.SpellHealingBonusTaken(unitCaster, m_spellInfo, heal, DamageEffectType.Heal);
@@ -872,11 +872,11 @@ namespace Game.Spells
Unit unitCaster = GetUnitCasterForEffectHandlers();
int heal = damage;
if (unitCaster)
if (unitCaster != null)
heal = unitCaster.SpellHealingBonusDone(unitTarget, m_spellInfo, heal, DamageEffectType.Heal, effectInfo, 1, this);
heal += (int)(heal * variance);
if (unitCaster)
if (unitCaster != null)
heal = unitTarget.SpellHealingBonusTaken(unitCaster, m_spellInfo, heal, DamageEffectType.Heal);
m_healing += heal;
@@ -1121,7 +1121,7 @@ namespace Game.Spells
else
return;
Cypher.Assert(dynObjAura.GetDynobjOwner());
Cypher.Assert(dynObjAura.GetDynobjOwner() != null);
dynObjAura._ApplyEffectForTargets(effectInfo.EffectIndex);
}
@@ -1228,7 +1228,7 @@ namespace Game.Spells
//CanUseBattlegroundObject() already called in CheckCast()
// in Battlegroundcheck
Battleground bg = player.GetBattleground();
if (bg)
if (bg != null)
{
bg.EventPlayerClickedOnFlag(player, gameObjTarget);
return;
@@ -1244,7 +1244,7 @@ namespace Game.Spells
//CanUseBattlegroundObject() already called in CheckCast()
// in Battlegroundcheck
Battleground bg = player.GetBattleground();
if (bg)
if (bg != null)
{
if (bg.GetTypeID() == BattlegroundTypeId.EY)
bg.EventPlayerClickedOnFlag(player, gameObjTarget);
@@ -1480,7 +1480,7 @@ namespace Game.Spells
}
WorldObject caster = m_caster;
if (m_originalCaster)
if (m_originalCaster != null)
caster = m_originalCaster;
ObjectGuid privateObjectOwner = caster.GetGUID();
@@ -1491,7 +1491,7 @@ namespace Game.Spells
privateObjectOwner = caster.GetPrivateObjectOwner();
if (properties.GetFlags().HasFlag(SummonPropertiesFlags.OnlyVisibleToSummonerGroup))
if (caster.IsPlayer() && m_originalCaster.ToPlayer().GetGroup())
if (caster.IsPlayer() && m_originalCaster.ToPlayer().GetGroup() != null)
privateObjectOwner = caster.ToPlayer().GetGroup().GetGUID();
TimeSpan duration = TimeSpan.FromMilliseconds(m_spellInfo.CalcDuration(caster));
@@ -2019,7 +2019,7 @@ namespace Game.Spells
else
{
// do not increase skill if vellum used
if (!(m_CastItem && m_CastItem.GetTemplate().HasFlag(ItemFlags.NoReagentCost)))
if (!(m_CastItem != null && m_CastItem.GetTemplate().HasFlag(ItemFlags.NoReagentCost)))
player.UpdateCraftSkill(m_spellInfo);
uint enchant_id = (uint)effectInfo.MiscValue;
@@ -2348,7 +2348,7 @@ namespace Game.Spells
// this effect use before aura Taunt apply for prevent taunt already attacking target
// for spell as marked "non effective at already attacking target"
if (!unitTarget || unitTarget.IsTotem())
if (unitTarget == null || unitTarget.IsTotem())
{
SendCastResult(SpellCastResult.DontReport);
return;
@@ -2613,7 +2613,7 @@ namespace Game.Spells
Position pos = new(x, y, z, o);
Quaternion rotation = Quaternion.CreateFromRotationMatrix(Extensions.fromEulerAnglesZYX(o, 0.0f, 0.0f));
GameObject go = GameObject.CreateGameObject((uint)effectInfo.MiscValue, map, pos, rotation, 255, GameObjectState.Ready);
if (!go)
if (go == null)
return;
PhasingHandler.InheritPhaseShift(go, m_caster);
@@ -2634,13 +2634,13 @@ namespace Game.Spells
if (player != null)
{
Battleground bg = player.GetBattleground();
if (bg)
if (bg != null)
bg.SetDroppedFlagGUID(go.GetGUID(), bg.GetPlayerTeam(player.GetGUID()) == Team.Alliance ? TeamId.Horde : TeamId.Alliance);
}
}
GameObject linkedTrap = go.GetLinkedTrap();
if (linkedTrap)
if (linkedTrap != null)
{
PhasingHandler.InheritPhaseShift(linkedTrap, m_caster);
linkedTrap.SetRespawnTime(duration > 0 ? duration / Time.InMilliseconds : 0);
@@ -2902,7 +2902,7 @@ namespace Game.Spells
Quaternion rotation = Quaternion.CreateFromRotationMatrix(Extensions.fromEulerAnglesZYX(pos.GetOrientation(), 0.0f, 0.0f));
GameObject go = GameObject.CreateGameObject((uint)effectInfo.MiscValue, map, pos, rotation, 0, GameObjectState.Ready);
if (!go)
if (go == null)
return;
PhasingHandler.InheritPhaseShift(go, caster);
@@ -3246,7 +3246,7 @@ namespace Game.Spells
Position pos = new(x, y, z, o);
Quaternion rotation = Quaternion.CreateFromRotationMatrix(Extensions.fromEulerAnglesZYX(o, 0.0f, 0.0f));
GameObject go = GameObject.CreateGameObject((uint)effectInfo.MiscValue, map, pos, rotation, 255, GameObjectState.Ready);
if (!go)
if (go == null)
return;
PhasingHandler.InheritPhaseShift(go, m_caster);
@@ -3276,9 +3276,9 @@ namespace Game.Spells
Player player = null;
if (corpseTarget)
if (corpseTarget != null)
player = Global.ObjAccessor.FindPlayer(corpseTarget.GetOwnerGUID());
else if (unitTarget)
else if (unitTarget != null)
player = unitTarget.ToPlayer();
if (player == null || player.IsAlive() || !player.IsInWorld)
@@ -3302,7 +3302,7 @@ namespace Game.Spells
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
return;
if (!unitTarget || !unitTarget.IsAlive())
if (unitTarget == null || !unitTarget.IsAlive())
return;
unitTarget.AddExtraAttacks((uint)damage);
@@ -3648,10 +3648,10 @@ namespace Game.Spells
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
return;
if (!unitTarget)
if (unitTarget == null)
return;
if (m_caster.GetAffectingPlayer())
if (m_caster.GetAffectingPlayer() != null)
{
Creature creatureTarget = unitTarget.ToCreature();
if (creatureTarget != null)
@@ -3775,7 +3775,7 @@ namespace Game.Spells
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
return;
if (!unitTarget)
if (unitTarget == null)
return;
Position pos = m_caster.GetFirstCollisionPosition(m_caster.GetCombatReach(), m_caster.GetRelativeAngle(unitTarget));
@@ -3806,7 +3806,7 @@ namespace Game.Spells
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
return;
if (!unitTarget)
if (unitTarget == null)
return;
if (!m_targets.HasDst())
@@ -3844,11 +3844,11 @@ namespace Game.Spells
return;
Player player = m_caster.ToPlayer();
if (!player || !m_targets.HasDst())
if (player == null || !m_targets.HasDst())
return;
Group group = player.GetGroup();
if (!group || (group.IsRaidGroup() && !group.IsLeader(player.GetGUID()) && !group.IsAssistant(player.GetGUID())))
if (group == null || (group.IsRaidGroup() && !group.IsLeader(player.GetGUID()) && !group.IsAssistant(player.GetGUID())))
return;
float x, y, z;
@@ -4136,7 +4136,7 @@ namespace Game.Spells
Quaternion rotation = Quaternion.CreateFromRotationMatrix(Extensions.fromEulerAnglesZYX(fo, 0.0f, 0.0f));
GameObject go = GameObject.CreateGameObject(name_id, cMap, pos, rotation, 255, GameObjectState.Ready);
if (!go)
if (go == null)
return;
PhasingHandler.InheritPhaseShift(go, m_caster);
@@ -4475,11 +4475,11 @@ namespace Game.Spells
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
return;
if (!unitTarget)
if (unitTarget == null)
return;
Player player = unitTarget.ToPlayer();
if (!player)
if (player == null)
return;
Quest quest = Global.ObjectMgr.GetQuestTemplate((uint)effectInfo.MiscValue);
@@ -4639,7 +4639,7 @@ namespace Game.Spells
if (summon.IsGuardian())
{
// level of pet summoned using engineering item based at engineering skill level
if (m_CastItem && unitCaster.IsPlayer())
if (m_CastItem != null && unitCaster.IsPlayer())
{
ItemTemplate proto = m_CastItem.GetTemplate();
if (proto != null)
@@ -4732,11 +4732,11 @@ namespace Game.Spells
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
return;
if (!unitTarget)
if (unitTarget == null)
return;
Player player = unitTarget.ToPlayer();
if (!player)
if (player == null)
return;
switch (m_spellInfo.Id)
@@ -4975,7 +4975,7 @@ namespace Game.Spells
Quaternion rot = Quaternion.CreateFromRotationMatrix(Extensions.fromEulerAnglesZYX(o, 0.0f, 0.0f));
GameObject go = GameObject.CreateGameObject(goId, map, pos, rot, 255, GameObjectState.Ready);
if (!go)
if (go == null)
{
Log.outWarn(LogFilter.Spells, $"SpellEffect Failed to summon personal gameobject. SpellId {m_spellInfo.Id}, effect {effectInfo.EffectIndex}");
return;
@@ -5062,7 +5062,7 @@ namespace Game.Spells
if (talent == null)
return;
Player player = unitTarget ? unitTarget.ToPlayer() : null;
Player player = unitTarget != null ? unitTarget.ToPlayer() : null;
if (player == null)
return;
@@ -5076,12 +5076,12 @@ namespace Game.Spells
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
return;
if (!unitTarget || !unitTarget.IsTypeId(TypeId.Player))
if (unitTarget == null || !unitTarget.IsTypeId(TypeId.Player))
return;
Player player = unitTarget.ToPlayer();
Item item = player.GetItemByEntry(effectInfo.ItemType);
if (item)
if (item != null)
player.DestroyItem(item.GetBagSlot(), item.GetSlot(), true);
}
@@ -5091,7 +5091,7 @@ namespace Game.Spells
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
return;
if (!unitTarget || !unitTarget.IsTypeId(TypeId.Player))
if (unitTarget == null || !unitTarget.IsTypeId(TypeId.Player))
return;
Garrison garrison = unitTarget.ToPlayer().GetGarrison();
@@ -5105,7 +5105,7 @@ namespace Game.Spells
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
return;
if (!unitTarget)
if (unitTarget == null)
return;
unitTarget.RemoveAppliedAuras(aurApp => aurApp.GetBase().GetSpellInfo().HasLabel((uint)effectInfo.MiscValue));
@@ -5117,7 +5117,7 @@ namespace Game.Spells
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
return;
if (!unitTarget || !unitTarget.IsTypeId(TypeId.Player))
if (unitTarget == null || !unitTarget.IsTypeId(TypeId.Player))
return;
unitTarget.ToPlayer().CreateGarrison((uint)effectInfo.MiscValue);
@@ -5142,7 +5142,7 @@ namespace Game.Spells
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
return;
if (!unitTarget)
if (unitTarget == null)
return;
List<WorldObject> objs = new();
@@ -5164,7 +5164,7 @@ namespace Game.Spells
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
return;
if (!unitTarget || !unitTarget.IsTypeId(TypeId.Player))
if (unitTarget == null || !unitTarget.IsTypeId(TypeId.Player))
return;
Garrison garrison = unitTarget.ToPlayer().GetGarrison();
@@ -5179,7 +5179,7 @@ namespace Game.Spells
return;
Player player = m_caster.ToPlayer();
if (!player)
if (player == null)
return;
CollectionMgr collectionMgr = player.GetSession().GetCollectionMgr();
@@ -5199,7 +5199,7 @@ namespace Game.Spells
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
return;
if (!unitTarget || !unitTarget.IsTypeId(TypeId.Player))
if (unitTarget == null || !unitTarget.IsTypeId(TypeId.Player))
return;
Garrison garrison = unitTarget.ToPlayer().GetGarrison();
@@ -5230,7 +5230,7 @@ namespace Game.Spells
return;
Player playerTarget = unitTarget?.ToPlayer();
if (!playerTarget)
if (playerTarget == null)
return;
uint xp = Quest.XPValue(playerTarget, (uint)effectInfo.MiscValue, (uint)effectInfo.MiscValueB);
@@ -5244,7 +5244,7 @@ namespace Game.Spells
return;
Player playerTarget = unitTarget?.ToPlayer();
if (!playerTarget)
if (playerTarget == null)
return;
// effect value is number of resting hours
@@ -5257,7 +5257,7 @@ namespace Game.Spells
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
return;
if (!unitTarget || !unitTarget.IsTypeId(TypeId.Player))
if (unitTarget == null || !unitTarget.IsTypeId(TypeId.Player))
return;
BattlePetMgr battlePetMgr = unitTarget.ToPlayer().GetSession().GetBattlePetMgr();
@@ -5307,7 +5307,7 @@ namespace Game.Spells
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
return;
if (!unitTarget || !unitTarget.IsPlayer())
if (unitTarget == null || !unitTarget.IsPlayer())
return;
unitTarget.ToPlayer().SendPlayerChoice(GetCaster().GetGUID(), effectInfo.MiscValue);
@@ -5319,7 +5319,7 @@ namespace Game.Spells
if (effectHandleMode != SpellEffectHandleMode.Hit)
return;
if (!m_CastItem || !m_caster || !m_caster.IsTypeId(TypeId.Player))
if (m_CastItem == null || m_caster == null || !m_caster.IsTypeId(TypeId.Player))
return;
uint speciesId = m_CastItem.GetModifier(ItemModifier.BattlePetSpeciesId);
@@ -5366,7 +5366,7 @@ namespace Game.Spells
return;
Player player = m_caster.ToPlayer();
if (player)
if (player != null)
{
CollectionMgr collectionMgr = player.GetSession().GetCollectionMgr();
if (collectionMgr != null)
@@ -5380,11 +5380,11 @@ namespace Game.Spells
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
return;
if (!itemTarget)
if (itemTarget == null)
return;
Player player = m_caster.ToPlayer();
if (!player || player.GetGUID() != itemTarget.GetOwnerGUID())
if (player == null || player.GetGUID() != itemTarget.GetOwnerGUID())
return;
itemTarget.SetState(ItemUpdateState.Changed, player);
@@ -5402,7 +5402,7 @@ namespace Game.Spells
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
return;
if (!unitTarget || !unitTarget.IsTypeId(TypeId.Player))
if (unitTarget == null || !unitTarget.IsTypeId(TypeId.Player))
return;
PhasingHandler.OnConditionChange(unitTarget);
@@ -5414,7 +5414,7 @@ namespace Game.Spells
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
return;
if (!unitTarget || !unitTarget.IsTypeId(TypeId.Player))
if (unitTarget == null || !unitTarget.IsTypeId(TypeId.Player))
return;
unitTarget.ToPlayer().UpdateAreaDependentAuras(unitTarget.GetAreaId());
@@ -5434,7 +5434,7 @@ namespace Game.Spells
if (artifactAura != null)
{
Item artifact = playerCaster.GetItemByGuid(artifactAura.GetCastItemGUID());
if (artifact)
if (artifact != null)
artifact.GiveArtifactXp((ulong)damage, m_CastItem, (ArtifactCategory)effectInfo.MiscValue);
}
}
@@ -5445,14 +5445,14 @@ namespace Game.Spells
if (effectHandleMode != SpellEffectHandleMode.LaunchTarget)
return;
if (!unitTarget || !m_caster.IsTypeId(TypeId.Player))
if (unitTarget == null || !m_caster.IsTypeId(TypeId.Player))
return;
Aura artifactAura = unitTarget.GetAura(PlayerConst.ArtifactsAllWeaponsGeneralWeaponEquippedPassive);
if (artifactAura != null)
{
Item artifact = unitTarget.ToPlayer().GetItemByGuid(artifactAura.GetCastItemGUID());
if (artifact)
if (artifact != null)
artifact.GiveArtifactXp((ulong)damage, m_CastItem, 0);
}
}
@@ -5488,7 +5488,7 @@ namespace Game.Spells
return;
Unit unitCaster = GetUnitCasterForEffectHandlers();
if (!unitCaster || !m_targets.HasDst())
if (unitCaster == null || !m_targets.HasDst())
return;
SceneObject sceneObject = SceneObject.CreateSceneObject((uint)effectInfo.MiscValue, unitCaster, destTarget.GetPosition(), ObjectGuid.Empty);
@@ -5507,7 +5507,7 @@ namespace Game.Spells
return;
Unit unitCaster = GetUnitCasterForEffectHandlers();
if (!unitCaster || !m_targets.HasDst())
if (unitCaster == null || !m_targets.HasDst())
return;
SceneObject sceneObject = SceneObject.CreateSceneObject((uint)effectInfo.MiscValue, unitCaster, destTarget.GetPosition(), unitCaster.GetGUID());
@@ -5537,7 +5537,7 @@ namespace Game.Spells
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
return;
if (!unitTarget || unitTarget.GetTypeId() != TypeId.Player)
if (unitTarget == null || unitTarget.GetTypeId() != TypeId.Player)
return;
PvPCredit packet = new();
@@ -5600,7 +5600,7 @@ namespace Game.Spells
if (effectHandleMode != SpellEffectHandleMode.HitTarget)
return;
if (!unitTarget || !unitTarget.IsPlayer())
if (unitTarget == null || !unitTarget.IsPlayer())
return;
unitTarget.ToPlayer().GetSession().GetCollectionMgr().AddTransmogSet((uint)effectInfo.MiscValue);
@@ -5613,7 +5613,7 @@ namespace Game.Spells
return;
Player playerTarget = unitTarget != null ? unitTarget.ToPlayer() : null;
if (!playerTarget)
if (playerTarget == null)
return;
Item heartOfAzeroth = playerTarget.GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth, ItemSearchLocation.Everywhere);
@@ -5687,7 +5687,7 @@ namespace Game.Spells
if (playerCaster == null)
return;
if (!unitTarget || !unitTarget.IsCreature())
if (unitTarget == null || !unitTarget.IsCreature())
return;
playerCaster.GetSession().GetBattlePetMgr().GrantBattlePetExperience(unitTarget.GetBattlePetCompanionGUID(), (ushort)damage, BattlePetXpSource.SpellEffect);
+15 -15
View File
@@ -177,7 +177,7 @@ namespace Game.Spells
public void HandleCooldowns(SpellInfo spellInfo, Item item, Spell spell = null)
{
HandleCooldowns(spellInfo, item ? item.GetEntry() : 0u, spell);
HandleCooldowns(spellInfo, item != null ? item.GetEntry() : 0u, spell);
}
public void HandleCooldowns(SpellInfo spellInfo, uint itemId, Spell spell = null)
@@ -189,7 +189,7 @@ namespace Game.Spells
return;
Player player = _owner.ToPlayer();
if (player)
if (player != null)
{
// potions start cooldown until exiting combat
ItemTemplate itemTemplate = Global.ObjectMgr.GetItemTemplate(itemId);
@@ -353,7 +353,7 @@ namespace Game.Spells
{
// Now we have cooldown data (if found any), time to apply mods
Player modOwner = _owner.GetSpellModOwner();
if (modOwner)
if (modOwner != null)
{
void applySpellMod(ref TimeSpan value)
{
@@ -386,7 +386,7 @@ namespace Game.Spells
{
// Apply SPELL_AURA_MOD_COOLDOWN only to own spells
Player playerOwner = GetPlayerOwner();
if (!playerOwner || playerOwner.HasSpell(spellInfo.Id))
if (playerOwner == null || playerOwner.HasSpell(spellInfo.Id))
{
needsCooldownPacket = true;
cooldown += TimeSpan.FromMilliseconds(cooldownMod); // SPELL_AURA_MOD_COOLDOWN does not affect category cooldows, verified with shaman shocks
@@ -438,7 +438,7 @@ namespace Game.Spells
if (needsCooldownPacket)
{
Player playerOwner = GetPlayerOwner();
if (playerOwner)
if (playerOwner != null)
{
SpellCooldownPkt spellCooldown = new();
spellCooldown.Caster = _owner.GetGUID();
@@ -453,7 +453,7 @@ namespace Game.Spells
public void SendCooldownEvent(SpellInfo spellInfo, uint itemId = 0, Spell spell = null, bool startCooldown = true)
{
Player player = GetPlayerOwner();
if (player)
if (player != null)
{
uint category = spellInfo.GetCategory();
GetCooldownDurations(spellInfo, itemId, ref category);
@@ -526,7 +526,7 @@ namespace Game.Spells
}
Player playerOwner = GetPlayerOwner();
if (playerOwner)
if (playerOwner != null)
{
ModifyCooldown modifyCooldown = new();
modifyCooldown.IsPet = _owner != playerOwner;
@@ -579,7 +579,7 @@ namespace Game.Spells
if (update)
{
Player playerOwner = GetPlayerOwner();
if (playerOwner)
if (playerOwner != null)
{
ClearCooldown clearCooldown = new();
clearCooldown.IsPet = _owner != playerOwner;
@@ -612,7 +612,7 @@ namespace Game.Spells
public void ResetAllCooldowns()
{
Player playerOwner = GetPlayerOwner();
if (playerOwner)
if (playerOwner != null)
{
List<uint> cooldowns = new();
foreach (var id in _spellCooldowns.Keys)
@@ -708,7 +708,7 @@ namespace Game.Spells
List<uint> knownSpells = new();
Player plrOwner = _owner.ToPlayer();
if (plrOwner)
if (plrOwner != null)
{
foreach (var p in plrOwner.GetSpellMap())
if (p.Value.State != PlayerSpellState.Removed)
@@ -752,7 +752,7 @@ namespace Game.Spells
}
Player player = GetPlayerOwner();
if (player)
if (player != null)
if (!spellCooldown.SpellCooldowns.Empty())
player.SendPacket(spellCooldown);
}
@@ -837,7 +837,7 @@ namespace Game.Spells
_categoryCharges.Remove(chargeCategoryId);
Player player = GetPlayerOwner();
if (player)
if (player != null)
{
ClearSpellCharges clearSpellCharges = new();
clearSpellCharges.IsPet = _owner != player;
@@ -852,7 +852,7 @@ namespace Game.Spells
_categoryCharges.Clear();
Player player = GetPlayerOwner();
if (player)
if (player != null)
{
ClearAllSpellCharges clearAllSpellCharges = new();
clearAllSpellCharges.IsPet = _owner != player;
@@ -929,7 +929,7 @@ namespace Game.Spells
public void SendClearCooldowns(List<uint> cooldowns)
{
Player playerOwner = GetPlayerOwner();
if (playerOwner)
if (playerOwner != null)
{
ClearCooldowns clearCooldowns = new();
clearCooldowns.IsPet = _owner != playerOwner;
@@ -1005,7 +1005,7 @@ namespace Game.Spells
public void RestoreCooldownStateAfterDuel()
{
Player player = _owner.ToPlayer();
if (player)
if (player != null)
{
// add all profession CDs created while in duel (if any)
foreach (var c in _spellCooldowns)
+17 -17
View File
@@ -608,7 +608,7 @@ namespace Game.Spells
return true;
// item dependent spell
if (item && item.IsFitToSpellRequirements(this))
if (item != null && item.IsFitToSpellRequirements(this))
return true;
return false;
@@ -839,7 +839,7 @@ namespace Game.Spells
if (HasAttribute(SpellAttr4.OnlyFlyingAreas))
{
AreaMountFlags mountFlags = 0;
if (player && player.HasAuraType(AuraType.MountRestrictions))
if (player != null && player.HasAuraType(AuraType.MountRestrictions))
{
foreach (AuraEffect auraEffect in player.GetAuraEffectsByType(AuraType.MountRestrictions))
mountFlags |= (AreaMountFlags)auraEffect.GetMiscValue();
@@ -853,7 +853,7 @@ namespace Game.Spells
if (!mountFlags.HasFlag(AreaMountFlags.AllowFlyingMounts))
return SpellCastResult.IncorrectArea;
if (player)
if (player != null)
{
uint mapToCheck = map_id;
MapRecord mapEntry1 = CliDB.MapStorage.LookupByKey(map_id);
@@ -917,7 +917,7 @@ namespace Game.Spells
return SpellCastResult.RequiresArea;
Battleground bg = player.GetBattleground();
return bg && bg.GetStatus() == BattlegroundStatus.WaitJoin ? SpellCastResult.SpellCastOk : SpellCastResult.RequiresArea;
return bg != null && bg.GetStatus() == BattlegroundStatus.WaitJoin ? SpellCastResult.SpellCastOk : SpellCastResult.RequiresArea;
}
case 32724: // Gold Team (Alliance)
case 32725: // Green Team (Alliance)
@@ -939,12 +939,12 @@ namespace Game.Spells
return SpellCastResult.RequiresArea;
Battleground bg = player.GetBattleground();
return bg && bg.GetStatus() == BattlegroundStatus.WaitJoin ? SpellCastResult.SpellCastOk : SpellCastResult.RequiresArea;
return bg != null && bg.GetStatus() == BattlegroundStatus.WaitJoin ? SpellCastResult.SpellCastOk : SpellCastResult.RequiresArea;
}
}
// aura limitations
if (player)
if (player != null)
{
foreach (var effectInfo in _effects)
{
@@ -1140,10 +1140,10 @@ namespace Game.Spells
if (HasAttribute(SpellAttr8.BattleResurrection))
{
Map map = caster.GetMap();
if (map)
if (map != null)
{
InstanceMap iMap = map.ToInstanceMap();
if (iMap)
if (iMap != null)
{
InstanceScript instance = iMap.GetInstanceScript();
if (instance != null)
@@ -1203,7 +1203,7 @@ namespace Game.Spells
return SpellCastResult.SpellCastOk;
Vehicle vehicle = caster.GetVehicle();
if (vehicle)
if (vehicle != null)
{
VehicleSeatFlags checkMask = 0;
foreach (var effectInfo in _effects)
@@ -2706,10 +2706,10 @@ namespace Game.Spells
{
int duration = GetDuration();
if (caster)
if (caster != null)
{
Player modOwner = caster.GetSpellModOwner();
if (modOwner)
if (modOwner != null)
modOwner.ApplySpellMod(this, SpellModOp.Duration, ref duration);
}
@@ -2813,7 +2813,7 @@ namespace Game.Spells
{
// gameobject casts don't use power
Unit unitCaster = caster.ToUnit();
if (!unitCaster)
if (unitCaster == null)
return null;
if (power.RequiredAuraSpellID != 0 && !unitCaster.HasAura(power.RequiredAuraSpellID))
@@ -3128,7 +3128,7 @@ namespace Game.Spells
public float CalcProcPPM(Unit caster, int itemLevel)
{
float ppm = ProcBasePPM;
if (!caster)
if (caster == null)
return ppm;
foreach (SpellProcsPerMinuteModRecord mod in ProcPPMMods)
@@ -3154,7 +3154,7 @@ namespace Game.Spells
case SpellProcsPerMinuteModType.Spec:
{
Player plrCaster = caster.ToPlayer();
if (plrCaster)
if (plrCaster != null)
if (plrCaster.GetPrimarySpecialization() == (ChrSpecialization)mod.Param)
ppm *= 1.0f + mod.Coeff;
break;
@@ -3291,12 +3291,12 @@ namespace Game.Spells
{
var playerCondition = CliDB.PlayerConditionStorage.LookupByKey(visual.CasterPlayerConditionID);
if (playerCondition != null)
if (!caster || !caster.IsPlayer() || !ConditionManager.IsPlayerMeetingCondition(caster.ToPlayer(), playerCondition))
if (caster == null || !caster.IsPlayer() || !ConditionManager.IsPlayerMeetingCondition(caster.ToPlayer(), playerCondition))
continue;
var unitCondition = CliDB.UnitConditionStorage.LookupByKey(visual.CasterUnitConditionID);
if (unitCondition != null)
if (!caster || !caster.IsUnit() || !ConditionManager.IsUnitMeetingCondition(caster.ToUnit(), viewer?.ToUnit(), unitCondition))
if (caster == null || !caster.IsUnit() || !ConditionManager.IsUnitMeetingCondition(caster.ToUnit(), viewer?.ToUnit(), unitCondition))
continue;
return visual.Id;
@@ -4245,7 +4245,7 @@ namespace Game.Spells
if (Scaling.Coefficient != 0.0f)
{
uint level = _spellInfo.SpellLevel;
if (target && _spellInfo.IsPositiveEffect(EffectIndex) && (Effect == SpellEffectName.ApplyAura))
if (target != null && _spellInfo.IsPositiveEffect(EffectIndex) && (Effect == SpellEffectName.ApplyAura))
level = target.GetLevel();
else if (caster != null && caster.IsUnit())
level = caster.ToUnit().GetLevel();
+10 -10
View File
@@ -112,7 +112,7 @@ namespace Game.Entities
{
if (msg)
{
if (player)
if (player != null)
player.SendSysMessage("Craft spell {0} not have create item entry.", spellInfo.Id);
else
Log.outError(LogFilter.Spells, "Craft spell {0} not have create item entry.", spellInfo.Id);
@@ -126,7 +126,7 @@ namespace Game.Entities
{
if (msg)
{
if (player)
if (player != null)
player.SendSysMessage("Craft spell {0} create not-exist in DB item (Entry: {1}) and then...", spellInfo.Id, spellEffectInfo.ItemType);
else
Log.outError(LogFilter.Spells, "Craft spell {0} create not-exist in DB item (Entry: {1}) and then...", spellInfo.Id, spellEffectInfo.ItemType);
@@ -460,8 +460,8 @@ namespace Game.Entities
if (((uint)procEntry.AttributesMask & 0x0000001) != 0)
{
Player actor = eventInfo.GetActor().ToPlayer();
if (actor)
if (eventInfo.GetActionTarget() && !actor.IsHonorOrXPTarget(eventInfo.GetActionTarget()))
if (actor != null)
if (eventInfo.GetActionTarget() != null && !actor.IsHonorOrXPTarget(eventInfo.GetActionTarget()))
return false;
}
@@ -4964,10 +4964,10 @@ namespace Game.Entities
if (player == null || (auraSpell > 0 && !player.HasAura((uint)auraSpell)) || (auraSpell < 0 && player.HasAura((uint)-auraSpell)))
return false;
if (player)
if (player != null)
{
Battleground bg = player.GetBattleground();
if (bg)
if (bg != null)
return bg.IsSpellAllowed(spellId, player);
}
@@ -4976,7 +4976,7 @@ namespace Game.Entities
{
case 91604: // No fly Zone - Wintergrasp
{
if (!player)
if (player == null)
return false;
BattleField Bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(player.GetMap(), player.GetZoneId());
@@ -4987,7 +4987,7 @@ namespace Game.Entities
case 56618: // Horde Controls Factory Phase Shift
case 56617: // Alliance Controls Factory Phase Shift
{
if (!player)
if (player == null)
return false;
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(player.GetMap(), player.GetZoneId());
@@ -5007,7 +5007,7 @@ namespace Game.Entities
case 57940: // Essence of Wintergrasp - Northrend
case 58045: // Essence of Wintergrasp - Wintergrasp
{
if (!player)
if (player == null)
return false;
BattleField battlefieldWG = Global.BattleFieldMgr.GetBattlefieldByBattleId(player.GetMap(), 1);
@@ -5017,7 +5017,7 @@ namespace Game.Entities
}
case 74411: // Battleground- Dampening
{
if (!player)
if (player == null)
return false;
BattleField bf = Global.BattleFieldMgr.GetBattlefieldToZoneId(player.GetMap(), player.GetZoneId());