Core/Spells: Implement spell queue

Port From (https://github.com/TrinityCore/TrinityCore/commit/27019a62a4294f8dd48d975f85b1907c5adee0e3)
This commit is contained in:
hondacrx
2024-02-03 13:11:01 -05:00
parent 284cb628c9
commit a5b8efd032
10 changed files with 390 additions and 192 deletions
+2
View File
@@ -8121,6 +8121,8 @@ namespace Game.Spells
return m_casttime;
}
public int GetRemainingCastTime() { return m_timer; }
bool IsAutoRepeat()
{
return m_autoRepeat;
+37
View File
@@ -0,0 +1,37 @@
// Copyright (c) CypherCore <http://github.com/CypherCore> All rights reserved.
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
using Game.Entities;
using Game.Networking.Packets;
namespace Game.Spells
{
public class SpellCastRequestItemData
{
public byte PackSlot;
public byte Slot;
public ObjectGuid CastItem;
public SpellCastRequestItemData(byte packSlot, byte slot, ObjectGuid castItem)
{
PackSlot = packSlot;
Slot = slot;
CastItem = castItem;
}
}
public class SpellCastRequest
{
public SpellCastRequestPkt CastRequest;
public ObjectGuid CastingUnitGUID;
public SpellCastRequestItemData ItemData;
public SpellCastRequest(SpellCastRequestPkt castRequest, ObjectGuid castingUnitGUID, SpellCastRequestItemData? itemData = null)
{
CastRequest = castRequest;
CastingUnitGUID = castingUnitGUID;
ItemData = itemData;
}
}
}
+1 -1
View File
@@ -18,7 +18,7 @@ namespace Game.Spells
m_dst = new SpellDestination();
}
public SpellCastTargets(Unit caster, SpellCastRequest spellCastRequest)
public SpellCastTargets(Unit caster, SpellCastRequestPkt spellCastRequest)
{
m_targetMask = spellCastRequest.Target.Flags;
m_objectTargetGUID = spellCastRequest.Target.Unit;
+15 -3
View File
@@ -537,7 +537,7 @@ namespace Game.Spells
}
if (cooldownEntry.CooldownEnd <= now)
{
{
_categoryCooldowns.Remove(cooldownEntry.CategoryId);
_spellCooldowns.Remove(cooldownEntry.SpellId);
}
@@ -697,7 +697,7 @@ namespace Game.Spells
{
return GetRemainingCategoryCooldown(spellInfo.GetCategory());
}
public void LockSpellSchool(SpellSchoolMask schoolMask, TimeSpan lockoutTime)
{
DateTime now = GameTime.GetSystemTime();
@@ -921,6 +921,18 @@ namespace Game.Spells
_globalCooldowns[spellInfo.StartRecoveryCategory] = new DateTime();
}
public TimeSpan GetRemainingGlobalCooldown(SpellInfo spellInfo)
{
if (!_globalCooldowns.TryGetValue(spellInfo.StartRecoveryCategory, out DateTime end))
return TimeSpan.Zero;
DateTime now = GameTime.GetDateAndTime();
if (end < now)
return TimeSpan.Zero;
return end - now;
}
public Player GetPlayerOwner()
{
return _owner.GetCharmerOrOwnerPlayerOrPlayerItself();
@@ -952,7 +964,7 @@ namespace Game.Spells
player.SendPacket(setSpellCharges);
}
}
void GetCooldownDurations(SpellInfo spellInfo, uint itemId, ref uint categoryId)
{
TimeSpan notUsed = TimeSpan.Zero;