Core/Spells: enable and implement SMSG_MISSILE_CANCEL
Port From (https://github.com/TrinityCore/TrinityCore/commit/71db17220ae67dc6a354e88451ffc0700fe6c5f9)
This commit is contained in:
@@ -60,7 +60,7 @@ namespace Framework.Dynamic
|
||||
AddEvent(Event, CalculateTime(1), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void KillAllEvents(bool force)
|
||||
{
|
||||
@@ -115,6 +115,8 @@ namespace Framework.Dynamic
|
||||
return (m_time + t_offset);
|
||||
}
|
||||
|
||||
public SortedMultiMap<ulong, BasicEvent> GetEvents() { return m_events; }
|
||||
|
||||
ulong m_time;
|
||||
SortedMultiMap<ulong, BasicEvent> m_events = new SortedMultiMap<ulong, BasicEvent>();
|
||||
}
|
||||
|
||||
@@ -1067,6 +1067,32 @@ namespace Game.Entities
|
||||
SendMessageToSet(playSpellVisualKit, true);
|
||||
}
|
||||
|
||||
void CancelSpellMissiles(uint spellId, bool reverseMissile = false)
|
||||
{
|
||||
bool hasMissile = false;
|
||||
foreach (var pair in m_Events.GetEvents())
|
||||
{
|
||||
Spell spell = Spell.ExtractSpellFromEvent(pair.Value);
|
||||
if (spell != null)
|
||||
{
|
||||
if (spell.GetSpellInfo().Id == spellId)
|
||||
{
|
||||
pair.Value.ScheduleAbort();
|
||||
hasMissile = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasMissile)
|
||||
{
|
||||
MissileCancel packet = new MissileCancel();
|
||||
packet.OwnerGUID = GetGUID();
|
||||
packet.SpellID = spellId;
|
||||
packet.Reverse = reverseMissile;
|
||||
SendMessageToSet(packet, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void UnsummonAllTotems()
|
||||
{
|
||||
for (byte i = 0; i < SharedConst.MaxSummonSlot; ++i)
|
||||
|
||||
@@ -1118,6 +1118,23 @@ namespace Game.Networking.Packets
|
||||
|
||||
public uint Result;
|
||||
}
|
||||
|
||||
class MissileCancel : ServerPacket
|
||||
{
|
||||
public MissileCancel() : base(ServerOpcodes.MissileCancel) { }
|
||||
|
||||
public override void Write()
|
||||
{
|
||||
_worldPacket.WritePackedGuid(OwnerGUID);
|
||||
_worldPacket.WriteUInt32(SpellID);
|
||||
_worldPacket.WriteBit(Reverse);
|
||||
_worldPacket.FlushBits();
|
||||
}
|
||||
|
||||
public ObjectGuid OwnerGUID;
|
||||
public bool Reverse;
|
||||
public uint SpellID;
|
||||
}
|
||||
|
||||
//Structs
|
||||
public struct SpellLogPowerData
|
||||
|
||||
@@ -4418,6 +4418,15 @@ namespace Game.Spells
|
||||
Global.SpellMgr.GetSpellEffectHandler(eff).Invoke(this, i);
|
||||
}
|
||||
|
||||
public static Spell ExtractSpellFromEvent(BasicEvent basicEvent)
|
||||
{
|
||||
SpellEvent spellEvent = (SpellEvent)basicEvent;
|
||||
if (spellEvent != null)
|
||||
return spellEvent.GetSpell();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public SpellCastResult CheckCast(bool strict)
|
||||
{
|
||||
uint param1 = 0, param2 = 0;
|
||||
@@ -7998,17 +8007,21 @@ namespace Game.Spells
|
||||
m_Spell.GetCaster().m_Events.AddEvent(this, e_time + 1, false);
|
||||
return false; // event not complete
|
||||
}
|
||||
|
||||
public override void Abort(ulong e_time)
|
||||
{
|
||||
// oops, the spell we try to do is aborted
|
||||
if (m_Spell.GetState() != SpellState.Finished)
|
||||
m_Spell.Cancel();
|
||||
}
|
||||
|
||||
public override bool IsDeletable()
|
||||
{
|
||||
return m_Spell.IsDeletable();
|
||||
}
|
||||
|
||||
public Spell GetSpell() { return m_Spell; }
|
||||
|
||||
Spell m_Spell;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user