Random Variable Engine suddenly broken?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Orion
Posts: 6
Joined: 22 Aug 2015 18:39

Random Variable Engine suddenly broken?

#1 Post by Orion » 22 Aug 2015 18:42

I have an issue with a Batch script. Im using a 20 sided dice roll script, which by itself works fine.
I added it to a game Im working on, and the first few times, it worked fine. Suddenly it broke. Now instead of rolling 20 or below, its spitting out 56, 89, 34, etc, and the result is repeatedly coming up at 1.

Here is the original script for the 20 sided dice:

Code: Select all

:ROLL
COLOR 0F
SET DICE_ROLL=%RANDOM:~3,4%
::
IF '%DICE_ROLL%'== '1' GOTO SHOWRESULT
IF '%DICE_ROLL%'== '2' GOTO SHOWRESULT
IF '%DICE_ROLL%'== '3' GOTO SHOWRESULT
IF '%DICE_ROLL%'== '4' GOTO SHOWRESULT
IF '%DICE_ROLL%'== '5' GOTO SHOWRESULT
IF '%DICE_ROLL%'== '6' GOTO SHOWRESULT
IF '%DICE_ROLL%'== '7' GOTO SHOWRESULT
IF '%DICE_ROLL%'== '8' GOTO SHOWRESULT
IF '%DICE_ROLL%'== '9' GOTO SHOWRESULT
IF '%DICE_ROLL%'== '10' GOTO SHOWRESULT
IF '%DICE_ROLL%'== '11' GOTO SHOWRESULT
IF '%DICE_ROLL%'== '12' GOTO SHOWRESULT
IF '%DICE_ROLL%'== '13' GOTO SHOWRESULT
IF '%DICE_ROLL%'== '14' GOTO SHOWRESULT
IF '%DICE_ROLL%'== '15' GOTO SHOWRESULT
IF '%DICE_ROLL%'== '16' GOTO SHOWRESULT
IF '%DICE_ROLL%'== '17' GOTO SHOWRESULT
IF '%DICE_ROLL%'== '18' GOTO SHOWRESULT
IF '%DICE_ROLL%'== '19' GOTO SHOWRESULT
IF '%DICE_ROLL%'== '20' GOTO SHOWRESULT
GOTO ROLL
::
:SHOWRESULT
ECHO.
ECHO.
ECHO 20 Sided Roll
ECHO You Rolled a "%DICE_ROLL%"
ECHO.
set /p ENTER= "again, restart"
IF '%ENTER%'=='again' GOTO ROLL
IF '%ENTER%'=='restart' CALL ENTRY.BAT

(ENTRY.BAT being an external file unrelated to this problem)



Now heres the code in question, as you can see its very repetitive:



Code: Select all

@ECHO OFF
TITLE GAMEMENU
::
CLS
:WELCOME
COLOR 0f
ECHO Welcome to the Delta Luminaire Star System.
ECHO Lets create a character, first.
ECHO Start By choosing a species...
PAUSE

set /p CHARRACE= "Mandriti, Human, Valluesuti"

IF '%CHARRACE%'=='Mandriti' GOTO GAMEMDRT
IF '%CHARRACE%'=='Human' GOTO GAMEHUMAN
IF '%CHARRACE%'=='Valluesuti' GOTO GAMEVALL
::
:GAMEMDRT
ECHO You have chosen Mandriti, a very rare and nearly extinct species.
ECHO Mandriti are thought to originate from the planet Verderous.
ECHO Althoug this is the preferred idea, the majority of living
ECHO Mandriti are extremely tight-lipped about their origins.
PAUSE
ECHO The Mandriti resemble a humanoid.
ECHO Part squid, part plant, and bipedal.
ECHO Their skin is a variety of a green and blue shades.
PAUSE
ECHO Next lets roll for your starting attributes, and
ECHO pick your starting skills, which will aid you in your adventures.
PAUSE
GOTO MDRTCHARCREATE





:MDRTCHARCREATE
ECHO In a moment, you will roll for your Attributes.
ECHO You will roll a d20 4 times, and each number, will be up to you
ECHO to assign to whichever attribute you prefer.
PAUSE
GOTO ROLL


So it goes to roll, but from there it goes to crap. and previously it was working fine before i repeated the script 3 extra times........



