Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Making an autoroller that can capture and store rolls

Making an autoroller that can capture and store rolls

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Kelston   (2 posts)  Bio
Date Sun 30 May 2004 04:13 AM (UTC)

Amended on Sun 30 May 2004 09:24 PM (UTC) by Nick Gammon

Message
I've seen a lot of autorollers on the forums. I currently have one that works. However, I've never seen one that has done autorolling for non-numerical rolling systems AND saves a current "best" roll as sort of like a tally system to see if you need to lower your roller settings to something that is more realistic.

I'd like to get some advice on how I would actually go about doing something like this without needing a third-party application.

The MUD in question has a rolling system that creates rolls looking like this:

EDIT: Autoformat messes up what the rolls look like.

There is a single space in front of Str and 3 spaces in between each attribute which follows. There is no space in front of the first stat and 2 spaces in between each statistic value.


 Str   Int   Wis   Dex   Agi   Con   Cha   Wil   Voi   Per   App              
Low   Good  Aver  Fair  Aver  Low   Good  Fair  Aver  Low   Good 


Where the stats can be (from low to high) - Awful, Low, Poor, Aver, Fair, Good

My current autoroller looks something like this:

To Accept Rolls:

^(Good|Fair).. (Good|Fair).. (Good|Fair).. (Good|Fair)..(Good).. (Good).. (Good|Fair|Aver).. (Good).. (Good|Fair).. (Good|Fair).. (Good|Fair)

And sends back "y" if the roll meets the set specifications.

With: Enabled, Keep Evaluating, Regular Expression, Repeat On Same Line checked and a sequence value of 99

And the second part of the roller is:

To Reject Rolls:

Use this body

and sends back "n", basically for any roll that does not meet the set specifications.

All options the same but with a sequence value of 100.

Edited by Nick to show the layout better
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 30 May 2004 09:40 PM (UTC)

Amended on Tue 01 Jun 2004 05:35 AM (UTC) by Nick Gammon

Message
You probably need to make a different regular expression that matches all possibilities, and then tests them in a short script. eg.


^
(?P<str>Awful|Low|Poor|Aver|Fair|Good)\s+
(?P<int>Awful|Low|Poor|Aver|Fair|Good)\s+
(?P<wis>Awful|Low|Poor|Aver|Fair|Good)\s+
(?P<dex>Awful|Low|Poor|Aver|Fair|Good)\s+
(?P<agi>Awful|Low|Poor|Aver|Fair|Good)\s+
(?P<con>Awful|Low|Poor|Aver|Fair|Good)\s+
(?P<cha>Awful|Low|Poor|Aver|Fair|Good)\s+
(?P<wil>Awful|Low|Poor|Aver|Fair|Good)\s+
(?P<voi>Awful|Low|Poor|Aver|Fair|Good)\s+
(?P<per>Awful|Low|Poor|Aver|Fair|Good)\s+
(?P<app>Awful|Low|Poor|Aver|Fair|Good)\s*
$


I have shown the trigger on multiple lines for clarity, you would just join them together when entering. The \s+ means "one or more spaces" which allows for the variable number of spaces between each word.

I have used named wildcards to give each matching thing a "wildcard name" (eg. "str" for the Str item).

You do not need to "repeat on same line" for this one - it will only match once.

Now set the trigger to "send to script" and do something like this:


If ("%<str>" = "Good" Or "%<str>" = "Fair") And _
   ("%<int>" = "Good" Or "%<int>" = "Fair") And _
   ("%<wis>" = "Good" Or "%<wis>" = "Fair") And _
' ... and so on ...
   ("%<app>" = "Good" Or "%<app>" = "Fair") Then
  Send "Y"
Else
  Send "N"
End If


What this will do is use wildcard substitution to put the actual matching words in instead of %<str> or whatever, so you can test the words. If you want to do more, like noting your best score so far, or whatever, you could.

One approach would be to convert each one to a number and then add the numbers up, so you can see how close you are getting.

eg.


Function ConvertScore (which)
  select which
    case "Good" 
      ConvertScore = 6
    case "Fair" 
      ConvertScore = 5
    case "Aver" 
      ConvertScore = 4
    case "Poor" 
      ConvertScore = 3
    case "Low" 
      ConvertScore = 2
    case "Awful" 
      ConvertScore = 1
    case Else
      ConvertScore = 0
  end select
end function


You can then use this function to get each one into a number, like this:


dim Str, Int, Wis, Dex, Agi, Con, Cha, Wil, Voi, Per, App
dim Total              

  Str = ConvertScore ("%<str>")
  Int = ConvertScore ("%<int>")
' ... and so on ...


  Total = Str + Int + ' ... and so on ...

  if Total > 55 Then
    Send "Y"
  else
    Note "Total so far is " & Total
    Send "Y"
  end if



- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #2 on Tue 01 Jun 2004 05:55 AM (UTC)
Message
A regular expression with the same effect can be done like this:


^(?x) (?P<str>Awful|Low|Poor|Aver|Fair|Good)\s+ (?P<int>(?1))\s+ (?P<wis>(?1))\s+ (?P<dex>(?1))\s+ (?P<agi>(?1))\s+ (?P<con>(?1))\s+ (?P<cha>(?1))\s+ (?P<wil>(?1))\s+ (?P<voi>(?1))\s+ (?P<per>(?1))\s+ (?P<app>(?1))\s*$


This saves repeating the "Awful|Low|Poor|Aver|Fair|Good" bit (and therefore makes it easier to change if you need to change what the options are).

This uses (?1) to mean "whatever pattern #1 was".

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


12,399 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.