Trigger to match variable lengths?

Posted by Sleeve on Sun 16 Jun 2002 06:54 PM — 8 posts, 25,306 views.

#0
Hello all, I am having a bit of trouble matching a trigger to a variable length. The trigger needs to match something like:

Your quest is to find * and deliver the punishment

But the problem is that depending on the mobile's name, the * can be 1 word to 7 words. Sometimes it can be something like "a troll" or sometimes it can be "a big, scary green troll". So far, I have only had success on matching if the mobile's name is only 1 word. Does that mean that I have to add 7 different triggers to match for varying lengths? Like:

Your quest is to find * and deliver the punishment
Your quest is to find * * and deliver the punishment
Your quest is to find * * * and deliver the punishment
etc.

Any help would be greatly appreciated. Thanks. :)
USA #1
Hmm. No it means using a script. Something like this should work:
sub getname(trigname, output, wildcards)
  dim mob, temp
  temp = split(wildcards(1)," ") 'Turns the words into an array.
  mob = temp(ubound(temp)) 'Retrieves the "last" word in the array (assumed to be the monsters name).
  ... 'Use world.setvariable to store the name for later or a world.send to execute a command. You where a bit unclear about what you intended here. ;)
end sub

As long as the last word is 'always' the monster you should be OK. If they starts sending you stuff like 'a horrible troll - wearing a green coat' you would have to do something a 'lot' more complicated.
Amended on Sun 16 Jun 2002 08:29 PM by Shadowfyr
#2
Well, not only is the mob's name sometimes not the last word, but there are times where I'm not going to be able to use only 1 word for the mob's name.
Example, I am using this for an auto-tracking of the mob. If I have a quest to seek out a "large cat" instead of a "grey cat", I can't attempt to simply "track cat" since it could lead me to the wrong one. I need to be able to "track 'large cat'". That's why I was hoping to be able to use the mob's name as a whole, not just the last word.
Thanks for the help though. I'll keep trying. :)
USA #3
Hmm. Ack!!

Well... Then:
sub getname(trigname, output, wildcards)
  dim test, test2, test3, mods, mobs
  mods = "large,small,grey,black"
  mobs = "cat,troll,dog"
  for each test in split(mods,",")
    for each test2 in split(mobs,",")
      test3 = test & " " & test2
      if InStr(wildcards(1),test3) then
        ... 'Do whatever (using test3).
        exit sub
      endif
    next
  next
end sub

The only drawback is that you need to provide all the possible modifiers and monster types, but this is 'probably' the only certain way of having it work. It may be possible to shorten it a bit by combining my previous one, instead of searching every mob type though (assuming again that the modifiers are 'only' in front of the name). ;)

i.e.:
sub getname(trigname, output, wildcards)
  dim test, test2, test3, mods
  mods = "large,small,grey,black"
  for each test in split(mods,",")
    if InStr(wildcards(1),test) then
      test2 = split(wildcards(1)," ")
      test3 = test & " " & test2(ubound(test2))
      ... 'Do whatever (using test3).
      exit sub
    endif
  next
end sub
Amended on Sun 16 Jun 2002 09:48 PM by Shadowfyr
#4
Thanks for taking the time to help me out Shadowfyr, but I don't think this will be to helpful either. :( Then the problem arises where the mob's have names, for example "Mayor Smith" or whatnot, not to mention having multiple modifiers before the mob's name or as you pointed out, modifiers not necessarily preceding the mob's name.
If it's simply easier to add the 7 triggers to check for varying lengths of a mob's name, then by all means I am not averse to doing that. I was just wondering if there was a simpler way than adding 7 triggers, to encompass them all in 1 trigger somehow.
Australia Forum Administrator #5
Are you making this more complicated than it needs to be? If the trigger is:


Your quest is to find * and deliver the punishment


Then that will match any number of words (* is any length text, not just a word).

Thus, if you receive:


Your quest is to find a big, scary green troll and deliver the punishment


Then wildcard 1 will be "a big, scary green troll".

Then by sending:


track %1


It will send:


track a big, scary green troll


Is this what you want, and if not, in what way?
USA #6
I suspect that some of those modifiers are just modifiers. i.e. the mud he plays expects 'green troll' or possibly 'scary green troll', but not 'a big, scary green troll'. If it did then his first attempt would have worked.

As an anti-botting feature it is definitely effective.
Amended on Sun 16 Jun 2002 10:44 PM by Shadowfyr
#7
Thanks Nick, I found the problem, my regular expression had an error in it. I'm so embarassed, sorry about that. :) Thank you both Shadowfyr and Nick.