:ROLL
COLOR 0F
SET DICE_ROLL=%RANDOM:~3,4%
::
IF '%DICE_ROLL%'== '1' GOTO SHOWRESULT1
IF '%DICE_ROLL%'== '2' GOTO SHOWRESULT2
IF '%DICE_ROLL%'== '3' GOTO SHOWRESULT3
IF '%DICE_ROLL%'== '4' GOTO SHOWRESULT4
IF '%DICE_ROLL%'== '5' GOTO SHOWRESULT5
IF '%DICE_ROLL%'== '6' GOTO SHOWRESULT6
IF '%DICE_ROLL%'== '7' GOTO SHOWRESULT7
IF '%DICE_ROLL%'== '8' GOTO SHOWRESULT8
IF '%DICE_ROLL%'== '9' GOTO SHOWRESULT9
IF '%DICE_ROLL%'== '10' GOTO SHOWRESULT10
IF '%DICE_ROLL%'== '11' GOTO SHOWRESULT11
IF '%DICE_ROLL%'== '12' GOTO SHOWRESULT12
IF '%DICE_ROLL%'== '13' GOTO SHOWRESULT13
IF '%DICE_ROLL%'== '14' GOTO SHOWRESULT14
IF '%DICE_ROLL%'== '15' GOTO SHOWRESULT15
IF '%DICE_ROLL%'== '16' GOTO SHOWRESULT16
IF '%DICE_ROLL%'== '17' GOTO SHOWRESULT17
IF '%DICE_ROLL%'== '18' GOTO SHOWRESULT18
IF '%DICE_ROLL%'== '19' GOTO SHOWRESULT19
IF '%DICE_ROLL%'== '20' GOTO SHOWRESULT20

IF '%DICE_ROLL%'== '%DICE_ROLL%>20' GOTO ROLL
::

:SHOWRESULT1
ECHO.
ECHO.
ECHO 20 Sided Roll
ECHO You Rolled a "%DICE_ROLL%"
ECHO.
GOTO ATRPICKMDRT1


:SHOWRESULT2
ECHO.
ECHO.
ECHO 20 Sided Roll
ECHO You Rolled a "%DICE_ROLL%"
ECHO.
GOTO ATRPICKMDRT2


:SHOWRESULT3
ECHO.
ECHO.
ECHO 20 Sided Roll
ECHO You Rolled a "%DICE_ROLL%"
ECHO.
GOTO ATRPICKMDRT3


:SHOWRESULT4
ECHO.
ECHO.
ECHO 20 Sided Roll
ECHO You Rolled a "%DICE_ROLL%"
ECHO.
GOTO ATRPICKMDRT4


:SHOWRESULT5
ECHO.
ECHO.
ECHO 20 Sided Roll
ECHO You Rolled a "%DICE_ROLL%"
ECHO.
GOTO ATRPICKMDRT5


:SHOWRESULT6
ECHO.
ECHO.
ECHO 20 Sided Roll
ECHO You Rolled a "%DICE_ROLL%"
ECHO.
GOTO ATRPICKMDRT6


:SHOWRESULT7
ECHO.
ECHO.
ECHO 20 Sided Roll
ECHO You Rolled a "%DICE_ROLL%"
ECHO.
GOTO ATRPICKMDRT7


:SHOWRESULT8
ECHO.
ECHO.
ECHO 20 Sided Roll
ECHO You Rolled a "%DICE_ROLL%"
ECHO.
GOTO ATRPICKMDRT8


:SHOWRESULT9
ECHO.
ECHO.
ECHO 20 Sided Roll
ECHO You Rolled a "%DICE_ROLL%"
ECHO.
GOTO ATRPICKMDRT9


:SHOWRESULT10
ECHO.
ECHO.
ECHO 20 Sided Roll
ECHO You Rolled a "%DICE_ROLL%"
ECHO.
GOTO ATRPICKMDRT10


:SHOWRESULT11
ECHO.
ECHO.
ECHO 20 Sided Roll
ECHO You Rolled a "%DICE_ROLL%"
ECHO.
GOTO ATRPICKMDRT11


:SHOWRESULT12
ECHO.
ECHO.
ECHO 20 Sided Roll
ECHO You Rolled a "%DICE_ROLL%"
ECHO.
GOTO ATRPICKMDRT12


:SHOWRESULT13
ECHO.
ECHO.
ECHO 20 Sided Roll
ECHO You Rolled a "%DICE_ROLL%"
ECHO.
GOTO ATRPICKMDRT13

