If npc is targeted...do this...help!?

Need some help with that macro you're working on or aren't quite sure how to get your macro to do something? Ask here!

Moderator: MacroQuest Developers

anon123
orc pawn
orc pawn
Posts: 10
Joined: Sat Jun 05, 2004 8:34 pm

If npc is targeted...do this...help!?

Post by anon123 » Sun Jun 06, 2004 1:33 am

Okay, I want to simply do an event if an npc is successfuly targeted...

Not sure how exactly the /if command works but from reading other's posts it should go something like this i believe...


/target Billy

/if (${Target}) {
/say "Billy is targeted!"}

/else /if ($!{Target}) {
/say "Billy is NOT present!"}

...

So this should target billy using the target command, and if he is present say he is targeted, but if he is not present it will say so.

Simple I know, but I'm not sure of the syntax yet, as I am a brand noob!

Thanks.

Drumstix42
a grimling bloodguard
a grimling bloodguard
Posts: 808
Joined: Mon May 03, 2004 4:25 pm

Post by Drumstix42 » Sun Jun 06, 2004 2:39 am

First of all this is the older forum. Post help in the the MQ2 section.

secondly, this is how I would do it, using /echo:

Code: Select all

/target Billy

/if (${Target.ID}) {
   /echo Billy is targeted!
} else {
   /say Billy is NOT present!
}
Not sure on the elseif syntax. But inthis case, there's only 2 options, your targeting something or your not.

For puting in like /say, you need to set a variable, I forget.

Thirdly, post your coding withing phpBB code tags [ code] [ / code ] (without the spaces; there is a button for it in the posting screen)

Chill
Contributing Member
Contributing Member
Posts: 435
Joined: Fri May 07, 2004 5:06 pm
Location: Erie, PA

Re: If npc is targeted...do this...help!?

Post by Chill » Sun Jun 06, 2004 2:08 pm

anon123 wrote:Okay, I want to simply do an event if an npc is successfuly targeted...
If you know you want to target a specific npc I would refine your code a bit:

Code: Select all

/declare name string inner Billy
/target npc ${name}
/delay 1
/if (${Target.CleanName.Equal[${name}]}) { 
   /echo Billy is targeted! 
} else { 
   /say Billy is NOT present! 
}
If this is going to be looped or you are going to be doing this a lot, you might want to be careful about targeting. If you just want to see if Billy is present, you could also use:

Code: Select all

/if (${SpawnCount[npc Billy]}) /echo Billy in zone

Oid
a snow griffon
a snow griffon
Posts: 416
Joined: Thu Oct 17, 2002 3:26 am
Contact:

Post by Oid » Sun Jun 06, 2004 5:20 pm

No

Code: Select all

/if ($String[$Target.CleanName}].Equal[${Name}])
Smokey the Lax says only you can prevent reproduction.

Chill
Contributing Member
Contributing Member
Posts: 435
Joined: Fri May 07, 2004 5:06 pm
Location: Erie, PA

Post by Chill » Sun Jun 06, 2004 8:02 pm

Oid wrote:No

Code: Select all

/if ($String[$Target.CleanName}].Equal[${Name}])
No, well unless youre into dumbass repitive stuff like converting strings to strings.
readme.chm wrote: spawn

Members
...
string CleanName The "cleaned up" name
Target.CleanName is already a string, so there is no need to convert it.

If, for whatever reason, you want to convert it anyway like Oid suggests, then you need some more brackets:

Code: Select all

/if (${String[${Target.CleanName}].Equal[${name}]})