|
guganslof Beginner
Joined: 05 Apr 2008 Posts: 19
|
Posted: Fri Apr 25, 2008 2:27 pm
Event Counting Script |
So I want to make a script that counts damage types as the hits occur, then lists them later for comparison.
You pierce the ancient tree's trunk into bloody fragments!
You pierce the ancient tree's crown extremely hard.
You pierce the ancient tree's trunk very hard.
You pierce the ancient tree's branch hard.
You pierce the ancient tree's trunk.
Those would be the damage types, bloody fragments, extremely hard, very hard, hard, and nothing at all. Then after a few minutes of fighting be able to do a 'list damage' and have:
Bloody fragments - 15 hits
Extremely Hard - 28 hits
Very Hard - 42 hits
etc.
Could someone point me towards an already make script I could work from or give me a starter one, it'd be greatly appreciated :) |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Fri Apr 25, 2008 2:40 pm |
Code: |
#var damagetypes ""
#addkey damagetypes bloody 0
#addkey damagetypes extremely 0
#addkey damagetypes very 0
#addkey damagetypes hard 0
#addkey damagetypes normal 0
#regex {You pierce [^.]+(into bloody fragments|extremely hard|very hard|hard)?[.!]} {#switch (%1)
("into bloody fragments") {#add damagetypes.bloody 1}
("extremely hard") {#add damagetypes.extremely 1}
("very hard") {#add damagetypes.very 1}
("hard") {#add damagetypes.hard 1}
{#add damagetypes.normal 1}
#alias ResetDamage {#var damagetypes ""}
#alias ShowDamage {#say %expanddb(@damagetypes,%crlf," - ") |
Try that. I'm at work (naughty me, I know) so I haven't tested it, but it should at least show you the direction I'm going. If you don't understand some (or any) of it, try looking up the commands and functions in the help. If that still doesn't help, just ask here and I'm sure someone (if not me) will explain. |
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Fri Apr 25, 2008 2:47 pm |
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<var name="dt" type="Record" copy="yes">very hard.=2|into bloody fragments!=3|extremely hard.=2|hard.=2</var>
<trigger type="Command Input" priority="30" copy="yes">
<pattern>^list damage$</pattern>
<value>#noinput
#say Damage summary.
#loopdb @dt {#show {%proper(%key) - %val hits.}}</value>
</trigger>
<trigger priority="10" copy="yes">
<pattern>^You pierce the ancient tree's %w (*)[!.?]</pattern>
<value>#if (%iskey(@dt,%1)) {#addkey dt {%1} (%db(@dt,%1)+1)} {#addkey dt {%1} 1}</value>
</trigger>
</cmud> |
|
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Fri Apr 25, 2008 2:47 pm |
Ninja'd oh well, try em both if you like.
|
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
|
guganslof Beginner
Joined: 05 Apr 2008 Posts: 19
|
Posted: Fri Apr 25, 2008 2:51 pm |
Hrmm, you were missing a closing } at the end of {#switch (%1) and {#say %expanddb(@damagetypes,%crlf," - ")
But after adding those in, I could do ShowDamage and it gave me:
very - 0
hard - 0
normal - 0
extremely - 0
bloody - 0
which was after a few rounds of combat.
Also I tried to do a ResetDamage, but after that the ShowDamage wouldn't work anymore :\ |
|
|
|
guganslof Beginner
Joined: 05 Apr 2008 Posts: 19
|
Posted: Fri Apr 25, 2008 2:58 pm |
Arminas wrote: |
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<var name="dt" type="Record" copy="yes">very hard.=2|into bloody fragments!=3|extremely hard.=2|hard.=2</var>
<trigger type="Command Input" priority="30" copy="yes">
<pattern>^list damage$</pattern>
<value>#noinput
#say Damage summary.
#loopdb @dt {#show {%proper(%key) - %val hits.}}</value>
</trigger>
<trigger priority="10" copy="yes">
<pattern>^You pierce the ancient tree's %w (*)[!.?]</pattern>
<value>#if (%iskey(@dt,%1)) {#addkey dt {%1} (%db(@dt,%1)+1)} {#addkey dt {%1} 1}</value>
</trigger>
</cmud> |
|
It's telling me theres an extra } bracer at }}</value> but I couldn't spot the error :\ |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Fri Apr 25, 2008 3:07 pm |
guganslof wrote: |
Hrmm, you were missing a closing } at the end of {#switch (%1) and {#say %expanddb(@damagetypes,%crlf," - ")
But after adding those in, I could do ShowDamage and it gave me:
very - 0
hard - 0
normal - 0
extremely - 0
bloody - 0
which was after a few rounds of combat.
Also I tried to do a ResetDamage, but after that the ShowDamage wouldn't work anymore :\ |
Bumcakes. That probably means that the trigger isn't matching properly, and I don't have the tools to check here. |
|
|
|
JQuilici Adept
Joined: 21 Sep 2005 Posts: 250 Location: Austin, TX
|
Posted: Fri Apr 25, 2008 3:25 pm |
Fang's regex trigger pattern above is:
Code: |
You pierce [^.]+(into bloody fragments|extremely hard|very hard|hard)?[.!] |
The '[^.]+' is absorbing the whole string up to the period, because the damage type part is optional. So nothing is ever captured into %1.
Try
Code: |
You pierce [^.]+?(into bloody fragments|extremely hard|very hard|hard)?[.!] |
(Note the additional '?') This should expand the first character class in a lazy way, so that it won't eat the damage section, if one is present.
(Also at work, so I can't test. ) |
|
_________________ Come visit Mozart Mud...and tell an imm that Aerith sent you! |
|
|
|
guganslof Beginner
Joined: 05 Apr 2008 Posts: 19
|
Posted: Fri Apr 25, 2008 3:39 pm |
That didn't help any :\
Still getting 0 0 0 0 for everything |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Fri Apr 25, 2008 3:51 pm |
JQuillici - I'm pretty sure that's not true, because the ? after the bracket in that is also greedy. It'll only try matching no string after it's tried all the string options. Which is why it's not helping.
|
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Fri Apr 25, 2008 4:10 pm |
Code: |
^You pierce .+?((?>into bloody fragments|extremely hard|very hard|hard|))[.!]$ |
This uses atomic grouping |
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
|
JQuilici Adept
Joined: 21 Sep 2005 Posts: 250 Location: Austin, TX
|
Posted: Fri Apr 25, 2008 5:10 pm |
Fang, the '?' in '[^.]+?' does not make the preceding thing optional (which wouldn't work anyway - it has to match the mob name and hit location at a minimum). It modifies the '+' quantifier to make it lazy, so that it matches the shortest possible string rather than the longest possible string. See this tutorial page and read the sections on laziness for details. Yes, I agree that the '?' character is horribly overloaded in the regex syntax.
I've actually tested it now...and it works.
Code: |
#var damagetypes ""
#regex pierceTrig {You pierce [^.]+?(into bloody fragments|extremely hard|very hard|hard)?[.!]} {#switch (%1)
("into bloody fragments") {#add damagetypes.bloody 1}
("extremely hard") {#add damagetypes.extremely 1}
("very hard") {#add damagetypes.very 1}
("hard") {#add damagetypes.hard 1}
{#add damagetypes.normal 1}}
#alias ResetDamage {#var damagetypes ""}
#alias ShowDamage {#say %expanddb(@damagetypes,%crlf," - ")}
#alias test {#show You pierce the ancient tree's trunk into bloody fragments!
#show You pierce the ancient tree's crown extremely hard.
#show You pierce the ancient tree's trunk very hard.
#show You pierce the ancient tree's branch hard.
#show You pierce the ancient tree's trunk.} |
Slap that into a blank session, then type
I get
Code: |
You pierce the ancient tree's trunk into bloody fragments!
You pierce the ancient tree's crown extremely hard.
You pierce the ancient tree's trunk very hard.
You pierce the ancient tree's branch hard.
You pierce the ancient tree's trunk.
very - 1
hard - 1
normal - 1
extremely - 1
bloody - 1 |
Which, I think, is the desired behavior.
FWIW, I did this test on 2.22 beta, so it's possible that this is tickling some bug in 2.18 that I've forgotten.
EDIT: Confirmed that I get the same results on 2.18 |
|
_________________ Come visit Mozart Mud...and tell an imm that Aerith sent you! |
|
|
|
guganslof Beginner
Joined: 05 Apr 2008 Posts: 19
|
Posted: Fri Apr 25, 2008 5:41 pm |
Victory! That worked ^_^
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Fri Apr 25, 2008 6:02 pm |
JQuilici wrote: |
Fang, the '?' in '[^.]+?' does not make the preceding thing optional (which wouldn't work anyway - it has to match the mob name and hit location at a minimum). It modifies the '+' quantifier to make it lazy, so that it matches the shortest possible string rather than the longest possible string. See this tutorial page and read the sections on laziness for details. Yes, I agree that the '?' character is horribly overloaded in the regex syntax. |
I was talking about the second ? in my regex. I should've made that clear, sorry. |
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Fri Apr 25, 2008 9:09 pm |
Apologies on not responding sooner.
What I gave you was in XML format. You do not paste XML stuff into the command line.
To try what I gave you you would need to open the package editor and past it into the tree view on the left hand side of the editor window. |
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
|
|
|