:SHOWRESULT14
ECHO.
ECHO.
ECHO 20 Sided Roll
ECHO You Rolled a "%DICE_ROLL%"
ECHO.
GOTO ATRPICKMDRT14


:SHOWRESULT15
ECHO.
ECHO.
ECHO 20 Sided Roll
ECHO You Rolled a "%DICE_ROLL%"
ECHO.
GOTO ATRPICKMDRT15


:SHOWRESULT16
ECHO.
ECHO.
ECHO 20 Sided Roll
ECHO You Rolled a "%DICE_ROLL%"
ECHO.
GOTO ATRPICKMDRT16


:SHOWRESULT17
ECHO.
ECHO.
ECHO 20 Sided Roll
ECHO You Rolled a "%DICE_ROLL%"
ECHO.
GOTO ATRPICKMDRT17

:SHOWRESULT18
ECHO.
ECHO.
ECHO 20 Sided Roll
ECHO You Rolled a "%DICE_ROLL%"
ECHO.
GOTO ATRPICKMDRT18


:SHOWRESULT19
ECHO.
ECHO.
ECHO 20 Sided Roll
ECHO You Rolled a "%DICE_ROLL%"
ECHO.
GOTO ATRPICKMDRT19

:SHOWRESULT20
ECHO.
ECHO.
ECHO 20 Sided Roll
ECHO You Rolled a "%DICE_ROLL%"
ECHO.
GOTO ATRPICKMDRT20




:ATRPICKMDRT1
ECHO You Rolled a 1.
ECHO Please pick an Attribute to assign 1 to.
ECHO These are your Attributes.
ECHO Health, Strength, Speed, Intelligence
ECHo Abreviated respectively, as Hp, Str, Spd, and Int.
set /p ENTER= "Hp, Str, Spd, Int"
IF '%ENTER%'=='Hp' GOTO MDRATRREMEMBERHP1
IF '%ENTER%'=='Str' GOTO MDRATRREMEMBERSTR1
IF '%ENTER%'=='Spd' GOTO MDRATRREMEMBERSPD1
IF '%ENTER%'=='Int' GOTO MDRATRREMEMBERINT1

:MDRATRREMEMBERHP1
ECHO You have an Hp of 1.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSTR1
ECHO You have an Str of 1.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSPD1
ECHO You have an Spd of 1.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERINT1
ECHO You have an Int of 1
PAUSE
GOTO ROLL2






:ATRPICKMDRT2
ECHO You Rolled a 2.
ECHO Please pick an Attribute to assign 2 to.
ECHO These are your Attributes.
ECHO Health, Strength, Speed, Intelligence
ECHo Abreviated respectively, as Hp, Str, Spd, and Int.
set /p ENTER= "Hp, Str, Spd, Int"
IF '%ENTER%'=='Hp' GOTO MDRATRREMEMBERHP2
IF '%ENTER%'=='Str' GOTO MDRATRREMEMBERSTR2
IF '%ENTER%'=='Spd' GOTO MDRATRREMEMBERSPD2
IF '%ENTER%'=='Int' GOTO MDRATRREMEMBERINT2

:MDRATRREMEMBERHP2
ECHO You have an Hp of 2.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSTR2
ECHO You have an Str of 2.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSPD2
ECHO You have an Spd of 2.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERINT2
ECHO You have an Int of 2
PAUSE
GOTO ROLL2

:ATRPICKMDRT3
ECHO You Rolled a 3.
ECHO Please pick an Attribute to assign 3 to.
ECHO These are your Attributes.
ECHO Health, Strength, Speed, Intelligence
ECHo Abreviated respectively, as Hp, Str, Spd, and Int.
set /p ENTER= "Hp, Str, Spd, Int"
IF '%ENTER%'=='Hp' GOTO MDRATRREMEMBERHP3
IF '%ENTER%'=='Str' GOTO MDRATRREMEMBERSTR3
IF '%ENTER%'=='Spd' GOTO MDRATRREMEMBERSPD3
IF '%ENTER%'=='Int' GOTO MDRATRREMEMBERINT3

:MDRATRREMEMBERHP3
ECHO You have an Hp of 3.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSTR3
ECHO You have an Str of 3.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSPD3
ECHO You have an Spd of 3.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERINT3
ECHO You have an Int of 3
PAUSE
GOTO ROLL2

