- Joined
- Sep 9, 2013
- Messages
- 178
- Reaction score
- 40
- First Language
- German
- Primarily Uses
- RMMV
Good evening!
For my project I'm designing a class which has some "card draw" (skill draw) mechanics. It will learn a given amount of its classes skills every turn and unlearn them on the end of turn.
I guess I got the basic principle of this right:
The issue with it is that unlike a card game, skills that are already learned cannot be "drawn" (learned) again. So occassionally instead of drawing 3 skills it will happen that only 2 are drawn. And extremely rarely only 1. This happens if the skills were already learned. So in translation: If the random number (var drawn) is the same number multiple times.
I suppose I need a while loop that will break when X ( = draw number) different skills are learned. I just don't know the syntax for this.
Could someone please check if I did it right and translate this in proper RPG Maker MV script syntax?
Thank you in advance!
For my project I'm designing a class which has some "card draw" (skill draw) mechanics. It will learn a given amount of its classes skills every turn and unlearn them on the end of turn.
I guess I got the basic principle of this right:
for (var i = 4; i >= 1; i--) {
if ($gameActors.actor(i).currentClass().id == 5) { //check if the actor is this class that has deck mechanics
var drawn1 = Math.randomInt(13)+67
var drawn2 = Math.randomInt(13)+67
var drawn3 = Math.randomInt(13)+67
$gameActors.actor(i).learnSkill(drawn1)
$gameActors.actor(i).learnSkill(drawn2)
$gameActors.actor(i).learnSkill(drawn3)
}}
The issue with it is that unlike a card game, skills that are already learned cannot be "drawn" (learned) again. So occassionally instead of drawing 3 skills it will happen that only 2 are drawn. And extremely rarely only 1. This happens if the skills were already learned. So in translation: If the random number (var drawn) is the same number multiple times.
I suppose I need a while loop that will break when X ( = draw number) different skills are learned. I just don't know the syntax for this.
Could someone please check if I did it right and translate this in proper RPG Maker MV script syntax?
for (var i = 4; i >= 1; i--) {
if ($gameActors.actor(i).currentClass().id == 5) { //check if the actor is this class that has deck mechanics
var learned = 0
var draw_amount = 3
while (learned<draw_amount) {
var drawn = Math.randomInt(13)+67
if !($gameActors.actor(i).skills().contains($dataSkills[drawn]) {
$gameActors.actor(i).learnSkill(drawn)
learned +=1
}
}}}
Thank you in advance!