The problem is that there's so many ways it can fail, which looks like this.You slash into yourself's left arm with an ornate steel rapier.
You swing an ornate steel rapier at yourself's left arm with all your might.
So the attack message is the same whether or not the attack actually succeeded, and failure is only indicated if you receive certain messages. You also fire both attacks at the same time, so there's no prompt or other indication in between, and there's a lot of other messages that can pop up right after the attack message that don't mean failure. I've tried making a chain trigger that stays open for one line, and having a single child trigger of ^(.+)$ to capture that second line, and I would use find() to detect if that second line contained failure messages or not. However, the ^(.+)$ message also fires on the attack message itself. So, with this script in the child triggerYou slash into yourself's right arm with an ornate steel rapier.
You parry the attack to your right arm with a deft maneuver.
You swing an ornate steel rapier at yourself's right arm with all your might.
You parry the attack to your right arm with a deft maneuver.
Code: Select all
if matches[2]:find("parry") then
echo(" FAILURE!")
else
echo(" SUCCESS!")
end
Which means that any code I put in the 'FAILURE!' section will fire no matter what, instead of what I want it to do, which is only if the line immediately after the "You slash" or "You swing" message does NOT contain the word "parry". And because there's so many possible messages that can come right after the hit message, I can't really use exact matches.You slash into yourself's right arm with an ornate steel rapier. SUCCESS!
You parry the attack to your right arm with a deft maneuver. FAILURE!
You swing an ornate steel rapier at yourself's right arm with all your might. SUCCESS!
You parry the attack to your right arm with a deft maneuver. FAILURE!
I have made successful systems for this using an annoying system of variables and not processing the detection of the hits until the prompt, but these always end up very buggy and are difficult and time consuming to code. Is there an easy way of doing this using multiline or chain triggers?
ETA: Here's another way I tried that didn't work. ONe trigger, with the first line set to ^You slash into yourself's right arm with an ornate steel rapier.$ and the second line ^(.+)$, multiline / AND checked with a delta of 1. The script is showMultimatches(). This is the result.
Again, the ^(.+)$ matches the FIRST line. The second line with the parry message is completely ignored.You slash into yourself's right arm with an ornate steel rapier.
-------------------------------------------------------
The table multimatches[n][m] contains:
-------------------------------------------------------
regex 1 captured: (multimatches[1][1-n])
key=1 value=You slash into yourself's right arm with an ornate steel rapier.
regex 2 captured: (multimatches[2][1-n])
key=1 value=You slash into yourself's right arm with an ornate steel rapier.
key=2 value=You slash into yourself's right arm with an ornate steel rapier.
-------------------------------------------------------
You parry the attack to your right arm with a deft maneuver.