1.

Solve : Help please! (diceroller/counter)?

Answer»

Hey,
Im working on a code that roles some dice, counts how many are above 4, then roles that many dice, then counts how many are above five, rolls that many dice, then displays how many are above 6... its for a game im working on...

This is the code i have:

Code: [Select]echo off
:1
cls
Echo To hit
set /a R1=%random%%% 6 +1
echo %R1%
set /a R2=%random%%% 6 +1
echo %R2%
set /a R3=%random%%% 6 +1
echo %R3%
set /a R4=%random%%% 6 +1
echo %R4%
set /a R5=%random%%% 6 +1
echo %R5%

:NEXT
if %R1% GEQ 4 set /a c=1
if %R2% GEQ 4 set /a c=%c%+1
if %R3% GEQ 4 set /a c=%c%+1
if %R4% GEQ 4 set /a c=%c%+1
if %R5% GEQ 4 set /a c=%c%+1

:2
Echo To WOUND
set /a W1=%random%%% 6 +1
echo %W1%
set /a c=%c%-1
if "%c%"=="0" goto NEXT2
set /a W2=%random%%% 6 +1
echo %W2%
set /a c=%c%-1
if "%c%"=="0" goto NEXT2
set /a W3=%random%%% 6 +1
echo %W3%
set /a c=%c%-1
if "%c%"=="0" goto NEXT2
set /a W4=%random%%% 6 +1
echo %W4%
set /a c=%c%-1
if "%c%"=="0" goto NEXT2
set /a W5=%random%%% 6 +1
echo %W5%
set /a c=%c%-1
if "%c%"=="0" goto NEXT2

:NEXT2
if %W1% GEQ 5 set /a c2=1
if %W2% GEQ 5 set /a c2=%c2%+1
if %W3% GEQ 5 set /a c2=%c2%+1
if %W4% GEQ 5 set /a c2=%c2%+1
if %W5% GEQ 5 set /a c2=%c2%+1

:3
Echo Armour Save
set /a A1=%random%%% 6 +1
echo %A1%
set /a c2=%c2%-1
if "%c2%"=="0" goto NEXT3
set /a A2=%random%%% 6 +1
echo %A2%
set /a c2=%c2%-1
if "%c2%"=="0" goto NEXT3
set /a A3=%random%%% 6 +1
echo %A3%
set /a c2=%c2%-1
if "%c2%"=="0" goto NEXT3
set /a A4=%random%%% 6 +1
echo %A4%
set /a c2=%c2%-1
if "%c2%"=="0" goto NEXT3
set /a A5=%random%%% 6 +1
echo %A5%
set /a c2=%c2%-1
if "%c2%"=="0" goto NEXT3

:NEXT3
pause

