[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Stat Roller

Stat Roller

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


Pages: 1 2  

Posted by Agent_702   (3 posts)  [Biography] bio
Date Sun 11 Nov 2001 04:26 PM (UTC)
Message
Hello. I have been trying to go about makeing a stat roller with mushclient to be used on the mud i play. BUt i can't even think about how to go start doing so. I guess that coding a stat roller would require me to know a scripting language? well i'm in luck because i'm not exactly an expert in VB but i'm definetly an advanced VB programmer. Any idea's how to start? How the whole thing should look? If you need more info just let me know and i'll give you everything that you need.

Thanks

Chris
[Go to top] top

Posted by Elric   USA  (51 posts)  [Biography] bio
Date Reply #1 on Sun 11 Nov 2001 10:14 PM (UTC)
Message
Emm.. What do you mean a "Stat Roller"

Is this something so you can just roll up stats? .. Because on a MUD usually the server itself rolls your stats.. And if they have a reroll system like mine does.. It usually just rerolls it for you..

In otherwords.. Why make a reroller.. When you won't be able to use it at all.. Erm.. Correct me if I'm wrong of course..

If you are a coder for the MUD and are trying to make a reroll system for the server itself.. Remember that there are ones already made for people like you and me who have little experience with actual coding.. In my case C++ .. That way you can add the reroll only by following instructions.. If the stat roller is only for your amusement.. Then I would say go for it.. But I have no idea where to get started..

"By the pricking of my thumbs, something wicked this way comes. Open locks, whoever knocks!" MacBeth, Shakespeare
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Sun 11 Nov 2001 11:46 PM (UTC)
Message

I presume you want to react automatically to the stats offered when you create a new character? To do this I would make a trigger that matches on the appropriate line (post an example from your mud, to make it easier to describe it exactly).

The trigger would call a script routine that (using wildcards for each stat) would decide whether or not to accept the roll and reply accordingly (using the script routine world.send).

Here is an example to get you started ...

Taking the character generation from the Dawn Of Time server as an example:


Rerolling please wait.
-====================== CHARACTER ATTRIBUTES SELECTION ======================-
            Strength (ST): 30( 77)   Constitution   (CO): 33( 53)
            Quickness(QU): 40( 40)   Agility        (AG): 52( 52)
            Presence (PR): 24( 84)   Self-Discipline(SD): 29( 39)
            Empathy  (EM): 20( 68)   Memory         (ME): 40( 40)
            Intuition(IN): 26( 47)   Reasoning      (RE): 29( 39)
            green is starting value, (blue) is potential with training.
Are you happy with these attributes?

You could match on the above with 5 triggers (one for each attribute line), or make a more complex regular expression. Let's make a regular expression because it lets us skip spaces more easily:

  • Trigger (one long line):

    ^\s*(Strength|Quickness|Presence|Empathy|Intuition)\s*\((ST|QU|PR|EM|IN)\):\s*(\d+)\(\s*(\d+)\)\s*(Constitution|Agility|Self-Discipline|Memory|Reasoning)\s*\((CO|AG|SD|ME|RE)\):\s*(\d+)\(\s*(\d+)\)$

  • Enabled: checked
  • Regular expression: checked
  • Label: Stats
  • Script: OnStats

This regular expression might look a little daunting, so let's break it up to explain what each bit does ...

^ Start of line
\s* Zero or more spaces
(Strength|Quickness|Presence|Empathy|Intuition) One of those words (wildcard 1)
\s* Zero or more spaces
\( The "(" character literally
(ST|QU|PR|EM|IN) One of those words (wildcard 2)
\) The ")" character literally
:\s* A colon followed by zero or more spaces
(\d+) One or more digits (0 to 9) (wildcard 3)
\( The "(" character literally
(\d+) One or more digits (0 to 9) (wildcard 4)
\) The ")" character literally
\s* Zero or more spaces
(Constitution|Agility|Self-Discipline|Memory|Reasoning) One of those words (wildcard 5)
\s* Zero or more spaces
\( The "(" character literally
(CO|AG|SD|ME|RE) One of those words (wildcard 6)
\) The ")" character literally
:\s* A colon followed by zero or more spaces
(\d+) One or more digits (0 to 9) (wildcard 7)
\( The "(" character literally
(\d+) One or more digits (0 to 9) (wildcard 8)
\) The ")" character literally
$ End of line

Parts of the regular expression in round brackets are "output" as wildcards, thus the expression above sets up 8 widcards, which we can retrieve in the script.

We add to the script file (this example is in VBscript) the "OnStats" handler:



sub OnStats (strName, strLine, aryWildcards) 

dim stat, start, potential

  ' get first stat (wildcards 2, 3, 4)

  stat = aryWildcards (2)
  start = aryWildcards (3) 
  potential = aryWildcards (4) 

  world.setvariable "stat_" & stat & "_start", start
  world.setvariable "stat_" & stat & "_potential", potential

  ' get second stat (wildcards 6, 7, 8)

  stat = aryWildcards (6)
  start = aryWildcards (7) 
  potential = aryWildcards (8) 

  world.setvariable "stat_" & stat & "_start", start
  world.setvariable "stat_" & stat & "_potential", potential

end sub 

After setting up this wildcard and testing it we can look at the "variables" window in the configuration dialog, to see that various variables have been set up to "remember" the rolls for each attribute.


stat_ag_potential = 52
stat_ag_start = 52
stat_co_potential = 53
stat_co_start = 33
stat_em_potential = 68
stat_em_start = 20
stat_in_potential = 47
stat_in_start = 26
stat_me_potential = 40
stat_me_start = 40
stat_pr_potential = 84
stat_pr_start = 24
stat_qu_potential = 40
stat_qu_start = 40
stat_re_potential = 39
stat_re_start = 29
stat_sd_potential = 39
stat_sd_start = 29
stat_st_potential = 77
stat_st_start = 30

Now what we need to do is reply to the question "Are you happy with these attributes?". The logical thing to do here is make a trigger that matches that line, retrieve each of the stats we saved in the earlier trigger, and make a decision. I don't know your criteria, so I'll do a simple example that tests that each stat exceeds a minimum value. You may want to do something more complex.

  • Trigger: Are you happy with these attributes?
  • Enabled: checked
  • Label: AreYouHappy
  • Script: OnAreYouHappy

Now we make the script "OnAreYouHappy" that makes the decision:



sub OnAreYouHappy  (strName, strLine, aryWildcards) 

dim ST, CO, QU, AG, PR, SD, EMP, MEM, INT, RE

  ST = cint (world.getvariable ("stat_st_start"))
  CO = cint (world.getvariable ("stat_co_start"))
  QU = cint (world.getvariable ("stat_qu_start"))
  AG = cint (world.getvariable ("stat_ag_start"))
  PR = cint (world.getvariable ("stat_pr_start"))
  SD = cint (world.getvariable ("stat_sd_start"))
  EMP = cint (world.getvariable ("stat_em_start"))
  MEM = cint (world.getvariable ("stat_me_start"))
  INT = cint (world.getvariable ("stat_in_start"))
  RE = cint (world.getvariable ("stat_re_start"))

' see if we accept these stats

  if ST > 30 and _
     CO > 50 and _
     QU > 25 and _
     AG > 40 and _
     PR > 30 and _
     SD > 22 and _
     EMP > 33 and _
     MEM > 47 and _
     INT > 21 and _
     RE > 13 then
    world.send "yes"
  else
    world.send "no"
  end if

end sub

Notice that this script sends "yes" or "no" to the world depending on the decision about each stat.

I hope this helps.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Mon 12 Nov 2001 12:23 AM (UTC)
Message
By the way, be careful that you don't set your sights too high with the stats reroller, or you may "spam" the MUD with thousands of requests for new stats in quick succession.

If that looks like it is happening you may have to go to the Connection menu and click on "Disconnect".

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Agent_702   (3 posts)  [Biography] bio
Date Reply #4 on Mon 12 Nov 2001 05:15 PM (UTC)
Message
HOLY CRAP THATS EXACTLY WHAT I NEEDED!!! lol and you know whats even funnier i play on BloodMoon and Darkening Sun which they both use the old DoT codebase. AHHH DoT, how i miss those days of mudding. lol. I'll try out what you suggest and thank you again.

Chris G
[Go to top] top

Posted by Agent_702   (3 posts)  [Biography] bio
Date Reply #5 on Mon 12 Nov 2001 09:33 PM (UTC)
Message
OK i've just tried making the stat roller to what you suggested. but it only works for 1 stat. I set it to try and roll a character above 70 strength and 70 constitution but it didn't work. it just keeps saying no and passed by 3 perfectly good rolls. WHat i then did was made it so that everything would have to be above 10 except for strength which had to be above 70 and it worked. I wonder why it doesn't work when i put strength and constitution above 70? i basically took your code and nothing more it seemed perfectly sound so i made no modifications to it. ANY ideas are welcome and thanks again so much for your help.

chris g
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #6 on Mon 12 Nov 2001 11:03 PM (UTC)
Message
I tried myself using DOT and looking for ST > 70 and CO > 70 but it kicked me off before it got a match.

You realise the way I have written it it matches on the *starting* value, not the potential with training.

The highest starting strength I got was 60, and the highest constitution was 59. Also, when I got 59 for constitution the strength was only 50.

You may be aiming too high. If you want to match on the *potential* for an attribute you need to change the line:


ST = cint (world.getvariable ("stat_st_start"))


to


ST = cint (world.getvariable ("stat_st_potential"))

and the rest in a similar way.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Melvyn   (1 post)  [Biography] bio
Date Reply #7 on Mon 21 Jan 2002 05:25 PM (UTC)
Message
Hmmm anyone came out with e multiline stats roller?
Cos I have no exp in programming and i do not know what is for wat...
So someone who have please mail me at lunloon@hotmail.com
[Go to top] top

Posted by Nosferat   (3 posts)  [Biography] bio
Date Reply #8 on Sun 09 Feb 2003 06:36 PM (UTC)
Message
Hello...I'm going to read the rest of the forums first...or I guess I'm not...hehe...If there is any possible way to include within the parameters of Alias and Trigger a way to setvariable like tintin uses...that would make scripting unncessary for 90% of MUSHclient users...or at least I feel I'm an average client user and that I can make anything work just using triggers aliases and variables but I need to have easy access to my variables...for example on this statrolling script wouldn't it have been easier to include in the trigger a setvariable command for each of those stat values and then have another alias which analysed them? I may just be too old fashioned but I think that would be easier for most users than having to learn all the scripting syntax to make use of variables
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #9 on Mon 10 Feb 2003 10:35 PM (UTC)
Message
You can retrieve variables by using the @variable syntax inside a trigger or alias, however having a trigger syntax set a variable I think is probably just as confusing as using a short script.

You can already use a trigger to set a single variable without scripting, and once you want to set more than one it is just as easy in a script, and I think more readable. eg.


sub myTrigger (line, output, wildcards)

  world.setvariable "var_a", wildcards (1)
  world.setvariable "var_b", wildcards (2)
 
end sub

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nosferat   (3 posts)  [Biography] bio
Date Reply #10 on Tue 11 Feb 2003 04:32 PM (UTC)
Message
Hello...It's me Variable boy again...okay I was almost able to do what I wanted to do using triggers to set my variables with one problem...I can only have one trigger per variable...this is problematic...because It doesn't allow me to switch my variables back and forth...unless there is a way to change the value of a variable from an alias I think I'm going to have to break down and try to script...

I saw some posts about variables within a script being different from the world variables that the triggers can access?...is that correct?

Maybe you guys can help me figure out how to do what I want to do...once this first problem is taken care of my style of alias/trigger/variable usage all revolves around doing this so this one problem will solve all the rest of them...

Here is what I want from a trigger/alias/variable system for backstabbing...

My alias is...

b *

which should

1) backstab %1
2) SetVariable TARGET %1
3) Turn on backstab Triggers

