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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Xerit
Newbie


Joined: 20 Mar 2009
Posts: 5

PostPosted: Fri Mar 20, 2009 2:45 am   

Trying to make an autoroller.
 
Alright I've been trying to make an auto-roller and im running into a few walls hopefully some of you more versed in Zmud's language can help me out.

The game input looks like this:

Code:
Str:  HIGH.   Int:  AVG.   Wis:  AVG.  Dex:  AVG. 
Con:  MAX.  Chr: BAVG.  Luc:  LOW.  - Accept? (Y/N):


EDIT: Oh Above is an example of every possible output, the range is LOW<BAVG<AVG<AAVG<HIGH<MAX

The words are always aligned so that the periods after the stat value line up with the period below it. This means the space between the stat name and the colon, and the actual stat value changes. Not sure if thats what was giving me some of my issues.

Anyway so I'm able to make simple triggers to check 1 stat, but whenever I try to expand it to multiple stats it seems to bug out and only check some of the stats some of the time.

Currently my #if statement looks like:

#if (@Str= LOW OR @Str= BAVG OR @Int= LOW OR @Int= BAVG OR @Wis= LOW OR @Wis= BAVG OR @Dex= LOW OR @Dex= BAVG) {n}

Ideally i'd like to get a roller going that checks every stat except Chr and rejects any stat set in which any single other stat is BAVG or LOW.

Also is there a "Else" statement hidden somewhere in Zmud like the "else" in C++? I probably could do this myself if I could use If/Then/Else formats.

Thanks in advance.


Last edited by Xerit on Fri Mar 20, 2009 5:54 pm; edited 1 time in total
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Fri Mar 20, 2009 1:02 pm   
 
How do the stats appear to come across? Does it get received as if it is one line or two? Is it definitely a prompt? What do you currently have as your trigger or triggers?

The latter part of an #if is the else. #if (test) {then} {else}
_________________
Taz :)
Reply with quote
Xerit
Newbie


Joined: 20 Mar 2009
Posts: 5

PostPosted: Fri Mar 20, 2009 5:53 pm   
 
Taz wrote:
How do the stats appear to come across? Does it get received as if it is one line or two? Is it definitely a prompt? What do you currently have as your trigger or triggers?

The latter part of an #if is the else. #if (test) {then} {else}


The lines come across exactly as I posted them, in two lines always that long. Pretty sure its a prompt.

My trigger is (and sorry for not really knowing how to properly post this)

Pattern:
^Str: &{Str}. Int: &{Int}. Wis: &{Wis}. Dex: &{Dex}.

Followed by that If statement from the post before. Right now I'm just trying to get the first line working so I know how to write the code before I move on to getting it to scan the second line as well.

Also, I realized you could put in a false command in the If statement, perhaps I should have been more clear I'm not really looking for a "else" as much as an "elseif", I tried using the "else" part of the if statement to string a series of "elseif" statements and while it didn't produce a code error it work either. But perhaps that could be for the same reason my current if isn't working.
Reply with quote
calesta
Apprentice


Joined: 07 Dec 2008
Posts: 102
Location: New Hampshire, USA

PostPosted: Sat Mar 21, 2009 2:07 am   
 
Untested except with a couple of #show commands using the sample output above, but something along these lines should work. Just replace the roll stats part inside the startroll alias with whatever command is used to start the process of choosing your stats. This also assumes that if you answer 'N' at the prompt, the next set of stats is automatically generated in the same format. It currently checks all stats except charisma, but it is easy to change which stats are checked just by modifying the stringlists in the #forall loops in both triggers.
Code:
#CLASS {AUTOROLL} {disable}
#VAR oklevels {AVG|AAVG|HIGH|MAX} {AVG|AAVG|HIGH|MAX}
#VAR numchecked {6} {0}
#VAR numok {5} {0}
#VAR con {MAX} {}
#VAR chr {BAVG} {}
#VAR luc {LOW} {}
#VAR str {HIGH} {}
#VAR int {AVG} {}
#VAR wis {AVG} {}
#VAR dex {AVG} {}
#TRIGGER {^Con:%s&%w{con}.%sChr:%s&%w{chr}.%sLuc:%s&%w{luc}.%s- Accept~? ~(Y/N~):} {#forall {con|luc} {#ad numchecked 1;#if (%ismember( @%i, @oklevels)) {#ad numok 1}};#if (@numok == numchecked) {#send "Y";#T- AUTOROLL} {numchecked = 0;numok = 0;#send "N"}} "" {nocr|prompt}
#TRIGGER {^Str:%s&%w{str}.%sInt:%s&%w{int}.%sWis:%s&%w{wis}.%sDex:%s&%w{dex}.%s$} {#forall {str|int|wis|dex} {#ad numchecked 1;#if (%ismember( @%i, @oklevels)) {#ad numok 1}}}
#CLASS 0
#ALIAS startroll {#T+ AUTOROLL;numok = 0;numchecked = 0;roll stats}


