Go Back   RunUO - Ultima Online Emulation > RunUO > Script Support

Script Support Get support for modifying RunUO Scripts, or writing your own!

Reply
 
Thread Tools Display Modes
Old 05-11-2008, 07:11 AM   #1 (permalink)
Forum Expert
 
ABTOP's Avatar
 
Join Date: Sep 2006
Location: Ukraine
Posts: 825
Rep Power: 13 ABTOP is just really niceABTOP is just really niceABTOP is just really niceABTOP is just really nice
Default Target & Effect

Hello so how i can search Mobiles in 1 range from place where i targeted?
I make this code
Code:
using System;
using System.Xml;
using Server;
using System.IO;
using Server.Commands;
using Server.Items;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
using Server.Engines.Quests;
using System.Collections;
using Server.Guilds;
using Server.Targeting;


namespace Server.Commands
{
	public static class gmad
	{     
		public static void Initialize()
		{
			CommandSystem.Register( "fb", AccessLevel.Player, new CommandEventHandler( eff_OnCommand ) );                       
		}

          	[Usage( "eff" )]
          	[Description( "eff" )]
          	private static void eff_OnCommand( CommandEventArgs e )
          	{
              		Mobile from = e.Mobile;     
               		PlayerMobile pm = (PlayerMobile)from;
			//pm.FixedEffect(0x36E4,0,40,0,7);
			//pm.FixedParticles(0x36E4,0,40,5004,EffectLayer.LeftFoot);
			//pm.MovingParticles(pm,0x36E4,0,40,false,true);
			/*foreach ( Object obj in pm.GetObjectsInRange(10) )
			{
				if ( obj != null && obj is Mobile && obj != pm)
					pm.MovingParticles((Mobile)obj,0x36E4,5,17,false,true,0,0,0);
			}*/
			pm.Target = new fbtarget();
				
          	} 

		private class fbtarget : Target
		{
			public fbtarget() : base( 15, true, TargetFlags.None )
			{
			}

			protected override void OnTarget( Mobile from, object targ )
			{
				if(targ is Mobile)
					Point3D p = ((Mobile)targ).Location;

				from.SendMessage("im from");
			
				foreach ( Mobile m in GetMobilesInRange(1) )
				{
					m.SendMessage("im Mobile in range 1");
				}
				
			}
		}
          
    	}
	
}
But now i have error. In red place something i cannot declare labeled statement in statement...
Srry i need go so i fast create this thread.
So please help me search players in range from targeted place.
I see 2 functions
map.GetMobilesInRange(Point3d, range);
and
GetMobilesInRange(int);
ABTOP is online now   Reply With Quote
Old 05-11-2008, 07:32 AM   #2 (permalink)
Forum Expert
 
Lokai's Avatar
 
Join Date: Aug 2003
Location: Bergen, NY (Rochester)
Age: 40
Posts: 1,349
Rep Power: 54 Lokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond repute
Send a message via ICQ to Lokai Send a message via MSN to Lokai Send a message via Yahoo to Lokai
Default

Try this (not sure about the Land Target part, but it compiled fine):

Code:
using System;
using System.Xml;
using Server;
using System.IO;
using Server.Commands;
using Server.Items;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
using Server.Engines.Quests;
using System.Collections;
using Server.Guilds;
using Server.Targeting;

