Targeting only LOS mobs within a range

Need help with a macro you are writing? Ask here!

Moderator: MacroQuest Developers

omper
a ghoul
a ghoul
Posts: 110
Joined: Sat Dec 06, 2003 10:46 pm

Targeting only LOS mobs within a range

Post by omper » Mon May 31, 2004 10:18 am

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

User avatar
blueninja
a grimling bloodguard
a grimling bloodguard
Posts: 541
Joined: Thu Aug 28, 2003 7:03 am
Location: Göteborg, Sweden

Post by blueninja » Mon May 31, 2004 11:13 am

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.

omper
a ghoul
a ghoul
Posts: 110
Joined: Sat Dec 06, 2003 10:46 pm

Post by omper » Mon May 31, 2004 4:20 pm

so how do i change this to a target next mob within that radius.. ???

valbarreq
orc pawn
orc pawn
Posts: 10
Joined: Tue Feb 01, 2005 2:57 pm

hmm

Post by valbarreq » Tue Jun 21, 2005 11:16 am

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...

User avatar
gimp
a grimling bloodguard
a grimling bloodguard
Posts: 584
Joined: Fri Oct 29, 2004 9:28 am
Location: internet

Post by gimp » Tue Jun 21, 2005 11:33 am

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.
Last edited by gimp on Tue Jun 21, 2005 11:41 am, edited 2 times in total.

User avatar
gimp
a grimling bloodguard
a grimling bloodguard
Posts: 584
Joined: Fri Oct 29, 2004 9:28 am
Location: internet

Post by gimp » Tue Jun 21, 2005 11:40 am

omper wrote:so how do i change this to a target next mob within that radius.. ???
/target next searchcriteria

DigitalMocking
a grimling bloodguard
a grimling bloodguard
Posts: 620
Joined: Mon Apr 04, 2005 5:53 pm

Post by DigitalMocking » Tue Jun 21, 2005 12:00 pm

/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

User avatar
gimp
a grimling bloodguard
a grimling bloodguard
Posts: 584
Joined: Fri Oct 29, 2004 9:28 am
Location: internet

Post by gimp » Tue Jun 21, 2005 12:12 pm

nice code digitalmocking, *yoink*

Morlock
orc pawn
orc pawn
Posts: 24
Joined: Fri Jun 24, 2005 5:32 am

One problem that may need to be addressed

Post by Morlock » Fri Jul 08, 2005 1:25 am

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.

DigitalMocking
a grimling bloodguard
a grimling bloodguard
Posts: 620
Joined: Mon Apr 04, 2005 5:53 pm

Post by DigitalMocking » Fri Jul 08, 2005 1:33 am

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.

User avatar
fearless
Not a Psychic
Posts: 2684
Joined: Wed Mar 10, 2004 3:52 pm

Post by fearless » Fri Jul 08, 2005 9:59 am

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?
Reading . . . it's not just for me.

[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
[quote="Ccomp5950"]Fearless showed me the light, you too shall learn.[/quote]