:ATRPICKMDRT4
ECHO You Rolled a 4.
ECHO Please pick an Attribute to assign 4 to.
ECHO These are your Attributes.
ECHO Health, Strength, Speed, Intelligence
ECHo Abreviated respectively, as Hp, Str, Spd, and Int.
set /p ENTER= "Hp, Str, Spd, Int"
IF '%ENTER%'=='Hp' GOTO MDRATRREMEMBERHP4
IF '%ENTER%'=='Str' GOTO MDRATRREMEMBERSTR4
IF '%ENTER%'=='Spd' GOTO MDRATRREMEMBERSPD4
IF '%ENTER%'=='Int' GOTO MDRATRREMEMBERINT4

:MDRATRREMEMBERHP4
ECHO You have an Hp of 4.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSTR4
ECHO You have an Str of 4.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSPD4
ECHO You have an Spd of 4.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERINT4
ECHO You have an Int of 4
PAUSE
GOTO ROLL2

:ATRPICKMDRT5
ECHO You Rolled a 5.
ECHO Please pick an Attribute to assign 5 to.
ECHO These are your Attributes.
ECHO Health, Strength, Speed, Intelligence
ECHo Abreviated respectively, as Hp, Str, Spd, and Int.
set /p ENTER= "Hp, Str, Spd, Int"
IF '%ENTER%'=='Hp' GOTO MDRATRREMEMBERHP5
IF '%ENTER%'=='Str' GOTO MDRATRREMEMBERSTR5
IF '%ENTER%'=='Spd' GOTO MDRATRREMEMBERSPD5
IF '%ENTER%'=='Int' GOTO MDRATRREMEMBERINT5

:MDRATRREMEMBERHP5
ECHO You have an Hp of 5.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSTR5
ECHO You have an Str of 5.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSPD5
ECHO You have an Spd of 5.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERINT5
ECHO You have an Int of 5
PAUSE
GOTO ROLL2

:ATRPICKMDRT6
ECHO You Rolled a 6.
ECHO Please pick an Attribute to assign 6 to.
ECHO These are your Attributes.
ECHO Health, Strength, Speed, Intelligence
ECHo Abreviated respectively, as Hp, Str, Spd, and Int.
set /p ENTER= "Hp, Str, Spd, Int"
IF '%ENTER%'=='Hp' GOTO MDRATRREMEMBERHP6
IF '%ENTER%'=='Str' GOTO MDRATRREMEMBERSTR6
IF '%ENTER%'=='Spd' GOTO MDRATRREMEMBERSPD6
IF '%ENTER%'=='Int' GOTO MDRATRREMEMBERINT6

:MDRATRREMEMBERHP6
ECHO You have an Hp of 6.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSTR6
ECHO You have an Str of 6.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSPD6
ECHO You have an Spd of 6.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERINT6
ECHO You have an Int of 6
PAUSE
GOTO ROLL2

:ATRPICKMDRT7
ECHO You Rolled a 7.
ECHO Please pick an Attribute to assign 7 to.
ECHO These are your Attributes.
ECHO Health, Strength, Speed, Intelligence
ECHo Abreviated respectively, as Hp, Str, Spd, and Int.
set /p ENTER= "Hp, Str, Spd, Int"
IF '%ENTER%'=='Hp' GOTO MDRATRREMEMBERHP7
IF '%ENTER%'=='Str' GOTO MDRATRREMEMBERSTR7
IF '%ENTER%'=='Spd' GOTO MDRATRREMEMBERSPD7
IF '%ENTER%'=='Int' GOTO MDRATRREMEMBERINT7

:MDRATRREMEMBERHP7
ECHO You have an Hp of 7.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSTR7
ECHO You have an Str of 7.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSPD7
ECHO You have an Spd of 7.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERINT7
ECHO You have an Int of 7
PAUSE
GOTO ROLL2

:ATRPICKMDRT8
ECHO You Rolled a 8.
ECHO Please pick an Attribute to assign 8 to.
ECHO These are your Attributes.
ECHO Health, Strength, Speed, Intelligence
ECHo Abreviated respectively, as Hp, Str, Spd, and Int.
set /p ENTER= "Hp, Str, Spd, Int"
IF '%ENTER%'=='Hp' GOTO MDRATRREMEMBERHP8
IF '%ENTER%'=='Str' GOTO MDRATRREMEMBERSTR8
IF '%ENTER%'=='Spd' GOTO MDRATRREMEMBERSPD8
IF '%ENTER%'=='Int' GOTO MDRATRREMEMBERINT8