namespace Server.Commands
{
    public static class gmad
    {
        public static void Initialize()
        {
            CommandSystem.Register("fb", AccessLevel.Player, new CommandEventHandler(eff_OnCommand));
        }
        [Usage("eff")]
        [Description("eff")]
        private static void eff_OnCommand(CommandEventArgs e)
        {
            Mobile from = e.Mobile;
            PlayerMobile pm = (PlayerMobile)from;
            //pm.FixedEffect(0x36E4,0,40,0,7);
            //pm.FixedParticles(0x36E4,0,40,5004,EffectLayer.LeftFoot);
            //pm.MovingParticles(pm,0x36E4,0,40,false,true);
            /*foreach ( Object obj in pm.GetObjectsInRange(10) )
            {
                if ( obj != null && obj is Mobile && obj != pm)
                    pm.MovingParticles((Mobile)obj,0x36E4,5,17,false,true,0,0,0);
            }*/
            pm.Target = new fbtarget();
        }
        private class fbtarget : Target
        {
            public fbtarget()
                : base(15, true, TargetFlags.None)
            {
            }
            protected override void OnTarget(Mobile from, object targ)
   {
                IPooledEnumerable mobiles;
                from.SendMessage("im from");
                if (targ is Mobile)
                {
                    mobiles = ((Mobile)targ).GetMobilesInRange(1);
                }
                else if (targ is StaticTarget)
                {
                    Item i = new Item(((StaticTarget)targ).ItemID);
                    i.Location = ((StaticTarget)targ).Location;
                    mobiles = i.GetMobilesInRange(1);
                    i.Delete();
                }
                else if (targ is LandTarget)
                {
                    Item i = new Item(((LandTarget)targ).TileID | 0x3FF);
                    i.Location = ((LandTarget)targ).Location;
                    mobiles = i.GetMobilesInRange(1);
                    i.Delete();
                }
                else return;
                foreach (Mobile m in mobiles)
                {
                    m.SendMessage("im Mobile in range 1");
                }
   }
        }
    }
}
Lokai is online now   Reply With Quote
Old 05-11-2008, 05:28 PM   #3 (permalink)
Forum Expert
 
ABTOP's Avatar
 
Join Date: Sep 2006
Location: Ukraine
Posts: 825
Rep Power: 13 ABTOP is just really niceABTOP is just really niceABTOP is just really niceABTOP is just really nice
Default

Ok explain few thing please:
1)What is IPooledEnumerable?
2)What is StaticTarget?
3)What is LandTarget?
4)What different 2 and 3.
ABTOP is online now   Reply With Quote
Old 05-11-2008, 06:34 PM   #4 (permalink)
Forum Expert
 
Lokai's Avatar
 
Join Date: Aug 2003
Location: Bergen, NY (Rochester)
Age: 40
Posts: 1,349
Rep Power: 54 Lokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond repute
Send a message via ICQ to Lokai Send a message via MSN to Lokai Send a message via Yahoo to Lokai
Default

Quote:
Originally Posted by ABTOP View Post
Ok explain few thing please:
1)What is IPooledEnumerable?
A collection. We have to use it because GetMobilesInRange is looking for one.

Quote:
Originally Posted by ABTOP View Post
2)What is StaticTarget?
Static objects in the world, like frozen buildings, deco, etc.

Quote:
Originally Posted by ABTOP View Post
3)What is LandTarget?
Land tiles, like grass, road, etc.

Quote:
Originally Posted by ABTOP View Post
4)What different 2 and 3.
That should be self-explanatory now.
Lokai is online now   Reply With Quote
Old 05-11-2008, 06:44 PM   #5 (permalink)
Forum Expert
 
Lokai's Avatar
 
Join Date: Aug 2003
Location: Bergen, NY (Rochester)
Age: 40
Posts: 1,349
Rep Power: 54 Lokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond reputeLokai has a reputation beyond repute
Send a message via ICQ to Lokai Send a message via MSN to Lokai Send a message via Yahoo to Lokai
Default

Also, since we created a new collection, it is probably best if we free up the resources associated with it using the built in "Free()" method.

After this:

Code:

foreach (Mobile m in mobiles)
{
m.SendMessage("im Mobile in range 1");
}
Add this:

Code:
 
mobiles.Free();
Lokai is online now   Reply With Quote
Old 05-12-2008, 05:14 PM   #6 (permalink)
Forum Expert
 
ABTOP's Avatar
 
Join Date: Sep 2006
Location: Ukraine
Posts: 825
Rep Power: 13 ABTOP is just really niceABTOP is just really niceABTOP is just really niceABTOP is just really nice
Default

Ok thank you i will compile it when i have free time.

Now as you can see thread has name Target & Effect.
So can you give me answer on this question.

