Sirenix
Member
I got an old set of scripts from Poe that I been trying to get to work. I use the method in other scripts so more then one of them are crashing. I cant seem to figure out why the dismount ability works fine, yet this crashes, and it seems like its the same code.
Heres the dismount code for a quick refrence:
Thanks for any help on this been driving me nuts!
Code:
Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at Server.Mobiles.SavageRider.OnActionCombat()
at Server.Mobiles.BaseAI.Think()
at Server.Mobiles.BaseAI.AITimer.OnTick()
at Server.Timer.Slice()
at Server.Core.Main(String[] args)
Code:
public override void OnActionCombat()
{
if ( DateTime.Now > m_Delay )
{
List<Mobile> targets = new List<Mobile>();
foreach ( Mobile m in this.GetMobilesInRange( 3 ) )
{
if ( Ability.CanTarget( this, m ) )
targets.Add( m );
}
for ( int i = 0; i < targets.Count; ++i )
{
Mobile m = (Mobile)targets[i];
int damage = Utility.RandomMinMax( 15, 25 );
if ( m is PlayerMobile )
{
if ( m.Mounted )
{
IMount mount = m.Mount;
mount.Rider = null;
mount.Rider.CanSwim=false;
m.SendLocalizedMessage( 1062315 ); // You fall off your mount!
}
else
damage = Utility.RandomMinMax( 10, 20 );
}
AOS.Damage( m, this, damage, 100, 0, 0, 0, 0 );
m.SendMessage( "The savage swings it's weapon around and hits you" );
}
targets.Clear();
m_Delay = DateTime.Now + TimeSpan.FromSeconds( Utility.RandomMinMax( 7, 14 ) );
}
base.OnActionCombat();
}
Heres the dismount code for a quick refrence:
Code:
public override void OnHit(Mobile attacker, Mobile defender, int damage)
{
if (!this.Validate(attacker))
return;
if (defender is ChaosDragoon || defender is ChaosDragoonElite)
return;
if (attacker.Mounted && !(defender.Weapon is Lance)) // TODO: Should there be a message here?
return;
ClearCurrentAbility(attacker);
IMount mount = defender.Mount;
if (mount == null)
{
attacker.SendLocalizedMessage(1060848); // This attack only works on mounted targets
return;
}
if (!this.CheckMana(attacker, true))
return;
if (Core.ML && attacker is LesserHiryu && 0.8 >= Utility.RandomDouble())
{
return; //Lesser Hiryu have an 80% chance of missing this attack
}
attacker.SendLocalizedMessage(1060082); // The force of your attack has dislodged them from their mount!
if (attacker.Mounted)
defender.SendLocalizedMessage(1062315); // You fall off your mount!
else
defender.SendLocalizedMessage(1060083); // You fall off of your mount and take damage!
defender.PlaySound(0x140);
defender.FixedParticles(0x3728, 10, 15, 9955, EffectLayer.Waist);
mount.Rider = null;
BaseMount.SetMountPrevention(defender, BlockMountType.Dazed, DefenderRemountDelay);
if (Core.ML && attacker is BaseCreature && ((BaseCreature)attacker).ControlMaster != null)
{
BaseMount.SetMountPrevention(((BaseCreature)attacker).ControlMaster, BlockMountType.DismountRecovery, AttackerRemountDelay);
}
else
{
BaseMount.SetMountPrevention(attacker, BlockMountType.DismountRecovery, AttackerRemountDelay);
}
if (!attacker.Mounted)
AOS.Damage(defender, attacker, Utility.RandomMinMax(15, 25), 100, 0, 0, 0, 0);
}
Thanks for any help on this been driving me nuts!