For a long time I have wanted to program a game and I always thought it would be too difficult, so I started programming in the popular site Scratch (http://ift.tt/1FVDfju) and doing websites with html and css.
I started to want to actually make a game with code so I am learning batch files. Unfortunately I only just started and am confused with a section on the game. I am making a game to try and recreate the game Swords and Sandals 2 to improve my knowledge of batch files. The important part of the game is the damage you deal to your opposition. Obviously you need a percentage chance for your attack to work to input luck into the game. I could easily do that but I want it so that if you have a higher level variable you will have a higher percentage chance, but if your opponent has some defence it will reduce the chance.
I did some basic maths to come up with some equations I was happy with, so here is the section of code :
if %move% equ 2 set /a tauntchance=%RANDOM%*(100+(%oppdefence%*5))/32768+1
if %move% equ 2 set /a tauntchance1=(7+(%charisma%*3))
if %move% equ 2 if tauntchance leq %tauntchance1% set /a damage= ((%charisma%*2)-%RANDOM%*1/32768+1)
if %move% equ 2 set /a energy=%energy%-%charisma%
move=The chosen option
tauntchance=A random number from 0-(100+(The opponents defence*5))
tauntchance1=(7+(Your charisma level*3))
3rd Line= If tauntchance is less than or equal to tauntchance1 then set your damage to Your Charisma Level*2 with a 50% chance to remove 1 or 0, which just stays the same.
4th Line= External variables including your energy amount.
When I run this code the window crashes. If you know if this is possible please let me know!
I have done lots of previous research without any results on this specific topic.
Aucun commentaire:
Enregistrer un commentaire