Simple battle / dice roller problem

Any help appreciated here!
I am trying to do a very simple combat system, a random number between 1 and 12 is added to a skill. I have defined these in startup. The higher number wins the round and takes off 2 hp from the loser, this repeats until someone dies. Something isn’t right with my coding though- the numbers don’t appear to show roll scores and it doesn’t determina winner/loser:

*label roll_dice_loop
*temp thugdiceresult
*rand diceresult 1 dicesides
*rand thugdiceresult 1 dicesides
*set diceresult +skill
*set thugdiceresult +thugskill
*if (thugdiceresult < diceresult)
	*set thughp -2
*if (thugdiceresult > diceresult)
	*set stamina -2
*if (thugdiceresult = diceresult)
	*goto roll_dice_loop
*if (stamina < 1)
	*goto lose
*if (thughp < 1)
	*goto win
	*goto roll_dice_loop
Diceresult ${diceresult}
Thugdiceresult ${thugdiceresult}
*label win
You win
*label lose
You lose

The scores aren’t showing up because you put it outside the subroutine. If you trace your codeflow carefully, the code will loop through the subroutine until either loss or win, and the proceeds to the relevant scene.

To get it right

put the scores just below the “diceresult” section.

1 Like

Fantastic! thanks so much!
It works now, I am going to tidy up how it looks awful :grinning:

Diceresult 10 Thugdiceresult 28 Stamina 18 ThugHP 4 Diceresult 9 Thugdiceresult 24 Stamina 16 ThugHP 4 Diceresult 8 Thugdiceresult 30 Stamina 14 ThugHP 4 Diceresult 13 Thugdiceresult 26 Stamina 12 ThugHP 4 Diceresult 5 Thugdiceresult 28 Stamina 10 ThugHP 4 Diceresult 2 Thugdiceresult 27 Stamina 8 ThugHP 4 Diceresult 5 Thugdiceresult 25 Stamina 6 ThugHP 4 Diceresult 2 Thugdiceresult 30 Stamina 4 ThugHP 4 Diceresult 5 Thugdiceresult 25 Stamina 2 ThugHP 4 You died

You can add *page_break command after each roll to chunk it up, and add [/n] tag for line breaks.

1 Like

Much better, cheers!

1 Like