My triggers trigger on...

"You flee northward!"...etc....

and should respond

s
backstab @TARGET

now I need to have two different flee commands

first flee is regular which allows me to come back in and backstab again

second flee turns off my backstabbing triggers before fleeing so I can escape...

My current system almost works by saying the targets name before I attack it to trigger capture the mob name for variable TARGET. I then can have two other sayings that would set four other variables that replace northward etc. in my triggers with some garbage like zyxyzxyzxyzxy so that it essentially turns off my flee triggers. My problem now is that I can only have one trigger per variable so I can't turn them back on, reset the variables to northward, eastward etc.
[Go to top] top

Posted by Neva   USA  (117 posts)  [Biography] bio
Date Reply #11 on Tue 11 Feb 2003 05:05 PM (UTC)
Message
Shouldn't this be a topic in one of the scripting sections, then, if you want help with scripting?
[Go to top] top

Posted by Nosferat   (3 posts)  [Biography] bio
Date Reply #12 on Tue 11 Feb 2003 06:04 PM (UTC)
Message
Hehe...Neva...

My point is...the client should allow me to easily manipulate my variables...Thankyou for your help everyone...I have found another client...I'm not sure if it's as fast as MUSH client but in my new client I can change my variables from aliases like this

b dragon

$var TARGET %1
backstab %1