1)Can i stop MovingParticle in some time? For example fireball not reach his target and i delete it or make explosion.

2)Can i make effect only for one player? This effect must see only one player.

Thanks
ABTOP is online now   Reply With Quote
Old 05-13-2008, 04:27 AM   #7 (permalink)
Forum Expert
 
Peoharen's Avatar
 
Join Date: Dec 2004
Location: USA
Age: 23
Posts: 896
Rep Power: 83 Peoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond repute
Send a message via Yahoo to Peoharen
Default

1. No.

2.
Code:
		protected override void OnTarget( Mobile from, object o )
		{
			IPoint3D p = (IPoint3D)o;

			if ( p == null && from == null && from.Map == null )
				return;

			List<Mobile> targets = new List<Mobile>();

			foreach ( Mobile m in from.Map.GetMobilesInRange( new Point3D( p ), 1 ) )
				if ( m != null && m.AccessLevel == AccessLevel.Player )
					targets.Add( m );

			if ( targets.Count <= 0 )
				return;

			Mobile target = targets[Utility.Random( targets.Count )];

			if ( target == null )
				return;

			/* Your effects here */
		}
Change as needed for your range.

This randomly selects one mobile found within the range.
Peoharen is offline   Reply With Quote
Old 05-13-2008, 05:03 PM   #8 (permalink)
Forum Expert
 
ABTOP's Avatar
 
Join Date: Sep 2006
Location: Ukraine
Posts: 825
Rep Power: 13 ABTOP is just really niceABTOP is just really niceABTOP is just really niceABTOP is just really nice
Default

1 Bad(
2 You not really understand what i mean. I mean effect for one player. For example you see this effect and im dont.
ABTOP is online now   Reply With Quote
Old 05-13-2008, 05:20 PM   #9 (permalink)
Forum Expert
 
Peoharen's Avatar
 
Join Date: Dec 2004
Location: USA
Age: 23
Posts: 896
Rep Power: 83 Peoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond repute
Send a message via Yahoo to Peoharen
Default

using System.Collections;
using System.Collections.Generic;
using Server.Network;

Code:
		protected override void OnTarget( Mobile from, object o )
		{
			IPoint3D p = (IPoint3D)o;

			if ( p == null && from == null && from.Map == null )
				return;

			List<Mobile> targets = new List<Mobile>();

			foreach ( Mobile m in from.Map.GetMobilesInRange( new Point3D( p ), 1 ) )
				if ( m != null && m.NetState != null && m.AccessLevel == AccessLevel.Player )
					targets.Add( m );

			if ( targets.Count <= 0 )
				return;

			Mobile target = targets[Utility.Random( targets.Count )];
			target.ProcessDelta();
			Packet packet = Packet.Acquire( new MovingEffect( from, target, itemID, speed, duration, fixeddirection, explodes, hue, rendermode ) );
			target.NetState.Send( packet );
		}
Fill in the red.

Last edited by Peoharen; 05-14-2008 at 05:40 PM.
Peoharen is offline   Reply With Quote
Old 05-13-2008, 05:34 PM   #10 (permalink)
Forum Expert
 
ABTOP's Avatar
 
Join Date: Sep 2006
Location: Ukraine
Posts: 825
Rep Power: 13 ABTOP is just really niceABTOP is just really niceABTOP is just really niceABTOP is just really nice
Default

omg )) what is that?)))))))
If it will be work it will be GREATTTTT.
Ok few questions.
1)What is target.ProcessDelta();
2)What is Packet.Acquire(....); Where i can see examples with that code?
3)Where you get state? state.Send(packet);
ABTOP is online now   Reply With Quote
Old 05-13-2008, 08:32 PM   #11 (permalink)
Forum Expert
 
Peoharen's Avatar
 
Join Date: Dec 2004
Location: USA
Age: 23
Posts: 896
Rep Power: 83 Peoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond repute
Send a message via Yahoo to Peoharen
Default

