JMB Networks
Wanderer
.
Same delegate errors with rems, not sure why
Same delegate errors with rems, not sure why
JMB Networks;660892 said:before i try to fix the OnInvetoryDeath,
i need to do something elser.
when the item is in the player backpack, i want it to have their curser up as a target, and if they target anywhere on the ground, the flag goes to that location.
ive looked in teleport, for targetting. couldent get much but errors.
how do you guys think i should go about doing this?
public override DeathMoveResult OnInventoryDeath(Mobile parent)
{
FlagItem fi = new FlagItem();
fi.MoveToWorld(parent.Location, parent.Map);
Timer.DelayCall(TimeSpan.FromMilliseconds(5), DeleteFlag_TimerCallback, state);
return DeathMoveResult.MoveToBackpack;
}
public TimerCallback DeleteFlag_TimerCallback(object state)
{
this.Delete();
}
using System;
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Network;
using Server.Targeting;
namespace Server.Items
{
public class FlagItem : Item
{
[Constructable]
public FlagItem() : base( 3699 )
{
Weight = 5.0;
Hue = 0x496;
Movable = false;
}
public override void OnDoubleClick(Mobile from)
{
if (from is PlayerMobile)
{
PlayerMobile pm = (PlayerMobile)from;
if( pm.Backpack != null )
{
if (IsChildOf(pm.Backpack))
{
from.Target = new InternalTarget(this);
}
}
}
}
private class InternalTarget : Target
{
private FlagItem m_Flag;
public InternalTarget( FlagItem flag )
: base(10, true, TargetFlags.Harmful)
{
m_Flag = flag;
}
protected override void OnTarget(Mobile from, object targeted)
{
if (targeted is PlayerMobile)
{
PlayerMobile pm = (PlayerMobile)from;
Container pack = pm.Backpack;
if (pack != null)
{
pack.DropItem(m_Flag);
}
else
{
m_Flag.MoveFlagToWorld((object)from);
}
}
else if( targeted is LandTarget )
{
LandTarget lt = (LandTarget)targeted;
m_Flag.MoveToWorld(lt.Location, from.Map);
}
}
}
public override bool HandlesOnMovement { get { return true; } }
public override bool OnMoveOver(Mobile m)
{
if (m is PlayerMobile)
{
PlayerMobile pm = (PlayerMobile)m;
if (pm.Backpack != null)
{
pm.Backpack.DropItem(this);
return true;
}
}
return false;
}
public override DeathMoveResult OnInventoryDeath(Mobile parent)
{
Timer.DelayCall(TimeSpan.FromMilliseconds(5), new TimerStateCallback( MoveFlagToWorld ), parent );
return DeathMoveResult.MoveToBackpack;
}
public void MoveFlagToWorld(object from)
{
if (from is PlayerMobile)
{
PlayerMobile m = (PlayerMobile)from;
this.MoveToWorld(m.Location, m.Map);
}
}
public FlagItem( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
}
}