Also, there is no elseif statement in zmud, but you were correct about just using the else part of the normal if command to do that.
Code:
#if (test) {then} {#if (test2) {then} {else}}
Reply with quote
Xerit
Newbie


Joined: 20 Mar 2009
Posts: 5

PostPosted: Sat Mar 21, 2009 5:43 am   
 
Testing it right now. If that really all works you're a god send and I was much farther away from figuring it out then I thought.

After a few posts here I had moved to a system with multiple triggers just for getting the information out of the prompts, and still couldn't figure out a way to chain the #if statements.

So would an "elseif" chain work then beyond the first set?

Once again thankyou very much for the help its much appreciated.

Edit: I'm giving it a try but it seems to be breaking, should it not turn off when you turn off triggers, usually when i'm doing this and I make a mistake turning off triggers and the screen continuing to scroll means that it was double-feedbacking (entering no more than once for a single prompt).

In case it helps the Mud in question is "The Final Challenge"

Host: mud.finalchallenge.net Port: 4000

Maybe you can see what I mean. This mud has been particularly troublesome, I've had success with basic trigger systems in the past but the roller here seems to screw up triggers pretty easily.
Reply with quote
calesta
Apprentice


Joined: 07 Dec 2008
Posts: 102
Location: New Hampshire, USA

PostPosted: Sat Mar 21, 2009 2:10 pm   
 
I tested it out on the MUD and had the same problem. I got it to work just by removing the #forall loop in the trigger for the first line of stats and just doing all of the checking in a single #forall loop in the prompt trigger for the second line of stats. This new version checks all stats except charisma and dex since I was never able to get a roll that had everything except charisma AVG or higher. This one is more tailored to the MUD too... it automatically turns itself on at the right time during character creation.
Code:
#CLASS {AUTOROLL} {disable}
#VAR oklevels {AVG|AAVG|HIGH|MAX} {AVG|AAVG|HIGH|MAX}
#VAR numchecked {5} {0}
#VAR numok {5} {0}
#VAR con {AVG} {}
#VAR chr {LOW} {}
#VAR luc {AVG} {}
#VAR str {AVG} {}
#VAR int {AAVG} {}
#VAR wis {AVG} {}
#VAR dex {LOW} {}
#TRIGGER {^Con:%s&%w{con}.%sChr:%s&%w{chr}.%sLuc:%s&%w{luc}.%s- Accept~? ~(Y/N~):} {numok = 0;numchecked = 0;#forall {str|int|wis|con|luc} {#ad numchecked 1;#if (%ismember( @%i, @oklevels)) {#ad numok 1}};#if (@numok == @numchecked) {Y;#T- AUTOROLL} {N}} "" {nocr|prompt}
#TRIGGER {^Str:%s&%w{str}.%sInt:%s&%w{int}.%sWis:%s&%w{wis}.%sDex:%s&%w{dex}.%s$} {}
#CLASS 0
#TRIGGER {^Your stats are:$} {#T+ AUTOROLL}


Also, the elseif chain can go on past the first set if needed.
Code:
#if (0) {#say true} {#if (0) {#say true2} {#if (0) {#say true3} {#say false3}}}
Reply with quote
Xerit
Newbie


Joined: 20 Mar 2009
Posts: 5

PostPosted: Sat Mar 21, 2009 6:46 pm   
 
Wow, that works perfectly.

Thankyou so much for your help, like I said above it looks like I was much farther from getting a working trigger set than I thought. You've saved me alot of time, hopefully I can look over your code and understand it should help me greatly in the future.

Oh and thanks for the information on nested If's, it must have been my data capture triggers that were the problem then when I tried to do that originally.