:MDRATRREMEMBERHP8
ECHO You have an Hp of 8.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSTR8
ECHO You have an Str of 8.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSPD8
ECHO You have an Spd of 8.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERINT8
ECHO You have an Int of 8
PAUSE
GOTO ROLL2

:ATRPICKMDRT9
ECHO You Rolled a 9.
ECHO Please pick an Attribute to assign 9 to.
ECHO These are your Attributes.
ECHO Health, Strength, Speed, Intelligence
ECHo Abreviated respectively, as Hp, Str, Spd, and Int.
set /p ENTER= "Hp, Str, Spd, Int"
IF '%ENTER%'=='Hp' GOTO MDRATRREMEMBERHP9
IF '%ENTER%'=='Str' GOTO MDRATRREMEMBERSTR9
IF '%ENTER%'=='Spd' GOTO MDRATRREMEMBERSPD9
IF '%ENTER%'=='Int' GOTO MDRATRREMEMBERINT9

:MDRATRREMEMBERHP9
ECHO You have an Hp of 9.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSTR9
ECHO You have an Str of 9.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSPD9
ECHO You have an Spd of 9.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERINT9
ECHO You have an Int of 9
PAUSE
GOTO ROLL2


:ATRPICKMDRT10
ECHO You Rolled a 10.
ECHO Please pick an Attribute to assign 10 to.
ECHO These are your Attributes.
ECHO Health, Strength, Speed, Intelligence
ECHo Abreviated respectively, as Hp, Str, Spd, and Int.
set /p ENTER= "Hp, Str, Spd, Int"
IF '%ENTER%'=='Hp' GOTO MDRATRREMEMBERHP10
IF '%ENTER%'=='Str' GOTO MDRATRREMEMBERSTR10
IF '%ENTER%'=='Spd' GOTO MDRATRREMEMBERSPD10
IF '%ENTER%'=='Int' GOTO MDRATRREMEMBERINT10

:MDRATRREMEMBERHP10
ECHO You have an Hp of 10.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSTR10
ECHO You have an Str of 10.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSPD10
ECHO You have an Spd of 10.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERINT10
ECHO You have an Int of 10
PAUSE
GOTO ROLL2

:ATRPICKMDRT11
ECHO You Rolled a 11.
ECHO Please pick an Attribute to assign 11 to.
ECHO These are your Attributes.
ECHO Health, Strength, Speed, Intelligence
ECHo Abreviated respectively, as Hp, Str, Spd, and Int.
set /p ENTER= "Hp, Str, Spd, Int"
IF '%ENTER%'=='Hp' GOTO MDRATRREMEMBERHP11
IF '%ENTER%'=='Str' GOTO MDRATRREMEMBERSTR11
IF '%ENTER%'=='Spd' GOTO MDRATRREMEMBERSPD11
IF '%ENTER%'=='Int' GOTO MDRATRREMEMBERINT11

:MDRATRREMEMBERHP11
ECHO You have an Hp of 11.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSTR11
ECHO You have an Str of 11.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSPD11
ECHO You have an Spd of 11.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERINT11
ECHO You have an Int of 11
PAUSE
GOTO ROLL2

:ATRPICKMDRT1
ECHO You Rolled a 12.
ECHO Please pick an Attribute to assign 12 to.
ECHO These are your Attributes.
ECHO Health, Strength, Speed, Intelligence
ECHo Abreviated respectively, as Hp, Str, Spd, and Int.
set /p ENTER= "Hp, Str, Spd, Int"
IF '%ENTER%'=='Hp' GOTO MDRATRREMEMBERHP1
IF '%ENTER%'=='Str' GOTO MDRATRREMEMBERSTR12
IF '%ENTER%'=='Spd' GOTO MDRATRREMEMBERSPD12
IF '%ENTER%'=='Int' GOTO MDRATRREMEMBERINT12

:MDRATRREMEMBERHP12
ECHO You have an Hp of 12.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSTR12
ECHO You have an Str of 12.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSPD12
ECHO You have an Spd of 12.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERINT12
ECHO You have an Int of 12
PAUSE
GOTO ROLL2


