PDA

View Full Version : affect only named mobs?


bloatedseachicken
08-30-2014, 01:49 PM
hi,

i need help with an if statement that will only select name mobs.

For example, i tried this, but it's not working

if ($mname =~ #) then blah blah.

What is the correct way?

Also tried this.

If ($mname->GetCleanName() =~/#/i) then blah blah.

Thanks

demonstar55
08-30-2014, 02:16 PM
You can do $mname =~ /^#/ I think? Might also help explain what your trying to accomplish. I assume you just want to do something with all named mobs in the global file?

Kingly_Krab
08-30-2014, 02:17 PM
Try this: sub EVENT_SPAWN {
if (substr($npc->GetName(), 0, 1) eq "#") {
blah;
}
}

bloatedseachicken
08-30-2014, 04:39 PM
Yes, global file... thanks guys! Will try those out

bloatedseachicken
08-30-2014, 10:32 PM
hmm cant get either of those to work either :(

is there a way to recognize only named in a script? like how does named get singled out? they don't all have # in front right? I know with MQ2, you can /target named and it will locate and target the named mobs in zone...that may have nothing to do with this, but just made me think there may be a way to do it in perl?

thanks either way

demonstar55
08-31-2014, 12:51 AM
MQ2's function just excludes a bunch of spawn types then excludes ones that start with A or An, then excludes a bunch of other stuff, then checks if the first character is an upper case letter or #.

bloatedseachicken
08-31-2014, 07:31 AM
ok, so this works as long as the mob has # in the name

sub EVENT_SPAWN {
if (substr($npc->GetName(), 0, 1) eq "#") {
blah;
}
}

but...how can I make it pick out mobs with an upper case letter at the beginning of the name? I saw demonstar use this ^, is that the function needed? how to apply to the above if statement?

thanks so much guys!

demonstar55
08-31-2014, 11:48 AM
The '^' means front of the line

bloatedseachicken
08-31-2014, 12:42 PM
is there some way to use =~ /([A-Z])/ in there to select only Uppercase mobs?

im at a loss lol

bloatedseachicken
08-31-2014, 12:59 PM
woot this worked

if($mname =~ /([A-Z])/)

:P