5. In The Gym!
It's been a long haul and I know this is the one people have been waiting for. As such this will probably the be last tutorial for a little while.
With it you can populate a gym with trainers or create legendaries throughout the world. We'll be covering each of these in turn in revere order.
5.1 Overworld Sprites
This script has to be one of the easiest to make and therefore it's very tempting to use it a lot but trust me.. You shouldn't. That's what wildbattles are for and they are set us using advancemap.
We already learned in 'In Motion' how to make a person disapear from the map. This script is going to create a wild pokemon which will hang around outside the Gym we will be creating later.
It's script will go something like this:
1. On talking to the pokemon it gives off a cry and makes the apropriate sound.
2. If you have the gym badge a wildbattle then commences
- If you beat the pokemon it will vanish.
Now. As discussed in "A Simple Pokescript Tutorial" the usual run is to perform the above functions in reverse, however this list actually comes in two part because 2b is dependant on number 2. This means that for once the first thing on the list is the first thing we do.
1. Pokemon Cry
Most of these commands will be familia to you. There's only one new command here and that's Cry.
Cry playes a sound from a bank of sound effects and takes one number only, the number of the pokemon. These numbers are the same as the numbers of the pokemon themselves making the script very simple. On this case we're going to make a Charmeleon. You can get this from the file in the Resources section.
#org $StartWild
lock
faceplayer
cry 5
message $charCry
$charcry 1 = Charmeleon:Raarg!
boxset 6
The above is pretty much the normal text box script. If all we were doing was making a pokemon sprite that didn't have to battle then we could just put an end statement after this and leave it at that. We have out message, we have our variable and we have the command 'boxset' to display the message.
In this case we're using pokemon 5 - Charmeleon. It's a simple command and adds that little bit of life to the pokemon.
Next comes our check. After defeating the Gym leader you get a badge and this badge is turned on and off by the setting of a flag. The flags for these badges are these ones:
0x807 - First Badge - Stone Badge
0x808 - Second Badge - Knuckle Badge
0x809 - Third Badge - Dyamo Badge
0x80A - Fourth Badge - Heat Badge
0x80B - Fifth Badge - Balance Badge
0x80C - Sixth Badge - Feather Badge
0x80D - Seventh Badge - Mind Badge
0x80E - Eighth Badge - Rainbow Badge
So our next step is to check one of these flags. For the purpose of this tutorial we're checking the Knuckle badge which means the next three lines look like this:
checkflag 0x808
if 0x1 goto $WildBatt
release
end
Thats the Pokemon event. Not all that difficult, all we need to do now is the actual battle so lets move right along.
5.2 WildBattle
Here's the start of this powerful but very short script.
#org $Wildbatt
lock
wildbattle 5 20 1
That's it. wildbattle. The command has three properties, <pokemon> <level> and <mode>.
Again, the pokemon is the same number as the givepokemon command and the same number as the cry command. That doesn't change at any point in the program. Wherever you see that command you can use that value. In this script we're going to use a level 20 charmeleon. The pokemons attacks and abilities will be sorted out by the computer as though it were a normal wild battle like you get when walking through the grass. The only thing you need to think about is the mode.
This mode determines the field the battle is taking place on.
0 = grass
1 = water
2 = rock
3 for desert
You can play with these all you want but remember that the field the pokemon plays on will influence it's strength as well as the strength of the players pokemon. Also these values may mean different things in Fire-Red/Leafgreen then they do in Ruby/Saphire.
Either way is provides a good way to balance or unbalance the battle that's going to take place. The battlefield can also be changed by the weather on the map and this can be set from advancedmap in the 'Header View' tab.
Last but not least, if you loose you battle your script will stop here and you'll wake up near the last pokemon center. That's built into the command so you don't need to worry about it. If you win the battle however then the pokemon must vanish; to do to this we set a flag just like we did with during the 'In Motion' section.
Remember you must release the character before setting the flag. Another trick here is to simply use the command fadescreen 0 without the original fadescreen 1[i] to create a kind of blink effect.
The resulting script looks like this:
Code:
#org $StartWild
lock
faceplayer
cry 5
message $charCry
$charcry 1 = Charmeleon:Raarg!
boxset 6
checkflag 0x808
if 0x1 goto $WildBatt
release
end
#org $Wildbatt
lock
wildbattle 5 20 1
release
setflag 0x500
fadescreen 0
endAnd that's your Overworld-Pokemon. Just make sure to set your pokemond PEOPLE ID in advanced-map to the flag at the end (0x500 in this case).
5.3 Find Your Trainer
Now we begin the processs of creating trainerbattle scripts. To fully explore the Trainerbattle command We're going to create three battle script which we can put inside a map of our choosing. These will be:
1. A simple Trainer battle.
2. A two-on-two battle.
3. A Gym Leader
We'll do these in order of complexity (top to bottom). The scripts aren't all that difficult, it's just keeping track of which one your using.
But first thing first.
You will also need to download a copy of Advanced Battle from the download site. This program will allow you to view the pokemon each trainer has and edit the the trainers stats. We wont be doing any editing today and I'll be telling you the trainers number for our scripts but this is a really handy program and much more stable than the one provided in the Elitemap package. The file "advancebattleevo.exe" is the english version of the program, the other is in German.
Please note that Advancebattle displays the trainers in Alphabetical Order. If you want to change this to number order then save the file "trainers.txt" from the resouces section into "inis/Dutch" in the Advanced Battle folder. and rename it to "Trainers.ini" Replacing the file there.
All of the battles we're about to use work with the same command, and the first few are actually quite simple so we're just going to breeze through them.
Here's the actual command.
[i]Trainerbattle <mode> <Trainer> <Challenge> <Defeat> <Optional>
The Reason we're covering it in sections is because the usage of the command changes slightly depending which mode you use. The modes are listed as this:
0 - Normal Battle
1 - Gym Battle
4 - Re-Battle Dual (Not Logged)
3 - Re-Battle Gym (Not Logged)
4 - Dual Battles
5 - Re-battle Normal (Not Logged)
Lets start at the very beginning shall we.
5.4. Basic Trainer Script
Alright. This is actually a very quick little script. so I'm simply going to give it to you and explain it afterwards.
[code]#org $Trainer1
lock
faceplayer
trainerbattle 0 395 $MadChall $MadDefeat
$MadChall 1 = Madeline: I am mighty... I hope!
$MadDefeat 1 = Madeline: Oh poor Numel!!!!
message $MadTalk
$MadTalk 1 = I thought having a fire pokemon\iwould help make me stronger.\pI Guess I was wrong.
boxset 6
release
end[code]
Believe it or not the command is that simple. 395 is the number for trainer Madeline (Parasol Lady with a Numel,) the pointers display the text to show before and after the battle and the final message is displayed if you talk to her again after the battle. This script is ready to put on a player as it is!
Heck, make two or three variations of these and you can populate your Gym with trainers...
5.5 Dual Battles
Now we are going to introduce the use of the <optional> property.
Under our previous script this <optional> was left out as it wasn't used. Here it will act as a pointer to text like this:
trainerbattle 4 258 $AMChall $AMDefeat $AMNoBattle
$AMChall 1 = Anna: The others say we're not tough\lenough for this Gym.\pMeg: Well Show Em!
$AMDefeat 1 = Anna: I guess they were right!\pMeg: Dont worry, We'll improve.
$AMNoBattle 1 = Meg:On no.\pAnna: You can't battle us with\ljust one pokemon!
You can clearly see the mesage here. This check is done automatically by the program and failing to have a minimum of two pokemon will cause the script to stop right there.
Otherwise it's almost identical... Make sure you use two sprites on the map and give them the same script, or you can create two versions of the script that say different things but use the same trainer number.
The complete code:
[code]#org $Trainer2
lock
faceplayer
trainerbattle 4 258 $AMChall $AMDefeat $AMNoBattle
$AMChall 1 = Anna: The others say we're not tough\lenough for this Gym.\pMeg: Well Show Em!
$AMDefeat 1 = Anna: I guess they were right!\pMeg: Dont worry, We'll improve.
$AMNoBattle 1 = Meg:On no.\pAnna: You can't battle us with\ljust one pokemon!
message $AMTalk
$AMTalk 1 = Anna: You just wait and see!
boxset 6
release
end[code]
5.6 Gym Leaders
Finally things start getting complicated.
The gym leader script is required to perform a series of tasks (such as handing over gym badges) after you beat them. The initial script is very similar to the above ones so here it is:
Code:
#org $Trainer1
lock
faceplayer
trainerbattle 0 114 $BernChall $BernDefeat $BernCode
$BernChall 1 = Bernie: I am might... I hope!
$BernDefeat 1 = Bernie: Oh poor Numel!!!!
message $BernTalk
$BernTalk 1 = Wow.. Colour be Burned!
boxset 6
release
endIn this script the last pointer for the trainerbattle command links to more code after the battle is over. If you loose then the script terminates without performing this code.
$Berncode can do anything you want but amongst that code you have to give the trainer a badge. This is done by setting the flag mentioned above.
Not all that difficult in reality is it. Here is the other half of the Gym Leader Script.
Code:
#org $BernCode
message $Congrats
$Congrats 1 = BERNIE: Your a pretty good trainer!\pAs leader of this Gym it is now my Duty to give you the Knuckle Badge.
boxset 6
setflag 0x808
jingle
message $GotBadge
$Gotbadge 1 = You recieved the Knuckle Badge!\pBERNIE: That badge will allow you to control\lall pokemon above level X\nAnd will also let your pokemon perform\lTASK outside of battle.\pWhile I'm at it you can have this!
boxset 6
giveitem 0x5f 1
message $FireStone
$FireStone 1 = That is a Firestone.\nIt will evolve some Fire type pokemon.\pAlso, There's a really strong pokemon outside.\nI couldn't catch it cause my pokemon\lweren't strong enough but you\ncan go for it if you want!
boxset 6
end
And that links up to the script we made earlier.
5.7 Rebattle
If you look at the battle types mentioned earlier you'll notice the 'Rebattle' values. Battles started with these types will take place every time you activate the trainer. You must aproach them to make these battles happen, but most trainers don't rebattle every time you aproach, only when the 'Rebattle' event allows them to. The way you check for this is with a compare command as trainerbattle will place the value '1' in LASTRESULT if the trainer is ready to battle again.
Moditying the 'Basic Trainer Script' from section 5.4 that makes the command look like this:
trainerbattle 0 395 $MadChall $MadDefeat
compare LASTRESULT 1
if B_TRUE goto $ReBattle
Just modify any of the script above to include that compare and you're ready to do a rebattle section. Rebattle scripts are identical to the normal scripts, the only difference being the lack of logging. You can also use the re-battle command on it's own without the check to make a trainer that will challenge you every time they see you, and the Pokemon League trainers are all made using Gym-Rebattle scripts.. Give it a go!
5.8 Battle On Site
Ok, this isn't actually pokescript related. To make a trainer battle you on site you need to configure it in Advancedmap. This means checking the box marked 'Trainer' and setting the 'View Range' field to a number of steps. This value must be written in hex.
Hope you Enjoy Your Gym.