|
Darenwin Newbie
Joined: 15 Aug 2008 Posts: 3
|
Posted: Wed Jun 15, 2011 5:48 pm
Engaged/Disengaged Detection |
I have a question for all you smarty pants out there.
The following output is various forms of engaged and disengaged states. I would like a script that can tell when I'm engaged and when I'm not.
I have this script already that tells me who my enemy is and what their health is:
#tri {^{o|*} * - (*): (*) >} {#VAR enemy "%1";#VAR health "%2"} (it wasn't exported, so bare with me if it's a bit wrong)
I wonder if it is possible to tell when the enemy is %null or void. Maybe that's how it can tell that I'm not engaged. I had tested something a while ago, and I never got it to work. I was thinking something along the lines of
#tri {^{o|*} * - (*): (*) >} {#if %1=%null {disengaged} {engaged}}
I am not sure I want to run the "#if" every line though. I'm not sure if that's going to be needlessly more laggy.
I also though if I could do something like this:
#tri {^{o|*} * - (*): (*) >} {#VAR enemy "%1";#VAR health "%2";engaged}
#tri {^{o|*} * >} {disengaged}
* R HP:Healthy MV:Fresh - a huge grizzly bear: Battered >
* R HP:Scratched MV:Fresh - a Red Eagle sentry: Critical >
* R HP:Wounded MV:Full - the gleeman: Healthy >
* HP:Battered MV:Strong - the writhing grass: Critical >
o HP:Battered MV:Strong - the writhing grass: Critical >
o R HP:Hurt MV:Weary >
* R HP:Hurt MV:Weary >
* HP:Wounded MV:Winded >
o HP:Healthy SP:Strong MV:Tiring >
* HP:Healthy SP:Strong MV:Strong >
* R HP:Scratched MV:Fresh - Edard: Wounded >
* R HP:Scratched MV:Fresh - Noah: Healthy >
* HP:Scratched MV:Tiring - Weir: Scratched >
* R HP:Scratched MV:Fresh - Yeri: Wounded - the Watchman: Hurt >
* R HP:Scratched MV:Fresh - Marth: Scratched - Gloria: Scratched >
* R HP:Scratched MV:Fresh - a raken: Wounded - the Watchman: Hurt >
* HP:Healthy SP:Full MV:Strong - a stout young sapling: Critical >
* HP:Scratched MV:Tiring - Apoc: Healthy - Croten: Battered >
Anyways, I hope this is clear and I hope it's tough enough that some of you might have fun doing it. I'm looking for a easy plain set of triggers/if strings that can update a variable. I'll use that variable to turn off other triggers/aliases and any other number of things.
Thanks in Advance
- Darenwin
ps. This is for zMUD. Though, I should be able to adapt anything from cMUD as long as the commands are also in zMUD.
pps. This is for WOTMud. Most Awesome Mud out there. ;) www.wotmud.org |
|
|
|
geniusclown Magician
Joined: 23 Apr 2003 Posts: 358 Location: USA
|
Posted: Wed Jul 06, 2011 3:21 pm |
You have to be careful about using the wildcard *. Since it's part of your MUD's output that you're trying to match, you have to escape it as such:
#tri {^{o|~*} . . .
Also, your disengagement trigger will fire even if you're engaged because the * will allow for the extra stuff. Because of the possibilities of having 0, 1, or 2 (or 3 or 4?) mobs who are described with 1 or more words listed on each line, I would use regular expressions to prevent overmatching the last string. That is, you don't want to match
* HP:Scratched MV:Tiring - Apoc: Healthy - Croten: Battered >
so that your target is "Apoc" who's health is "Healthy - Croten: Battered"... you want Apoc and Croten to be matched separately, each with its own health stat. Here's how I would do it:
#TR "detectengage" {^{0|~*}*HP: (%w) MV: (%w)~>} {myhp=%1;mymv=%2;target1="";target1health="";target2="";target2health=""}
#COND {^[A-Za-z :]+ - ([A-Za-z ]+): ([A-Za-z ]+)} {target1=%1;target1health=%2} "" {reparse|regex}
#COND {^[A-Za-z :]+ - [A-Za-z ]+: [A-Za-z ]+ - ([A-Za-z ]+): ([A-Za-z ]+)} {target2=%1;target2health=%2} "" {reparse|regex}
The original trigger will detect the lines beginning with o or *, and store your hp and mv while clearing the other variables in case you're not engaged. The next trigger will add a state that will look for the first target, and if it's there store its name and health. The "[A-Za-z :]+" in a regular expression will match any letter, space, or colon one or more times, while "[A-Za-z ]+" will match any letter or space, but if it runs into any other character, such as the - that separates the targets, it will stop matching. The {reparse|regex} conditions will make the state check the same line that fired in the first place (that's reparsing) and let it know that you're using Regular Expression to match. The final line adds another state to the original trigger, and will only fire if there are two targets - notice the () omitted on the first match, because you already captured that information - this is in case there's a second target. You can easily add more states to this pattern if you can have more than two targets show on this line.
*disclaimer: these are untested triggers, but should give you an idea of how you might proceed. |
|
_________________ .geniusclown |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|