From 2fc4e3e71fcc0ca88aa73bc16284672c8d0aece5 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Tue, 19 May 2020 14:49:37 -0400 Subject: [PATCH] TC Ports: Core/Misc: 522f537048 followup (https://github.com/TrinityCore/TrinityCore/commit/9a57e95f102a9d35ac8416d02e24c0dddbc755ed) Core/CreatureAI: b6b0353bff followup (https://github.com/TrinityCore/TrinityCore/commit/5d411e0b21b1f1a4653d274d9b1cc7fef17f232b) Core/Spell: move creature focus (https://github.com/TrinityCore/TrinityCore/commit/8c12f36915b2fddd48a5e4c9244c2b0498a64ae9) Core/Unit: 2170541a51 followup (https://github.com/TrinityCore/TrinityCore/commit/2d4549023a6655d19671f7f7e6b4f7c9b71ae632) Core/Misc: cleanup SetInFront uses (https://github.com/TrinityCore/TrinityCore/commit/104e745edfb89f95e34cad7840eae0b6e183bf94) Core/Unit: 229444b74a follow-up (https://github.com/TrinityCore/TrinityCore/commit/6a96addadd5dea633b3066b8d0427302ba514364) Core/Unit: revert 3ea46e57af (https://github.com/TrinityCore/TrinityCore/commit/a46286a803b41b375ed9352858c742626bb85720) Core/Scripts: remove OnDummyEffect hook/sOnDummyEffect ai hook (https://github.com/TrinityCore/TrinityCore/commit/1929ca3aa14f6cd83ea3ac9d7e8c0e2ed0e87a26) Core/Entities: moved PetAura handling to Player where it belongs (https://github.com/TrinityCore/TrinityCore/commit/4f6d38fe9d5c07e6e8eb88e517af71b6cdc4f9f8) Core/Spells: Fixed Chilled to the Bone (https://github.com/TrinityCore/TrinityCore/commit/08635c740a7ee04da9b0cd5045075a9432121b06) Core/Spell: implement pvp trinket immunity against Judgement of Justice (https://github.com/TrinityCore/TrinityCore/commit/05ba662d5daaa3428cc01cdaa3794bf5a073ef17) --- Source/Framework/Constants/SmartAIConst.cs | 3 +- Source/Game/AI/CoreAI/CreatureAI.cs | 8 ++--- Source/Game/AI/CoreAI/TotemAI.cs | 3 +- Source/Game/AI/CoreAI/UnitAI.cs | 1 - Source/Game/AI/SmartScripts/SmartAI.cs | 6 ---- Source/Game/AI/SmartScripts/SmartAIManager.cs | 13 ++------ Source/Game/AI/SmartScripts/SmartScript.cs | 7 ---- Source/Game/Entities/Creature/Creature.cs | 33 +++++++++++++++---- Source/Game/Entities/Pet.cs | 11 ++----- Source/Game/Entities/Player/Player.Fields.cs | 1 + Source/Game/Entities/Player/Player.cs | 18 ++++++++++ Source/Game/Entities/Unit/Unit.Combat.cs | 11 ++++--- Source/Game/Entities/Unit/Unit.Fields.cs | 1 - Source/Game/Entities/Unit/Unit.Movement.cs | 9 ++--- Source/Game/Entities/Unit/Unit.Pets.cs | 22 ------------- Source/Game/Entities/Unit/Unit.Spells.cs | 15 ++++----- Source/Game/Handlers/PetHandler.cs | 6 ++-- Source/Game/Loot/LootItemStorage.cs | 26 +++++++++++---- Source/Game/Scripting/CoreScripts.cs | 9 ----- Source/Game/Scripting/ScriptManager.cs | 21 ------------ Source/Game/Spells/Auras/AuraEffect.cs | 17 ++++------ Source/Game/Spells/Spell.cs | 23 ++++++------- Source/Game/Spells/SpellEffects.cs | 26 ++++++--------- Source/Game/Spells/SpellInfo.cs | 7 ++-- Source/Game/Spells/SpellManager.cs | 4 +++ .../ForgeOfSouls/BossDevourerOfSouls.cs | 2 +- Source/Scripts/World/NpcSpecial.cs | 2 +- 27 files changed, 139 insertions(+), 166 deletions(-) diff --git a/Source/Framework/Constants/SmartAIConst.cs b/Source/Framework/Constants/SmartAIConst.cs index 4295926ca..6c9b9e669 100644 --- a/Source/Framework/Constants/SmartAIConst.cs +++ b/Source/Framework/Constants/SmartAIConst.cs @@ -35,6 +35,7 @@ namespace Framework.Constants public struct SmartScriptTypeMaskId { + public const uint None = 0; public const uint Creature = 1; public const uint Gameobject = 2; public const uint Areatrigger = 4; @@ -203,7 +204,7 @@ namespace Framework.Constants JustCreated = 63, // None GossipHello = 64, // noReportUse (for GOs) FollowCompleted = 65, // None - DummyEffect = 66, // Spellid, Effectindex + Unused66 = 66, IsBehindTarget = 67, // Cooldownmin, Cooldownmax GameEventStart = 68, // GameEvent.Entry GameEventEnd = 69, // GameEvent.Entry diff --git a/Source/Game/AI/CoreAI/CreatureAI.cs b/Source/Game/AI/CoreAI/CreatureAI.cs index 820659114..55d95a076 100644 --- a/Source/Game/AI/CoreAI/CreatureAI.cs +++ b/Source/Game/AI/CoreAI/CreatureAI.cs @@ -155,9 +155,9 @@ namespace Game.AI me.SendAIReaction(AiReaction.Alert); // Face the unit (stealthed player) and set distracted state for 5 seconds - me.SetFacingTo(me.GetAngle(who.GetPositionX(), who.GetPositionY()), true); - me.StopMoving(); me.GetMotionMaster().MoveDistract(5 * Time.InMilliseconds); + me.StopMoving(); + me.SetFacingTo(me.GetAngle(who)); } // Called for reaction at stopping attack at no attackers or targets @@ -193,7 +193,7 @@ namespace Game.AI void SetGazeOn(Unit target) { - if (me.IsValidAttackTarget(target)) + if (me.IsValidAttackTarget(target) && target != me.GetVictim()) { if (!me.IsFocusing(null, true)) AttackStart(target); @@ -217,7 +217,7 @@ namespace Game.AI Unit victim = me.SelectVictim(); if (victim != null) { - if (!me.IsFocusing(null, true)) + if (!me.IsFocusing(null, true) && victim != me.GetVictim()) AttackStart(victim); } diff --git a/Source/Game/AI/CoreAI/TotemAI.cs b/Source/Game/AI/CoreAI/TotemAI.cs index 0a68843f3..787515ecf 100644 --- a/Source/Game/AI/CoreAI/TotemAI.cs +++ b/Source/Game/AI/CoreAI/TotemAI.cs @@ -70,8 +70,7 @@ namespace Game.AI i_victimGuid = victim.GetGUID(); // attack - me.SetInFront(victim); // client change orientation by self - me.CastSpell(victim, me.ToTotem().GetSpell(), false); + me.CastSpell(victim, me.ToTotem().GetSpell()); } else i_victimGuid.Clear(); diff --git a/Source/Game/AI/CoreAI/UnitAI.cs b/Source/Game/AI/CoreAI/UnitAI.cs index cfd49fa9e..21abc644f 100644 --- a/Source/Game/AI/CoreAI/UnitAI.cs +++ b/Source/Game/AI/CoreAI/UnitAI.cs @@ -385,7 +385,6 @@ namespace Game.AI public virtual void QuestSelect(Player player, Quest quest) { } public virtual void QuestComplete(Player player, Quest quest) { } public virtual void QuestReward(Player player, Quest quest, uint opt) { } - public virtual bool OnDummyEffect(Unit caster, uint spellId, int effIndex) { return false; } public virtual void OnGameEvent(bool start, ushort eventId) { } public static AISpellInfoType[] AISpellInfo; diff --git a/Source/Game/AI/SmartScripts/SmartAI.cs b/Source/Game/AI/SmartScripts/SmartAI.cs index 15db5d788..bf317294a 100644 --- a/Source/Game/AI/SmartScripts/SmartAI.cs +++ b/Source/Game/AI/SmartScripts/SmartAI.cs @@ -811,12 +811,6 @@ namespace Game.AI GetScript().ProcessEventsFor(SmartEvents.RewardQuest, player, quest.Id, opt); } - public override bool OnDummyEffect(Unit caster, uint spellId, int effIndex) - { - GetScript().ProcessEventsFor(SmartEvents.DummyEffect, caster, spellId, (uint)effIndex); - return true; - } - public void SetCombatMove(bool on) { if (mCanCombatMove == on) diff --git a/Source/Game/AI/SmartScripts/SmartAIManager.cs b/Source/Game/AI/SmartScripts/SmartAIManager.cs index 069d2da28..c761e47ef 100644 --- a/Source/Game/AI/SmartScripts/SmartAIManager.cs +++ b/Source/Game/AI/SmartScripts/SmartAIManager.cs @@ -641,15 +641,6 @@ namespace Game.AI return false; break; } - case SmartEvents.DummyEffect: - { - if (!IsSpellValid(e, e.Event.dummy.spell)) - return false; - - if (e.Event.dummy.effIndex > 2) - return false; - break; - } case SmartEvents.IsBehindTarget: { if (!IsMinMaxValid(e, e.Event.behindTarget.cooldownMin, e.Event.behindTarget.cooldownMax)) @@ -1579,7 +1570,7 @@ namespace Game.AI { { SmartEvents.UpdateIc, SmartScriptTypeMaskId.Creature + SmartScriptTypeMaskId.TimedActionlist }, { SmartEvents.UpdateOoc, SmartScriptTypeMaskId.Creature + SmartScriptTypeMaskId.Gameobject + SmartScriptTypeMaskId.Instance }, - { SmartEvents.HealthPct, SmartScriptTypeMaskId.Creature }, + { SmartEvents.HealthPct, SmartScriptTypeMaskId.Creature }, { SmartEvents.ManaPct, SmartScriptTypeMaskId.Creature }, { SmartEvents.Aggro, SmartScriptTypeMaskId.Creature }, { SmartEvents.Kill, SmartScriptTypeMaskId.Creature }, @@ -1643,7 +1634,7 @@ namespace Game.AI { SmartEvents.JustCreated, SmartScriptTypeMaskId.Creature + SmartScriptTypeMaskId.Gameobject }, { SmartEvents.GossipHello, SmartScriptTypeMaskId.Creature + SmartScriptTypeMaskId.Gameobject }, { SmartEvents.FollowCompleted, SmartScriptTypeMaskId.Creature }, - { SmartEvents.DummyEffect, SmartScriptTypeMaskId.Spell }, + { SmartEvents.Unused66, SmartScriptTypeMaskId.None }, { SmartEvents.IsBehindTarget, SmartScriptTypeMaskId.Creature }, { SmartEvents.GameEventStart, SmartScriptTypeMaskId.Creature + SmartScriptTypeMaskId.Gameobject }, { SmartEvents.GameEventEnd, SmartScriptTypeMaskId.Creature + SmartScriptTypeMaskId.Gameobject }, diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index 3da6f798f..def1a81e5 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -3624,13 +3624,6 @@ namespace Game.AI ProcessAction(e, unit, var0, var1); break; } - case SmartEvents.DummyEffect: - { - if (e.Event.dummy.spell != var0 || e.Event.dummy.effIndex != var1) - return; - ProcessAction(e, unit, var0, var1); - break; - } case SmartEvents.GameEventStart: case SmartEvents.GameEventEnd: { diff --git a/Source/Game/Entities/Creature/Creature.cs b/Source/Game/Entities/Creature/Creature.cs index fd86e9d57..6497b2232 100644 --- a/Source/Game/Entities/Creature/Creature.cs +++ b/Source/Game/Entities/Creature/Creature.cs @@ -930,6 +930,27 @@ namespace Game.Entities && !GetCreatureTemplate().FlagsExtra.HasAnyFlag(CreatureFlagsExtra.NoXpAtKill); } + public override bool IsMovementPreventedByCasting() + { + // first check if currently a movement allowed channel is active and we're not casting + Spell spell = GetCurrentSpell(CurrentSpellTypes.Channeled); + if (spell != null) + { + if (spell.GetState() != SpellState.Finished && spell.IsChannelActive()) + if (spell.GetSpellInfo().IsMoveAllowedChannel()) + if (HasUnitState(UnitState.Casting)) + return true; + } + + if (IsFocusing(null, true)) + return true; + + if (HasUnitState(UnitState.Casting)) + return true; + + return false; + } + public void StartPickPocketRefillTimer() { _pickpocketLootRestore = Time.UnixTime + WorldConfig.GetIntValue(WorldCfg.CreaturePickpocketRefill); @@ -2768,19 +2789,19 @@ namespace Game.Entities bool canTurnDuringCast = !focusSpell.GetSpellInfo().HasAttribute(SpellAttr5.DontTurnDuringCast); // Face the target - we need to do this before the unit state is modified for no-turn spells if (target) - SetFacingToObject(target); + SetFacingToObject(target, false); else if (!canTurnDuringCast) { Unit victim = GetVictim(); if (victim) - SetFacingToObject(victim); // ensure server-side orientation is correct at beginning of cast + SetFacingToObject(victim, false); // ensure server-side orientation is correct at beginning of cast } if (!canTurnDuringCast) AddUnitState(UnitState.CannotTurn); } - public override bool IsFocusing(Spell focusSpell = null, bool withDelay = false) + public bool IsFocusing(Spell focusSpell = null, bool withDelay = false) { if (!IsAlive()) // dead creatures cannot focus { @@ -2821,10 +2842,10 @@ namespace Game.Entities { WorldObject objTarget = Global.ObjAccessor.GetWorldObject(this, m_suppressedTarget); if (objTarget) - SetFacingToObject(objTarget); + SetFacingToObject(objTarget, false); } else - SetFacingTo(m_suppressedOrientation); + SetFacingTo(m_suppressedOrientation, false); } else // tell the creature that it should reacquire its actual target after the delay expires (this is handled in ::Update) @@ -3156,7 +3177,7 @@ namespace Game.Entities if (target != null && _IsTargetAcceptable(target) && CanCreatureAttack(target)) { - if (!IsFocusing()) + if (!IsFocusing(null, true)) SetInFront(target); return target; } diff --git a/Source/Game/Entities/Pet.cs b/Source/Game/Entities/Pet.cs index 76372c4c1..e055ccd66 100644 --- a/Source/Game/Entities/Pet.cs +++ b/Source/Game/Entities/Pet.cs @@ -1386,11 +1386,9 @@ namespace Game.Entities void CastPetAuras(bool current) { - Unit owner = GetOwner(); - if (!owner || !owner.IsTypeId(TypeId.Player)) - return; + Player owner = GetOwner(); - if (!IsPermanentPetFor(owner.ToPlayer())) + if (!IsPermanentPetFor(owner)) return; foreach (var pa in owner.m_petAuras) @@ -1419,10 +1417,7 @@ namespace Game.Entities bool IsPetAura(Aura aura) { - Unit owner = GetOwner(); - - if (!owner || !owner.IsTypeId(TypeId.Player)) - return false; + Player owner = GetOwner(); // if the owner has that pet aura, return true foreach (var petAura in owner.m_petAuras) diff --git a/Source/Game/Entities/Player/Player.Fields.cs b/Source/Game/Entities/Player/Player.Fields.cs index c0b9b84f4..f8e8e6fa7 100644 --- a/Source/Game/Entities/Player/Player.Fields.cs +++ b/Source/Game/Entities/Player/Player.Fields.cs @@ -129,6 +129,7 @@ namespace Game.Entities public bool m_mailsUpdated; //Pets + public List m_petAuras = new List(); public uint m_stableSlots; uint m_temporaryUnsummonedPetNumber; uint m_lastpetnumber; diff --git a/Source/Game/Entities/Player/Player.cs b/Source/Game/Entities/Player/Player.cs index 986fc835d..b55f1819c 100644 --- a/Source/Game/Entities/Player/Player.cs +++ b/Source/Game/Entities/Player/Player.cs @@ -4995,6 +4995,24 @@ namespace Game.Entities } } + public void AddPetAura(PetAura petSpell) + { + m_petAuras.Add(petSpell); + + Pet pet = GetPet(); + if (pet != null) + pet.CastPetAura(petSpell); + } + + public void RemovePetAura(PetAura petSpell) + { + m_petAuras.Remove(petSpell); + + Pet pet = GetPet(); + if (pet != null) + pet.RemoveAurasDueToSpell(petSpell.GetAura(pet.GetEntry())); + } + public bool InArena() { Battleground bg = GetBattleground(); diff --git a/Source/Game/Entities/Unit/Unit.Combat.cs b/Source/Game/Entities/Unit/Unit.Combat.cs index 27da6da11..03f67cfa1 100644 --- a/Source/Game/Entities/Unit/Unit.Combat.cs +++ b/Source/Game/Entities/Unit/Unit.Combat.cs @@ -184,7 +184,9 @@ namespace Game.Entities if (target && target == taunter) return; - SetInFront(taunter); + if (!IsFocusing(null, true)) + SetInFront(taunter); + if (creature.IsAIEnabled) creature.GetAI().AttackStart(taunter); } @@ -219,7 +221,8 @@ namespace Game.Entities if (target && target != taunter) { - SetInFront(target); + if (!IsFocusing(null, true)) + SetInFront(target); if (creature.IsAIEnabled) creature.GetAI().AttackStart(target); } @@ -597,7 +600,7 @@ namespace Game.Entities return; if (IsTypeId(TypeId.Unit) && !HasUnitFlag(UnitFlags.PlayerControlled)) - SetFacingToObject(victim); // update client side facing to face the target (prevents visual glitches when casting untargeted spells) + SetFacingToObject(victim, false); // update client side facing to face the target (prevents visual glitches when casting untargeted spells) // melee attack spell casted at main hand attack only - no normal melee dmg dealt if (attType == WeaponAttackType.BaseAttack && GetCurrentSpell(CurrentSpellTypes.Melee) != null && !extra) @@ -678,7 +681,7 @@ namespace Game.Entities return; // ignore ranged case if (IsTypeId(TypeId.Unit) && !HasUnitFlag(UnitFlags.PlayerControlled)) - SetFacingToObject(victim); // update client side facing to face the target (prevents visual glitches when casting untargeted spells) + SetFacingToObject(victim, false); // update client side facing to face the target (prevents visual glitches when casting untargeted spells) CalcDamageInfo damageInfo = new CalcDamageInfo(); damageInfo.attacker = this; diff --git a/Source/Game/Entities/Unit/Unit.Fields.cs b/Source/Game/Entities/Unit/Unit.Fields.cs index 48f798bc9..0bc13da3f 100644 --- a/Source/Game/Entities/Unit/Unit.Fields.cs +++ b/Source/Game/Entities/Unit/Unit.Fields.cs @@ -92,7 +92,6 @@ namespace Game.Entities SpellHistory _spellHistory; //Auras - public List m_petAuras = new List(); List AuraEffectList = new List(); MultiMap m_modAuras = new MultiMap(); List m_removedAuras = new List(); diff --git a/Source/Game/Entities/Unit/Unit.Movement.cs b/Source/Game/Entities/Unit/Unit.Movement.cs index 49a964853..694a1c52d 100644 --- a/Source/Game/Entities/Unit/Unit.Movement.cs +++ b/Source/Game/Entities/Unit/Unit.Movement.cs @@ -164,9 +164,10 @@ namespace Game.Entities Orientation = GetAngle(target.GetPosition()); } - public void SetFacingTo(float ori, bool force = false) + public void SetFacingTo(float ori, bool force = true) { - if (!force && !IsStopped()) + // do not face when already moving + if (!force && (!IsStopped() || !MoveSpline.Finalized())) return; MoveSplineInit init = new MoveSplineInit(this); @@ -175,10 +176,10 @@ namespace Game.Entities init.Launch(); } - public void SetFacingToObject(WorldObject obj, bool force = false) + public void SetFacingToObject(WorldObject obj, bool force = true) { // do not face when already moving - if (!force && !IsStopped()) + if (!force && (!IsStopped() || !MoveSpline.Finalized())) return; // @todo figure out under what conditions creature will move towards object instead of facing it where it currently is. diff --git a/Source/Game/Entities/Unit/Unit.Pets.cs b/Source/Game/Entities/Unit/Unit.Pets.cs index add0c11d7..933320a54 100644 --- a/Source/Game/Entities/Unit/Unit.Pets.cs +++ b/Source/Game/Entities/Unit/Unit.Pets.cs @@ -26,28 +26,6 @@ namespace Game.Entities { public partial class Unit { - public void AddPetAura(PetAura petSpell) - { - if (!IsTypeId(TypeId.Player)) - return; - - m_petAuras.Add(petSpell); - Pet pet = ToPlayer().GetPet(); - if (pet) - pet.CastPetAura(petSpell); - } - - public void RemovePetAura(PetAura petSpell) - { - if (!IsTypeId(TypeId.Player)) - return; - - m_petAuras.Remove(petSpell); - Pet pet = ToPlayer().GetPet(); - if (pet) - pet.RemoveAurasDueToSpell(petSpell.GetAura(pet.GetEntry())); - } - public CharmInfo GetCharmInfo() { return m_charmInfo; } public CharmInfo InitCharmInfo() diff --git a/Source/Game/Entities/Unit/Unit.Spells.cs b/Source/Game/Entities/Unit/Unit.Spells.cs index 842db0116..32e24ea22 100644 --- a/Source/Game/Entities/Unit/Unit.Spells.cs +++ b/Source/Game/Entities/Unit/Unit.Spells.cs @@ -30,11 +30,6 @@ namespace Game.Entities { public virtual bool HasSpell(uint spellId) { return false; } - public virtual bool IsFocusing(Spell focusSpell = null, bool withDelay = false) - { - return false; - } - public void SetInstantCast(bool set) { _instantCast = set; } public bool CanInstantCast() { return _instantCast; } @@ -1388,7 +1383,12 @@ namespace Game.Entities return 0; } - public bool IsMovementPreventedByCasting() + public virtual bool IsFocusing(Spell focusSpell = null, bool withDelay = false) { return false; } + + /// + /// Check if our current channel spell has attribute SPELL_ATTR5_CAN_CHANNEL_WHEN_MOVING + /// + public virtual bool IsMovementPreventedByCasting() { // can always move when not casting if (!HasUnitState(UnitState.Casting)) @@ -1401,9 +1401,6 @@ namespace Game.Entities if (spell.GetSpellInfo().IsMoveAllowedChannel()) return false; - if (IsFocusing(null, true)) - return false; - // prohibit movement for all other spell casts return true; } diff --git a/Source/Game/Handlers/PetHandler.cs b/Source/Game/Handlers/PetHandler.cs index bf9821da8..1e759e02b 100644 --- a/Source/Game/Handlers/PetHandler.cs +++ b/Source/Game/Handlers/PetHandler.cs @@ -322,14 +322,16 @@ namespace Game Unit unit_target2 = spell.m_targets.GetUnitTarget(); if (unit_target) { - pet.SetInFront(unit_target); + if (!pet.IsFocusing()) + pet.SetInFront(unit_target); Player player = unit_target.ToPlayer(); if (player) pet.SendUpdateToPlayer(player); } else if (unit_target2) { - pet.SetInFront(unit_target2); + if (!pet.IsFocusing()) + pet.SetInFront(unit_target2); Player player = unit_target2.ToPlayer(); if (player) pet.SendUpdateToPlayer(player); diff --git a/Source/Game/Loot/LootItemStorage.cs b/Source/Game/Loot/LootItemStorage.cs index c80a1cbaf..b914a459a 100644 --- a/Source/Game/Loot/LootItemStorage.cs +++ b/Source/Game/Loot/LootItemStorage.cs @@ -1,13 +1,27 @@ -using Framework.Constants; +/* + * Copyright (C) 2012-2020 CypherCore + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +using Framework.Collections; +using Framework.Constants; using Framework.Database; using Game.Entities; -using Game.Loots; -using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Text; -using Game.Loots; -using Framework.Collections; -using System.Collections.Concurrent; namespace Game.Loots { diff --git a/Source/Game/Scripting/CoreScripts.cs b/Source/Game/Scripting/CoreScripts.cs index e008b6f64..460ab02cc 100644 --- a/Source/Game/Scripting/CoreScripts.cs +++ b/Source/Game/Scripting/CoreScripts.cs @@ -268,9 +268,6 @@ namespace Game.Scripting public override bool IsDatabaseBound() { return true; } - // Called when a dummy spell effect is triggered on the item. - public virtual bool OnDummyEffect(Unit caster, uint spellId, uint effIndex, Item target) { return false; } - // Called when a player accepts a quest from the item. public virtual bool OnQuestAccept(Player player, Item item, Quest quest) { return false; } @@ -336,9 +333,6 @@ namespace Game.Scripting public override bool IsDatabaseBound() { return true; } - // Called when a dummy spell effect is triggered on the creature. - public virtual bool OnDummyEffect(Unit caster, uint spellId, uint effIndex, Creature target) { return false; } - // Called when a player opens a gossip dialog with the creature. public virtual bool OnGossipHello(Player player, Creature creature) { return false; } @@ -381,9 +375,6 @@ namespace Game.Scripting public override bool IsDatabaseBound() { return true; } - // Called when a dummy spell effect is triggered on the gameobject. - public virtual bool OnDummyEffect(Unit caster, uint spellId, uint effIndex, GameObject target) { return false; } - // Called when a player opens a gossip dialog with the gameobject. public virtual bool OnGossipHello(Player player, GameObject go) { return false; } diff --git a/Source/Game/Scripting/ScriptManager.cs b/Source/Game/Scripting/ScriptManager.cs index 74731dcfe..8cbe5784e 100644 --- a/Source/Game/Scripting/ScriptManager.cs +++ b/Source/Game/Scripting/ScriptManager.cs @@ -709,13 +709,6 @@ namespace Game.Scripting } //ItemScript - public bool OnDummyEffect(Unit caster, uint spellId, uint effIndex, Item target) - { - Cypher.Assert(caster != null); - Cypher.Assert(target != null); - - return RunScriptRet(p => p.OnDummyEffect(caster, spellId, effIndex, target), target.GetScriptId()); - } public bool OnQuestAccept(Player player, Item item, Quest quest) { Cypher.Assert(player != null); @@ -756,13 +749,6 @@ namespace Game.Scripting } //CreatureScript - public bool OnDummyEffect(Unit caster, uint spellId, uint effIndex, Creature target) - { - Cypher.Assert(caster); - Cypher.Assert(target); - - return RunScriptRet(p => p.OnDummyEffect(caster, spellId, effIndex, target), target.GetScriptId()); - } public bool OnGossipHello(Player player, Creature creature) { Cypher.Assert(player); @@ -848,13 +834,6 @@ namespace Game.Scripting } //GameObjectScript - public bool OnDummyEffect(Unit caster, uint spellId, uint effIndex, GameObject target) - { - Cypher.Assert(caster != null); - Cypher.Assert(target != null); - - return RunScriptRet(p => p.OnDummyEffect(caster, spellId, effIndex, target), target.GetScriptId()); - } public bool OnGossipHello(Player player, GameObject go) { Cypher.Assert(player != null); diff --git a/Source/Game/Spells/Auras/AuraEffect.cs b/Source/Game/Spells/Auras/AuraEffect.cs index 539699470..431aa51a6 100644 --- a/Source/Game/Spells/Auras/AuraEffect.cs +++ b/Source/Game/Spells/Auras/AuraEffect.cs @@ -3812,7 +3812,7 @@ namespace Game.Spells [AuraEffectHandler(AuraType.ModMeleeRangedHaste2)] void HandleModMeleeRangedSpeedPct(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply) { - if (!mode.HasAnyFlag((AuraEffectHandleModes.ChangeAmountMask | AuraEffectHandleModes.Stat))) + if (!mode.HasAnyFlag(AuraEffectHandleModes.ChangeAmountMask | AuraEffectHandleModes.Stat)) return; //! ToDo: Haste auras with the same handler _CAN'T_ stack together @@ -4223,16 +4223,16 @@ namespace Game.Spells Unit caster = GetCaster(); - if (mode.HasAnyFlag(AuraEffectHandleModes.Real)) + // pet auras + if (target.GetTypeId() == TypeId.Player && mode.HasAnyFlag(AuraEffectHandleModes.Real)) { - // pet auras PetAura petSpell = Global.SpellMgr.GetPetAura(GetId(), m_effIndex); if (petSpell != null) { if (apply) - target.AddPetAura(petSpell); + target.ToPlayer().AddPetAura(petSpell); else - target.RemovePetAura(petSpell); + target.ToPlayer().RemovePetAura(petSpell); } } @@ -5332,12 +5332,7 @@ namespace Game.Spells } } else - { - Creature c = target.ToCreature(); - if (c == null || caster == null || !Global.ScriptMgr.OnDummyEffect(caster, GetId(), GetEffIndex(), target.ToCreature()) || - !c.GetAI().OnDummyEffect(caster, GetId(), GetEffIndex())) - Log.outDebug(LogFilter.Spells, "AuraEffect.HandlePeriodicTriggerSpellAuraTick: Spell {0} has non-existent spell {1} in EffectTriggered[{2}] and is therefor not triggered.", GetId(), triggerSpellId, GetEffIndex()); - } + Log.outDebug(LogFilter.Spells, "AuraEffect.HandlePeriodicTriggerSpellAuraTick: Spell {0} has non-existent spell {1} in EffectTriggered[{2}] and is therefor not triggered.", GetId(), triggerSpellId, GetEffIndex()); } void HandlePeriodicTriggerSpellWithValueAuraTick(Unit target, Unit caster) diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index d6aac75b2..a0044967e 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -2436,17 +2436,6 @@ namespace Game.Spells else m_casttime = m_spellInfo.CalcCastTime(m_caster.GetLevel(), this); - 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))) - { - if (m_targets.GetObjectTarget() && m_caster != m_targets.GetObjectTarget()) - m_caster.ToCreature().FocusTarget(this, m_targets.GetObjectTarget()); - else if (m_spellInfo.HasAttribute(SpellAttr5.DontTurnDuringCast)) - m_caster.ToCreature().FocusTarget(this, null); - } - } - // don't allow channeled spells / spells with cast time to be casted while moving // exception are only channeled spells that have no casttime and SPELL_ATTR5_CAN_CHANNEL_WHEN_MOVING // (even if they are interrupted on moving, spells with almost immediate effect get to have their effect processed before movement interrupter kicks in) @@ -2463,6 +2452,18 @@ namespace Game.Spells } } + // focus if not controlled creature + if (m_caster.GetTypeId() == TypeId.Unit && !m_caster.HasUnitFlag(UnitFlags.PlayerControlled)) + { + if (!(m_spellInfo.IsNextMeleeSwingSpell() || IsAutoRepeat() || _triggeredCastFlags.HasAnyFlag(TriggerCastFlags.IgnoreSetFacing))) + { + if (m_targets.GetObjectTarget() && m_caster != m_targets.GetObjectTarget()) + m_caster.ToCreature().FocusTarget(this, m_targets.GetObjectTarget()); + else if (m_spellInfo.HasAttribute(SpellAttr5.DontTurnDuringCast)) + m_caster.ToCreature().FocusTarget(this, null); + } + } + // set timer base at cast time ReSetTimer(); diff --git a/Source/Game/Spells/SpellEffects.cs b/Source/Game/Spells/SpellEffects.cs index 3d8c48039..0980f5603 100644 --- a/Source/Game/Spells/SpellEffects.cs +++ b/Source/Game/Spells/SpellEffects.cs @@ -306,25 +306,19 @@ namespace Game.Spells } // pet auras - PetAura petSpell = Global.SpellMgr.GetPetAura(m_spellInfo.Id, (byte)effIndex); - if (petSpell != null) + if (m_caster.GetTypeId() == TypeId.Player) { - m_caster.AddPetAura(petSpell); - return; + PetAura petSpell = Global.SpellMgr.GetPetAura(m_spellInfo.Id, (byte)effIndex); + if (petSpell != null) + { + m_caster.ToPlayer().AddPetAura(petSpell); + return; + } } // normal DB scripted effect Log.outDebug(LogFilter.Spells, "Spell ScriptStart spellid {0} in EffectDummy({1})", m_spellInfo.Id, effIndex); m_caster.GetMap().ScriptsStart(ScriptsType.Spell, (uint)((int)m_spellInfo.Id | (int)(effIndex << 24)), m_caster, unitTarget); - - // Script based implementation. Must be used only for not good for implementation in core spell effects - // So called only for not proccessed cases - if (gameObjTarget) - Global.ScriptMgr.OnDummyEffect(m_caster, m_spellInfo.Id, effIndex, gameObjTarget); - else if (unitTarget && unitTarget.IsTypeId(TypeId.Unit)) - Global.ScriptMgr.OnDummyEffect(m_caster, m_spellInfo.Id, effIndex, unitTarget.ToCreature()); - else if (itemTarget) - Global.ScriptMgr.OnDummyEffect(m_caster, m_spellInfo.Id, effIndex, itemTarget); } [SpellEffectHandler(SpellEffectName.TriggerSpell)] @@ -1957,11 +1951,11 @@ namespace Game.Spells if (unitTarget.HasUnitState(UnitState.Confused | UnitState.Stunned | UnitState.Fleeing)) return; - unitTarget.SetFacingTo(unitTarget.GetAngle(destTarget)); - unitTarget.ClearUnitState(UnitState.Moving); - if (unitTarget.IsTypeId(TypeId.Unit)) unitTarget.GetMotionMaster().MoveDistract((uint)(damage * Time.InMilliseconds)); + + unitTarget.StopMoving(); + unitTarget.SetFacingTo(unitTarget.GetAngle(destTarget)); } [SpellEffectHandler(SpellEffectName.Pickpocket)] diff --git a/Source/Game/Spells/SpellInfo.cs b/Source/Game/Spells/SpellInfo.cs index f18b97d01..fc929fccf 100644 --- a/Source/Game/Spells/SpellInfo.cs +++ b/Source/Game/Spells/SpellInfo.cs @@ -2304,11 +2304,14 @@ namespace Game.Spells { switch (Id) { + case 42292: // PvP trinket + case 59752: // Every Man for Himself + mechanicImmunityMask |= (uint)Mechanics.ImmuneToMovementImpairmentAndLossControlMask; + immuneInfo.AuraTypeImmune.Add(AuraType.UseNormalMovementSpeed); + break; case 34471: // The Beast Within case 19574: // Bestial Wrath - case 42292: // PvP trinket case 46227: // Medallion of Immunity - case 59752: // Every Man for Himself case 53490: // Bullheaded case 65547: // PvP Trinket case 134946: // Supremacy of the Alliance diff --git a/Source/Game/Spells/SpellManager.cs b/Source/Game/Spells/SpellManager.cs index 129419aa2..304d3bdcf 100644 --- a/Source/Game/Spells/SpellManager.cs +++ b/Source/Game/Spells/SpellManager.cs @@ -2976,6 +2976,10 @@ namespace Game.Entities break; case 69846: // Frost Bomb spellInfo.Speed = 0.0f; // This spell's summon happens instantly + break; + case 70106: // Chilled to the Bone + spellInfo.AttributesEx3 |= SpellAttr3.NoDoneBonus; + spellInfo.AttributesEx6 |= SpellAttr6.NoDonePctDamageMods; break; case 71614: // Ice Lock spellInfo.Mechanic = Mechanics.Stun; diff --git a/Source/Scripts/Northrend/FrozenHalls/ForgeOfSouls/BossDevourerOfSouls.cs b/Source/Scripts/Northrend/FrozenHalls/ForgeOfSouls/BossDevourerOfSouls.cs index f2eb819f4..269c10d5e 100644 --- a/Source/Scripts/Northrend/FrozenHalls/ForgeOfSouls/BossDevourerOfSouls.cs +++ b/Source/Scripts/Northrend/FrozenHalls/ForgeOfSouls/BossDevourerOfSouls.cs @@ -201,7 +201,7 @@ namespace Scripts.Northrend.FrozenHalls.ForgeOfSouls.DevourerOfSouls _scheduler.Schedule(TimeSpan.FromSeconds(3), tickTask => { beamAngle += beamAngleDiff; - me.SetFacingTo(beamAngle, true); + me.SetFacingTo(beamAngle); me.StopMoving(); DoCast(me, SpellIds.WailingSouls); diff --git a/Source/Scripts/World/NpcSpecial.cs b/Source/Scripts/World/NpcSpecial.cs index 96185d9c4..02e75bd29 100644 --- a/Source/Scripts/World/NpcSpecial.cs +++ b/Source/Scripts/World/NpcSpecial.cs @@ -703,7 +703,7 @@ namespace Scripts.World.NpcSpecial { if (me.IsWithinLOS(player.GetPositionX(), player.GetPositionY(), player.GetPositionZ()) && me.IsWithinDistInMap(player, 30.0f)) { - me.SetInFront(player); + me.SetFacingToObject(player); Active = false; switch (emote)