sahisahi
Member
I would like provocation to work on players (similar to taunt in mmorpgs)
Whenever i try provocation on someone server crash on second target
Im using runuo 2.2
Crashlog
Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at Server.SkillHandlers.Provocation.InternalSecondTarget.OnTarget(Mobile from, Object targeted) in c:\Users\mypc\Desktop\\Skills\Provocation.cs:line 104
at Server.Targeting.Target.Invoke(Mobile from, Object targeted)
at Server.Network.PacketHandlers.TargetResponse(NetState state, PacketReader pvSrc)
at Server.Network.MessagePump.HandleReceive(NetState ns)
at Server.Network.MessagePump.Slice()
at Server.Core.Main(String[] args)
Provocation.cs
Basecreature.cs Provoke method:
Thanks!
Whenever i try provocation on someone server crash on second target
Im using runuo 2.2
Crashlog
Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at Server.SkillHandlers.Provocation.InternalSecondTarget.OnTarget(Mobile from, Object targeted) in c:\Users\mypc\Desktop\\Skills\Provocation.cs:line 104
at Server.Targeting.Target.Invoke(Mobile from, Object targeted)
at Server.Network.PacketHandlers.TargetResponse(NetState state, PacketReader pvSrc)
at Server.Network.MessagePump.HandleReceive(NetState ns)
at Server.Network.MessagePump.Slice()
at Server.Core.Main(String[] args)
Provocation.cs
Code:
using System;
using Server.Targeting;
using Server.Network;
using Server.Mobiles;
using Server.Items;
namespace Server.SkillHandlers
{
public class Provocation
{
public static void Initialize()
{
SkillInfo.Table[(int)SkillName.Provocation].Callback = new SkillUseCallback( OnUse );
}
public static TimeSpan OnUse( Mobile m )
{
m.RevealingAction();
BaseInstrument.PickInstrument( m, new InstrumentPickedCallback( OnPickedInstrument ) );
return TimeSpan.FromSeconds( 1.0 ); // Cannot use another skill for 1 second
}
public static void OnPickedInstrument( Mobile from, BaseInstrument instrument )
{
from.RevealingAction();
from.SendLocalizedMessage( 501587 ); // Whom do you wish to incite?
from.Target = new InternalFirstTarget( from, instrument );
}
private class InternalFirstTarget : Target
{
private BaseInstrument m_Instrument;
public InternalFirstTarget( Mobile from, BaseInstrument instrument ) : base( BaseInstrument.GetBardRange( from, SkillName.Provocation ), false, TargetFlags.None )
{
m_Instrument = instrument;
}
protected override void OnTarget( Mobile from, object targeted )
{
from.RevealingAction();
if( targeted is PlayerMobile )
{
PlayerMobile b = (PlayerMobile)targeted;
if (!m_Instrument.IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1062488); // The instrument you are trying to play is no longer in your backpack!
}
else if (b.Map != b.Map || !b.InRange(b, BaseInstrument.GetBardRange(from, SkillName.Provocation)))
{
from.SendLocalizedMessage(1049450); // The creatures you are trying to provoke are too far away from each other for your music to have an effect.
}
else
{
from.RevealingAction();
m_Instrument.PlayInstrumentWell( from );
from.SendLocalizedMessage( 1008085 ); // You play your music and your target becomes angered. Whom do you wish them to attack?
from.Target = new InternalSecondTarget(from, m_Instrument, b);
}
}
}
}
private class InternalSecondTarget : Target
{
private BaseCreature m_Creature;
private BaseInstrument m_Instrument;
public InternalSecondTarget( Mobile from, BaseInstrument instrument, PlayerMobile b ) : base( BaseInstrument.GetBardRange( from, SkillName.Provocation ), false, TargetFlags.None )
{
m_Instrument = instrument;
//m_Creature = creature;
}
protected override void OnTarget( Mobile from, object targeted )
{
from.RevealingAction();
if( targeted is PlayerMobile )
{
PlayerMobile b = (PlayerMobile)targeted;
if (!m_Instrument.IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1062488); // The instrument you are trying to play is no longer in your backpack!
}
else if (b.Map != b.Map || !b.InRange(b, BaseInstrument.GetBardRange(from, SkillName.Provocation)))
{
from.SendLocalizedMessage(1049450); // The creatures you are trying to provoke are too far away from each other for your music to have an effect.
}
else
{
from.SendLocalizedMessage( 501602 ); // Your music succeeds, as you start a fight.
m_Instrument.PlayInstrumentWell( from );
m_Instrument.ConsumeUse( from );
m_Creature.Provoke( true, from, b ); ////<- Line 104 crash
}
}
else
{
from.SendLocalizedMessage(501589); // You can't incite that!
}
}
}
}
}
Basecreature.cs Provoke method:
Code:
public void Provoke(Mobile master, Mobile target, bool bSuccess)
{
BardProvoked = true;
PublicOverheadMessage(MessageType.Emote, EmoteHue, false, "*Seems furious*");
if (bSuccess)
{
PlaySound(GetIdleSound());
BardMaster = master;
BardTarget = target;
Combatant = target;
BardEndTime = DateTime.Now + TimeSpan.FromSeconds(30.0);
if (target is BaseCreature)
{
BaseCreature t = (BaseCreature)target;
if (t.Unprovokable || (t.IsParagon && BaseInstrument.GetBaseDifficulty(t) >= 160.0))
return;
t.BardProvoked = true;
t.BardMaster = master;
t.BardTarget = this;
t.Combatant = this;
t.BardEndTime = DateTime.Now + TimeSpan.FromSeconds(30.0);
}
}
else
{
PlaySound(GetAngerSound());
BardMaster = master;
BardTarget = target;
}
}
Thanks!