:ATRPICKMDRT13
ECHO You Rolled a 13.
ECHO Please pick an Attribute to assign 13 to.
ECHO These are your Attributes.
ECHO Health, Strength, Speed, Intelligence
ECHo Abreviated respectively, as Hp, Str, Spd, and Int.
set /p ENTER= "Hp, Str, Spd, Int"
IF '%ENTER%'=='Hp' GOTO MDRATRREMEMBERHP13
IF '%ENTER%'=='Str' GOTO MDRATRREMEMBERSTR13
IF '%ENTER%'=='Spd' GOTO MDRATRREMEMBERSPD13
IF '%ENTER%'=='Int' GOTO MDRATRREMEMBERINT13

:MDRATRREMEMBERHP13
ECHO You have an Hp of 13.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSTR13
ECHO You have an Str of 13.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSPD13
ECHO You have an Spd of 13.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERINT13
ECHO You have an Int of 13
PAUSE
GOTO ROLL2

:ATRPICKMDRT14
ECHO You Rolled a 14.
ECHO Please pick an Attribute to assign 14 to.
ECHO These are your Attributes.
ECHO Health, Strength, Speed, Intelligence
ECHo Abreviated respectively, as Hp, Str, Spd, and Int.
set /p ENTER= "Hp, Str, Spd, Int"
IF '%ENTER%'=='Hp' GOTO MDRATRREMEMBERHP14
IF '%ENTER%'=='Str' GOTO MDRATRREMEMBERSTR14
IF '%ENTER%'=='Spd' GOTO MDRATRREMEMBERSPD14
IF '%ENTER%'=='Int' GOTO MDRATRREMEMBERINT14

:MDRATRREMEMBERHP14
ECHO You have an Hp of 14.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSTR14
ECHO You have an Str of 14.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSPD14
ECHO You have an Spd of 14.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERINT14
ECHO You have an Int of 14
PAUSE
GOTO ROLL2

:ATRPICKMDRT15
ECHO You Rolled a 15.
ECHO Please pick an Attribute to assign 15 to.
ECHO These are your Attributes.
ECHO Health, Strength, Speed, Intelligence
ECHo Abreviated respectively, as Hp, Str, Spd, and Int.
set /p ENTER= "Hp, Str, Spd, Int"
IF '%ENTER%'=='Hp' GOTO MDRATRREMEMBERHP15
IF '%ENTER%'=='Str' GOTO MDRATRREMEMBERSTR15
IF '%ENTER%'=='Spd' GOTO MDRATRREMEMBERSPD15
IF '%ENTER%'=='Int' GOTO MDRATRREMEMBERINT15

:MDRATRREMEMBERHP15
ECHO You have an Hp of 15.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSTR15
ECHO You have an Str of 15.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSPD15
ECHO You have an Spd of 15.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERINT15
ECHO You have an Int of 15
PAUSE
GOTO ROLL2


:ATRPICKMDRT16
ECHO You Rolled a 16.
ECHO Please pick an Attribute to assign 16 to.
ECHO These are your Attributes.
ECHO Health, Strength, Speed, Intelligence
ECHo Abreviated respectively, as Hp, Str, Spd, and Int.
set /p ENTER= "Hp, Str, Spd, Int"
IF '%ENTER%'=='Hp' GOTO MDRATRREMEMBERHP16
IF '%ENTER%'=='Str' GOTO MDRATRREMEMBERSTR16
IF '%ENTER%'=='Spd' GOTO MDRATRREMEMBERSPD16
IF '%ENTER%'=='Int' GOTO MDRATRREMEMBERINT16

:MDRATRREMEMBERHP16
ECHO You have an Hp of 16.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSTR16
ECHO You have an Str of 16.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSPD16
ECHO You have an Spd of 16.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERINT16
ECHO You have an Int of 16
PAUSE
GOTO ROLL2

:ATRPICKMDRT17
ECHO You Rolled a 17.
ECHO Please pick an Attribute to assign 17 to.
ECHO These are your Attributes.
ECHO Health, Strength, Speed, Intelligence
ECHo Abreviated respectively, as Hp, Str, Spd, and Int.
set /p ENTER= "Hp, Str, Spd, Int"
IF '%ENTER%'=='Hp' GOTO MDRATRREMEMBERHP17
IF '%ENTER%'=='Str' GOTO MDRATRREMEMBERSTR17
IF '%ENTER%'=='Spd' GOTO MDRATRREMEMBERSPD17
IF '%ENTER%'=='Int' GOTO MDRATRREMEMBERINT17

:MDRATRREMEMBERHP17
ECHO You have an Hp of 17.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSTR17
ECHO You have an Str of 17.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSPD17
ECHO You have an Spd of 17.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERINT17
ECHO You have an Int of 17
PAUSE
GOTO ROLL2

