RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

move to ground

JMB Networks

Wanderer
.

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?
 

Malaperth

Wanderer
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?

In my opinion, that would be way too much work to even try to figure out how to even attempt it than benefit you would get out of it.

I am also convinced that you will need to move your code into PlayerMobile in order to get it to drop to the ground on player death. I can find no method in Item that seems to suit the purpose, but sharper eyes than mine may find something.
 

JMB Networks

Wanderer
.

im gonna go check out commands - move

if anyone has any ideas how to get this to work would be much apreciated. cant seem to get it right
 

remnant

Wanderer
I don't think you can force it to be a target the entire time they have the flag. Client side limits this possibility.
Just make it so they have to double click the flag. They can always make a macro in razor for it.
 

remnant

Wanderer
Well, the only thing I can think of for OnInventoryDeath is to make a Timer delete it after the DeathMoveResult is finished:

Code:
        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();
        }

Try that.
 

JMB Networks

Wanderer
.

reading the on invetory death atm, but how would i go about doing the targetting? i tried getting some info out of teleport and targetting but didnt get much information
 

remnant

Wanderer
Here:
Code:
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();
		}
	}
}
 

JMB Networks

Wanderer
.

works good but i cant seem to get it so the target comes up at (OnMoveOver) too, instead of just having on double clikc i figured id have both
 
Top