Abracadabra2.0
Member
I am attempting to create a custom system in which the player can select from a menu of different types of paintings and then, when selected, get a target which will allow them to identify the subject of the work. The end result would produce a painting or portrait of the subject by the artist.
I'm having a little trouble with a few key elements.
1. I'm not quite sure about how to write the targeting methods. I've created one for each art style because each one will do something a little different.
Here is the way I did that particular targeting method:
I've attached all of the needed files for testing. I'd appreciate help with any or all of these questions. Thanks
I'm having a little trouble with a few key elements.
1. I'm not quite sure about how to write the targeting methods. I've created one for each art style because each one will do something a little different.
- Portraits should produce "A portrait of (subject) by (artist)" or, in the event the player targets themselves, "A self portrait by (artist)".
- Still Lifes should produce "A painting of (subject item) by (artist)".
- Abstracts should produce "An abstract painting by (artist)".
Code:
Server Crash Report
===================
RunUO Version 2.6, Build 0.13549
Operating System: Microsoft Windows NT 6.2.9200.0
.NET Framework: 4.0.30319.42000
Time: 3/19/2017 12:21:43 AM
Mobiles: 17107
Items: 144434
Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at Server.Gumps.PaintingGump.AbstractTarget1.OnTarget(Mobile from, Object targeted)
at Server.Targeting.Target.Invoke(Mobile from, Object targeted) in C:\Users\Tom\Desktop\RunUO-2.6 + Distro151\RunUO-2.6 + Distro151\RunUO-2.6\Server\Targeting\Target.cs:line 291
at Server.Network.PacketHandlers.TargetResponse(NetState state, PacketReader pvSrc) in C:\Users\Tom\Desktop\RunUO-2.6 + Distro151\RunUO-2.6 + Distro151\RunUO-2.6\Server\Network\PacketHandlers.cs:line 1200
at Server.Network.MessagePump.HandleReceive(NetState ns) in C:\Users\Tom\Desktop\RunUO-2.6 + Distro151\RunUO-2.6 + Distro151\RunUO-2.6\Server\Network\MessagePump.cs:line 260
at Server.Network.MessagePump.Slice() in C:\Users\Tom\Desktop\RunUO-2.6 + Distro151\RunUO-2.6 + Distro151\RunUO-2.6\Server\Network\MessagePump.cs:line 127
at Server.Core.Main(String[] args) in C:\Users\Tom\Desktop\RunUO-2.6 + Distro151\RunUO-2.6 + Distro151\RunUO-2.6\Server\Main.cs:line 532
Here is the way I did that particular targeting method:
Code:
public class AbstractTarget1 : Target
{
private Mobile m_Owner;
private PaintBrush m_abstracttarget;
public AbstractTarget1() : base(1, false, TargetFlags.None)
{
}
protected override void OnTarget(Mobile from, object targeted)
{
if (targeted is Item)
{
Item subject = (Item)targeted;
subject.Name = "An abstract painting by " + m_Owner.Name.ToString();
from.AddToBackpack(new AbstractPainting1());
}
else if (targeted is Static)
{
Static staticsubject = (Static)targeted;
staticsubject.Name = "An abstract painting by" + m_Owner.Name.ToString();
from.AddToBackpack(new AbstractPainting1());
}
else
{
from.SendMessage("You cannot immagine an abstract of that!");
return;
}
}
}
public class AbstractTarget2 : Target
{
private Mobile m_Owner;
private PaintBrush m_abstracttarget;
public AbstractTarget2() : base(1, false, TargetFlags.None)
{
}
protected override void OnTarget(Mobile from, object targeted)
{
if (targeted is Item)
{
Item subject = (Item)targeted;
subject.Name = "An abstract painting by " + m_Owner.Name.ToString();
from.AddToBackpack(new AbstractPainting2());
}
else if (targeted is Static)
{
Static staticsubject = (Static)targeted;
staticsubject.Name = "An abstract painting by" + m_Owner.Name.ToString();
from.AddToBackpack(new AbstractPainting2());
}
else
{
from.SendMessage("You cannot immagine an abstract of that!");
return;
}
}
}
public class AbstractTarget3 : Target
{
private Mobile m_Owner;
private PaintBrush m_abstracttarget;
public AbstractTarget3() : base(1, false, TargetFlags.None)
{
}
protected override void OnTarget(Mobile from, object targeted)
{
if (targeted is Item)
{
Item subject = (Item)targeted;
subject.Name = "An abstract painting by " + m_Owner.Name.ToString();
from.AddToBackpack(new AbstractPainting3());
}
else if (targeted is Static)
{
Static staticsubject = (Static)targeted;
staticsubject.Name = "An abstract painting by" + m_Owner.Name.ToString();
from.AddToBackpack(new AbstractPainting3());
}
else
{
from.SendMessage("You cannot immagine an abstract of that!");
return;
}
}
}
I've attached all of the needed files for testing. I'd appreciate help with any or all of these questions. Thanks
Attachments
Last edited: