Page 1 of 1

using pattern matching in triggers

Posted: Mon Mar 19, 2012 7:15 pm
by Huggly
So, I took a look at this program. Can't figure out how to implement a trigger that will match for multiple people.

Just as an example, if someone misses jumping in Resplendent temple, the emote is "xzy failed to make the sacrifice"

How would I create a trigger that will work for any name replacing xyz.

You can do this in GTT using {s} in the emote, and in the audio and text display portions.

Re: using pattern matching in triggers

Posted: Tue Mar 20, 2012 7:37 am
by Gimagukk
For compatibility and ease of use, I have added support for the {S} token. You will need to get the latest update (from the blue menu bar in the app, select "Check for Updates").
------------------------------------

You can also match it using regular expressions. Using your example, let's say there are multiple things that the player could fail to do, such as "xyz failed to make the sacrifice" or "xyz failed to run away":
Search Text: (?<name>.+) failed to (?<action>.+)
Use Regular Expressions checkbox: Checked
Display Text: Failure: ${name} did not ${action}

The search text is basically equivalent of multiple {S} tags to match pieces of the trigger. The (?<xxxx>yyyy) notation just says "this part of the trigger is a section that should match "yyyy" which I would like to refer to as variable ${xxxx} later". The "yyyy" in this case is ".+", which is just a wildcard that matches any string fo characters. (Thinking about this now, I will probably add support for tags like {S1}, {S2}, etc. tonight to make this type of trigger easier to set up.)

------------------------------------

While regular expressions are admittedly more complicated to set up, they allow for more complicated trigger matches. For example, if I wanted a trigger that would fire whenever I critically nuke a mob for 80k+ damage (but not 79k or lower), I can use the following:
Search Text: You deliver a critical blast! \((?<dmg>(\d{6})|([8-9]\d{4}))\)
Display Text: You crit for ${dmg}!

That search text is basically saying if you see the "You deliver a critical blast" line followed by a number that is either (a) 5 digits long and starts with and 8 or a 9, or (b) 6 digits long, consider it a match and store the matched number in a variable called ${dmg}.

------------------------------------

Another example is VoA where I want a trigger to alert me when my name is in a list of characters that are called out. The trigger text is "Voice of Ryken shouts 'John, Jack, and Fred: Find new targets for your actions!'" I want to be alerted if my name (Fred) is called, but not if my buddy Freddie is called.
Search Text: Voice of Ryken shouts(.+('|\s){C}(,|:).+|)Find new targets for your actions!'
Display Text: {C} Change Targets!

This will match if it finds my character's name (using GINA's {C} tag) in the list of players called.

Re: using pattern matching in triggers

Posted: Tue Mar 20, 2012 4:44 pm
by Huggly
Thanks for adding the {s} it will allow triggers imported from GTT to work without modification.

I was getting hung up on the regex portion of the search text. I misunderstood that it had to be wrapped in curly brackets. The webpage doesn't explain it quite as well as your post did.

Re: using pattern matching in triggers

Posted: Tue Mar 20, 2012 6:38 pm
by Gimagukk
Thanks for the feedback. I'll work on adding a section to the web site to explain the regex feature in more detail, as well as adding more regex samples to the Examples package in the Library.

Re: using pattern matching in triggers

Posted: Thu Apr 05, 2012 4:31 pm
by brogett
With the new language requirements in VoA, I'm wondering if it could be possible to implement a simple approximate matching algorithm. This is hard for regular expressions (although not impossible, but it's a royal PITA), but for sub-string matching it maybe easier. Eg slide a window along looking for more than X% of characters being identical.

This means T4 emotes with people on say language 70 or 80 may still be sufficiently accurate to trigger. I'll have to think about whether a combination of nasty a|b|c combinations allows for the same thing via regexps though.

Thanks.

Re: using pattern matching in triggers

Posted: Fri Apr 06, 2012 9:01 pm
by Gimagukk
I won't be implementing a deliberate "language buster" feature. However, you may be able to get a decent match on some triggers by using regular expressions to focus more on where the spaces in sentences are. For example, take the sentence:

The quick brown fox jumped over the lazy dog.

The following regular expression would register as a match:
.{3} .{5} .{5} .{3} .{6} .{4} .{3} .{4} .{4}

This means "look for any 3 characters, followed by a space, followed by any 5 characters, followed by a space, follow by any 5 characters, followed by a space" etc. Of course, this pattern would also match "The sleek black cat jumped over the slow dog." Also, I can't remember if the language scrambling is applied to character names, so you may or may not be able to use the {C} tag.