sahisahi
Member
Today i was at Deceit dungeon and a Lizard shaman casted a lightning to a Energy Vortex and server crashed.
This is the crash log:
Exception:
System.InvalidCastException: Unable to cast object of type 'Server.Mobiles.EnergyVortex' to type 'Server.Mobiles.PlayerMobile'.
at Server.Spells.Fourth.LightningSpell.Target(Mobile m)
at Server.Targeting.Target.Invoke(Mobile from, Object targeted)
at Server.Mobiles.SphereMageAI.ProcessTarget(Target targ)
at Server.Mobiles.SphereMageAI.Think()
at Server.Mobiles.BaseAI.AITimer.OnTick()
at Server.Timer.Slice()
at Server.Core.Main(String[] args)
I added this, because i thought the crash issue was there, not sure thought.
Thanks!
This is the crash log:
Exception:
System.InvalidCastException: Unable to cast object of type 'Server.Mobiles.EnergyVortex' to type 'Server.Mobiles.PlayerMobile'.
at Server.Spells.Fourth.LightningSpell.Target(Mobile m)
at Server.Targeting.Target.Invoke(Mobile from, Object targeted)
at Server.Mobiles.SphereMageAI.ProcessTarget(Target targ)
at Server.Mobiles.SphereMageAI.Think()
at Server.Mobiles.BaseAI.AITimer.OnTick()
at Server.Timer.Slice()
at Server.Core.Main(String[] args)
Code:
using Server.Items;
using Server.Mobiles;
using Server.Targeting;
using System;
using Server.Regions;
using Server.Guilds;
using System; //edited
namespace Server.Spells.Fourth
{
public class LightningSpell : MagerySpell
{
public override SpellCircle Circle { get { return SpellCircle.Fourth; } }
public override int Sound { get { return 0x29; } }
public override int ManaCost { get { return 11; } } // edited
private static readonly SpellInfo m_Info = new SpellInfo(
"Lightning", "Por Ort Grav",
263,
9021,
Reagent.MandrakeRoot,
Reagent.SulfurousAsh
);
public LightningSpell( Mobile caster, Item scroll ) : base( caster, scroll, m_Info )
{
}
// pvp changes
public override TimeSpan GetCastDelay()
{
return TimeSpan.FromSeconds(1.6);
}
public override double GetResistPercent( Mobile target )
{
return 37.0;
}
public override void OnPlayerCast()
{
if (SphereSpellTarget is Mobile)
Target((Mobile)SphereSpellTarget);
else if (SphereSpellTarget is BaseWand)
{
BaseWand bw = SphereSpellTarget as BaseWand;
bw.RechargeWand(Caster, this);
}
else
DoFizzle();
}
public override void OnCast()
{
Caster.Target = new InternalTarget( this );
}
public override bool DelayedDamage{ get{ return false; } }
public void Target( Mobile m )
{
if ( !Caster.CanSee( m ) )
{
Caster.SendLocalizedMessage( 500237 ); // Target can not be seen.
}
if ( CheckHSequence( m ) )
{
SpellHelper.CheckReflect( (int)Circle, Caster, ref m );
double damage = 12 + ((int)(GetDamageSkill(Caster) - GetResistSkill(m)) / 12);
if ( CheckResisted( m ) )
{
Caster.SendAsciiMessage (28, "Your target resist the spell");
m.SendAsciiMessage(93,"You resist the spell");
damage = (int)(damage * 0.8);
}
m.BoltEffect( 0 );
Caster.RevealingAction();
//////////guild edit///////////////
if (m is PlayerMobile) // 12/04/2017 not sure if this fix the Shaman lizardman crash
{ // 12/04/2017 not sure if this fix the Shaman lizardman crash
Guild guild = Caster.Guild as Guild;
if (guild != null && Caster is PlayerMobile)
{
switch (Caster.Guild.Type)
{
case GuildType.Chaos: damage += 2; break;
case GuildType.Order: damage += 2; break;
}
}
///////////end of guild edit////////////////
Item weap = Caster.FindItemOnLayer(Layer.TwoHanded);
if (weap != null && weap is bastonarchimago && Caster is PlayerMobile)
damage += 3;
////////////////Key bonus//////////////////
PlayerMobile mobile = (PlayerMobile)m;
Container pack = m.Backpack;
Item keyyflame = m.Backpack.FindItemByType(typeof(Keyyew));
if (keyyflame != null)
{
damage -= 3;
}
///////////////end of keybonus//////////////
SpellHelper.Damage( this, m, damage, 0, 0, 0, 0, 100 );
m.PlaySound(m.GetHurtSound());
m.Animate(!m.Mounted ? 20 : 29, 5, 1, true, false, 0);
FinishSequence();
}
}
}
private class InternalTarget : Target
{
private readonly LightningSpell m_Owner;
public InternalTarget( LightningSpell owner ) : base( 12, false, TargetFlags.Harmful )
{
m_Owner = owner;
}
protected override void OnTarget( Mobile from, object o )
{
if ( o is Mobile )
m_Owner.Target( (Mobile)o );
}
protected override void OnTargetFinish( Mobile from )
{
m_Owner.FinishSequence();
}
}
}
}
I added this, because i thought the crash issue was there, not sure thought.
Code:
//////////guild edit///////////////
if (m is PlayerMobile) // 12/04/2017 not sure if this fix the Shaman lizardman crash
{ // 12/04/2017 not sure if this fix the Shaman lizardman crash
///////////end of guild edit////////////////
Thanks!