:ATRPICKMDRT18
ECHO You Rolled a 18.
ECHO Please pick an Attribute to assign 18 to.
ECHO These are your Attributes.
ECHO Health, Strength, Speed, Intelligence
ECHo Abreviated respectively, as Hp, Str, Spd, and Int.
set /p ENTER= "Hp, Str, Spd, Int"
IF '%ENTER%'=='Hp' GOTO MDRATRREMEMBERHP18
IF '%ENTER%'=='Str' GOTO MDRATRREMEMBERSTR18
IF '%ENTER%'=='Spd' GOTO MDRATRREMEMBERSPD18
IF '%ENTER%'=='Int' GOTO MDRATRREMEMBERINT18

:MDRATRREMEMBERHP18
ECHO You have an Hp of 18.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSTR18
ECHO You have an Str of 18.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSPD18
ECHO You have an Spd of 18.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERINT18
ECHO You have an Int of 18
PAUSE
GOTO ROLL2


:ATRPICKMDRT19
ECHO You Rolled a 19.
ECHO Please pick an Attribute to assign 19 to.
ECHO These are your Attributes.
ECHO Health, Strength, Speed, Intelligence
ECHo Abreviated respectively, as Hp, Str, Spd, and Int.
set /p ENTER= "Hp, Str, Spd, Int"
IF '%ENTER%'=='Hp' GOTO MDRATRREMEMBERHP19
IF '%ENTER%'=='Str' GOTO MDRATRREMEMBERSTR19
IF '%ENTER%'=='Spd' GOTO MDRATRREMEMBERSPD19
IF '%ENTER%'=='Int' GOTO MDRATRREMEMBERINT19

:MDRATRREMEMBERHP19
ECHO You have an Hp of 19.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSTR19
ECHO You have an Str of 19.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSPD19
ECHO You have an Spd of 19.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERINT19
ECHO You have an Int of 19
PAUSE
GOTO ROLL2


:ATRPICKMDRT20
ECHO You Rolled a 20.
ECHO Please pick an Attribute to assign 20 to.
ECHO These are your Attributes.
ECHO Health, Strength, Speed, Intelligence
ECHo Abreviated respectively, as Hp, Str, Spd, and Int.
set /p ENTER= "Hp, Str, Spd, Int"
IF '%ENTER%'=='Hp' GOTO MDRATRREMEMBERHP20
IF '%ENTER%'=='Str' GOTO MDRATRREMEMBERSTR20
IF '%ENTER%'=='Spd' GOTO MDRATRREMEMBERSPD20
IF '%ENTER%'=='Int' GOTO MDRATRREMEMBERINT20

:MDRATRREMEMBERHP20
ECHO You have an Hp of 20.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSTR20
ECHO You have an Str of 20.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERSPD20
ECHO You have an Spd of 20.
PAUSE
GOTO ROLL2
:MDRATRREMEMBERINT20
ECHO You have an Int of 20
PAUSE
GOTO ROLL2

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Random Variable Engine suddenly broken?

#2 Post by foxidrive » 22 Aug 2015 19:30

You can get the dice roll from 1 to 20 using this line:

Code: Select all

SET /a DICE_ROLL=%RANDOM% %% 20 + 1
echo %dice_roll%


This line is broken syntax but you don't need it with the code above.

Code: Select all

IF '%DICE_ROLL%'== '%DICE_ROLL%>20' GOTO ROLL

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: Random Variable Engine suddenly broken?

#3 Post by Compo » 24 Aug 2015 07:21

As a side note, to the fix provided by foxidrive

Here is some re-jigging of your code in order to show you how you may achieve similar results without having so much repetition.

Code: Select all

@ECHO OFF
TITLE GAMEMENU
COLOR 0F
CLS

:WELCOME
ECHO=&ECHO=Welcome to the Delta Luminaire Star System.
ECHO=Lets create a character, first.
PING -n 6 0.0.0.0 1>NUL

:SPECIES
CLS
ECHO=&ECHO=Start By choosing a species...

ECHO=&ECHO=      Human
ECHO=Some information about the Humans

ECHO=&ECHO=      Manditiri
ECHO=The Mandriti resemble a humanoid.
ECHO=Part squid, part plant, and bipedal.
ECHO=Their skin is a variety of a green and blue shades.
ECHO=A very rare and nearly extinct species, the Mandriti
ECHO= are thought to originate from the planet Verderous.
ECHO=Although this is the preferred idea, the majority of living
ECHO= Mandriti are extremely tight-lipped about their origins.

