*I have a RunUO Version 2.1 setup on my shard*
Well . . I have driven my brain to mush on this one with no luck so . . here I am looking for a lesson.
I made a Trap item and now I am trying to make a TrapperKit so players can DBL Click on the Kit then select a LandTile on which to place the trap. The idea is for them to try luring a monster to walk over the trap.
I have had several Null Ref crashes in the "protected override void OnTarget" section. That problem may still be there but now my recent changes will not even Compile.
I'm having trouble recognizing a LandTile as a target location and then being able to place the Trap on that LandTile location.
Here are my most recent Errors:
and . . Here is my most recent script attempt:
Can anyone help me recognize a Landtile as the Target location and then MoveToWorld my trap on that location?
Help from the community is appreciated.
Many Thanks
Well . . I have driven my brain to mush on this one with no luck so . . here I am looking for a lesson.
I made a Trap item and now I am trying to make a TrapperKit so players can DBL Click on the Kit then select a LandTile on which to place the trap. The idea is for them to try luring a monster to walk over the trap.
I have had several Null Ref crashes in the "protected override void OnTarget" section. That problem may still be there but now my recent changes will not even Compile.
I'm having trouble recognizing a LandTile as a target location and then being able to place the Trap on that LandTile location.
Here are my most recent Errors:
Code:
Errors:
+ Customs/Crafting - Animal Traps/TrapperKit.cs:
CS1061: Line 109: 'object' does not contain a definition for 'Location' and no extension method 'Location' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
CS1061: Line 109: 'object' does not contain a definition for 'Map' and no extension method 'Map' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
and . . Here is my most recent script attempt:
Code:
using System;
using Server;
using System.Text;
using Server.Misc;
using Server.Gumps;
using Server.Items;
using Server.Multis;
using Server.Network;
using Server.Mobiles;
using Server.Commands;
using Server.Targeting;
using System.Collections;
using System.Collections.Generic;
namespace Server.Items
{
public class TrapperKit : Item
{
private int m_UsesRemaining;
[CommandProperty( AccessLevel.GameMaster )]
public int UsesRemaining
{
get{ return m_UsesRemaining; }
set{ m_UsesRemaining = value; InvalidateProperties(); }
}
[Constructable]
public TrapperKit() : base( 0x1EB7 )
{
Name = "Trapper's Kit";
ItemID = 0x1EB7;
Weight = 0.10;
Hue = 0;
m_UsesRemaining = 25;
}
public override void AddNameProperties( ObjectPropertyList list )
{
base.AddNameProperties( list );
if ( m_UsesRemaining >= 0 )
list.Add( 1060658, "Uses Remaining\t{0}", m_UsesRemaining.ToString() );
}
public override void OnDoubleClick( Mobile from )
{
if ( !IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
return;
}
else
{
if ( m_UsesRemaining > 1 )
{
m_UsesRemaining -= 1;
InvalidateProperties();
from.SendMessage( "Place trap where?" );
from.Target = new InternalTarget();
}
else if ( m_UsesRemaining == 1 )
{
from.SendMessage( "Place trap where?" );
from.Target = new InternalTarget();
this.Delete();
return;
}
}
}
private class InternalTarget : Target
{
private AnimalSpikeTrap m_AnimalSpikeTrap;
public InternalTarget() : base( 3, true, TargetFlags.None )
{
}
protected override void OnTarget( Mobile from, object targeted )
{
LandTarget land = targeted as LandTarget;
if ( targeted == null )
{
return;
}
if ( land == null )
{
return;
}
if ( (targeted != null) && targeted == land)
{
return;
}
if ( !from.CanSee( targeted ) )
{
from.SendLocalizedMessage( 500237 ); // Target can not be seen.
return;
}
if ( (targeted != null) && targeted is LandTarget)
{
from.SendMessage( "You set a trap" );
m_AnimalSpikeTrap.Map = from.Map;
m_AnimalSpikeTrap.MoveToWorld(targeted.Location, targeted.Map);
}
else
{
from.SendMessage( "You cannot set a trap there" );
return;
}
}
protected override void OnTargetOutOfRange( Mobile from, object targeted )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 502825 ); // That location is too far away
}
}
public TrapperKit( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 1 ); // version
writer.Write( (int) m_UsesRemaining );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
m_UsesRemaining = (int)reader.ReadInt();
}
}
}
Can anyone help me recognize a Landtile as the Target location and then MoveToWorld my trap on that location?
Help from the community is appreciated.
Many Thanks