it doesnt seem to work after the second count though... any advice?
Thanks!You used some QUOTES (") where you shouldn't have, and you used some variables that don't always GET a value (w1,w2,w3,w4: not all of these get a value if you roll the dice low => prog can't handle empty variables).

this should do the trick, please tell me if it works

Code: [Select]echo off
:1
cls
Echo To hit
set /a R1=%random%%% 6 +1
echo %R1%
set /a R2=%random%%% 6 +1
echo %R2%
set /a R3=%random%%% 6 +1
echo %R3%
set /a R4=%random%%% 6 +1
echo %R4%
set /a R5=%random%%% 6 +1
echo %R5%

:NEXT
if %R1% GEQ 4 set /a c=1
if %R2% GEQ 4 set /a c=%c%+1
if %R3% GEQ 4 set /a c=%c%+1
if %R4% GEQ 4 set /a c=%c%+1
if %R5% GEQ 4 set /a c=%c%+1

:2
Echo To wound
set w1=0
set W2=0
set w3=0
set W4=0
set w5=0
set /a W1=%random%%% 6 +1
echo %W1%
set /a c=%c%-1
if %c%==0 goto NEXT2
set /a W2=%random%%% 6 +1
echo %W2%
set /a c=%c%-1
if %c%==0 goto NEXT2
set /a W3=%random%%% 6 +1
echo %W3%
set /a c=%c%-1
if %c%==0 goto NEXT2
set /a W4=%random%%% 6 +1
echo %W4%
set /a c=%c%-1
if %c%==0 goto NEXT2
set /a W5=%random%%% 6 +1
echo %W5%
set /a c=%c%-1
if %c%==0 goto NEXT2

:NEXT2

if %W1% GEQ 5 set /a c2=1
if %W2% GEQ 5 set /a c2=%c2%+1
if %W3% GEQ 5 set /a c2=%c2%+1
if %W4% GEQ 5 set /a c2=%c2%+1
if %W5% GEQ 5 set /a c2=%c2%+1

:3
Echo Armour Save
set /a A1=%random%%% 6 +1
echo %A1%
set /a c2=%c2%-1
if "%c2%"=="0" goto NEXT3
set /a A2=%random%%% 6 +1
echo %A2%
set /a c2=%c2%-1
if "%c2%"=="0" goto NEXT3
set /a A3=%random%%% 6 +1
echo %A3%
set /a c2=%c2%-1
if "%c2%"=="0" goto NEXT3
set /a A4=%random%%% 6 +1
echo %A4%
set /a c2=%c2%-1
if "%c2%"=="0" goto NEXT3
set /a A5=%random%%% 6 +1
echo %A5%
set /a c2=%c2%-1
if "%c2%"=="0" goto NEXT3

:NEXT3
pause
Hi,
Its working now, but its not rolling the correct amount of Armour SAVES. Im going to give it a look and if i find the problem ill post back.
Thankyou After running the batch a few times i found what the problem is; if no rolls to wound succeed (are GEQ 5) then it rolls all of the Armour Save dice. On the other hand, if at least 1 dice is GEQ 5 then it rolls the correct amount.
I still cant find a solution, but im going to keep on looking! i got it to work. Here is the code
Code: [Select]echo off
:SV
set w1=0
set W2=0
set w3=0
set W4=0
set w5=0
set A1=0
set A2=0
set A3=0
set A4=0
set A5=0

:1
cls
Echo To hit
set /a R1=%random%%% 6 +1
echo %R1%
set /a R2=%random%%% 6 +1
echo %R2%
set /a R3=%random%%% 6 +1
echo %R3%
set /a R4=%random%%% 6 +1
echo %R4%
set /a R5=%random%%% 6 +1
echo %R5%

:NEXT
set c=1
if %R1% GEQ 4 set /a c=%c%+1
if %R2% GEQ 4 set /a c=%c%+1
if %R3% GEQ 4 set /a c=%c%+1
if %R4% GEQ 4 set /a c=%c%+1
if %R5% GEQ 4 set /a c=%c%+1

:2
Echo To wound
if %c%==1 goto NEXT2
set /a W1=%random%%% 6 +1
echo %W1%
set /a c=%c%-1
if %c%==1 goto NEXT2
set /a W2=%random%%% 6 +1
echo %W2%
set /a c=%c%-1
if %c%==1 goto NEXT2
set /a W3=%random%%% 6 +1
echo %W3%
set /a c=%c%-1
if %c%==1 goto NEXT2
set /a W4=%random%%% 6 +1
echo %W4%
set /a c=%c%-1
if %c%==1 goto NEXT2
set /a W5=%random%%% 6 +1
echo %W5%
set /a c=%c%-1
if %c%==1 goto NEXT2

:NEXT2
set c2=1
if %W1% GEQ 5 set /a c2=%c2%+1
if %W2% GEQ 5 set /a c2=%c2%+1
if %W3% GEQ 5 set /a c2=%c2%+1
if %W4% GEQ 5 set /a c2=%c2%+1
if %W5% GEQ 5 set /a c2=%c2%+1

:3
Echo Armour Save
set /a od=%c2%-1
if "%c2%"=="1" goto NEXT3
set /a A1=%random%%% 6 +1
echo %A1%
set /a c2=%c2%-1
if "%c2%"=="1" goto NEXT3
set /a A2=%random%%% 6 +1
echo %A2%
set /a c2=%c2%-1
if "%c2%"=="1" goto NEXT3
set /a A3=%random%%% 6 +1
echo %A3%
set /a c2=%c2%-1
if "%c2%"=="1" goto NEXT3
set /a A4=%random%%% 6 +1
echo %A4%
set /a c2=%c2%-1
if "%c2%"=="1" goto NEXT3
set /a A5=%random%%% 6 +1
echo %A5%
set /a c2=%c2%-1
if "%c2%"=="1" goto NEXT3

:NEXT3
if %A1% GEQ 6 set /a od=%od%-1
if %A2% GEQ 6 set /a od=%od%-1
if %A3% GEQ 6 set /a od=%od%-1
if %A4% GEQ 6 set /a od=%od%-1
if %A5% GEQ 6 set /a od=%od%-1

:FINAL
Echo %od% orks died this turn
pausegood job, i always love it when people find their own mistakes



Discussion

No Comment Found