ECHO=&ECHO=      Valluesuti
ECHO=Some information about the Valluesuti

ECHO=&SETLOCAL ENABLEDELAYEDEXPANSION
SET/P CHARRACE="Human, Mandriti, Valluesuti [ H | M | V ]: "
ECHO=%CHARRACE:~,1%|FINDSTR/I "H M V">NUL||GOTO :SPECIES
IF /I %CHARRACE:~,1%==H (SET CHARRACE=Human
) ELSE (IF /I %CHARRACE:~,1%==M (SET CHARRACE=Mandriti
   ) ELSE (SET CHARRACE=Valluesuti
   )
)
CLS&ECHO=&ECHO=You have chosen %CHARRACE%&ECHO=

:CHARCREATE
ECHO=Next lets roll for your starting attributes, and
ECHO=pick your starting skills, which will aid you in your adventures.
PING -n 6 0.0.0.0 1>NUL
ECHO=&ECHO=In a moment, you will roll for your Attributes.
ECHO=You will roll a d20 4 times, and each number, will be up to you
ECHO=to assign to whichever attribute you prefer.
ECHO=&PAUSE

CALL :ROLL 1
CALL :ATRPICK 1
CALL :ROLL 2
CALL :ATRPICK 2
CALL :ROLL 3
CALL :ATRPICK 3
CALL :ROLL 4
CALL :ATRPICK 4

ECHO=&ECHO=Your %CHARRACE% HEALTH is %HEALTH%
ECHO=Your %CHARRACE% KNOWLEDGE is %KNOWLEDGE%
ECHO=Your %CHARRACE% MIGHT is %MIGHT%
ECHO=Your %CHARRACE% SPEED is %SPEED%
ECHO=&PAUSE

EXIT/B

:ROLL
SET/A "DICE_ROLL=%RANDOM% %% 20 + 1"
CLS&ECHO=&ECHO=&ECHO=20 Sided Roll&ECHO=&ECHO=You Rolled a "%DICE_ROLL%"&ECHO=
GOTO :EOF
   
:ATRPICK
SET FAT=
FOR %%A IN (HEALTH KNOWLEDGE MIGHT SPEED) DO (
   IF !%%A!' EQU  ' SET "FAT=!FAT! %%A,"
)
SET IAT=
FOR %%A IN (%FAT%) DO (FOR /F "DELIMS=ENIP" %%B IN ("%%A"
   ) DO SET "IAT=!IAT! %%B |"
)
ECHO=HEALTH [%HEALTH%] KNOWLEDGE [%KNOWLEDGE%] MIGHT [%MIGHT%] SPEED [%SPEED%]
ECHO=&ECHO=Please pick an Attribute to assign %DICE_ROLL% to.
ECHO=&ECHO=These are your available Attributes.
SET/P "ATT=!FAT:~,-1! [%IAT:~,-1%]: "
ECHO=%ATT:~,1%|FINDSTR/I "!IAT:|=!">NUL||GOTO :ATRPICK
IF /I %ATT:~,1%==H (SET HEALTH=%DICE_ROLL%
) ELSE (IF /I %ATT:~,1%==K (SET KNOWLEDGE=%DICE_ROLL%
   ) ELSE (IF /I %ATT:~,1%==M (SET MIGHT=%DICE_ROLL%
      ) ELSE (SET SPEED=%DICE_ROLL%
      )
   )
)
GOTO :EOF

Orion
Posts: 6
Joined: 22 Aug 2015 18:39

Re: Random Variable Engine suddenly broken?

#4 Post by Orion » 24 Aug 2015 12:14

Thanks for the replies.

I'll have to reconsider editing the script.

I have a second question...

How would I get the code to remember which variable is picked for charrace. For instance I've got the mandriti or MDRT tag on nearly every variable so far. But

What I want is for after character creation the game to go to charfinalize. I guess what I was thinking is char finalize would call the variables that were entered either way because the path that would be chosen by the player.

Like Mdrthp and humnhp ....the later game would need to be able to store that value.... what I was thinking was the same script for charcreation would bounce in the end to charfinalize.. or would I have to make 3 separate char finalize for each race.... Cuz I'm not sure char finalize would distinguish between the race attributes without tacking on a whole new variable....does that make sense?

Post Reply