So there is some problem in this code, its probably just some punctuation error that I haven't noticed yet but for some reason I cant find it.
I read that this is how to do a loop with Do then the number of times, in this case '%dmg%', tell me if this wasn't true.
I do have parts that define the variables;
set dmgt=0 set /a wl=1000*%upts%/%epts% and I do have all of the others set.
Using the pause command I found this is the problem;
if %upts%*%utroop% LEQ %epts%*%etroopt% ( goto fail
) else ( set /a dmg=%wl%*%etroop%/1000
set /a dmgt=%dmg%+%dmgt%
do %dmg%
SET /A type=%RANDOM% * 3 / 32768 + 1
if %type% == 1 ( if %snip% GEQ 1 ( set /a dmg=%dmg%-1
set /a snip=%snip%-1
)
)
if %type% == 2 ( if %mgs% GEQ 1 ( set /a dmg=%dmg%-2
set /a mgs=%mgs%-1
)
)
if %type% == 3 ( if %rif% GEQ 1 ( set /a dmg=%dmg%-1
set /a rif=%rif%-1
)
)
enddo
)
if %upts%*%utroop% LEQ %epts%*%etroopt%does not calculate the value of each side, it strings togetherthe contants of upts*the contents of utroopand compares that string against the RHS. You need to explicitly calculate the two values into variables using aSET.Your
ELSEclause invokes a "block statement" that is, the ENTIRE contents of the parenthesised series of statements up to the closing)followingenddo. Batch parses the statement from theIFthrough to the closing parenthesis of theELSEblock, substitutes for any%var%with the PARSE-TIME value ofvarand THEN executes the result. Consequently,TYPEwill appear unchanged to the logic within the block.You'd need to invoke
delayedexpansionmode and use!var!to access the RUN-TIME value ofvar. This is done with aSETLOCAL ENABLEDELAYEDEXPANSIONstatement, usually inserted after the opening@echo offat the start of the batch (hence turning delayedexpansion and the!var!facility ON for the entire duration of the batch)Actually, there's no need for an
ELSEclause as you have it because youGOTOa label in the true part. This may simplify your code.Finally, there's no
DO/ENDDOfacility in batch - or at least, not in that form. I'll presume that you intend to do the intervening code%dmg%times. You can achieve this by usingwhere the metavariable
%%zwill be incremented from the first element in the parentheses to the last in steps of the second.%%zcan be any letter, but is one of the very few cases in batch which IS case-sensitive.