Updated to 8.2.0.31429 (scripts disabled atm, they still need updated)

Code Port from TrinityCore https://github.com/TrinityCore/TrinityCore
Casc from WoW-Tools https://github.com/WoW-Tools/CASCExplorer
This commit is contained in:
hondacrx
2019-08-14 11:20:42 -04:00
parent e4d500f4b5
commit 125e3b3ac7
232 changed files with 12268 additions and 14670 deletions
+1 -1
View File
@@ -730,7 +730,7 @@ namespace Game.Spells
int duration = m_spellInfo.GetMaxDuration();
// Calculate duration of periodics affected by haste.
if (caster.HasAuraTypeWithAffectMask(AuraType.PeriodicHaste, m_spellInfo) || m_spellInfo.HasAttribute(SpellAttr5.HasteAffectDuration))
duration = (int)(duration * caster.GetFloatValue(UnitFields.ModCastSpeed));
duration = (int)(duration * caster.m_unitData.ModCastingSpeed);
SetMaxDuration(duration);
SetDuration(duration);
+155 -177
View File
@@ -78,49 +78,7 @@ namespace Game.Spells
if (!m_spellInfo.HasAttribute(SpellAttr8.MasterySpecialization) || MathFunctions.fuzzyEq(GetSpellEffectInfo().BonusCoefficient, 0.0f))
amount = GetSpellEffectInfo().CalcValue(caster, m_baseAmount, GetBase().GetOwner().ToUnit(), GetBase().GetCastItemLevel());
else if (caster != null && caster.IsTypeId(TypeId.Player))
amount = (int)(caster.GetFloatValue(ActivePlayerFields.Mastery) * GetSpellEffectInfo().BonusCoefficient);
// check item enchant aura cast
if (amount == 0 && caster != null)
{
ObjectGuid itemGUID = GetBase().GetCastItemGUID();
if (!itemGUID.IsEmpty())
{
Player playerCaster = caster.ToPlayer();
if (playerCaster != null)
{
Item castItem = playerCaster.GetItemByGuid(itemGUID);
if (castItem != null)
{
if (castItem.GetItemSuffixFactor() != 0)
{
var item_rand_suffix = CliDB.ItemRandomSuffixStorage.LookupByKey((uint)Math.Abs(castItem.GetItemRandomPropertyId()));
if (item_rand_suffix != null)
{
for (int k = 0; k < ItemConst.MaxItemRandomProperties; k++)
{
var pEnchant = CliDB.SpellItemEnchantmentStorage.LookupByKey(item_rand_suffix.Enchantment[k]);
if (pEnchant != null)
{
for (int t = 0; t < ItemConst.MaxItemEnchantmentEffects; t++)
{
if (pEnchant.EffectArg[t] == m_spellInfo.Id)
{
amount = (int)((item_rand_suffix.AllocationPct[k] * castItem.GetItemSuffixFactor()) / 10000);
break;
}
}
}
if (amount != 0)
break;
}
}
}
}
}
}
}
amount = (int)(caster.ToPlayer().m_activePlayerData.Mastery * GetSpellEffectInfo().BonusCoefficient);
// custom amount calculations go here
switch (GetAuraType())
@@ -217,7 +175,7 @@ namespace Game.Spells
if (m_spellInfo.IsChanneled())
caster.ModSpellDurationTime(m_spellInfo, ref m_period);
else if (m_spellInfo.HasAttribute(SpellAttr5.HasteAffectDuration))
m_period = (int)(m_period * caster.GetFloatValue(UnitFields.ModCastHaste));
m_period = (int)(m_period * caster.m_unitData.ModCastingSpeed);
}
}
@@ -1088,8 +1046,9 @@ namespace Game.Spells
if (apply)
{
// apply glow vision
if (target.IsTypeId(TypeId.Player))
target.SetByteFlag(ActivePlayerFields.Bytes2, PlayerFieldOffsets.FieldBytes2OffsetAuraVision, PlayerFieldByte2Flags.InvisibilityGlow);
Player playerTarget = target.ToPlayer();
if (playerTarget != null)
playerTarget.AddAuraVision(PlayerFieldByte2Flags.InvisibilityGlow);
target.m_invisibility.AddFlag(type);
target.m_invisibility.AddValue(type, GetAmount());
@@ -1100,8 +1059,9 @@ namespace Game.Spells
{
// if not have different invisibility auras.
// remove glow vision
if (target.IsTypeId(TypeId.Player))
target.RemoveByteFlag(ActivePlayerFields.Bytes2, PlayerFieldOffsets.FieldBytes2OffsetAuraVision, PlayerFieldByte2Flags.InvisibilityGlow);
Player playerTarget = target.ToPlayer();
if (playerTarget != null)
playerTarget.RemoveAuraVision(PlayerFieldByte2Flags.InvisibilityGlow);
target.m_invisibility.DelFlag(type);
}
@@ -1172,9 +1132,10 @@ namespace Game.Spells
{
target.m_stealth.AddFlag(type);
target.m_stealth.AddValue(type, GetAmount());
target.SetStandFlags(UnitStandFlags.Creep);
if (target.IsTypeId(TypeId.Player))
target.SetByteFlag(ActivePlayerFields.Bytes2, PlayerFieldOffsets.FieldBytes2OffsetAuraVision, PlayerFieldByte2Flags.Stealth);
target.AddVisFlags(UnitVisFlags.Creep);
Player playerTarget = target.ToPlayer();
if (playerTarget != null)
playerTarget.AddAuraVision(PlayerFieldByte2Flags.Stealth);
}
else
{
@@ -1184,9 +1145,10 @@ namespace Game.Spells
{
target.m_stealth.DelFlag(type);
target.RemoveStandFlags(UnitStandFlags.Creep);
if (target.IsTypeId(TypeId.Player))
target.RemoveByteFlag(ActivePlayerFields.Bytes2, PlayerFieldOffsets.FieldBytes2OffsetAuraVision, PlayerFieldByte2Flags.Stealth);
target.RemoveVisFlags(UnitVisFlags.Creep);
Player playerTarget = target.ToPlayer();
if (playerTarget != null)
playerTarget.RemoveAuraVision(PlayerFieldByte2Flags.Stealth);
}
}
@@ -1253,14 +1215,13 @@ namespace Game.Spells
if (!mode.HasAnyFlag(AuraEffectHandleModes.SendForClientMask))
return;
Unit target = aurApp.GetTarget();
if (!target.IsTypeId(TypeId.Player))
Player target = aurApp.GetTarget().ToPlayer();
if (target == null)
return;
if (apply)
{
target.SetFlag(PlayerFields.Flags, PlayerFlags.Ghost);
target.AddPlayerFlag(PlayerFlags.Ghost);
target.m_serverSideVisibility.SetValue(ServerSideVisibilityType.Ghost, GhostVisibilityType.Ghost);
target.m_serverSideVisibilityDetect.SetValue(ServerSideVisibilityType.Ghost, GhostVisibilityType.Ghost);
}
@@ -1269,7 +1230,7 @@ namespace Game.Spells
if (target.HasAuraType(AuraType.Ghost))
return;
target.RemoveFlag(PlayerFields.Flags, PlayerFlags.Ghost);
target.RemovePlayerFlag(PlayerFlags.Ghost);
target.m_serverSideVisibility.SetValue(ServerSideVisibilityType.Ghost, GhostVisibilityType.Alive);
target.m_serverSideVisibilityDetect.SetValue(ServerSideVisibilityType.Ghost, GhostVisibilityType.Alive);
}
@@ -1631,8 +1592,8 @@ namespace Game.Spells
target.SetDisplayId(model_id);
// Dragonmaw Illusion (set mount model also)
if (GetId() == 42016 && target.GetMountID() != 0 && !target.GetAuraEffectsByType(AuraType.ModIncreaseMountedFlightSpeed).Empty())
target.SetUInt32Value(UnitFields.MountDisplayId, 16314);
if (GetId() == 42016 && target.GetMountDisplayId() != 0 && !target.GetAuraEffectsByType(AuraType.ModIncreaseMountedFlightSpeed).Empty())
target.SetMountDisplayId(16314);
}
}
}
@@ -1663,7 +1624,7 @@ namespace Game.Spells
target.RestoreDisplayId(target.IsMounted());
// Dragonmaw Illusion (restore mount model)
if (GetId() == 42016 && target.GetMountID() == 16314)
if (GetId() == 42016 && target.GetMountDisplayId() == 16314)
{
if (!target.GetAuraEffectsByType(AuraType.Mounted).Empty())
{
@@ -1674,7 +1635,7 @@ namespace Game.Spells
CreatureModel model = ObjectManager.ChooseDisplayId(ci);
Global.ObjectMgr.GetCreatureModelRandomGender(ref model, ci);
target.SetUInt32Value(UnitFields.MountDisplayId, model.CreatureDisplayID);
target.SetMountDisplayId(model.CreatureDisplayID);
}
}
}
@@ -1690,7 +1651,7 @@ namespace Game.Spells
Unit target = aurApp.GetTarget();
float scale = target.GetFloatValue(ObjectFields.ScaleX);
float scale = target.GetObjectScale();
MathFunctions.ApplyPercentModFloatVar(ref scale, GetAmount(), apply);
target.SetObjectScale(scale);
}
@@ -1712,12 +1673,12 @@ namespace Game.Spells
// What must be cloned? at least display and scale
target.SetDisplayId(caster.GetDisplayId());
//target.SetObjectScale(caster.GetFloatValue(OBJECT_FIELD_SCALE_X)); // we need retail info about how scaling is handled (aura maybe?)
target.SetFlag(UnitFields.Flags2, UnitFlags2.MirrorImage);
target.AddUnitFlag2(UnitFlags2.MirrorImage);
}
else
{
target.SetDisplayId(target.GetNativeDisplayId());
target.RemoveFlag(UnitFields.Flags2, UnitFlags2.MirrorImage);
target.RemoveUnitFlag2(UnitFlags2.MirrorImage);
}
}
@@ -1765,24 +1726,17 @@ namespace Game.Spells
// stop handling the effect if it was removed by linked event
if (aurApp.HasRemoveMode())
return;
// blizz like 2.0.x
target.SetFlag(UnitFields.Flags, UnitFlags.Unk29);
// blizz like 2.0.x
target.SetFlag(UnitFields.Flags2, UnitFlags2.FeignDeath);
// blizz like 2.0.x
target.SetFlag(ObjectFields.DynamicFlags, UnitDynFlags.Dead);
target.AddUnitFlag(UnitFlags.Unk29);
target.AddUnitFlag2(UnitFlags2.FeignDeath);
target.AddDynamicFlag(UnitDynFlags.Dead);
target.AddUnitState(UnitState.Died);
}
else
{
// blizz like 2.0.x
target.RemoveFlag(UnitFields.Flags, UnitFlags.Unk29);
// blizz like 2.0.x
target.RemoveFlag(UnitFields.Flags2, UnitFlags2.FeignDeath);
// blizz like 2.0.x
target.RemoveFlag(ObjectFields.DynamicFlags, UnitDynFlags.Dead);
target.RemoveUnitFlag(UnitFlags.Unk29);
target.RemoveUnitFlag2(UnitFlags2.FeignDeath);
target.RemoveDynamicFlag(UnitDynFlags.Dead);
target.ClearUnitState(UnitState.Died);
}
}
@@ -1799,7 +1753,10 @@ namespace Game.Spells
if (!apply && target.HasAuraType(AuraType.ModUnattackable))
return;
target.ApplyModFlag(UnitFields.Flags, UnitFlags.NonAttackable, apply);
if (apply)
target.AddUnitFlag(UnitFlags.NonAttackable);
else
target.RemoveUnitFlag(UnitFlags.NonAttackable);
// call functions which may have additional effects after chainging state of unit
if (apply && mode.HasAnyFlag(AuraEffectHandleModes.Real))
@@ -1822,26 +1779,34 @@ namespace Game.Spells
//Prevent handling aura twice
if ((apply) ? target.GetAuraEffectsByType(type).Count > 1 : target.HasAuraType(type))
return;
UnitFields field;
uint flag, slot;
Action<Unit> flagAddFn = null;
Action<Unit> flagRemoveFn = null;
uint slot;
WeaponAttackType attType;
switch (type)
{
case AuraType.ModDisarm:
field = UnitFields.Flags;
flag = (uint)UnitFlags.Disarmed;
if (apply)
flagAddFn = unit => { unit.AddUnitFlag(UnitFlags.Disarmed); };
else
flagRemoveFn = unit => { unit.RemoveUnitFlag(UnitFlags.Disarmed); };
slot = EquipmentSlot.MainHand;
attType = WeaponAttackType.BaseAttack;
break;
case AuraType.ModDisarmOffhand:
field = UnitFields.Flags2;
flag = (uint)UnitFlags2.DisarmOffhand;
if (apply)
flagAddFn = unit => { unit.AddUnitFlag2(UnitFlags2.DisarmOffhand); };
else
flagRemoveFn = unit => { unit.RemoveUnitFlag2(UnitFlags2.DisarmOffhand); };
slot = EquipmentSlot.OffHand;
attType = WeaponAttackType.OffAttack;
break;
case AuraType.ModDisarmRanged:
field = UnitFields.Flags2;
flag = (uint)UnitFlags2.DisarmRanged;
if (apply)
flagAddFn = unit => { unit.AddUnitFlag2(UnitFlags2.DisarmRanged); };
else
flagRemoveFn = unit => { unit.RemoveUnitFlag2(UnitFlags2.DisarmRanged); };
slot = EquipmentSlot.MainHand;
attType = WeaponAttackType.RangedAttack;
break;
@@ -1850,8 +1815,7 @@ namespace Game.Spells
}
// if disarm aura is to be removed, remove the flag first to reapply damage/aura mods
if (!apply)
target.RemoveFlag(field, flag);
flagRemoveFn?.Invoke(target);
// Handle damage modification, shapeshifted druids are not affected
if (target.IsTypeId(TypeId.Player) && !target.IsInFeralForm())
@@ -1870,8 +1834,7 @@ namespace Game.Spells
}
// if disarm effects should be applied, wait to set flag until damage mods are unapplied
if (apply)
target.SetFlag(field, flag);
flagAddFn?.Invoke(target);
if (target.IsTypeId(TypeId.Unit) && target.ToCreature().GetCurrentEquipmentId() != 0)
target.UpdateDamagePhysical(attType);
@@ -1887,7 +1850,7 @@ namespace Game.Spells
if (apply)
{
target.SetFlag(UnitFields.Flags, UnitFlags.Silenced);
target.AddUnitFlag(UnitFlags.Silenced);
// call functions which may have additional effects after chainging state of unit
// Stop cast only spells vs PreventionType & SPELL_PREVENTION_TYPE_SILENCE
@@ -1906,7 +1869,7 @@ namespace Game.Spells
if (target.HasAuraType(AuraType.ModSilence) || target.HasAuraType(AuraType.ModPacifySilence))
return;
target.RemoveFlag(UnitFields.Flags, UnitFlags.Silenced);
target.RemoveUnitFlag(UnitFlags.Silenced);
}
}
@@ -1919,13 +1882,13 @@ namespace Game.Spells
Unit target = aurApp.GetTarget();
if (apply)
target.SetFlag(UnitFields.Flags, UnitFlags.Pacified);
target.AddUnitFlag(UnitFlags.Pacified);
else
{
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
if (target.HasAuraType(AuraType.ModPacify) || target.HasAuraType(AuraType.ModPacifySilence))
return;
target.RemoveFlag(UnitFields.Flags, UnitFlags.Pacified);
target.RemoveUnitFlag(UnitFlags.Pacified);
}
}
@@ -1942,9 +1905,9 @@ namespace Game.Spells
if (m_spellInfo.Id == 45839)
{
if (apply)
target.SetFlag(UnitFields.Flags, UnitFlags.NonAttackable);
target.AddUnitFlag(UnitFlags.NonAttackable);
else
target.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable);
target.RemoveUnitFlag(UnitFlags.NonAttackable);
}
if (!(apply))
{
@@ -1962,18 +1925,17 @@ namespace Game.Spells
if (!mode.HasAnyFlag(AuraEffectHandleModes.SendForClientMask))
return;
Unit target = aurApp.GetTarget();
if (target.IsTypeId(TypeId.Player))
Player target = aurApp.GetTarget().ToPlayer();
if (target != null)
{
if (apply)
target.SetFlag(PlayerFields.Flags, PlayerFlags.AllowOnlyAbility);
target.AddPlayerFlag(PlayerFlags.AllowOnlyAbility);
else
{
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
if (target.HasAuraType(AuraType.AllowOnlyAbility))
return;
target.RemoveFlag(PlayerFields.Flags, PlayerFlags.AllowOnlyAbility);
target.RemovePlayerFlag(PlayerFlags.AllowOnlyAbility);
}
}
}
@@ -1988,7 +1950,7 @@ namespace Game.Spells
if (apply)
{
target.SetFlag(UnitFields.Flags2, UnitFlags2.NoActions);
target.AddUnitFlag2(UnitFlags2.NoActions);
// call functions which may have additional effects after chainging state of unit
// Stop cast only spells vs PreventionType & SPELL_PREVENTION_TYPE_SILENCE
@@ -2007,7 +1969,7 @@ namespace Game.Spells
if (target.HasAuraType(AuraType.ModNoActions))
return;
target.RemoveFlag(UnitFields.Flags2, UnitFlags2.NoActions);
target.RemoveUnitFlag2(UnitFlags2.NoActions);
}
}
@@ -2020,15 +1982,14 @@ namespace Game.Spells
if (!mode.HasAnyFlag(AuraEffectHandleModes.SendForClientMask))
return;
Unit target = aurApp.GetTarget();
if (!target.IsTypeId(TypeId.Player))
Player target = aurApp.GetTarget().ToPlayer();
if (target == null)
return;
if (apply)
target.SetFlag(ActivePlayerFields.TrackCreatures, 1 << (GetMiscValue() - 1));
target.AddTrackCreatureFlag(1u << (GetMiscValue() - 1));
else
target.RemoveFlag(ActivePlayerFields.TrackCreatures, 1 << (GetMiscValue() - 1));
target.RemoveTrackCreatureFlag(1u << (GetMiscValue() - 1));
}
[AuraEffectHandler(AuraType.TrackResources)]
@@ -2037,15 +1998,17 @@ namespace Game.Spells
if (!mode.HasAnyFlag(AuraEffectHandleModes.SendForClientMask))
return;
Unit target = aurApp.GetTarget();
if (!target.IsTypeId(TypeId.Player))
Player target = aurApp.GetTarget().ToPlayer();
if (target == null)
return;
uint bitIndex = (uint)GetMiscValue() - 1;
uint index = bitIndex / 32;
uint flag = 1u << ((int)bitIndex % 32);
if (apply)
target.SetFlag(ActivePlayerFields.TrackResources, 1 << (GetMiscValue() - 1));
target.AddTrackResourceFlag(index, flag);
else
target.RemoveFlag(ActivePlayerFields.TrackResources, 1 << (GetMiscValue() - 1));
target.RemoveTrackResourceFlag(index, flag);
}
[AuraEffectHandler(AuraType.TrackStealthed)]
@@ -2054,9 +2017,8 @@ namespace Game.Spells
if (!mode.HasAnyFlag(AuraEffectHandleModes.SendForClientMask))
return;
Unit target = aurApp.GetTarget();
if (!target.IsTypeId(TypeId.Player))
Player target = aurApp.GetTarget().ToPlayer();
if (target == null)
return;
if (!(apply))
@@ -2065,7 +2027,10 @@ namespace Game.Spells
if (target.HasAuraType(GetAuraType()))
return;
}
target.ApplyModFlag(ActivePlayerFields.LocalFlags, PlayerLocalFlags.TrackStealthed, apply);
if (apply)
target.AddPlayerLocalFlag(PlayerLocalFlags.TrackStealthed);
else
target.RemovePlayerLocalFlag(PlayerLocalFlags.TrackStealthed);
}
[AuraEffectHandler(AuraType.ModStalked)]
@@ -2078,12 +2043,12 @@ namespace Game.Spells
// used by spells: Hunter's Mark, Mind Vision, Syndicate Tracker (MURP) DND
if (apply)
target.SetFlag(ObjectFields.DynamicFlags, UnitDynFlags.TrackUnit);
target.AddDynamicFlag(UnitDynFlags.TrackUnit);
else
{
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
if (!target.HasAuraType(GetAuraType()))
target.RemoveFlag(ObjectFields.DynamicFlags, UnitDynFlags.TrackUnit);
target.RemoveDynamicFlag(UnitDynFlags.TrackUnit);
}
// call functions which may have additional effects after chainging state of unit
@@ -2096,16 +2061,18 @@ namespace Game.Spells
if (!mode.HasAnyFlag(AuraEffectHandleModes.SendForClientMask))
return;
Unit target = aurApp.GetTarget();
Player target = aurApp.GetTarget().ToPlayer();
if (target == null)
return;
if (apply)
target.SetByteFlag(UnitFields.Bytes1, UnitBytes1Offsets.VisFlag, UnitStandFlags.Untrackable);
target.AddVisFlags(UnitVisFlags.Untrackable);
else
{
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
if (target.HasAuraType(GetAuraType()))
return;
target.RemoveByteFlag(UnitFields.Bytes1, UnitBytes1Offsets.VisFlag, UnitStandFlags.Untrackable);
target.RemoveVisFlags(UnitVisFlags.Untrackable);
}
}
@@ -2179,8 +2146,8 @@ namespace Game.Spells
}
}
// TODO: CREATE TABLE mount_vehicle (mountId, vehicleCreatureId) for future mounts that are vehicles (new mounts no longer have proper data in MiscValue)
//if (MountVehicle const* mountVehicle = sObjectMgr->GetMountVehicle(mountEntry->Id))
// creatureEntry = mountVehicle->VehicleCreatureId;
//if (MountVehicle const* mountVehicle = sObjectMgr.GetMountVehicle(mountEntry.Id))
// creatureEntry = mountVehicle.VehicleCreatureId;
}
CreatureTemplate creatureInfo = Global.ObjectMgr.GetCreatureTemplate(creatureEntry);
@@ -2329,13 +2296,13 @@ namespace Game.Spells
Unit target = aurApp.GetTarget();
if (apply)
target.SetFlag(UnitFields.Flags2, UnitFlags2.ForceMove);
target.AddUnitFlag2(UnitFlags2.ForceMove);
else
{
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
if (target.HasAuraType(GetAuraType()))
return;
target.RemoveFlag(UnitFields.Flags2, UnitFlags2.ForceMove);
target.RemoveUnitFlag2(UnitFlags2.ForceMove);
}
}
@@ -2692,8 +2659,8 @@ namespace Game.Spells
target.ApplySpellImmune(GetId(), SpellImmunity.Mechanic, (uint)Mechanics.Polymorph, apply);
// Dragonmaw Illusion (overwrite mount model, mounted aura already applied)
if (apply && target.HasAuraEffect(42016, 0) && target.GetMountID() != 0)
target.SetUInt32Value(UnitFields.MountDisplayId, 16314);
if (apply && target.HasAuraEffect(42016, 0) && target.GetMountDisplayId() != 0)
target.SetMountDisplayId(16314);
}
}
}
@@ -2963,17 +2930,19 @@ namespace Game.Spells
if (!mode.HasAnyFlag((AuraEffectHandleModes.ChangeAmountMask | AuraEffectHandleModes.Stat)))
return;
Unit target = aurApp.GetTarget();
Player target = aurApp.GetTarget().ToPlayer();
if (target == null)
return;
// applied to damage as HandleNoImmediateEffect in Unit.CalcAbsorbResist and Unit.CalcArmorReducedDamage
// show armor penetration
if (target.IsTypeId(TypeId.Player) && Convert.ToBoolean(GetMiscValue() & (int)SpellSchoolMask.Normal))
target.ApplyModUInt32Value(ActivePlayerFields.ModTargetPhysicalResistance, GetAmount(), apply);
target.ApplyModTargetPhysicalResistance(GetAmount(), apply);
// show as spell penetration only full spell penetration bonuses (all resistances except armor and holy
if (target.IsTypeId(TypeId.Player) && ((SpellSchoolMask)GetMiscValue() & SpellSchoolMask.Spell) == SpellSchoolMask.Spell)
target.ApplyModUInt32Value(ActivePlayerFields.ModTargetResistance, GetAmount(), apply);
target.ApplyModTargetResistance(GetAmount(), apply);
}
/********************************/
@@ -3261,7 +3230,7 @@ namespace Game.Spells
if (!target)
return;
target.ApplyModSignedFloatValue(ActivePlayerFields.OverrideSpellPowerByApPct, m_amount, apply);
target.ApplyModOverrideSpellPowerByAPPercent(m_amount, apply);
target.UpdateSpellDamageAndHealingBonus();
}
@@ -3275,7 +3244,7 @@ namespace Game.Spells
if (!target)
return;
target.ApplyModSignedFloatValue(ActivePlayerFields.OverrideApBySpellPowerPercent, m_amount, apply);
target.ApplyModOverrideAPBySpellPowerPercent(m_amount, apply);
target.UpdateAttackPowerAndDamage();
target.UpdateAttackPowerAndDamage(true);
}
@@ -3289,7 +3258,7 @@ namespace Game.Spells
Player target = aurApp.GetTarget().ToPlayer();
if (target)
{
target.SetStatFloatValue(ActivePlayerFields.VersatilityBonus, target.GetTotalAuraModifier(AuraType.ModVersatility));
target.SetVersatilityBonus(target.GetTotalAuraModifier(AuraType.ModVersatility));
target.UpdateHealingDonePercentMod();
target.UpdateVersatilityDamageDone();
}
@@ -3519,10 +3488,10 @@ namespace Game.Spells
if (apply)
{
target.RemoveAurasByType(GetAuraType(), ObjectGuid.Empty, GetBase());
target.SetUInt32Value(UnitFields.OverrideDisplayPowerId, powerDisplay.Id);
target.SetOverrideDisplayPowerId(powerDisplay.Id);
}
else
target.SetUInt32Value(UnitFields.OverrideDisplayPowerId, 0);
target.SetOverrideDisplayPowerId(0);
}
[AuraEffectHandler(AuraType.ModMaxPowerPct)]
@@ -3933,16 +3902,21 @@ namespace Game.Spells
// Magic damage modifiers implemented in Unit::SpellBaseDamageBonusDone
// This information for client side use only
if (target.IsTypeId(TypeId.Player))
Player playerTarget = target.ToPlayer();
if (playerTarget != null)
{
ActivePlayerFields baseField = GetAmount() >= 0 ? ActivePlayerFields.ModDamageDonePos : ActivePlayerFields.ModDamageDoneNeg;
for (int i = 0; i < (int)SpellSchools.Max; ++i)
{
if (Convert.ToBoolean(GetMiscValue() & (1 << i)))
target.ApplyModInt32Value(baseField + i, GetAmount(), apply);
{
if (GetAmount() >= 0)
playerTarget.ApplyModDamageDonePos((SpellSchools)i, GetAmount(), apply);
else
playerTarget.ApplyModDamageDoneNeg((SpellSchools)i, GetAmount(), apply);
}
}
Guardian pet = target.ToPlayer().GetGuardianPet();
Guardian pet = playerTarget.GetGuardianPet();
if (pet)
pet.UpdateAttackPowerAndDamage();
}
@@ -3973,16 +3947,17 @@ namespace Game.Spells
target.HandleStatModifier(UnitMods.DamageRanged, UnitModifierType.TotalPCT, GetAmount(), apply);
}
if (target.IsTypeId(TypeId.Player))
Player thisPlayer = target.ToPlayer();
if (thisPlayer != null)
{
for (int i = 0; i < (int)SpellSchools.Max; ++i)
{
if (Convert.ToBoolean(GetMiscValue() & (1 << i)))
{
if (spellGroupVal != 0)
target.ApplyPercentModFloatValue(ActivePlayerFields.ModDamageDonePct + i, spellGroupVal, !apply);
thisPlayer.ApplyModDamageDonePercent((SpellSchools)i, spellGroupVal, !apply);
target.ApplyPercentModFloatValue(ActivePlayerFields.ModDamageDonePct + i, GetAmount(), apply);
thisPlayer.ApplyModDamageDonePercent((SpellSchools)i, GetAmount(), apply);
}
}
}
@@ -4024,7 +3999,7 @@ namespace Game.Spells
float amount = MathFunctions.CalculatePct(1.0f, GetAmount());
for (int i = 0; i < (int)SpellSchools.Max; ++i)
if (Convert.ToBoolean(GetMiscValue() & (1 << i)))
target.ApplyModSignedFloatValue(UnitFields.PowerCostMultiplier + i, amount, apply);
target.ApplyModPowerCostMultiplier((SpellSchools)i, amount, apply);
}
[AuraEffectHandler(AuraType.ModPowerCostSchool)]
@@ -4037,7 +4012,7 @@ namespace Game.Spells
for (int i = 0; i < (int)SpellSchools.Max; ++i)
if (Convert.ToBoolean(GetMiscValue() & (1 << i)))
target.ApplyModUInt32Value(UnitFields.PowerCostModifier + i, GetAmount(), apply);
target.ApplyModPowerCostModifier((SpellSchools)i, GetAmount(), apply);
}
[AuraEffectHandler(AuraType.ArenaPreparation)]
@@ -4049,13 +4024,13 @@ namespace Game.Spells
Unit target = aurApp.GetTarget();
if (apply)
target.SetFlag(UnitFields.Flags, UnitFlags.Preparation);
target.AddUnitFlag(UnitFlags.Preparation);
else
{
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
if (target.HasAuraType(GetAuraType()))
return;
target.RemoveFlag(UnitFields.Flags, UnitFlags.Preparation);
target.RemoveUnitFlag(UnitFlags.Preparation);
}
}
@@ -4079,9 +4054,7 @@ namespace Game.Spells
mask |= effect.SpellClassMask;
}
target.SetUInt32Value(ActivePlayerFields.NoReagentCost, mask[0]);
target.SetUInt32Value(ActivePlayerFields.NoReagentCost + 1, mask[1]);
target.SetUInt32Value(ActivePlayerFields.NoReagentCost + 2, mask[2]);
target.ToPlayer().SetNoRegentCostMask(mask);
}
[AuraEffectHandler(AuraType.RetainComboPoints)]
@@ -4556,7 +4529,12 @@ namespace Game.Spells
}
if (target.GetCreatureType() == CreatureType.Beast)
target.ApplyModUInt32Value(ObjectFields.DynamicFlags, (int)UnitDynFlags.SpecialInfo, apply);
{
if (apply)
target.AddDynamicFlag(UnitDynFlags.SpecialInfo);
else
target.RemoveDynamicFlag(UnitDynFlags.SpecialInfo);
}
}
[AuraEffectHandler(AuraType.ModFaction)]
@@ -4571,13 +4549,13 @@ namespace Game.Spells
{
target.SetFaction((uint)GetMiscValue());
if (target.IsTypeId(TypeId.Player))
target.RemoveFlag(UnitFields.Flags, UnitFlags.PvpAttackable);
target.RemoveUnitFlag(UnitFlags.PvpAttackable);
}
else
{
target.RestoreFaction();
if (target.IsTypeId(TypeId.Player))
target.SetFlag(UnitFields.Flags, UnitFlags.PvpAttackable);
target.AddUnitFlag(UnitFlags.PvpAttackable);
}
}
@@ -4590,13 +4568,13 @@ namespace Game.Spells
Unit target = aurApp.GetTarget();
if (apply)
target.SetFlag(UnitFields.Flags2, UnitFlags2.ComprehendLang);
target.AddUnitFlag2(UnitFlags2.ComprehendLang);
else
{
if (target.HasAuraType(GetAuraType()))
return;
target.RemoveFlag(UnitFields.Flags2, UnitFlags2.ComprehendLang);
target.RemoveUnitFlag2(UnitFlags2.ComprehendLang);
}
}
@@ -4670,11 +4648,9 @@ namespace Game.Spells
target.m_invisibilityDetect.AddFlag(InvisibilityType.Drunk);
target.m_invisibilityDetect.AddValue(InvisibilityType.Drunk, GetAmount());
if (target.IsTypeId(TypeId.Player))
{
int oldval = target.ToPlayer().GetInt32Value(PlayerFields.FakeInebriation);
target.ToPlayer().SetInt32Value(PlayerFields.FakeInebriation, oldval + GetAmount());
}
Player playerTarget = target.ToPlayer();
if (playerTarget)
playerTarget.ApplyModFakeInebriation(GetAmount(), true);
}
else
{
@@ -4682,13 +4658,13 @@ namespace Game.Spells
target.m_invisibilityDetect.AddValue(InvisibilityType.Drunk, -GetAmount());
if (target.IsTypeId(TypeId.Player))
Player playerTarget = target.ToPlayer();
if (playerTarget != null)
{
int oldval = target.ToPlayer().GetInt32Value(PlayerFields.FakeInebriation);
target.ToPlayer().SetInt32Value(PlayerFields.FakeInebriation, oldval - GetAmount());
playerTarget.ApplyModFakeInebriation(GetAmount(), false);
if (removeDetect)
removeDetect = target.ToPlayer().GetDrunkValue() == 0;
removeDetect = playerTarget.GetDrunkValue() == 0;
}
if (removeDetect)
@@ -4714,7 +4690,7 @@ namespace Game.Spells
if (apply)
{
target.SetUInt16Value(ActivePlayerFields.Bytes3, PlayerFieldOffsets.FieldBytes3OffsetOverrideSpellsIdUint16Offset, (ushort)overrideId);
target.SetOverrideSpellsId(overrideId);
OverrideSpellDataRecord overrideSpells = CliDB.OverrideSpellDataStorage.LookupByKey(overrideId);
if (overrideSpells != null)
{
@@ -4728,7 +4704,7 @@ namespace Game.Spells
}
else
{
target.SetUInt16Value(ActivePlayerFields.Bytes3, PlayerFieldOffsets.FieldBytes3OffsetOverrideSpellsIdUint16Offset, 0);
target.SetOverrideSpellsId(0);
OverrideSpellDataRecord overrideSpells = CliDB.OverrideSpellDataStorage.LookupByKey(overrideId);
if (overrideSpells != null)
{
@@ -4776,13 +4752,14 @@ namespace Game.Spells
if (!mode.HasAnyFlag(AuraEffectHandleModes.Real))
return;
if (!aurApp.GetTarget().IsTypeId(TypeId.Player))
Player target = aurApp.GetTarget().ToPlayer();
if (target == null)
return;
if (apply)
aurApp.GetTarget().RemoveByteFlag(ActivePlayerFields.LocalFlags, 0, PlayerLocalFlags.ReleaseTimer);
else if (!aurApp.GetTarget().GetMap().Instanceable())
aurApp.GetTarget().SetByteFlag(ActivePlayerFields.LocalFlags, 0, PlayerLocalFlags.ReleaseTimer);
target.RemovePlayerLocalFlag(PlayerLocalFlags.ReleaseTimer);
else if (!target.GetMap().Instanceable())
target.AddPlayerLocalFlag(PlayerLocalFlags.ReleaseTimer);
}
[AuraEffectHandler(AuraType.Mastery)]
@@ -4917,7 +4894,7 @@ namespace Game.Spells
if (GetId() == 52179) // Astral Shift
{
// Periodic need for remove visual on stun/fear/silence lost
if (!Convert.ToBoolean(target.GetUInt32Value(UnitFields.Flags) & (uint)(UnitFlags.Stunned | UnitFlags.Fleeing | UnitFlags.Silenced)))
if (!target.HasUnitFlag(UnitFlags.Stunned | UnitFlags.Fleeing | UnitFlags.Silenced))
target.RemoveAurasDueToSpell(52179);
break;
}
@@ -5947,13 +5924,14 @@ namespace Game.Spells
if (!mode.HasAnyFlag(AuraEffectHandleModes.Real))
return;
if (!aurApp.GetTarget().IsTypeId(TypeId.Player))
Player target = aurApp.GetTarget().ToPlayer();
if (target == null)
return;
if (apply)
aurApp.GetTarget().SetFlag(ActivePlayerFields.LocalFlags, PlayerLocalFlags.CanUseObjectsMounted);
else if (!aurApp.GetTarget().HasAuraType(AuraType.AllowUsingGameobjectsWhileMounted))
aurApp.GetTarget().RemoveFlag(ActivePlayerFields.LocalFlags, PlayerLocalFlags.CanUseObjectsMounted);
target.AddPlayerLocalFlag(PlayerLocalFlags.CanUseObjectsMounted);
else if (!target.HasAuraType(AuraType.AllowUsingGameobjectsWhileMounted))
target.RemovePlayerLocalFlag(PlayerLocalFlags.CanUseObjectsMounted);
}
[AuraEffectHandler(AuraType.PlayScene)]
+21 -21
View File
@@ -431,7 +431,7 @@ namespace Game.Spells
{
case Targets.UnitChannelTarget:
{
foreach (ObjectGuid channelTarget in m_originalCaster.GetChannelObjects())
foreach (ObjectGuid channelTarget in m_originalCaster.m_unitData.ChannelObjects)
{
WorldObject target = Global.ObjAccessor.GetUnit(m_caster, channelTarget);
CallScriptObjectTargetSelectHandlers(ref target, effIndex, targetType);
@@ -450,7 +450,7 @@ namespace Game.Spells
m_targets.SetDst(channeledSpell.m_targets);
else
{
var channelObjects = m_originalCaster.GetChannelObjects();
List<ObjectGuid> channelObjects = m_originalCaster.m_unitData.ChannelObjects;
WorldObject target = channelObjects.Count > 0 ? Global.ObjAccessor.GetWorldObject(m_caster, channelObjects[0]) : null;
if (target != null)
{
@@ -2090,7 +2090,7 @@ namespace Game.Spells
if (m_caster != unit)
{
// Recheck UNIT_FLAG_NON_ATTACKABLE for delayed spells
if (m_spellInfo.Speed > 0.0f && unit.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable) && unit.GetCharmerOrOwnerGUID() != m_caster.GetGUID())
if (m_spellInfo.Speed > 0.0f && unit.HasUnitFlag(UnitFlags.NonAttackable) && unit.GetCharmerOrOwnerGUID() != m_caster.GetGUID())
return SpellMissInfo.Evade;
if (m_caster._IsValidAttackTarget(unit, m_spellInfo))
@@ -2214,7 +2214,7 @@ namespace Game.Spells
// if there is no periodic effect
if (duration == 0)
duration = (int)(origDuration * m_originalCaster.GetFloatValue(UnitFields.ModCastSpeed));
duration = (int)(origDuration * m_originalCaster.m_unitData.ModCastingSpeed);
}
}
@@ -2504,7 +2504,7 @@ namespace Game.Spells
else
m_casttime = m_spellInfo.CalcCastTime(m_caster.getLevel(), this);
if (m_caster.IsTypeId(TypeId.Unit) && !m_caster.HasFlag(UnitFields.Flags, UnitFlags.PlayerControlled)) // _UNIT actually means creature. for some reason.
if (m_caster.IsTypeId(TypeId.Unit) && !m_caster.HasUnitFlag(UnitFlags.PlayerControlled)) // _UNIT actually means creature. for some reason.
{
if (!(m_spellInfo.IsNextMeleeSwingSpell() || IsAutoRepeat() || _triggeredCastFlags.HasAnyFlag(TriggerCastFlags.IgnoreSetFacing)))
{
@@ -2566,7 +2566,7 @@ namespace Game.Spells
TriggerGlobalCooldown();
//item: first cast may destroy item and second cast causes crash
// commented out !m_spellInfo->StartRecoveryTime, it forces instant spells with global cooldown to be processed in spell::update
// commented out !m_spellInfo.StartRecoveryTime, it forces instant spells with global cooldown to be processed in spell::update
// as a result a spell that passed CheckCast and should be processed instantly may suffer from this delayed process
// the easiest bug to observe is LoS check in AddUnitTarget, even if spell passed the CheckCast LoS check the situation can change in spell::update
// because target could be relocated in the meantime, making the spell fly to the air (no targets can be registered, so no effects processed, nothing in combat log)
@@ -2731,7 +2731,7 @@ namespace Game.Spells
// if the spell allows the creature to turn while casting, then adjust server-side orientation to face the target now
// client-side orientation is handled by the client itself, as the cast target is targeted due to Creature::FocusTarget
if (m_caster.IsTypeId(TypeId.Unit) && !m_caster.HasFlag(UnitFields.Flags, UnitFlags.PlayerControlled))
if (m_caster.IsTypeId(TypeId.Unit) && !m_caster.HasUnitFlag(UnitFlags.PlayerControlled))
{
if (!m_spellInfo.HasAttribute(SpellAttr5.DontTurnDuringCast))
{
@@ -3203,7 +3203,7 @@ namespace Game.Spells
Unit charm = m_caster.GetCharm();
if (charm != null)
if (charm.IsTypeId(TypeId.Unit) && charm.ToCreature().HasUnitTypeMask(UnitTypeMask.Puppet)
&& charm.GetUInt32Value(UnitFields.CreatedBySpell) == m_spellInfo.Id)
&& charm.m_unitData.CreatedBySpell == m_spellInfo.Id)
((Puppet)charm).UnSummon();
}
@@ -3216,7 +3216,7 @@ namespace Game.Spells
if (m_caster.IsTypeId(TypeId.Unit) && m_caster.ToCreature().IsSummon())
{
// Unsummon statue
uint spell = m_caster.GetUInt32Value(UnitFields.CreatedBySpell);
uint spell = m_caster.m_unitData.CreatedBySpell;
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spell);
if (spellInfo != null && spellInfo.IconFileDataId == 134230)
{
@@ -3961,7 +3961,7 @@ namespace Game.Spells
{
if (time == 0)
{
m_caster.ClearDynamicValue(UnitDynamicFields.ChannelObjects);
m_caster.ClearChannelObjects();
m_caster.SetChannelSpellId(0);
m_caster.SetChannelSpellXSpellVisualId(0);
}
@@ -4357,7 +4357,7 @@ namespace Game.Spells
if (m_caster.IsTypeId(TypeId.Player))
{
//can cast triggered (by aura only?) spells while have this flag
if (!_triggeredCastFlags.HasAnyFlag(TriggerCastFlags.IgnoreCasterAurastate) && m_caster.ToPlayer().HasFlag(PlayerFields.Flags, PlayerFlags.AllowOnlyAbility))
if (!_triggeredCastFlags.HasAnyFlag(TriggerCastFlags.IgnoreCasterAurastate) && m_caster.ToPlayer().HasPlayerFlag(PlayerFlags.AllowOnlyAbility))
return SpellCastResult.SpellInProgress;
// check if we are using a potion in combat for the 2nd+ time. Cooldown is added only after caster gets out of combat
@@ -4374,7 +4374,7 @@ namespace Game.Spells
}
}
if (m_spellInfo.HasAttribute(SpellAttr7.IsCheatSpell) && !m_caster.HasFlag(UnitFields.Flags2, UnitFlags2.AllowCheatSpells))
if (m_spellInfo.HasAttribute(SpellAttr7.IsCheatSpell) && !m_caster.HasUnitFlag2(UnitFlags2.AllowCheatSpells))
{
m_customError = SpellCustomErrors.GmOnly;
return SpellCastResult.CustomError;
@@ -4785,10 +4785,10 @@ namespace Game.Spells
List<uint> glyphRequiredSpecs = Global.DB2Mgr.GetGlyphRequiredSpecs(glyphId);
if (!glyphRequiredSpecs.Empty())
{
if (caster.GetUInt32Value(PlayerFields.CurrentSpecId) == 0)
if (caster.GetPrimarySpecialization() == 0)
return SpellCastResult.GlyphNoSpec;
if (!glyphRequiredSpecs.Contains(caster.GetUInt32Value(PlayerFields.CurrentSpecId)))
if (!glyphRequiredSpecs.Contains(caster.GetPrimarySpecialization()))
return SpellCastResult.GlyphInvalidSpec;
}
@@ -4903,7 +4903,7 @@ namespace Game.Spells
if (!m_caster.IsTypeId(TypeId.Player) || m_targets.GetUnitTarget() == null || !m_targets.GetUnitTarget().IsTypeId(TypeId.Unit))
return SpellCastResult.BadTargets;
if (!Convert.ToBoolean(m_targets.GetUnitTarget().GetUInt32Value(UnitFields.Flags) & (uint)UnitFlags.Skinnable))
if (!m_targets.GetUnitTarget().HasUnitFlag(UnitFlags.Skinnable))
return SpellCastResult.TargetUnskinnable;
Creature creature = m_targets.GetUnitTarget().ToCreature();
@@ -5395,7 +5395,7 @@ namespace Game.Spells
// Check whether the cast should be prevented by any state you might have.
SpellCastResult result = SpellCastResult.SpellCastOk;
// Get unit state
UnitFlags unitflag = (UnitFlags)m_caster.GetUInt32Value(UnitFields.Flags);
UnitFlags unitflag = (UnitFlags)(byte)m_caster.m_unitData.Flags;
// this check should only be done when player does cast directly
// (ie not when it's called from a script) Breaks for example PlayerAI when charmed
@@ -5447,7 +5447,7 @@ namespace Game.Spells
result = SpellCastResult.Fleeing;
else if (unitflag.HasAnyFlag(UnitFlags.Confused) && !usableWhileConfused && !CheckSpellCancelsConfuse(ref param1))
result = SpellCastResult.Confused;
else if (m_caster.HasFlag(UnitFields.Flags2, UnitFlags2.NoActions) && m_spellInfo.PreventionType.HasAnyFlag(SpellPreventionType.NoActions))
else if (m_caster.HasUnitFlag2(UnitFlags2.NoActions) && m_spellInfo.PreventionType.HasAnyFlag(SpellPreventionType.NoActions))
result = SpellCastResult.NoActions;
// Attr must make flag drop spell totally immune from all effects
@@ -6993,13 +6993,13 @@ namespace Game.Spells
// Apply haste rating
if (gcd > 750 && ((m_spellInfo.StartRecoveryCategory == 133 && !isMeleeOrRangedSpell) || m_caster.HasAuraTypeWithAffectMask(AuraType.ModGlobalCooldownByHaste, m_spellInfo)))
{
gcd = (int)(gcd * m_caster.GetFloatValue(UnitFields.ModCastHaste));
gcd = (int)(gcd * m_caster.m_unitData.ModSpellHaste);
MathFunctions.RoundToInterval(ref gcd, 750, 1500);
}
if (gcd > 750 && m_caster.HasAuraTypeWithAffectMask(AuraType.ModGlobalCooldownByHasteRegen, m_spellInfo))
{
gcd = (int)(gcd * m_caster.GetFloatValue(UnitFields.ModHasteRegen));
gcd = (int)(gcd * m_caster.m_unitData.ModHasteRegen);
MathFunctions.RoundToInterval(ref gcd, 750, 1500);
}
}
@@ -7663,8 +7663,8 @@ namespace Game.Spells
else
{
if (!_caster.IsWithinBoundaryRadius(target.ToUnit()))
// ConeAngle > 0 -> select targets in front
// ConeAngle < 0 -> select targets in back
// ConeAngle > 0 . select targets in front
// ConeAngle < 0 . select targets in back
if (_caster.HasInArc(_coneAngle, target) != MathFunctions.fuzzyGe(_coneAngle, 0.0f))
return false;
}
+36 -35
View File
@@ -1132,7 +1132,7 @@ namespace Game.Spells
if (num_to_add != 0)
{
// create the new item and store it
Item pItem = player.StoreNewItem(dest, newitemid, true, ItemEnchantment.GenerateItemRandomPropertyId(newitemid), null, context, bonusListIds);
Item pItem = player.StoreNewItem(dest, newitemid, true, ItemEnchantmentManager.GenerateItemRandomBonusListId(newitemid), null, context, bonusListIds);
// was it successful? return error if not
if (pItem == null)
@@ -1143,7 +1143,7 @@ namespace Game.Spells
// set the "Crafted by ..." property of the item
if (pItem.GetTemplate().GetClass() != ItemClass.Consumable && pItem.GetTemplate().GetClass() != ItemClass.Quest && newitemid != 6265 && newitemid != 6948)
pItem.SetGuidValue(ItemFields.Creator, player.GetGUID());
pItem.SetCreator(player.GetGUID());
// send info to the client
player.SendNewItem(pItem, num_to_add, true, bgType == 0);
@@ -1522,7 +1522,7 @@ namespace Game.Spells
SendLoot(guid, LootType.Skinning);
else if (itemTarget != null)
{
itemTarget.SetFlag(ItemFields.Flags, ItemFieldFlags.Unlocked);
itemTarget.AddItemFlag(ItemFieldFlags.Unlocked);
itemTarget.SetState(ItemUpdateState.Changed, itemTarget.GetOwner());
}
@@ -1581,11 +1581,11 @@ namespace Game.Spells
for (var j = EnchantmentSlot.Perm; j <= EnchantmentSlot.Temp; ++j)
if (m_CastItem.GetEnchantmentId(j) != 0)
pNewItem.SetEnchantment(j, m_CastItem.GetEnchantmentId(j), m_CastItem.GetEnchantmentDuration(j), m_CastItem.GetEnchantmentCharges(j));
pNewItem.SetEnchantment(j, m_CastItem.GetEnchantmentId(j), m_CastItem.GetEnchantmentDuration(j), (uint)m_CastItem.GetEnchantmentCharges(j));
if (m_CastItem.GetUInt32Value(ItemFields.Durability) < m_CastItem.GetUInt32Value(ItemFields.MaxDurability))
if (m_CastItem.m_itemData.Durability < m_CastItem.m_itemData.MaxDurability)
{
double lossPercent = 1 - m_CastItem.GetUInt32Value(ItemFields.Durability) / (double)m_CastItem.GetUInt32Value(ItemFields.MaxDurability);
double lossPercent = 1 - m_CastItem.m_itemData.Durability / m_CastItem.m_itemData.MaxDurability;
player.DurabilityLoss(pNewItem, lossPercent);
}
@@ -1788,9 +1788,10 @@ namespace Game.Spells
return;
summon.SelectLevel(); // some summoned creaters have different from 1 DB data for level/hp
summon.SetUInt64Value(UnitFields.NpcFlags, (ulong)summon.GetCreatureTemplate().Npcflag);
summon.SetNpcFlags((NPCFlags)((int)summon.GetCreatureTemplate().Npcflag & 0xFFFFFFFF));
summon.SetNpcFlags2((NPCFlags2)((int)summon.GetCreatureTemplate().Npcflag >> 32));
summon.SetFlag(UnitFields.Flags, UnitFlags.ImmuneToPc | UnitFlags.ImmuneToNpc);
summon.AddUnitFlag(UnitFlags.ImmuneToPc | UnitFlags.ImmuneToNpc);
summon.GetAI().EnterEvadeMode();
break;
@@ -1817,8 +1818,8 @@ namespace Game.Spells
if (properties.Control == SummonCategory.Ally)
{
summon.SetOwnerGUID(m_originalCaster.GetGUID());
summon.SetFaction(m_originalCaster.getFaction());
summon.SetUInt32Value(UnitFields.CreatedBySpell, m_spellInfo.Id);
summon.SetFaction(m_originalCaster.GetFaction());
summon.SetCreatedBySpell(m_spellInfo.Id);
}
ExecuteLogEffectSummonObject(effIndex, summon);
@@ -1851,7 +1852,7 @@ namespace Game.Spells
uint faction = properties.Faction;
if (faction == 0)
faction = m_originalCaster.getFaction();
faction = m_originalCaster.GetFaction();
summon.SetFaction(faction);
break;
@@ -2383,13 +2384,13 @@ namespace Game.Spells
uint level = (creatureTarget.GetLevelForTarget(m_caster) < (m_caster.GetLevelForTarget(creatureTarget) - 5)) ? (m_caster.GetLevelForTarget(creatureTarget) - 5) : creatureTarget.GetLevelForTarget(m_caster);
// prepare visual effect for levelup
pet.SetUInt32Value(UnitFields.Level, level - 1);
pet.SetLevel(level - 1);
// add to world
pet.GetMap().AddToMap(pet.ToCreature());
// visual effect for levelup
pet.SetUInt32Value(UnitFields.Level, level);
pet.SetLevel(level);
// caster have pet now
m_caster.SetMinion(pet, true);
@@ -2469,7 +2470,7 @@ namespace Game.Spells
pet.SetReactState(ReactStates.Defensive);
}
pet.SetUInt32Value(UnitFields.CreatedBySpell, m_spellInfo.Id);
pet.SetCreatedBySpell(m_spellInfo.Id);
// generate new name for summon pet
string new_name = Global.ObjectMgr.GeneratePetName(petentry);
@@ -3515,8 +3516,8 @@ namespace Game.Spells
PhasingHandler.InheritPhaseShift(go, m_caster);
go.SetUInt32Value(GameObjectFields.Faction, m_caster.getFaction());
go.SetUInt32Value(GameObjectFields.Level, m_caster.getLevel() + 1);
go.SetFaction(m_caster.GetFaction());
go.SetLevel(m_caster.getLevel() + 1);
int duration = m_spellInfo.CalcDuration(m_caster);
go.SetRespawnTime(duration > 0 ? duration / Time.InMilliseconds : 0);
go.SetSpellId(m_spellInfo.Id);
@@ -3553,8 +3554,8 @@ namespace Game.Spells
duel2.isMounted = (GetSpellInfo().Id == 62875); // Mounted Duel
target.duel = duel2;
caster.SetGuidValue(PlayerFields.DuelArbiter, go.GetGUID());
target.SetGuidValue(PlayerFields.DuelArbiter, go.GetGUID());
caster.SetDuelArbiter(go.GetGUID());
target.SetDuelArbiter(go.GetGUID());
Global.ScriptMgr.OnPlayerDuelRequest(target, caster);
}
@@ -4066,8 +4067,8 @@ namespace Game.Spells
SkillType skill = creature.GetCreatureTemplate().GetRequiredLootSkill();
m_caster.ToPlayer().SendLoot(creature.GetGUID(), LootType.Skinning);
creature.RemoveFlag(UnitFields.Flags, UnitFlags.Skinnable);
creature.SetFlag(ObjectFields.DynamicFlags, UnitDynFlags.Lootable);
creature.RemoveUnitFlag(UnitFlags.Skinnable);
creature.AddDynamicFlag(UnitDynFlags.Lootable);
if (skill == SkillType.Skinning)
{
@@ -4396,8 +4397,8 @@ namespace Game.Spells
player.GetMap().CreatureRelocation(pet, x, y, z, player.GetOrientation());
pet.SetUInt32Value(ObjectFields.DynamicFlags, (uint)UnitDynFlags.HideModel);
pet.RemoveFlag(UnitFields.Flags, UnitFlags.Skinnable);
pet.SetDynamicFlags(UnitDynFlags.HideModel);
pet.RemoveUnitFlag(UnitFlags.Skinnable);
pet.setDeathState(DeathState.Alive);
pet.ClearUnitState(UnitState.AllState);
pet.SetHealth(pet.CountPctFromMaxHealth(damage));
@@ -4422,7 +4423,7 @@ namespace Game.Spells
Creature totem = m_caster.GetMap().GetCreature(m_caster.m_SummonSlot[slot]);
if (totem != null && totem.IsTotem())
{
uint spell_id = totem.GetUInt32Value(UnitFields.CreatedBySpell);
uint spell_id = totem.m_unitData.CreatedBySpell;
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spell_id);
if (spellInfo != null)
{
@@ -4577,10 +4578,10 @@ namespace Game.Spells
{
case GameObjectTypes.FishingNode:
{
go.SetFaction(m_caster.getFaction());
go.SetFaction(m_caster.GetFaction());
ObjectGuid bobberGuid = go.GetGUID();
// client requires fishing bobber guid in channel object slot 0 to be usable
m_caster.SetDynamicStructuredValue(UnitDynamicFields.ChannelObjects, 0, bobberGuid);
m_caster.SetChannelObject(0, bobberGuid);
m_caster.AddGameObject(go); // will removed at spell cancel
// end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(m_spellInfo))
@@ -4759,8 +4760,8 @@ namespace Game.Spells
continue;
// The charges / stack amounts don't count towards the total number of auras that can be dispelled.
// Ie: A dispel on a target with 5 stacks of Winters Chill and a Polymorph has 1 / (1 + 1) -> 50% chance to dispell
// Polymorph instead of 1 / (5 + 1) -> 16%.
// Ie: A dispel on a target with 5 stacks of Winters Chill and a Polymorph has 1 / (1 + 1) . 50% chance to dispell
// Polymorph instead of 1 / (5 + 1) . 16%.
bool dispelCharges = aura.GetSpellInfo().HasAttribute(SpellAttr7.DispelCharges);
byte charges = dispelCharges ? aura.GetCharges() : aura.GetStackAmount();
if (charges > 0)
@@ -5017,7 +5018,7 @@ namespace Game.Spells
return;
FactionTemplateRecord casterFaction = caster.GetFactionTemplateEntry();
FactionTemplateRecord targetFaction = CliDB.FactionTemplateStorage.LookupByKey(gameObjTarget.GetUInt32Value(GameObjectFields.Faction));
FactionTemplateRecord targetFaction = CliDB.FactionTemplateStorage.LookupByKey(gameObjTarget.GetFaction());
// Do not allow to damage GO's of friendly factions (ie: Wintergrasp Walls/Ulduar Storm Beacons)
if (targetFaction == null || (casterFaction != null && targetFaction != null && !casterFaction.IsFriendlyTo(targetFaction)))
gameObjTarget.ModifyHealth(-damage, caster, GetSpellInfo().Id);
@@ -5095,18 +5096,18 @@ namespace Game.Spells
((Guardian)summon).InitStatsForLevel(level);
if (properties != null && properties.Control == SummonCategory.Ally)
summon.SetFaction(caster.getFaction());
summon.SetFaction(caster.GetFaction());
if (summon.HasUnitTypeMask(UnitTypeMask.Minion) && m_targets.HasDst())
((Minion)summon).SetFollowAngle(m_caster.GetAngle(summon.GetPosition()));
if (summon.GetEntry() == 27893)
{
uint weapon = m_caster.GetUInt32Value(PlayerFields.VisibleItem + (EquipmentSlot.MainHand * 2));
if (weapon != 0)
VisibleItem weapon = m_caster.ToPlayer().m_playerData.VisibleItems[EquipmentSlot.MainHand];
if (weapon.ItemID != 0)
{
summon.SetDisplayId(11686);
summon.SetVirtualItem(0, weapon);
summon.SetVirtualItem(0, weapon.ItemID, weapon.ItemAppearanceModID, weapon.ItemVisual);
}
else
summon.SetDisplayId(1126);
@@ -5128,7 +5129,7 @@ namespace Game.Spells
!unitTarget.IsPet() || unitTarget.ToPet().getPetType() != PetType.Hunter)
return;
unitTarget.SetByteFlag(UnitFields.Bytes2, UnitBytes2Offsets.PetFlags, UnitPetFlags.CanBeRenamed);
unitTarget.AddPetFlag(UnitPetFlags.CanBeRenamed);
}
[SpellEffectHandler(SpellEffectName.PlayMusic)]
@@ -5557,7 +5558,7 @@ namespace Game.Spells
return;
Player plr = unitTarget.ToPlayer();
plr.SetFlag(PlayerFields.Flags, PlayerFlags.PetBattlesUnlocked);
plr.AddPlayerFlag(PlayerFlags.PetBattlesUnlocked);
plr.GetSession().GetBattlePetMgr().UnlockSlot(0);
}
@@ -5658,7 +5659,7 @@ namespace Game.Spells
itemTarget.SetState(ItemUpdateState.Changed, player);
itemTarget.SetModifier(ItemModifier.EnchantIllusionAllSpecs, (uint)effectInfo.MiscValue);
if (itemTarget.IsEquipped())
player.SetUInt16Value(PlayerFields.VisibleItem + 1 + (itemTarget.GetSlot() * 2), 1, itemTarget.GetVisibleItemVisual(player));
player.SetVisibleItemSlot(itemTarget.GetSlot(), itemTarget);
player.RemoveTradeableItem(itemTarget);
itemTarget.ClearSoulboundTradeable(player);
+7 -7
View File
@@ -351,7 +351,7 @@ namespace Game.Spells
// shoot spells used equipped item cooldown values already assigned in GetAttackTime(RANGED_ATTACK)
// prevent 0 cooldowns set by another way
if (cooldown <= 0 && categoryCooldown <= 0 && (categoryId == 76 || (spellInfo.IsAutoRepeatRangedSpell() && spellInfo.Id != 75)))
cooldown = (int)_owner.GetUInt32Value(UnitFields.RangedAttackTime);
cooldown = (int)(uint)_owner.m_unitData.RangedAttackRoundBaseTime;
// Now we have cooldown data (if found any), time to apply mods
Player modOwner = _owner.GetSpellModOwner();
@@ -366,14 +366,14 @@ namespace Game.Spells
if (_owner.HasAuraTypeWithAffectMask(AuraType.ModSpellCooldownByHaste, spellInfo))
{
cooldown = (int)(cooldown * _owner.GetFloatValue(UnitFields.ModCastHaste));
categoryCooldown = (int)(categoryCooldown * _owner.GetFloatValue(UnitFields.ModCastHaste));
cooldown = (int)(cooldown * _owner.m_unitData.ModSpellHaste);
categoryCooldown = (int)(categoryCooldown * _owner.m_unitData.ModSpellHaste);
}
if (_owner.HasAuraTypeWithAffectMask(AuraType.ModCooldownByHasteRegen, spellInfo))
{
cooldown = (int)(cooldown * _owner.GetFloatValue(UnitFields.ModHasteRegen));
categoryCooldown = (int)(categoryCooldown * _owner.GetFloatValue(UnitFields.ModHasteRegen));
cooldown = (int)(cooldown * _owner.m_unitData.ModHasteRegen);
categoryCooldown = (int)(categoryCooldown * _owner.m_unitData.ModHasteRegen);
}
int cooldownMod = _owner.GetTotalAuraModifier(AuraType.ModCooldown);
@@ -804,10 +804,10 @@ namespace Game.Spells
recoveryTimeF *= _owner.GetTotalAuraMultiplierByMiscValue(AuraType.ChargeRecoveryMultiplier, (int)chargeCategoryId);
if (_owner.HasAuraType(AuraType.ChargeRecoveryAffectedByHaste))
recoveryTimeF *= _owner.GetFloatValue(UnitFields.ModCastHaste);
recoveryTimeF *= _owner.m_unitData.ModSpellHaste;
if (_owner.HasAuraType(AuraType.ChargeRecoveryAffectedByHasteRegen))
recoveryTimeF *= _owner.GetFloatValue(UnitFields.ModHasteRegen);
recoveryTimeF *= _owner.m_unitData.ModHasteRegen;
return (int)Math.Floor(recoveryTimeF);
}
+37 -17
View File
@@ -83,6 +83,7 @@ namespace Game.Spells
IconFileDataId = _misc.SpellIconFileDataID;
ActiveIconFileDataId = _misc.ActiveIconFileDataID;
ContentTuningId = _misc.ContentTuningID;
}
if (visuals != null)
@@ -1307,8 +1308,9 @@ namespace Game.Spells
}
// if target is magnet (i.e Grounding Totem) the check is skipped
//if (target.IsMagnet())
//return true;
if (target.IsMagnet())
return true;
uint creatureType = target.GetCreatureTypeMask();
return TargetCreatureType == 0 || creatureType == 0 || Convert.ToBoolean(creatureType & TargetCreatureType);
@@ -2900,10 +2902,10 @@ namespace Game.Spells
float CalcPPMHasteMod(SpellProcsPerMinuteModRecord mod, Unit caster)
{
float haste = caster.GetFloatValue(UnitFields.ModHaste);
float rangedHaste = caster.GetFloatValue(UnitFields.ModRangedHaste);
float spellHaste = caster.GetFloatValue(UnitFields.ModCastHaste);
float regenHaste = caster.GetFloatValue(UnitFields.ModHasteRegen);
float haste = caster.m_unitData.ModHaste;
float rangedHaste = caster.m_unitData.ModRangedHaste;
float spellHaste = caster.m_unitData.ModSpellHaste;
float regenHaste = caster.m_unitData.ModHasteRegen;
switch (mod.Param)
{
@@ -2926,12 +2928,13 @@ namespace Game.Spells
float CalcPPMCritMod(SpellProcsPerMinuteModRecord mod, Unit caster)
{
if (!caster.IsTypeId(TypeId.Player))
Player player = caster.ToPlayer();
if (player == null)
return 0.0f;
float crit = caster.GetFloatValue(ActivePlayerFields.CritPercentage);
float rangedCrit = caster.GetFloatValue(ActivePlayerFields.RangedCritPercentage);
float spellCrit = caster.GetFloatValue(ActivePlayerFields.SpellCritPercentage1);
float crit = player.m_activePlayerData.CritPercentage;
float rangedCrit = player.m_activePlayerData.RangedCritPercentage;
float spellCrit = player.m_activePlayerData.SpellCritPercentage;
switch (mod.Param)
{
@@ -2955,8 +2958,8 @@ namespace Game.Spells
if (itemLevel == mod.Param)
return 0.0f;
float itemLevelPoints = ItemEnchantment.GetRandomPropertyPoints((uint)itemLevel, ItemQuality.Rare, InventoryType.Chest, 0);
float basePoints = ItemEnchantment.GetRandomPropertyPoints(mod.Param, ItemQuality.Rare, InventoryType.Chest, 0);
float itemLevelPoints = ItemEnchantmentManager.GetRandomPropertyPoints((uint)itemLevel, ItemQuality.Rare, InventoryType.Chest, 0);
float basePoints = ItemEnchantmentManager.GetRandomPropertyPoints(mod.Param, ItemQuality.Rare, InventoryType.Chest, 0);
if (itemLevelPoints == basePoints)
return 0.0f;
@@ -2993,7 +2996,7 @@ namespace Game.Spells
{
Player plrCaster = caster.ToPlayer();
if (plrCaster)
if (plrCaster.GetUInt32Value(PlayerFields.CurrentSpecId) == mod.Param)
if (plrCaster.GetPrimarySpecialization() == mod.Param)
ppm *= 1.0f + mod.Coeff;
break;
}
@@ -3705,6 +3708,7 @@ namespace Game.Spells
public uint[] TotemCategory = new uint[SpellConst.MaxTotems];
public uint IconFileDataId { get; set; }
public uint ActiveIconFileDataId { get; set; }
public uint ContentTuningId { get; set; }
public LocalizedString SpellName { get; set; }
public float ConeAngle { get; set; }
public float Width { get; set; }
@@ -3931,16 +3935,16 @@ namespace Game.Spells
if (_spellInfo.Scaling.ScalesFromItemLevel != 0)
effectiveItemLevel = _spellInfo.Scaling.ScalesFromItemLevel;
if (_spellInfo.Scaling._Class == -8)
if (_spellInfo.Scaling._Class == -8 || _spellInfo.Scaling._Class == -9)
{
RandPropPointsRecord randPropPoints = CliDB.RandPropPointsStorage.LookupByKey(effectiveItemLevel);
if (randPropPoints == null)
randPropPoints = CliDB.RandPropPointsStorage.LookupByKey(CliDB.RandPropPointsStorage.Count - 1);
tempValue = randPropPoints.DamageReplaceStat;
tempValue = _spellInfo.Scaling._Class == -8 ? randPropPoints.DamageReplaceStat : randPropPoints.DamageSecondary;
}
else
tempValue = ItemEnchantment.GetRandomPropertyPoints(effectiveItemLevel, ItemQuality.Rare, InventoryType.Chest, 0);
tempValue = ItemEnchantmentManager.GetRandomPropertyPoints(effectiveItemLevel, ItemQuality.Rare, InventoryType.Chest, 0);
}
else
tempValue = CliDB.GetSpellScalingColumnForClass(CliDB.SpellScalingGameTable.GetRow(level), _spellInfo.Scaling._Class);
@@ -3970,8 +3974,14 @@ namespace Game.Spells
stat = ExpectedStatType.CreatureAutoAttackDps;
// TODO - add expansion and content tuning id args?
uint contentTuningId = _spellInfo.ContentTuningId; // content tuning should be passed as arg, the one stored in SpellInfo is fallback
int expansion = -2;
ContentTuningRecord contentTuning = CliDB.ContentTuningStorage.LookupByKey(contentTuningId);
if (contentTuning != null)
expansion = contentTuning.ExpansionID;
uint level = caster ? caster.getLevel() : 1;
tempValue = Global.DB2Mgr.EvaluateExpectedStat(stat, level, -2, 0, Class.None) * BasePoints / 100.0f;
tempValue = Global.DB2Mgr.EvaluateExpectedStat(stat, level, expansion, 0, Class.None) * BasePoints / 100.0f;
}
return (int)Math.Round(tempValue);
@@ -4439,6 +4449,16 @@ namespace Game.Spells
new StaticData(SpellEffectImplicitTargetTypes.Explicit, SpellTargetObjectTypes.Item), // 259 SPELL_EFFECT_RESPEC_AZERITE_EMPOWERED_ITEM
new StaticData(SpellEffectImplicitTargetTypes.None, SpellTargetObjectTypes.None), // 260 SPELL_EFFECT_SUMMON_STABLED_PET
new StaticData(SpellEffectImplicitTargetTypes.Explicit, SpellTargetObjectTypes.Item), // 261 SPELL_EFFECT_SCRAP_ITEM
new StaticData(SpellEffectImplicitTargetTypes.None, SpellTargetObjectTypes.None), // 262 SPELL_EFFECT_262
new StaticData(SpellEffectImplicitTargetTypes.Explicit, SpellTargetObjectTypes.Item), // 263 SPELL_EFFECT_REPAIR_ITEM
new StaticData(SpellEffectImplicitTargetTypes.Explicit, SpellTargetObjectTypes.Item), // 264 SPELL_EFFECT_REMOVE_GEM
new StaticData(SpellEffectImplicitTargetTypes.None, SpellTargetObjectTypes.None), // 265 SPELL_EFFECT_LEARN_AZERITE_ESSENCE_POWER
new StaticData(SpellEffectImplicitTargetTypes.None, SpellTargetObjectTypes.None), // 266 SPELL_EFFECT_266
new StaticData(SpellEffectImplicitTargetTypes.None, SpellTargetObjectTypes.None), // 267 SPELL_EFFECT_267
new StaticData(SpellEffectImplicitTargetTypes.None, SpellTargetObjectTypes.None), // 268 SPELL_EFFECT_APPLY_MOUNT_EQUIPMENT
new StaticData(SpellEffectImplicitTargetTypes.None, SpellTargetObjectTypes.None), // 269 SPELL_EFFECT_UPGRADE_ITEM
new StaticData(SpellEffectImplicitTargetTypes.None, SpellTargetObjectTypes.None), // 270 SPELL_EFFECT_270
new StaticData(SpellEffectImplicitTargetTypes.None, SpellTargetObjectTypes.None), // 271 SPELL_EFFECT_APPLY_AREA_AURA_PARTY_NONRANDOM
};
#region Fields