You would write a random value 1-20 into a variable and then do 20 conditional branches, if the variable is 1 you teach Fire Bolt, if it's 2 you teach Dragon Breath, and so on.
This gets a bit more complicated if you want to make sure the hero will only learn a skill they don't already know - this case I'd say the easiest way would be to put the whole thing in a loop, and instead of just teaching each skill you would use another condition inside each condition to check whether the skill was already learned, and only if no you teach it and break the loop. This way it would just try again and again random skills until it finds one that can be learned.
To avoid getting the game stuck in an infinite loop if
all 20 skills are already known, you'd then add a condition before everything else where you basically
nest 20 conditions that check for each skill, so only if all 20 are true (skills known), you would then show some message that there is nothing left to learn and exit.
Pseudocode:
Code:
if hero knows skill A
if hero knows skill B
if hero knows skill C
...
...
...
if hero knows skill T
show message: "nothing to learn"!
end event processing
: end
...
...
...
: end
: end
: end
label 1
change variable SKILL_NUM = random (1...20)
if SKILL_NUM == 1
if hero knows skill A
go to label 1
: else
teach hero skill A
: end
: end
if SKILL_NUM == 2
if hero knows skill B
go to label 1
: else
teach hero skill B
: end
: end
if SKILL_NUM == 3
if hero knows skill C
go to label 1
: else
teach hero skill C
: end
: end
...
...
...
if SKILL_NUM == 20
if hero knows skill T
go to label 1
: else
teach hero skill T
: end
: end
Here instead of a loop command and breaking the loop after teaching, I used a label at the start of the code to create the loop in order to make it shorter (because we can jump to it in one case and learn the skill in the other, instead of having an awkward empty case first and then both the breaking and the teaching in the "else").