Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sat May 17, 2008 3:19 am   

Still having trouble with arena pattern matching
 
Here's some output, now, admittedly this guy has an odd '' in his name, but I'm still missing a lot that I think should be there.


[ Eastern Coliseum Wall ] Blurrin''s shadow's slap injures Sarverk.
[ Eastern Coliseum Wall ] Blurrin''s magic misses Sarverk.
[ Eastern Coliseum Wall ] Blurrin''s magic misses Sarverk.
[ Eastern Coliseum Wall ] Sarverk's crush decimates Blurrin''s shadow!
[ Eastern Coliseum Wall ] Sarverk's divine power mauls Blurrin''s shadow.
[ Eastern Coliseum Wall ] Sarverk's crush decimates Blurrin''s shadow!
[ Eastern Coliseum Wall ] Sarverk's divine power decimates Blurrin''s shadow!
[ Eastern Coliseum Wall ] Sarverk's crush devastates Blurrin''s shadow!
[ Eastern Coliseum Wall ] Sarverk's crush decimates Blurrin''s shadow!
[ Eastern Coliseum Wall ] Sarverk's divine power misses Blurrin''s shadow.
[ Eastern Coliseum Wall ] Sarverk's crush devastates Blurrin''s shadow!

<1449/1449hp 1012/1012m 406/406mv 36891tnl 126pq 194/390w 927g/3s
[The Northern Arena Stands] [U-SW-SE] 3:00am [Night Time] [Elvish]>

[ Eastern Coliseum Wall ] Blurrin''s acid blast *** DEVASTATES *** Sarverk!


Code:

#regex Damage_Convert {^(?>\[[^\]]*\] )?(?>\w+\-?'?\s?)+?(@attack_type) (?>does )?(@damage_type) (?>things to )?(?>a |the )?(?>\w+\-?'?\s?)+?[!.]}   
{
  $DmgVal=%2
  $Dmg=" "
  #switch ($DmgVal)
    ("misses") {$Dmg=0}
    ("scratches") {$Dmg=2.5}
    ("grazes") {$Dmg=6.5}
    ("hits") {$Dmg=10.5}
    ("injures") {$Dmg=14.5}
    ("wounds") {$Dmg=18.5}
    ("mauls") {$Dmg=22.5}
    ("decimates") {$Dmg=26.5}
    ("devastates") {$Dmg=30.5}
    ("maims") {$Dmg=34.5}
    ("MUTILATES") {$Dmg=38.5}
    ("DISEMBOWELS") {$Dmg=42.5}
    ("DISMEMBERS") {$Dmg=46.5}
    ("MASSACRES") {$Dmg=50.5}
    ("MANGLES") {$Dmg=54.5}
    ("*** DEMOLISHES ***") {$Dmg=58.5}
    ("*** DEVASTATES ***") {$Dmg=68}
    ("=== OBLITERATES ===") {$Dmg=88}
    (">>> ANNIHILATES <<<") {$Dmg= 112}
    ("<<< ERADICATES >>>") {$Dmg=136}
    ("GHASTLY") {$Dmg=163}
    ("HORRID") {$Dmg=188}
    ("DREADFUL") {$Dmg=228}
    ("HIDEOUS") {$Dmg=238}
    ("INDESCRIBABLE") {$Dmg=263}
    ("UNSPEAKABLE") {$Dmg=280}

  #switch ($Dmg=0) {#sayadd { <color #CCCCCC>~(</color><color #2D2D00>$Dmg</color><color #CCCCCC>~) dmg </color>}}
     (($Dmg > 0) AND ($Dmg <=34.5)) {#sayadd { <color #CCCCCC>~(</color><color @Pcolor1>$Dmg</color><color #CCCCCC>~) dmg </color>}}
     (($Dmg > 34.5) AND ($Dmg <= 54.5)) {#sayadd { <color #CCCCCC>~(</color><color @Pcolor2>$Dmg</color><color #CCCCCC>~) dmg </color>}}
     (($Dmg > 54.5) AND ($Dmg <= 136)) {#sayadd { <color #CCCCCC>~(</color><color @Pcolor3>$Dmg</color><color #CCCCCC>~) dmg </color>}}
     (($Dmg >= 163) AND ($Dmg <= 280)) {#sayadd { %ansi(blink)<color #CCCCCC>~(</color><color @Pcolor3>$Dmg</color><color #CCCCCC>~) dmg </color>%ansi(none)}}

} {General Triggers|Damage Calculator}


Oh, and some of it works:


[ Southern Coliseum Wall ] Blurrin''s shadow's slap misses Sarverk.
[ Southern Coliseum Wall ] Sarverk's crush mauls Blurrin'. (22.5) dmg
[ Southern Coliseum Wall ] Sarverk's crush mauls Blurrin'. (22.5) dmg


This is just... confusing to me
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Sat May 17, 2008 3:58 am   
 
Personally, I think you're making your regex way too complicated. For the name, why not have [A-Za-z'] as a range instead of what you currently have it as? Admittedly, I'm not an expert in regex, but my code makes more sense to me. :p

Charneus
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sat May 17, 2008 4:05 am   
 
Because it isn't just always a single proper name, otherwise this whole thing would have been simple from the beginning.

http://forums.zuggsoft.com/forums/viewtopic.php?t=30663

It's kind of stupid your Mud allows crap like that Chamenas, but just add the quotation mark in the pattern like you did the apostrophe.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sat May 17, 2008 4:22 am   
 
You think it's just the ' ?

It's not usually allowed. No clue how he got away with that.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Caled
Sorcerer


Joined: 21 Oct 2000
Posts: 821
Location: Australia

PostPosted: Sat May 17, 2008 9:10 am   
 
I don't know anything about regex, but the answer is pretty easy if you were to do it in normal zcript Confused
Isn't regex supposed to open up more options, not make simple stuff difficult?
_________________
Athlon 64 3200+
Win XP Pro x64
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat May 17, 2008 10:18 am   
 
The pattern really does need to be simplified. The reason it is not matching those lines is because they do not contain a part that matches your attack_type list. An adjusted pattern might be
Code:
^(?>\[[^\]]*\] )?(?>[\w'-]+ ){1,5}(?>(@attack_type) (?>does )?)?(@damage_type) (?>things to )?(?>a |the )?(?>[\w'-]+[ !.]){1,5}

_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sat May 17, 2008 11:57 am   
 
What is the {1,5} doing?
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sat May 17, 2008 2:58 pm   
 
Repeating the item between 1 and 5 times.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sun May 18, 2008 11:28 pm   
 
That's not the problem. The problem is the quotation mark in the guys name. Your pattern still won't match those lines.

Quote:

I don't know anything about regex, but the answer is pretty easy if you were to do it in normal zcript Confused
Isn't regex supposed to open up more options, not make simple stuff difficult?


What just use * everywhere? This is fine if you want your client to be slow as hell.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
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

© 2009 Zugg Software. Hosted by Wolfpaw.net