CMUD Conditional Triggers.

by Isuka

Back to Mechanic's Corner.

Isuka2008-12-13 22:30:00
Ok, I'm stuck.

I'm using CMUD, and writing a counter to track my percentages of hits, misses and crits. What I'm doing is creating a trigger that recognizes an attempt to attack from mud output, then uses a conditional within state to see if the attack hit or missed.

example:
CODE
  
     ^\\* ka punch \\a+ left{:content:}lt;/pattern>
     $atk=@attacks.attack
              #add $atk 1
              attacks.attack=$atk
  

    
       ^You strike out at .+, but your fist misses by mere inches.{:content:}lt;/pattern>
       bals.leftarm=0
                $misses=@attacks.miss
               #add $misses 1
               attacks.miss=$misses
                #say Missed with left arm
    

    

    
       ^Drawing back your (left|right) fist, you punch.+\\.{:content:}lt;/pattern>
       bals.leftarm=0
                $hits=@attacks.hit
               #add $hits 1
                attacks.hit=$hits
                #say Hit with left arm
    

    

  


The problem I'm running into is that CMUD stops processing the conditions after the first "within" state. So if the first state is the hit trigger, and the second state is the miss trigger, the hit will process but the miss will not. If I switch it so that the miss is the first trigger and the miss is the second, the miss will process but the hit will not.

What's the problem?
Unknown2008-12-13 22:43:09
It's looking for line 1, line 2, line 3, but you're giving it line 1, line 2 OR line 3. Your line 3 needs to be a reparse state instead of within 1 lines state. If that first conditional doesn't match, it should check the second one.
Isuka2008-12-13 22:50:18
QUOTE (Zarquan @ Dec 13 2008, 02:43 PM) <{POST_SNAPBACK}>
It's looking for line 1, line 2, line 3, but you're giving it line 1, line 2 OR line 3. Your line 3 needs to be a reparse state instead of within 1 lines state. If that first conditional doesn't match, it should check the second one.


Thanks for the quick reply, Zarquan.

Take two:
CODE

   ^\\* ka punch \\a+ left{:content:}lt;/pattern>
   $atk=@attacks.attack
#add $atk 1
attacks.attack=$atk

  
     ^You strike out at .+, but your fist misses by mere inches.{:content:}lt;/pattern>
     bals.leftarm=0
$misses=@attacks.miss
#add $misses 1
attacks.miss=$misses
#say Missed with left arm

  

  
     ^Drawing back your (left|right) fist, you punch.+\\.{:content:}lt;/pattern>
     bals.leftarm=0
$hits=@attacks.hit
#add $hits 1
attacks.hit=$hits
#say Hit with left arm

  



Still no go. Any more thoughts?

Edit: A miss successfully triggers (being the first state).
Isuka2008-12-14 02:57:48
Figured it out. The reason that the reparse wasn't working is because the #SAY i was using for debugging was counting as the next line. I created a new trigger to try out three states, grabbing three lines after a test line and printing them out. All three constantly printed the same message (the say from the test trigger's output). Removing all of the #say commands fixed the problem.

That said... Kinda sucks if you intend to output anything to the screen for personal use.
Unknown2008-12-14 03:00:30
Ah. I hadn't thought of that, but glad you figured it out. One technique I've found useful is to queue up things to be printed as debug on the next prompt (or just setting strings in variables and checking when you need).