Thanks again!

EDIT: In case you were interested all AVG or above is possible, its just exceedingly rare (Like maybe you hit one in 5+ minutes of solid rolling) hence why I wanted a system to do it instead of the way I used to (Simple trigger that checked one stat and then I manually check the others).
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sat Apr 11, 2009 11:34 pm   
 
Better than the MUD I used to play, where getting the max possible rollable stats once took me over 20 hours. Of course, it also once took me 8 seconds. Was VERY random.

Another thing you may want to do here, is assign number values to the vars instead of letter values, and then require a minimum value that would garner a better return.

You can do that with THIS code (I eliminated the numchecked since it isn't needed)
Code:
#CLASS {AUTOROLL} {disable}
#VAR oklevels {AVG|AAVG|HIGH|MAX} {AVG|AAVG|HIGH|MAX}
#VAR toolow {0}
#VAR numok {5} {0}
#VAR con {AVG} {}
#VAR chr {LOW} {}
#VAR luc {AVG} {}
#VAR str {AVG} {}
#VAR int {AAVG} {}
#VAR wis {AVG} {}
#VAR dex {LOW} {}
#TRIGGER {^Con:%s&%w{con}.%sChr:%s&%w{chr}.%sLuc:%s&%w{luc}.%s- Accept~? ~(Y/N~):} {
   numok = 0
   toolow = 0
   #forall {str|int|wis|con|luc} {
      #IF (%ismember(@%i,@oklevels) < 1) {toolow = 1}
      #ADD numok (%ismember( @%i, @oklevels))
   }
   #if (@numok > 6 AND @toolow < 1) {Y;#T- AUTOROLL} {N}
} "" {nocr|prompt}
#TRIGGER {^Str:%s&%w{str}.%sInt:%s&%w{int}.%sWis:%s&%w{wis}.%sDex:%s&%w{dex}.%s$} {}
#CLASS 0
#TRIGGER {^Your stats are:$} {#T+ AUTOROLL}


I've written this using a 6 for my minimum, but this is the number you'd wish to change to vary how "good" you want your stats to be. Since there are 5 stats, and I'm using greater than for my check, the bare minimum number this could be is 4. So that if you got all AVGs it would equal 5 and be greater than 4. By using 6, I have guaranteed that at least 2 of the stats are AAVG or better. You'll also notice that this setup requires there to be a check for if any of the stats failed to pass muster, for which I used the toolow variable as a boolean (YES or NO, or in this case 0 or anything else, I used 1 since usually in code YES=TRUE=1 and NO=FALSE=0 for boolean checks.) Enjoy.

EDIT: Corrected an issue with the codeblock that was preventing this from working. In case anyone else stumbles across this and has issues.
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate

Last edited by ralgith on Wed Mar 25, 2020 4:22 am; edited 1 time in total
Reply with quote
Thrillhouse8
Beginner


Joined: 21 Sep 2004
Posts: 18

PostPosted: Tue Apr 14, 2009 10:26 am   
 
Call me a sucker for simplicity:

Code:
#REGEX {^Str:\s+(\w+)\.\s+Int:\s+(\w+)\.\s+Wis:\s+(\w+)\.\s+Dex:\s+(\w+)\.\s*\nCon:\s+(\w+)\.\s+Chr:\s+\w+\.\s+Luc:\s+(\w+)\.\s+- Accept\? \(Y/N\):\s+} {#IF (%ismember( "LOW", "%1|%2|%3|%4|%5|%6")) {NO} {#IF (%ismember( "BAVG", "%1|%2|%3|%4|%5|%6")) {NO} {YES}}} "" {nocr|prompt}
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Tue Apr 14, 2009 1:20 pm   
 
<--- Still hasn't truly learned REGEX ;) I just understand the basics. However, you've not got the additional functionality I added to the other guys post :D
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
disobayish1@gmail.com
Beginner


Joined: 19 Jul 2016
Posts: 12

PostPosted: Mon Aug 08, 2016 1:04 am   
 
I know this is an old thread but I tried the script that Ralgith posted and it seemed to work fine, then i tried the #regex script and it failed miserably,

so i deleted the session and made another, loaded the script from ralgith but it seems that the #regex has comprimised my entire cmud program not just that single session and now it wont even let me roll a character on my own on my mud!
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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