Quote:
Originally Posted by ABTOP View Post
omg )) what is that?)))))))
If it will be work it will be GREATTTTT.
Ok few questions.
1)What is target.ProcessDelta();
2)What is Packet.Acquire(....); Where i can see examples with that code?
3)Where you get state? state.Send(packet);
1.
ProcessDelta updates and resyncs the connected users information of their character with the server. The MovingEffect method calls it before sending the effect packet so I included it. (see Mobile.cs & Effect.cs in the server files)

2.
Try looking in Packets.cs (server).

3.
Fixed.
Peoharen is offline   Reply With Quote
Old 05-14-2008, 03:24 AM   #12 (permalink)
Forum Expert
 
ABTOP's Avatar
 
Join Date: Sep 2006
Location: Ukraine
Posts: 825
Rep Power: 13 ABTOP is just really niceABTOP is just really niceABTOP is just really niceABTOP is just really nice
Default

Thanks i'll try
ABTOP is online now   Reply With Quote
Old 05-14-2008, 11:01 AM   #13 (permalink)
Forum Expert
 
ABTOP's Avatar
 
Join Date: Sep 2006
Location: Ukraine
Posts: 825
Rep Power: 13 ABTOP is just really niceABTOP is just really niceABTOP is just really niceABTOP is just really nice
Default

Hmm i have more errors with ur code.
Also i cant understand where you get function MovingEffect with ur parametrs.
I have all functions so there
Code:
void MovingEffect( IEntity to, int itemID, int speed, int duration, bool fixedDirection, bool explodes )
void MovingEffect( IEntity to, int itemID, int speed, int duration, bool fixedDirection, bool explodes, int hue, int renderMode )
So my problem without solution))) But now i have one crazy idea)) I recompile server and add there function for send effect in some area.
But i still will need example how to make effect visible only for one player.
ABTOP is online now   Reply With Quote
Old 05-14-2008, 05:24 PM   #14 (permalink)
Forum Expert
 
Peoharen's Avatar
 
Join Date: Dec 2004
Location: USA
Age: 23
Posts: 896
Rep Power: 83 Peoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond reputePeoharen has a reputation beyond repute
Send a message via Yahoo to Peoharen
Default

Effect.cs, line 318, dunno what SVN version I have.

Code:
		public static void SendMovingParticles( IEntity from, IEntity to, int itemID, int speed, int duration, bool fixedDirection, bool explodes, int hue, int renderMode, int effect, int explodeEffect, int explodeSound, EffectLayer layer, int unknown )
		{
			if ( from is Mobile )
				((Mobile)from).ProcessDelta();

			if ( to is Mobile )
				((Mobile)to).ProcessDelta();

			Map map = from.Map;

			if ( map != null )
			{
				Packet, particles = null regular = null;

				IPooledEnumerable eable = map.GetClientsInRange( from.Location );

				foreach ( NetState state in eable )
				{
					state.Mobile.ProcessDelta();

					if ( SendParticlesTo( state ) )
					{
						if ( particles == null )
							particles = Packet.Acquire( new MovingParticleEffect( from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode, effect, explodeEffect, explodeSound, layer, unknown ) );

						state.Send( particles );
					}
					else if ( itemID > 1 )
					{
						if ( regular == null )
							regular = Packet.Acquire( new MovingEffect( from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode ) );

						state.Send( regular );
					}
				}

				Packet.Release( particles );
				Packet.Release( regular );

				eable.Free();
			}

			//SendPacket( from.Location, from.Map, new MovingParticleEffect( from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode, effect, explodeEffect, explodeSound, unknown ) );
		}
I pretty much just pasted the code from RunUOs script into my post. I dunno why you're having parameter problems. I suppose I'll update my SVN and give it a shot later.

Edit, tried my posted code. it had ONE error.
if ( m != null && target.NetState != null && m.AccessLevel == AccessLevel.Player )
should be
if ( m != null && m.NetState != null && m.AccessLevel == AccessLevel.Player )
Attached Files
File Type: cs Test.cs (1.1 KB, 1 views)

Last edited by Peoharen; 05-14-2008 at 05:41 PM.
Peoharen is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5