Core/Misc: Fixes

This commit is contained in:
hondacrx
2018-05-11 11:40:29 -04:00
parent 6224c4f6be
commit 87d9adca9a
5 changed files with 43 additions and 39 deletions
+1 -1
View File
@@ -141,7 +141,7 @@ namespace Game.Chat
if (spellId == 0)
return false;
if (CheckSpellExistsAndIsValid(handler, spellId))
if (!CheckSpellExistsAndIsValid(handler, spellId))
return false;
target.CastSpell(target, spellId, false);
+4 -4
View File
@@ -53,7 +53,7 @@ namespace Game.Chat.Commands
[Command("casttime", RBACPermissions.CommandCheatCasttime)]
static bool HandleCasttimeCheat(StringArguments args, CommandHandler handler)
{
if (handler.GetSession() == null || handler.GetSession().GetPlayer())
if (handler.GetSession() == null || !handler.GetSession().GetPlayer())
return false;
string argstr = args.NextString();
@@ -80,7 +80,7 @@ namespace Game.Chat.Commands
[Command("cooldown", RBACPermissions.CommandCheatCooldown)]
static bool HandleCoolDownCheat(StringArguments args, CommandHandler handler)
{
if (handler.GetSession() == null || handler.GetSession().GetPlayer())
if (handler.GetSession() == null || !handler.GetSession().GetPlayer())
return false;
string argstr = args.NextString();
@@ -107,7 +107,7 @@ namespace Game.Chat.Commands
[Command("power", RBACPermissions.CommandCheatPower)]
static bool HandlePowerCheat(StringArguments args, CommandHandler handler)
{
if (handler.GetSession() == null || handler.GetSession().GetPlayer())
if (handler.GetSession() == null || !handler.GetSession().GetPlayer())
return false;
string argstr = args.NextString();
@@ -152,7 +152,7 @@ namespace Game.Chat.Commands
[Command("waterwalk", RBACPermissions.CommandCheatWaterwalk)]
static bool HandleWaterWalkCheat(StringArguments args, CommandHandler handler)
{
if (handler.GetSession() == null || handler.GetSession().GetPlayer())
if (handler.GetSession() == null || !handler.GetSession().GetPlayer())
return false;
string argstr = args.NextString();
+2
View File
@@ -31,6 +31,7 @@ namespace Game
GetPlayer().GetSceneMgr().OnSceneTrigger(sceneTriggerEvent.SceneInstanceID, sceneTriggerEvent._Event);
}
[WorldPacketHandler(ClientOpcodes.ScenePlaybackComplete)]
void HandleScenePlaybackComplete(ScenePlaybackComplete scenePlaybackComplete)
{
Log.outDebug(LogFilter.Scenes, "HandleScenePlaybackComplete: SceneInstanceID: {0}", scenePlaybackComplete.SceneInstanceID);
@@ -38,6 +39,7 @@ namespace Game
GetPlayer().GetSceneMgr().OnSceneComplete(scenePlaybackComplete.SceneInstanceID);
}
[WorldPacketHandler(ClientOpcodes.ScenePlaybackCanceled)]
void HandleScenePlaybackCanceled(ScenePlaybackCanceled scenePlaybackCanceled)
{
Log.outDebug(LogFilter.Scenes, "HandleScenePlaybackCanceled: SceneInstanceID: {0}", scenePlaybackCanceled.SceneInstanceID);
+5 -3
View File
@@ -97,7 +97,7 @@ namespace Game.Spells
// Patch 1.2 notes: Spell Reflection no longer reflects abilities
m_canReflect = m_spellInfo.DmgClass == SpellDmgClass.Magic && !m_spellInfo.HasAttribute(SpellAttr0.Ability)
&& !m_spellInfo.HasAttribute(SpellAttr1.CantBeReflected) && !m_spellInfo.HasAttribute(SpellAttr0.UnaffectedByInvulnerability)
&& !m_spellInfo.IsPassive() && !m_spellInfo.IsPositive();
&& !m_spellInfo.IsPassive();
CleanupTargetList();
@@ -1657,7 +1657,7 @@ namespace Game.Spells
// Calculate hit result
if (m_originalCaster != null)
{
targetInfo.missCondition = m_originalCaster.SpellHitResult(target, m_spellInfo, m_canReflect);
targetInfo.missCondition = m_originalCaster.SpellHitResult(target, m_spellInfo, m_canReflect && !(m_spellInfo.IsPositive() && m_caster.IsFriendlyTo(target)));
if (m_skipCheck && targetInfo.missCondition != SpellMissInfo.Immune)
targetInfo.missCondition = SpellMissInfo.None;
}
@@ -7495,14 +7495,16 @@ namespace Game.Spells
{
public ObjectGuid targetGUID;
public ulong timeDelay;
public int damage;
public SpellMissInfo missCondition;
public SpellMissInfo reflectResult;
public uint effectMask;
public bool processed;
public bool alive;
public bool crit;
public bool scaleAura;
public int damage;
}
public class GOTargetInfo
+31 -31
View File
@@ -1920,7 +1920,7 @@ namespace Game.Spells
for (int count = 0; count < damage && remaining > 0;)
{
// Random select buff for dispel
var dispelableAura = dispelList[RandomHelper.IRand(0, dispelList.Count - 1)];
var dispelableAura = dispelList[RandomHelper.IRand(0, remaining - 1)];
if (dispelableAura.RollDispel())
{
@@ -4708,7 +4708,7 @@ namespace Game.Spells
if (unitTarget == null || unitTarget == m_caster) // can't steal from self
return;
List<Tuple<Aura, byte>> steal_list = new List<Tuple<Aura, byte>>();
List<DispelableAura> stealList = new List<DispelableAura>();
// Create dispel mask by dispel type
uint dispelMask = SpellInfo.GetDispelMask((DispelType)effectInfo.MiscValue);
@@ -4726,21 +4726,29 @@ namespace Game.Spells
if (!aurApp.IsPositive() || aura.IsPassive() || aura.GetSpellInfo().HasAttribute(SpellAttr4.NotStealable))
continue;
// 2.4.3 Patch Notes: "Dispel effects will no longer attempt to remove effects that have 100% dispel resistance."
int chance = aura.CalcDispelChance(unitTarget, !unitTarget.IsFriendlyTo(m_caster));
if (chance == 0)
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)
steal_list.Add(Tuple.Create(aura, charges));
stealList.Add(new DispelableAura(aura, chance, charges));
}
}
if (steal_list.Empty())
if (stealList.Empty())
return;
int remaining = stealList.Count;
// Ok if exist some buffs for dispel try dispel it
List<KeyValuePair<uint, ObjectGuid>> success_list = new List<KeyValuePair<uint, ObjectGuid>>();
uint failCount = 0;
List<Tuple<uint, ObjectGuid>> successList = new List<Tuple<uint, ObjectGuid>>();
DispelFailed dispelFailed = new DispelFailed();
dispelFailed.CasterGUID = m_caster.GetGUID();
@@ -4748,40 +4756,32 @@ namespace Game.Spells
dispelFailed.SpellID = m_spellInfo.Id;
// dispel N = damage buffs (or while exist buffs for dispel)
for (int count = 0; count < damage && !steal_list.Empty();)
for (int count = 0; count < damage && remaining > 0;)
{
// Random select buff for dispel
var pair = steal_list[RandomHelper.IRand(0, steal_list.Count - 1)];
var dispelableAura = stealList[RandomHelper.IRand(0, remaining - 1)];
int chance = pair.Item1.CalcDispelChance(unitTarget, !unitTarget.IsFriendlyTo(m_caster));
// 2.4.3 Patch Notes: "Dispel effects will no longer attempt to remove effects that have 100% dispel resistance."
if (chance == 0)
if (dispelableAura.RollDispel())
{
steal_list.Remove(pair);
continue;
successList.Add(Tuple.Create(dispelableAura.GetAura().GetId(), dispelableAura.GetAura().GetCasterGUID()));
if (!dispelableAura.DecrementCharge())
{
--remaining;
stealList[remaining] = dispelableAura;
}
}
else
{
if (RandomHelper.randChance(chance))
{
success_list.Add(new KeyValuePair<uint, ObjectGuid>(pair.Item1.GetId(), pair.Item1.GetCasterGUID()));
var temp = pair.Item2;
--temp;
pair = Tuple.Create(pair.Item1, temp);
if (pair.Item2 <= 0)
steal_list.Remove(pair);
}
else
dispelFailed.FailedSpells.Add(pair.Item1.GetId());
++count;
++failCount;
dispelFailed.FailedSpells.Add(dispelableAura.GetAura().GetId());
}
++count;
}
if (!dispelFailed.FailedSpells.Empty())
m_caster.SendMessageToSet(dispelFailed, true);
if (success_list.Empty())
if (successList.Empty())
return;
SpellDispellLog spellDispellLog = new SpellDispellLog();
@@ -4792,15 +4792,15 @@ namespace Game.Spells
spellDispellLog.CasterGUID = m_caster.GetGUID();
spellDispellLog.DispelledBySpellID = m_spellInfo.Id;
foreach (var dispell in success_list)
foreach (var dispell in successList)
{
var dispellData = new SpellDispellData();
dispellData.SpellID = dispell.Key;
dispellData.SpellID = dispell.Item1;
dispellData.Harmful = false; // TODO: use me
//dispellData.Rolled = none; // TODO: use me
//dispellData.Needed = none; // TODO: use me
unitTarget.RemoveAurasDueToSpellBySteal(dispell.Key, dispell.Value, m_caster);
unitTarget.RemoveAurasDueToSpellBySteal(dispell.Item1, dispell.Item2, m_caster);
spellDispellLog.DispellData.Add(dispellData);
}