|
||
|
|||||||
| Script Support Get support for modifying RunUO Scripts, or writing your own! |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Forum Expert
Join Date: Sep 2006
Location: Ukraine
Posts: 879
|
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");
}
}
}
}
}
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); |
|
|
|
|
|
#2 (permalink) |
|
Forum Expert
|
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");
}
}
}
}
}
|
|
|
|
|
|
#5 (permalink) |
|
Forum Expert
|
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");
}
Code:
mobiles.Free(); |
|
|
|
|
|
#6 (permalink) |
|
Forum Expert
Join Date: Sep 2006
Location: Ukraine
Posts: 879
|
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 |
|
|
|
|
|
#7 (permalink) |
|
Account Terminated
|
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 */
}
This randomly selects one mobile found within the range. |
|
|
|
|
|
#9 (permalink) |
|
Account Terminated
|
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 );
}
Last edited by Peoharen; 05-14-2008 at 05:40 PM. |
|
|
|
|
|
#10 (permalink) |
|
Forum Expert
Join Date: Sep 2006
Location: Ukraine
Posts: 879
|
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); |
|
|
|
|
|
#11 (permalink) | |
|
Account Terminated
|
Quote:
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. |
|
|
|
|
|
|
#13 (permalink) |
|
Forum Expert
Join Date: Sep 2006
Location: Ukraine
Posts: 879
|
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 ) But i still will need example how to make effect visible only for one player. |
|
|
|
|
|
#14 (permalink) |
|
Account Terminated
|
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 ) );
}
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 ) Last edited by Peoharen; 05-14-2008 at 05:41 PM. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|