|
Joined: Feb 2004
Posts: 9
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Feb 2004
Posts: 9 |
i was trying to make a random dice roller for D&D
something like
on *:text:!*d*+*:*:{
and then it takes the number before the d (the humber of times rolled) the # after the d (sides on the dice) and the # after the + (adds to total roll) and displays the final roll
i couldnt get anything to work, any help would be appreciated
|
|
|
|
Joined: May 2005
Posts: 106
Vogon poet
|
Vogon poet
Joined: May 2005
Posts: 106 |
its not how you want it but its just a start
on *:TEXT:!roll:#:{
if ($rand(1,6) == 1 {
/msg $chan the number is 1
}
if ($rand(2,6) == 2 {
/msg $chan the number is 2
}
if ($rand(3,6) == 3 {
/msg $chan the number is 3
}
if ($rand(4,6) == 4 {
/msg $chan the number is 4
}
if ($rand(5,6) == 5 {
/msg $chan the number is 5
}
if ($rand(6,6) == 6 {
/msg $chan the number is 6
}
}
UNTESTED
Last edited by Sleepyfreak; 25/06/05 08:12 AM.
and thats the way the scout leader burns
|
|
|
|
Joined: Feb 2004
Posts: 9
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Feb 2004
Posts: 9 |
well this is what i had before
on *:text:!d4:*:{ msg $chan $nick rolles a $rand(1,4) }
on *:text:!d6:*:{ msg $chan $nick rolles a $rand(1,6) }
on *:text:!d8:*:{ msg $chan $nick rolles a $rand(1,8) }
on *:text:!d10:*:{ msg $chan $nick rolles a $rand(0,10) }
on *:text:!d12:*:{ msg $chan $nick rolles a $rand(1,12) }
on *:text:!d20:*:{ msg $chan $nick rolles a $rand(1,20) }
on *:text:!d100:*:{ msg $chan $nick rolles a $rand(0,100) }
but i want something to do this in an all in one command - where it would create a variable for each # i need 1 - number of rolls 2 - sides on the rolled die 3 - # added to end result 4 - final result
|
|
|
|
Joined: May 2005
Posts: 106
Vogon poet
|
Vogon poet
Joined: May 2005
Posts: 106 |
well this is what i had before
on *:text:!d4:*:{ msg $chan $nick rolles a $rand(1,4) }
on *:text:!d6:*:{ msg $chan $nick rolles a $rand(1,6) }
on *:text:!d8:*:{ msg $chan $nick rolles a $rand(1,8) }
on *:text:!d10:*:{ msg $chan $nick rolles a $rand(0,10) }
on *:text:!d12:*:{ msg $chan $nick rolles a $rand(1,12) }
on *:text:!d20:*:{ msg $chan $nick rolles a $rand(1,20) }
on *:text:!d100:*:{ msg $chan $nick rolles a $rand(0,100) } that should work but the next step i don't know if it will work but heres my best guess
on *:text:*:*:{
if ($2 == !d4) {
msg $chan $nick rolles a $rand(1,4)
}
if ($2 == !d6) {
msg $chan $nick rolles a $rand(1,6)
}
if ($2 == !d8) {
msg $chan $nick rolles a $rand(1,8)
}
if ($2 == !d10) {
msg $chan $nick rolles a $rand(1,10)
}
if ($2 == !d12) {
msg $chan $nick rolles a $rand(1,12)
}
if ($2 == !d20) {
msg $chan $nick rolles a $rand(1,20)
}
if ($2 == !d100) {
msg $chan $nick rolles a $rand(1,100)
}
like i said earlier UNTESTED
Last edited by Sleepyfreak; 25/06/05 08:25 AM.
and thats the way the scout leader burns
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
on *:text:!d*:#:{ if ($int($mid($1,3)) isnum 1-) { msg $chan $nick rolles a $rand(1, [ $v1 ] ) } }
|
|
|
|
Joined: May 2005
Posts: 106
Vogon poet
|
Vogon poet
Joined: May 2005
Posts: 106 |
nice script Davec but should mine work altho?
and thats the way the scout leader burns
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
if ($2 == !d4) {
should have been
if ($1 == !d4) {
same for the others
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Hehe couldn't resist:
on *:text:/^!d([1-9]\d?|100)$/:#: msg # $nick rolls a $r(1,$regml(1))
Gone.
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
on *:TEXT:!d*:#:{
tokenize 32 $int($+(0,[color:orange]$mid($1,3)[/color])) $iif(($int($+(0,$2)) >= 1),$v1,1) $int($3) 0
[color:blue]if (($1 isnum 2-100) && ($2 isnum 1-20) && ($3 isnum)) {[/color]
var %rolls, %total
var %i = $2
while (%i) {
var %roll = $rand(1,$1)
var %rolls = $instok(%rolls,%roll,1,44)
inc %total %roll
dec %i
}
inc %total $3
msg $chan Die Rolls %rolls giving a final value of %total
}
[color:blue]else { msg $chan !d<dice sides 2-100> <number of rolls 1-20> <additional value> }[/color]
}
If you want to change the sides of the dice from being up to 100 then change the 2-100 in the blue lines, same for the number of rolls allowed 1-20, large disce sides and or to many rolls well cause the script to not display correctly due to line length limits in /msg and or in mirc itself. If you alter the trigger from !d then you must correct the orange $mid($1,3) replacing the 3 with one more than the letters in the trigger, ie : !diceroll would be $mid($1,10)
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Errr I forgot the $ event prefix there. Oh well
Gone.
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
I was going to try a regex but im still sucky at them, and though the time it takes me to make it would out weigh its worth, and someone would eend up showing me one half its size <groan>
|
|
|
|
Joined: Sep 2004
Posts: 200
Fjord artisan
|
Fjord artisan
Joined: Sep 2004
Posts: 200 |
on $*:text:/^!(\d+)d(\d+)(\+(\d+))?$/g:#: {
; $regml(1) is the number before the d
; $regml(2) is the number after the d
; $regml(3) is the number after the +
; You dont need the +num so it will work without it or with it
var %1 = $regml(1)
var %2 = $regml(2)
var %3 = $regml(3)
if (%2 !isnum 2-1000) || (%1 !isnum 1-200) .notice $nick The number of sides on the die must be within 2-1000, the number of die that are rolled must be within 1-200.
else {
while (%1) {
dec %1
var %4 = $calc(%4 + $rand(1,%2))
}
msg $chan $nick $+ , You rolled $calc(%4 + %3) in total.
}
}
i tested it and it works perfectly.
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
Two things. (1) It helps to tell them what the format of the trigger is !<rolls>d<dice sides>+<additional value> (2) If your not going to show the dice rolls why do em? on $*:text:/^!(\d+)d(\d+)(\+(\d+))?$/g:#: {
if (($regml(1) isnum 1-200) && ($regml(2) isnum 2-1000)) { msg $chan $nick $+ , You rolled $calc($rand($regml(1),$calc($regml(1) * $regml(2))) + $regml(3)) in total. }
else { .notice $nick Format !<rolls>d<dice sides>+<additional value> The number of die that are rolled must be within 1-200 & The number of sides on the die must be within 2-1000 . }
}
|
|
|
|
Joined: Sep 2004
Posts: 200
Fjord artisan
|
Fjord artisan
Joined: Sep 2004
Posts: 200 |
thats the wrong format. the format is !<num>d<num>[+num] the last +num i improved my old one so you can use '-', too
on $*:text:/^!(\d+)d(\d+)((\+|-)(\d+))?$/g:#: {
var %1 = $regml(1), %2 = $regml(2), %3 = $regml(3)
if (%2 !isnum 2-1000) || (%1 !isnum 1-200) .notice $nick The syntax for rolling die is !<1-200>d<2-200>(+/- num)
else {
while (%1) {
dec %1
var %4 = $calc(%4 + $rand(1,%2))
}
msg $chan $nick $+ , You rolled $calc(%4 %3) in total.
}
}
Last edited by IR_n00b; 26/06/05 12:38 PM.
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
the format is !<num>d<num>[+num] Looks the same in my books, its just i dont use < > or [ ] to indercate optionability, i write it down in docs normally, i was just being quick and dirty here, guess thats my fault. Anyway, nice improvement, accept you didnt pickup on that fact you dont need to roll the dice X number of times say its a 6 sided dice rolled 10 times, any result is possable from 10 to 60, so you just choose a random number from 10 to 60 var %4 = $rand(%1,$calc(%1 * %2))
|
|
|
|
Joined: Sep 2004
Posts: 200
Fjord artisan
|
Fjord artisan
Joined: Sep 2004
Posts: 200 |
well, i guess thats true, but its easier for people to learn if you use it this way, i dont realy think people learn that fast from crowded things it makes it look complicated and it ends in them giving up
on $*:text:/^!(\d+)d(\d+)((\+|-|\^|\*|\/)(\d+))?$/g:#: {
; $regml(1) is the number before the d
; $regml(2) is the number after the d
; $regml(3) is the number after the +|-|*|/|^
; You dont need the +-*/^, but if you do specify it you need to put a value after it so it will work without it or with it
var %1 = $regml(1), %2 = $regml(2), %3 = $regml(3), %a = $regml(4), %b = $regml(5)
if (%a == ^) && (%b !isnum 1-5) .notice $nick If you use ^ (to the X power) the last number you specify must be within 1-5.
elseif (%a == *) && (%b !isnum 0.01-50) .notice $nick If you use * (multiply by) the last number you specify must be within 0.01-50.
elseif (%a = /) && (%b !isnum 2-50) .notice $nick If you use / (divide by) the last number you specify must be within 1-50.
elseif (%2 !isnum 2-1000) || (%1 !isnum 1-200) .notice $nick The number of sides on the die must be within 2-1000, the number of die that are rolled must be within 1-200.
else {
msg $chan $nick $+ , You rolled $calc($rand(%1,$calc(%1 * %2)) %3) in total.
}
}
|
|
|
|
Joined: Feb 2004
Posts: 9
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Feb 2004
Posts: 9 |
thanks all!
it works great now plus i learned some new functions with scripting.
|
|
|
|
Joined: Sep 2004
Posts: 200
Fjord artisan
|
Fjord artisan
Joined: Sep 2004
Posts: 200 |
you can read mIRCs scripting manual, type /help or /help <somthing to search for> most people probly learned to script that way and advanced by experiance
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
In addition: If you are using this as part of a script, where you want to store the damage values of a weapon or spell or whatever, and have it calculate damage at a later point, you can use something like this... Create a table of your weapons (you can add more weapon data such as weight and speed and size if you want):
hmake weapons 10
hadd weapons shortsword 1d4
hadd weapons flail 1d8+1
Send your weapon name with /attack:
alias attack {
set %damage 0
set %dice 1
while (%dice <= $gettok($gettok($hget(weapons,$1).data,1,32),1,100)) {
set %damage $calc(%damage + $rand(1,$gettok($gettok($gettok($hget(weapons,$1).data,1,32),2,100),1,43)) + $gettok($hget(weapons,$1),2,43))
inc %dice
}
unset %dice
}
Example attack: Player has the Flail: /attack flail %damage = 1 roll of $rand(1,8) + 1
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Apr 2003
Posts: 701
Hoopy frood
|
Hoopy frood
Joined: Apr 2003
Posts: 701 |
If you throw 10 6 sided dice (or 1 die 10 times) the sum will indeed be a number between 10 and 60, but it will not be the same as just picking a random number between 10 and 60.
Let's check probabilities for 2 dice: throwing a 2=1+1: 1/6 * 1/6 = 1/36 chance throwing a 3=2+1 or 1+2: 2/36 chance throwing a 4=1+3 or 2+2 or 3+1: 3/36 chance throwing a 7= 1+6 or 2+5 or 3+3 or 4+2 or 5+2 or 6+1: 6/36 chance etc
Just choosing a random number between 2 and 12: 1/10 chance for all outcomes...
|
|
|
|
|