When you scripting something, you expect something to happen BY THE BOOK. This also means that you know exactly what will happen. Pokemon never really had an element of randomness, other than maybe the pokemon you encounter. However, PKSV does come with a way to implement some randomness into your scripts. This can cause events to happen RANDOMLY!!!
randomnumbers.pks | |
File Size: | 0 kb |
File Type: | pks |
Since randomness is not used much in the pokemon games, this is probably the first "new" thing that can be implemented into the game. Random events scripts are also not very hard to write, since there is only 1 new line to learn today.
random (dec or hex number) shall generate a random number from the range of 0 to the largest integer smaller than the selected number. For example, if I write
random 10 -OR- random 0xA
The possible numbers generated are from 0-9. The generated number is then stored into "LASTRESULT", or "0x800D". You then compare LASTRESULT with a possible number to get different results.
We're going to write a script where you can trigger a level script. Depending on the number generated, stepping on the level script can get you different results. I'm going to make a small 3x3 area of level scripts.
random (dec or hex number) shall generate a random number from the range of 0 to the largest integer smaller than the selected number. For example, if I write
random 10 -OR- random 0xA
The possible numbers generated are from 0-9. The generated number is then stored into "LASTRESULT", or "0x800D". You then compare LASTRESULT with a possible number to get different results.
We're going to write a script where you can trigger a level script. Depending on the number generated, stepping on the level script can get you different results. I'm going to make a small 3x3 area of level scripts.
I'm going to make it so that every time you step on one of these level scripts, there is a 1/4 chance that a message pops up, telling you that you found a masterball (I'm going to add onto this mini-game in a future lesson if I remember).
The ending result looks something like this.
The ending result looks something like this.
found_masterball.pks | |
File Size: | 0 kb |
File Type: | pks |
Adding some randomness to a game can be frustrating to the player, but this always gives the game an "original" taste. The player can play the game a million times, but will never be able to know exactly what will happen. While Pokemon lacks this element, adding it into the game isn't hard. But all this talk about Pokemon allows us to get into the magical creatures of the game. Go onto the next lesson to learn commands relating to the pokemon.