|
Vathael Newbie
Joined: 27 Dec 2008 Posts: 4
|
Posted: Sat Dec 27, 2008 10:17 pm
Prompt trigger help! |
Alright, I play this game called Aetolia and I'm working on coding my own auto-curing system. Basically got it all finished with but I'm having troubles tracking a couple of defenses which show up on the prompt.
The prompt looks like so:
H:3312 M:2445 E:13110 W:14805 B:100% [cdb eb]
My prompt trigger looks like so:
Code: |
^H\:(\d+) M\:(\d+) E\:(\d+) W\:(\d+) B:(\d+)\% \[(.*)\]?(?:\(.*\))?$ |
And the value.. like so (not really necessary but I'll post so you get the gist of how I'm doing things):
Code: |
(some various stuff)
#if (%iskey( @scan, reckless)) {
#if ((@health == @max_health) and (@mana == @max_mana)) {i_queue i_aff recklessness}
i_del scan reckless
} {i_del scan reckless}
#if (!%pos( p, %6)) {i_del afflictions paralysis|stunned|entangled|roped}
#if (!%pos( e, %6)) {i_add lost_bals eq} {
i_del lost_bals eq
i_add scan todo
}
#if (!%pos( b, %6)) {i_add lost_bals bal} {
i_del lost_bals bal
i_add scan todo
}
(some various other stuff) |
Alright and now onto my question. In the initial prompt trigger you have [cdb eb] which shows some balances and a few defenses c=cloak d=deaf b=blind e=equilibrium b=balance. Now if you have yet to notice my problem stands at tracking blindness since it's the same letter as balance. I'll always be keeping the "db" up so I was wondering how I could check for that "db" which will always show up in position 2 and 3 (I think) and if one or the other is missing it will put them up without getting the blindness confused with balance or the other way around.. if that makes sense. Thanks for any help in advance.
EDIT: Coding this in zmud for reference. |
|
|
|
Vathael Newbie
Joined: 27 Dec 2008 Posts: 4
|
Posted: Sat Dec 27, 2008 10:46 pm |
Well, I think I just figured out a way to do it or solve part of the problem which goes something along the lines of reworking the prompt trig to distinguish between the two sides of the space. Something along the lines of:
Code: |
^H\:(\d+) M\:(\d+) E\:(\d+) W\:(\d+) B:(\d+)\% \[(.*)\s+(.*)\]?(?:\(.*\))?$ |
And changing the defense tracking part to work from the %6 variable and the balances working from the %7 variable? Such as..:
Code: |
#if (!%pos( p, %6)) {i_del afflictions paralysis|stunned|entangled|roped}
#if (!%pos( c, %6)) {i_del defenses cloak} {i_gaindef cloak}
#if (!%pos( d, %6)) {i_del defenses deaf} {i_gaindef deaf}
#if (!%pos( b, %6)) {i_del defenses blind} {i_gaindef blind}
#if (!%pos( e, %7)) {i_add lost_bals eq} {
i_del lost_bals eq
i_add scan todo
}
#if (!%pos( b, %7)) {i_add lost_bals bal} {
i_del lost_bals bal
i_add scan todo
} |
Thoughts or suggestions? |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Sun Dec 28, 2008 4:05 am |
1)As a prompt trigger, the $ is going to delay matching and at any rate it's unnecessary when you have the * in play at the end of a pattern (it will match to the end of the line anyways).
2)You might want to ditch the * in favor of a more focused wildcard, especially if there is a limited list of possibilities:
[edb] -- zscript range pattern, specifically matching any continuous combination of e's, d's, and b's (edb, eedb, edbedb, etc)
%w -- zscript word wildcard, matches any continuous configuration of letters
3)If the cdb eb string is always a fixed length, you might be able to use a fixed-width pattern (& followed by a number, ie, &3 &2) |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sun Dec 28, 2008 2:42 pm |
I didn't see any examples that indicate what if anything should be matched by the '(?:\(.*\))?' section. As this trigger has a speed critical function I removed that part from the pattern. If you provide some examples I should be able to suggest a more speed efficient pattern.
Next you had ']?' in the pattern. This would make only the closing bracket optional. I figured you actually meant to have the entire bracketted section of text optional. Adding the proper grouping handled that.
Then I broke down all the various flags that had thus far shown. Each of these would be in its own capture. The reason to do this is to accelerate both matching and testing. The order of the flags will always be the same, but there presence won't. I might not have the order correct since I don't play Aetolia and you didn't supply examples.
Code: |
^H\:(\d+) M\:(\d+) E\:(\d+) W\:(\d+) B:(\d+)\%(?: \[(p)?(c)?(d)?(b)? ?(e)?(b)?\])?$ |
Now we get to the code part
Code: |
#if (%6) {i_del afflictions paralysis|stunned|entangled|roped}
#if (%7) {i_del defenses cloak} {i_gaindef cloak}
#if (%8) {i_del defenses deaf} {i_gaindef deaf}
#if (%9) {i_del defenses blind} {i_gaindef blind}
#if (%10) {i_add lost_bals eq} {
i_del lost_bals eq
i_add scan todo
}
#if (%11) {i_add lost_bals bal} {
i_del lost_bals bal
i_add scan todo
} |
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
Vathael Newbie
Joined: 27 Dec 2008 Posts: 4
|
Posted: Mon Dec 29, 2008 3:53 am |
The (?:\(.*\))? at the end of the trigger was used to capture a command sent through while using mudbot so even if mudbot is sending things the prompt still tracks. For example:
H:3401 M:3260 E:13153 W:16270 B:100% [cs eb](west)
and
H:3401 M:3260 E:13151 W:16270 B:100% [cs eb](Done.)
It's just not always there and that's what that is for if it's there it still tracks if it's not well then no problem. The only thing is if I did it properly which someone I talked to said the '?' before the (?:\(.*\))? was wrong as you had stated.
H:3401 M:3160 E:13165 W:16270 B:100% [csdb eb]
is what a normal prompt looks like.
There can also be a p thrown in there depending if I get proned or not which would in turn look like
H:3401 M:3160 E:13165 W:16270 B:100% [cspdb eb]<<prone +>>
The <<prone +>> is just something that the system itself adds in there stating the affliction received so it's a non-factor.
At any rate, I'll toy around with what you have given me and see what I can make of it. Thank you. |
|
|
|
|
|