Skip to content

Commit

Permalink
improv: tidy up SpellHandler.FinishSpellCast player checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Mishura4 committed Nov 24, 2024
1 parent 1c507b7 commit 19ef51a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
2 changes: 2 additions & 0 deletions GameServer/gameobjects/GamePlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16597,6 +16597,8 @@ public virtual bool IsOnHorse
{
if (m_whistleMountTimer != null)
StopWhistleTimers();
if (value == m_isOnHorse)
return;
m_isOnHorse = value;
Out.SendControlledHorse(this, value); // fix very rare bug when this player not in GetPlayersInRadius;
foreach (GamePlayer plr in GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
Expand Down
30 changes: 15 additions & 15 deletions GameServer/spells/SpellHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1977,27 +1977,27 @@ public virtual void SendEffectAnimation(GameObject target, ushort clientEffect,
/// </summary>
public virtual void FinishSpellCast(GameLiving target)
{
if (Caster is GamePlayer && ((GamePlayer)Caster).IsOnHorse && !HasPositiveEffect)
((GamePlayer)Caster).IsOnHorse = false;

if (m_caster is GamePlayer && (m_caster as GamePlayer)!.IsSummoningMount)
if (Caster is GamePlayer playerCaster)
{
(m_caster as GamePlayer)?.Out.SendMessage(LanguageMgr.GetTranslation((m_caster as GamePlayer)?.Client.Account.Language, "GameObjects.GamePlayer.UseSlot.CantMountSpell"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
(m_caster as GamePlayer)!.IsOnHorse = false;
if (playerCaster.IsSummoningMount)
{
playerCaster.SendTranslatedMessage( "GameObjects.GamePlayer.UseSlot.CantMountSpell", eChatType.CT_System, eChatLoc.CL_SystemWindow);
playerCaster.IsOnHorse = false;
}
if (!HasPositiveEffect)
{
playerCaster.IsOnHorse = false;
if (playerCaster.AttackWeapon is GameInventoryItem weapon)
{
weapon.OnSpellCast(playerCaster, target, Spell);
}
}
}

//[Stryve]: Do not break stealth if spell never breaks stealth.
if (UnstealthCasterOnFinish)
Caster.Stealth(false);

if (Caster is GamePlayer && !HasPositiveEffect)
{
if (Caster.AttackWeapon != null && Caster.AttackWeapon is GameInventoryItem)
{
(Caster.AttackWeapon as GameInventoryItem)!.OnSpellCast(Caster, target, Spell);
}
}

// messages
if (Spell.InstrumentRequirement == 0 && Spell.ClientEffect != 0 && Spell.CastTime > 0)
{
Expand Down

0 comments on commit 19ef51a

Please sign in to comment.