Quick and easy...the $var command works in triggers also...if I find this new client to be as fast as MUSH client I won't need to come back and learn how to script to make up for an incomplete mud client...I can see scripting for more complex things...but I won't learn to script to control variables...I'm a MUDder not a programmer Jim!
[Go to top] top

Posted by Shadowfyr   USA  (1,786 posts)  [Biography] bio
Date Reply #13 on Tue 11 Feb 2003 06:37 PM (UTC)
Message
Well Nosferat. Being able to do what you want is on the list and the next version 'may' include it. It is quite likely that mushclient will eventually include such, even if not in the very next version. Have some patients. ;)

Oh. And most clients that allow inline variable setting don't use syntax like $var TARGET %1. It also looks to me like an inline 'script', which means like it or not you are a scripter. ;) lol Clients that use such inlined stuff btw, are by definition slower, because they essentially process all aliases through scripting to look for commands, before actually sending any text to the mud.

It probably wouldn't hurt if aliases in mushclient accepted /{command} syntax and processed through the normal command interpreter (or at least the part that handles inline commands), but if it did, to avoid slowing the client, there would likely need to be an 'Process inline scripts' option for them that you could turn on as needed. Otherwise, the result of adding such a thing would slow down all aliased commands. Whether Nick thinks an option to enable such functionality is reasonable though... ;)
[Go to top] top

Posted by Guest1   USA  (256 posts)
Date Reply #14 on Tue 11 Feb 2003 06:40 PM (UTC)
Message
watch this thread

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=2274&page=999999

and see what Nick replies.. :)
[Go to top] 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.


69,483 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]