Dice Based Combat

N

Nasaki

Guest
So currently I'm working on a game where the battle system is completely RNG based kinda like D and D where number values determine damage or crits. I was able to get a dice working but i noticed that you can continuously press the right key to continue rolling which is something that shouldn't be available is there something i can do about this?

Also there are currently 3 different dices each does something different which i will go into detail below:
1. Crit dice: This is a 4 sided dice that is labeled as 0,1,2,3 which is a multiplier for your damage dice that obviously increases your damage if you land on it.
2. Damage dice: This is a 4 sided dice (can be upgraded to 6 sided) that has set numbers depending on the dice level (lvl. 1 is 4 reaches 4, lvl. 2 is a 5 sided reaches max 5, and lvl 3 is max number 6) and every so often a glow will appear on a random number (this is a crit glow I'm probably gonna need help programming that as well.
3. Item Dice: This is a 4 sided dice (can be upgraded) that uses items that are currently in your inventory but instead of numbers they are symbols that display either a buff, debuff , healing , or a S.S item which again i wanna make these dice consistent to be random and be only pressed once per turn.

I'm relatively new to GMS 2 and I hope I can get some good advice or some code that i can use as a basis or structure if anyone has some advice or some tips please let me know.
 
D

dannyjenn

Guest
Are you new to programming (in general), or just to GMS2? Because turn-based stuff is generally going to be harder to make than action-based stuff.

To fix the problem with the continuous dice roll, you need to use a variable. Each time the player's turn starts, you'll need to do:
Code:
number_of_rolls = 1;
Then when the player rolls the die (presumably in the key pressed check event, not in the regular key check event),
Code:
if(number_of_rolls>0){
    // your code
    number_of_rolls -= 1;
}
But you're also going to need a good program flow or you're going to run into all sorts of other problems. Read up on "finite state machines" if you haven't done so already, because that's going to be important for what you're trying to do.
 
N

Nasaki

Guest
Are you new to programming (in general), or just to GMS2? Because turn-based stuff is generally going to be harder to make than action-based stuff.

To fix the problem with the continuous dice roll, you need to use a variable. Each time the player's turn starts, you'll need to do:
Code:
number_of_rolls = 1;
Then when the player rolls the die (presumably in the key pressed check event, not in the regular key check event),
Code:
if(number_of_rolls>0){
    // your code
    number_of_rolls -= 1;
}
But you're also going to need a good program flow or you're going to run into all sorts of other problems. Read up on "finite state machines" if you haven't done so already, because that's going to be important.
Thanks i appreciate it and yea im kinda new to programming but the combat isnt complex its mostly your turn you roll your dice then begin your attack then boss attacks and vice versa till you die or the boss dies.
 
Top