Page 1 of 1

Targeting only LOS mobs within a range

Posted: Mon May 31, 2004 10:18 am
by omper
I am looking to target only mobs that are in LOS.. if they are not then to switch to next mob .. and this is what i have started with.. it gives me all mobs in a sphere of 150 game feet. but that will get stuff that i cant cast ensnare on..

Code: Select all

/target npc radius 150
		/if (!${Target.ID}) /goto :loopgainexp
  	/face nolook fast
	/call Cast "ensnare" 
	/delay 2s
	/attack on
So again i am looking to get rid of the ones that are not in Line of Sight. Thanks for your help.


Omper

Posted: Mon May 31, 2004 11:13 am
by blueninja
There is no good way of determining LoS availiable. You could just catch the event for the spell failure message, not very pretty but it works. Since I see you use the spell.inc routines to cast your spell that might already be caught.

Posted: Mon May 31, 2004 4:20 pm
by omper
so how do i change this to a target next mob within that radius.. ???

hmm

Posted: Tue Jun 21, 2005 11:16 am
by valbarreq
there is ONE way...if you use the "cycle thru NPC's key" supplied by EQ itself (using /keypress) then it only cycles thru NPCs in front of you and in visual range...

Posted: Tue Jun 21, 2005 11:33 am
by gimp
a simple solution to your problem would be

Code: Select all

      /if (!${Target.ID} || !{Target.LineOfSight}) /goto :loopgainexp 
but to make some more useful code, you could use

Code: Select all

/if (${Spawn[searchcriteria].LineOfSight]}) {
 ...
}
to determinate this without targeting. this would be The Right Way To Do It (tm), as /target'ing everything around you constantly probably would make both 1 and 2 people wonder what you are up to

i believe you can cycle thru a spawn list with the "next" parameter (you can with the /target command), but i havent looked into that myself very much. i use similar code above to check for stuff like:

trigger event on "a npc healer mob begins to cast a spell <Complete Healing>"

if "a npc healer" is in line of sight, target it and cast stun spell.

Posted: Tue Jun 21, 2005 11:40 am
by gimp
omper wrote:so how do i change this to a target next mob within that radius.. ???
/target next searchcriteria

Posted: Tue Jun 21, 2005 12:00 pm
by DigitalMocking
/target is pretty buggy for cycling through targets, here's the code I use to check for mobs and adds, works very well:

Code: Select all

Sub GetTarget
  /declare s   int local 
  /declare i   int local 1
  /for i 1 to 4
    /varset s ${NearestSpawn[${i},npc radius 200].ID} 
    /if (${Spawn[${s}].Type.Equal["Corpse"]} || !${Spawn[${s}].LineOfSight}) /next i
      /delay 1
      /squelch /target id ${s}
      /return
    } 
  /next i
/return

Posted: Tue Jun 21, 2005 12:12 pm
by gimp
nice code digitalmocking, *yoink*

One problem that may need to be addressed

Posted: Fri Jul 08, 2005 1:25 am
by Morlock
I have incorporated the code from DigitalMocking. Big Thanks! However if there are no mobs in LOS I will target myself and bein to attack myself. Any advice? Thanks.

Posted: Fri Jul 08, 2005 1:33 am
by DigitalMocking

Code: Select all

 
/if (${s}) /squelch /target id ${s}

or: 

/if (${s} != ${Me.ID}) /squelch /target id ${s}
or about a dozen other ways to do the same thing.

Posted: Fri Jul 08, 2005 9:59 am
by fearless
DigitalMocking wrote:/target is pretty buggy for cycling through targets, here's the code I use to check for mobs and adds, works very well:

Code: Select all

Sub GetTarget
  /declare s   int local 
  /declare i   int local 1
  /for i 1 to 4
    /varset s ${NearestSpawn[${i},npc radius 200].ID} 
    /if (${Spawn[${s}].Type.Equal["Corpse"]} || !${Spawn[${s}].LineOfSight}) /next i
      /delay 1
      /squelch /target id ${s}
      /return
    } 
  /next i
/return
DM: Are you missing a { in there?