• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Pokescript Tutorials

Status
Not open for further replies.

Irish Witch

Office Jenny
147
Posts
17
Years
  • I have noticed a lot of poeple asking here and there for a 'Dumbed Down' or simple scripting tutorial. I am now going to attempt to make such a tutorial however (ever the spam bot) I will be writing this for MY script editor - PokeScript, which is available in the toolbox.

    First - Go to my thread in the toolbox and download the latest release of PokeScript and the PkmAdv database.
    The database needs to be installed to the same folder as PokeScript (usually c:/pokewitch)

    Note: You must have Release 11 May or Later due to Bug in Defines handler
    Update: Corrected misuse of Fanfare command in Sections 3 and 4. Use Jingle command instead.
    Update: 14/6/07 - Corrected typos in 'sample codes' that should have been picked up on by anybody actually reading the tutorial instead of copy-pasting.

    This first post will contain a list of Terms, some resource files and and full index of the threads...

    PLEASE DONT ASK QUESTIONS IN THIS THREAD
    There is now a thread titled "Pokescript Tutorials: Discussion" for questions about the tutorials or help editing them.

    This thread is divided into the Following sections:

    FORWARD
    A. Keywords
    - Hex Number
    - Offsets[/index]
    B. Resources

    ( The above will change as more tutorials are added here )

    1. My Name Is
    1.1 Getting Started
    1.2 Displaying a Message
    1.3 Writing to the rom
    1.4 Plugging it into the map

    2. I'll give you this for this!
    2.1 One time only. (Using Flags)
    2.2 Yes Or No
    2.3 Recieving Items
    2.4 Checking for Items
    2.5 Removing Items

    3. Would you like this Pokemon?!
    3.1 Vanishing Sprites
    3.2 GivePokemon
    3.3 NamePokemon
    3.4 Enable Pokedex
    3.5 CountPokemon (Proffesional Give Pokemon Script)
    3.6 SelectPokemon (Name Rater Script)

    4. In Motion!
    4.1 Preparing to Move
    4.2 Subroutines
    4.3 Applymovement
    4.4 SetVar
    4.5 Follow Me!

    5. In The Gym!
    5.1 Overworld Sprites
    5.2 Wildbattle
    5.3 Find Your Trainer
    5.4 Basic Trainer Battle
    5.5 Dual Battles
    5.6 Gym Leaders
    5.7 Rebattling
    5.8 Battle on Sight

    Coming Soon:
    6. Pokemarts
    - This may even apear before the motion scripts thanks to discussions help in the Script Debugging/Discussion Thread.!
    Forward

    Keywords
    Here are a list of keywords you might encounter while using the script and what they mean. Hopefully it will same some explaining later on.

    Hex Numbers
    A hexadecimal number (or hex number) is a number where each digit goes not from 0-9 but 0-f and is a key part of handling numbers inside of a computer environment. Hex numbers are usually identified by having the characters "&H" or "0x" written in front of them

    YOU DONT NEED TO USE HEX
    Throughout our scripts we will be alternating between hex and decimal.. if you are writing a decimal number leave the 0x off. Most of the numbers listed in the resource files are in decimal.

    Offsets
    There are three kind of offsets used in this tutorial. They look like this:
    In all of the following the number represents one of 15 buffers (or banks) inside which scripts, text and movement data can be placed. Changing this number allows you to isolate sections of script (such as text) from other sections (such as code)

    #ORG $Offset 0
    A Relative Offset This is any combination of letters and number starting with a $ symbol.. Emphasis on there being no puntuation in this kind of offset. In the case above this indicates the start of a script. The buffer if ommitted will be whatever the buffer was in the last #org statement and is usually 0.

    #inline $Variable 1 = Hi I'm John!
    $Variable 1 = Hi I'm John!

    This is a Variable (or inline) offset. In this case the buffer must be written as Only information placed on the same line as an inline offset gets placed in the buffer. Normally this is 1.

    #org 0x800100
    This is an absolute offset. Prior scripting tools only allowed these types of offsets and they refer to a fixed location in the rom itself. Needless to say this meant guessing at the offset when using older scripting tools.

    Resources
    Attached below are files you can refer to when following these tutorials or links to programs we will use.
    The Official Advanced Map Website
    Advanced Battle
    Items.txt - List of inventory items (Ruby)
    Poke.txt - Pokemon (R/S/E/FR/LG)
    FR-MOVE.txt - Movements Table(FR/LF)
    ruby-move.txt - Movements Table(R/S)
    trainers.txt - List of Trainers (r/s)​
     
    Last edited:

    Irish Witch

    Office Jenny
    147
    Posts
    17
    Years
  • My Name Is....
    The first in my re-vamped series of tutorials. Here we go into the process of thinking up your script, displaying message boxes and giving items.
    So lets get this ball rolling.

    1.1 Getting Started
    Normally the first thing you do before creating any script is to create a set of guidelines. This is essential because more often than not the order that you perform the functions in your script have to be the opposite of those listed in your guideline.

    In this case we're going to build up a give item script in a series of stages and our guideline should be something like this:

    1. You activate a character on the map.
    2. The character asks you a question
    3. If you answer yes to the question then you recieve a LavaCookie
    4. If you have already recieved then a message is displayed.​

    This is the basic list of what need to happen, but we're not going to tackle that straight away. We're going to start with just displaying a message and the basic layout of a script, followed with inserting that into your rom.

    To create the script itself you have to open notepad from the startmenu.
    The we begin almost every script the same way:
    #ORG $ShowText
    Lock
    Faceplayer


    The first command is our offset marking the beginning of a script segment. It's the equivelent of a sub or function command in other languages and is also used when performing goto and gusub commands.
    The next two commands 'lock down' the character you activate in the game so that they won't move around while the script is running and makes them turn to face the player. Virtually every script will have these two commands in the beginning of them.

    The next step is
    1.2 Displaying a message
    These commands will always be placed together. Anytime you want to display text on the screen you will come back to these commands:
    message $NoCookie
    $NoCookie 1 = I'm not made of cookies!\lYou only get one.
    boxset 6


    $NoCookie is a Variable name. You can use any word you want for a veriable name but there can't be any puntuation in it. The text itself is ordinary text. The only characters you cant write in it are [ ] ;

    To write next line chacters, end of line characters and next page characters use the symbols \l \n and \p respectively.

    And since that's all we're doing right now we'll finish this script of with
    release
    end


    Simple enough. Release is the opposite of the lock command, and end finishes the script.
    So here's a basic messagebox script:
    Code:
    #ORG $ShowText
    Lock
    Faceplayer
    message $NoCookie
    $NoCookie 1 = I'm not made of cookies!\lYou only get one.
    boxset 6
    release
    end

    In Notepad's File menu clisk "Save As" and select "All Files" from the Save As Types pull down list. Once you've done that save your file somewhere you can find it. Usually the same place as the rom your editing.

    Now to put it into our rom.

    1.3 Writing it into the Rom

    Alright. Open Explorer (My computer or My Documents) and go to the location where you saved you're .RBC file from the last section.
    click on the .rbc file with the right mouse button and click 'Compile'. A program will open up displaying a log of the compile. Some time I'll make a post explaining how to understand that but for now just close the window.
    In the folder where the .rbc file was there will now be a file with a .buf extention. Open it with a double click.
    The file will open in a program called bufrite. From here there are two ways to do this.
    The direct way, and the Fun way. Please read the direct way first to save me having to explain stuff twice..

    The Direct Way
    The direct way is, well... Direct.
    Without clicking anywhere olse Click on the book icon and you will be asked to open the rom (GBA FILE) that you want to put the script in. If you clicked on the one of the items in the listbox then hold down the shift key on your keyboard and slect the rest of the.
    After selecting your rom A little window will open up telling you how many bytes it's about to write and where to start looking. This is the free space finder. By default it will start at hex 800000.
    Click the torch button (The searchlight, get it) then select the first item in the list and click the button marked assign.

    Finally click 'Burn' in the file menu, but before you close the program write down the number that apears next to the first offset in the list ($StartScript). You'll need it later!

    The Fun Way
    Alright. Going back to just after you select the destination there is different way to do this. If you look at the names in the list then you'll notice the variable names for the text are all listed at the bottom.
    Select the items at the top that contain the scripts (not the text) and press the assign button.
    Now you are only looking for space to put the first few items - (The scripts)
    Do everything as you did with the direct way but now you'll notice the 'assign' button will read 'Reserve' and the checkbox inside the button will be checked. This safety will prevent you from overwriting anything during step two..

    Having clicked reserve, now select the items on the bottom of the list that don't have offsets written next to them. This time either change the start offset to start at &h810000 or some other number, or if you're not going to write a lot of scripts then simply select the second item that apears in the list after clicking the torch. That way you can keep you'r scripts seperate from you're text!

    Note: If you know where you wat to place your script (Like when your collowing this tutorial) then you can write it into the field next to the assign button.

    1.4 Plugging it into the map

    Last step.. I know this has been a long post but here goes.
    Open Advanced Map (Or you can use Elite map, but I'll only speek for Advanced Map)
    Open you're rom using the first button on the toolbar.
    On the left hand side will appear a list of maps in groups. Open you're map and click on 'Event View', then click on a character. It is possible to change you're characters apearance at this time but I'm not going to cover that.
    On the right hand side scroll down until you find the 'Script Offset' field. That's where you write the value you wrote down from bufrite. Save it, play it!

    YOUR DONE
    That a very basic script.

    Lets move on and make the rest of the script we planned earlier.
     
    Last edited:

    Irish Witch

    Office Jenny
    147
    Posts
    17
    Years
  • 2. I'll give you this for this!
    Keeping the ball rolling from the last tutorial, lets begin our script in earnest.

    We already now how we'll start our script so lets do the next part of our tutorial. This is actually the section we should have done first. For this script we'll Rename $ShowText to $GotCookie

    2.1 One time only. (Using Flags)
    Alright. When creating our script this function would normally go first because this is the start of our script.
    Apropriatly our first few lines are:
    #org $Startscript
    Lock
    Faceplayer


    The last item on our list is actually a check to see if we've done this script already.
    The ONLY way to store this value so that it won't be forgotten when you restart the game is by using the command setflag.

    There are aproximately 6000 true/false flags available in the program however there are a large number inside the range of 0x300 - 0x400 and 0x800 to 0x900 that are used by the program itself so it's best to avoid these numbers. Flags are usually written in hex. So pick a value.
    At this point in time we don't need to set the flag but we do need to check it using checkflag, and if true we go to another section of script.

    since I'm going to use flag 0x200 the next two lines look like this.
    checkflag 0x200
    if B_TRUE goto $GotCookie


    In the above if statement B_TRUE can also be written as 1 or 0x1. $GotCookie refers to the script we made earlier which will be placed at the end of the script we're working on now. If you've been reading along then we renamed the script for the purposes of our new script.

    2.2 Yes Or No
    Yes and no Questions are actually very similar to message boxes, mainly cause they both start with a message.
    message $AskMe
    $AskMe 1 = Would you like a Lava Cookie?
    boxset 5


    As you can see, the only difference here is in the boxset command. 6 displayed a normal textbox, but 5 also displays a "Yes/No" dialog so the user can select one.
    Unlike checkflag the boxset statement can not be followed by an if statement. The way messagebox works is by placing you're response into a location in memory referred to as LASTRESULT. To find out what this is we need to use a compare statement first.
    compare LASTRESUILT B_TRUE
    if B_False goto $DontGet


    Compare can also be used at a more advanced level to check other values in locations other than LASTRESULT and not only that but you can compare it to values other than 1 or 0 (B_True and B_False). For example, the command Countpokemon will return the number of pokemon in your party. At the moment though we don't need to worry about that cause we're nearly half way through our list of actions.
    $DontGet will be another message script we will write later making a witty remark about your not taking a cookie.

    2.3 Recieving Items
    And finally we get to recieve our cookie. The value representing the cookie is 0x26. You can get item values from items.txt in the resource section of this thread.
    It's a very simple command that has a built in check to make sure you have room in your bag. If your bag is full it will tell you and your script will end automatically.
    The command is:
    giveitem 0x26 1

    Follow that with
    setflag 0x200

    to say we've completed the script all the way through and compliment the checkflag at the beginning of the script all that remains is the usual:
    Release
    end


    So the overall code so far should read:
    Code:
    #org $Startscript
    Lock
    Faceplayer
    checkflag 0x200
    if B_TRUE goto $GotCookie
    message $AskMe
    $AskMe 1 = Would you like a Lava Cookie?
    boxset 5
    compare LASTRESUILT B_TRUE
    if B_False goto $DontGet
    giveitem 0x26 1
    setflag 0x200
    Release
    end
    
    #ORG $GotCookie
    Lock
    Faceplayer
    message $NoCookie
    $NoCookie 1 = I'm not made of cookies!\lYou only get one.
    boxset 6
    release
    end
    
    #ORG $DontGet
    Lock
    Faceplayer
    message $AllMine
    $AllMine 1 = All the more for me!
    boxset 6
    release
    end

    That's your giveitem script.

    2.4 Checking for Items

    Time for a new script. This one will follow on from the script above and I'm going to play it out like this:
    1. You activate the character on the map.
    2. If you have a lava cookie she trades it for an UltraBall
    3. If you dont have the lava cookie from the last script she tells you she likes lava cookies.
    4. If you gave her the cookie then she thanks you[/i]

    This is actually an expansion of the last script we made. The script will be almost identical so we'll breeze through most of it.
    Because our last script used flag 0x200 this script will use flag 0x201 and we'll change the offset name $GotCookie to $GotBall both at the if statement and where we display the message so we'll change that in the above script now.
    Then we put in a new command.
    Checkitem 0x26

    Checkitem will return a value indicating the number of items you have. This will be stored in LASTRESULT and can be checked using compare.
    So, bare minimum we need to do this:
    Compare LASTRESULT 1

    But this is where things get interesting. Because this is a special item it is wholely possible for us to have got lavacookies for elsewhere, so what happens if we have two cookies in our bag?
    What we need is an if statement that checks if the number is greater or lower than our desired number. So, here are the statements you can use for the IF command.
    B_<< Lower Than (0)
    B_== Equals (1)
    B_>> Greater Than (2)
    B_<= Lower than or Equal to (3)
    B_>= Greater than or Equal to (4)
    B_!= Not exactly equal to (5)​

    This brings our code to date as thus:
    #Org $StartScript
    checkflag 0x201
    if B_True goto $GotBall
    checkitem 0x26
    compare LASTRESULT 1
    if B_<< goto $NoCookie


    2.5 Removing Items
    Now assuming all goes well we need to ask the ever important Question.
    message $WantBall
    $WantBall 1 = Oh, You have a lavacookie.\pIf you give it to me I'll\lgive you this UltraBall...\pWhat do you say?
    message 5
    boxset 5
    compare LASTRESULT 1
    if B_FALSE goto $DontGet


    Later on we'll change the text in these message functions to say something apropriate.
    Now it's time to recieve the ball, and more importantly take away one of the cookies. You know the first command and the second one will seam obvious to you once you read it.
    As per the last script if you don't have room in the ball pouch the script will stop at this point.
    giveitem 0x2 1
    removeitem 0x26 1


    Simple no. Just like giveitem the properties for removeitem are the item number followed by the number of items to remove.
    If we had wanted to make the price of the UltraBall 5 cookies then we could easily change the above lines like this:
    compare LASTRESULT 5
    if B_<< goto $NoCookie


    and
    giveitem 0x2 1
    removeitem 0x26 5


    And before you know it we're done. All that remains is
    Release
    end


    and to adjust the text to something apropriate for our new script.

    Here's your code:
    Code:
    #Org $StartScript
    checkflag 0x201
    if B_True goto $GotBall
    checkitem 0x26
    compare LASTRESULT 1
    if B_<< goto $NoCookie
    message $WantBall
    $WantBall 1 = Oh, You have a lavacookie.\pIf you give it to me I'll\lgive you this UltraBall...\pWhat do you say?
    boxset 5
    compare LASTRESULT 1
    if B_FALSE goto $DontGet
    giveitem 0x2 1
    removeitem 0x26 1
    Release
    end
    
    #ORG $GotBall
    Lock
    Faceplayer
    message $LikeCookie
    $LikeCookie 1 = Thanks for the cookie!
    boxset 6
    release
    end
    
    #ORG $NoCookie
    Lock
    Faceplayer
    message $LoveCookie
    $LoveCookie 1 = I Absolutely LOVE Lava Cookies!\lThey're Just so Spicy!
    boxset 6
    release
    end
    
    #ORG $DontGet
    Lock
    Faceplayer
    message $AAAW
    $AAAW 1 = Aaw C'Mon. It's a fair trade!!\nI Love those things.
    boxset 6
    release
    end

    And Thats Part Two.
    Burn these scripts and Your Done
     
    Last edited:

    Irish Witch

    Office Jenny
    147
    Posts
    17
    Years
  • 3. Would You Like This Pokemon!

    NOTE BEFORE USE: You must be using build 30/3/7 or later of the Database for this to work smoothly
    UPDATE: Note on vanishing sprites. Must use Release before updating the screen.

    I know you've all been waiting for it so here it is.
    In this tutorial we are going to create three pokeballs that can sit on the ground or a table.
    Each script will then perform the following activities.

    1. You activate the pokeball
    2. It Tells you there's a pokemon inside the pokeball and asks if you want it.
    3. If you say no you put the pokeball back
    4. If you say yes you get the pokemon and are asked to give it a name.
    5. If you already have your first pokemon display a refusal​

    Naturally this script can be used for choosing your starting pokemon in a method other than Professor Birch's Bag so an optional sixth part is:

    If you've been following the tutorial in order than most of our script above will be old hat.
    However you will also notice that we actually have two scripts here.

    3.1 Vanishing Sprites
    The last thing that happens in the above script however is most important. The ability to make a person (or pokeball) disapear in response to the map is something you'll use much more than the give-pokemon command itself.
    It can be used for over-world pokemon like Legendaries, to make obstacles apear and disapear from your path or even to make a character 'leave' the current map.
    The process is simple enough and can even be applied to the scripts we have already made.

    At the end of each script so far we have been using the command setflag. In advanced map (right underneath the script offset field) is a field called People ID.
    To make the character vanish simply plage the number of the flag you set (leave of the 0x) into the peopl ID. It's that simple!
    When you set the flag the character will vanish when the screen updates next. There is a condition. For this to work you must Release the sprite before updating the screen or it wont vanish.
    By vanishing the sprite you can also leave the checkflag command off the beginning of the script.

    3.2 GivePokemon
    Since each of these scripts are almost identical We'll only go through it the once. We already know the bulk of this script and it's actually very similar to our giveitem script.
    We start with the following
    #org $StartChik
    checkflag 0x800
    if B_True goto $NoBall
    message $Chick
    $Chick 1 = Chikorita!\lThe Fire Bird.\pTake the Chikorita?
    boxset 5
    compare LASTRESULT 1
    if B_False goto $PutBack


    Here we deviate with two new commands. The first is Jingle. Jingle plays the sound you hear when you recieve an object. We left it out from the giveitem script simply to keep the tutorial short but we'll place it in here.
    The second command is the one we've been waiting for.
    givepokemon 152 5 0
    jingle
    message $GotChick
    $GotChick 1 = You Recieved a Chikorita
    boxset 6


    Givepokemon has three properties. <Pokemon> <Level> and <Item Held>
    The pokemon number can be retrieved from poke.txt in the resources section and the item held from the items.txt likewise. Your level can be any level you want but try to be realistic.
    Your pokemons attacks and exprience are calculated by the computer automatically and the pokemon is placed in your party and added to the pokedex. We'll activate that later.

    3.3 NamePokemon
    Now lets give the pokemon a name:
    message $NameChick
    $NameChick 1 = Would You like to give Chikorita a name?
    boxset 5
    compare LASTRESULT 1
    if b_False goto $GiveDex
    Namepokemon



    I know what your going to ask... Is that all there is to it??? Yes. Namepokemon is a specific command. It is designed to work exclusively with two other commands (Givepokemon and Selectpokemon).
    This makes it very limited to use but at the same time very powerful. The goto command here is simply being used to bypass namepokemon and go directly to our next script.
    We'll top this off by setting the flag to make the sprite vanish as we discussed earlier.
    [/i]setflag 0x203
    goto $GiveDex[/i]

    And that's the script we're going to use. We need three of these (one for each Trainer) as per these spoilers.
    At the end we're using an Absolute goto. You won't use these all that much but we're using it here to make all the script link up.
    Lets move on...

    Spoiler:


    Spoiler:


    Spoiler:


    3.4 Pokedex
    No matter which pokemon you select we then need to proceed to the following tiny script.
    It only does one thing at the moment but we'll be building on this in the next tutorial.
    It is a very simple script to give you the pokedex, turn on the 'Pokemon' option in the menu (also known as the party menu).
    The first two commands are done using system flags:
    setflag 0x800 will set turn on the pokemon menu and
    setflag 0x801 will turn on the pokedex

    So here's our Final Script
    Code:
    #org $StartChik
    checkflag 0x800
    if B_True goto $NoBall
    message $Chick
    $Chick 1 = Chikorita!\lThe Fire Bird.\pTake the Chikorita?
    boxset 5
    compare LASTRESULT 1
    if B_False goto $PutBack
    givepokemon 152 5 0
    jingle
    message $GotChick
    $GotChick 1 = You Recieved a Chikorita
    boxset 6
    message $NameChick
    $NameChick 1 = Would You like to give Chikorita a name?
    boxset 5
    compare LASTRESULT 1
    if b_False goto $GiveDex
    Namepokemon
    setflag 0x203
    goto $GiveDex
    
    #org $StartShrew
    checkflag 0x800
    if B_True goto $NoBall
    message $Shrew
    $Shrew 1 = SandShrew!\lDesert Mole.\pTake the Sandshrew?
    boxset 5
    compare LASTRESULT 1
    if B_False goto $PutBack
    givepokemon 27 5 0
    jingle
    message $GotChick
    $GotShrew 1 = You Recieved a Sandshrew
    boxset 6
    message $NameShrew
    $NameShrew 1 = Would You like to give Sandshrew a name?
    boxset 5
    compare LASTRESULT 1
    if b_False goto $GiveDex
    Namepokemon
    setflag 0x204
    goto $GiveDex
    
    #org $StartWing
    checkflag 0x800
    if B_True goto $NoBall
    message $Chick
    $Wing 1 = Wingull!\lThe Ocean Bird.\pTake the Wingull?
    boxset 5
    compare LASTRESULT 1
    if B_False goto $PutBack
    givepokemon 152 5 0
    jingle
    message $GotGull
    $GotGull 1 = You Recieved a Wingull
    boxset 6
    message $NameGull
    $NameGull 1 = Would You like to give Wingull a name?
    boxset 5
    compare LASTRESULT 1
    if b_False goto $GiveDex
    Namepokemon
    setflag 0x205
    goto $GiveDex
    
    #org $GiveDex
    setflag 0x800
    setflag 0x801
    message $Pokedex
    $Pokedex 1 = I hope You like your new pokemon.\pWhile your on your journeys I have\la favour to ask you.\pProf OAK and I are trying to make an\lindex of everything pokemon.\pTake this pokedex with you and it\lwill log all the pokemon you see and catch.\pIt would greatly help our studies!
    boxset 6
    jingle
    message $GotDex
    $Gotdex 1 = You got the Pokedex!
    boxset 6
    end
    
    #org $PutBack
    message $PutBack
    $PutBack 1 = You put the pokeball back.
    boxset 6
    end
    
    #org $NoBall
    message $Lastball
    $Lastball 1 = You already have your pokemon.\nDont be so greedy!
    boxset 6

    Note: Bufrite will switch to the log view after you write this script to the rom. If you scroll up to the beginning of the log it will look something like this:
    Code:
     - Pushed startpokemon.$startchik to 800000
    #PROCESS: D:\PokeWitch\POKEMON SAPPHIRE VERSION.GBA F:2 for read
    ---------------------------------------------------------------
     - Pushed startpokemon.$startshrew to 80007A
     - Pushed startpokemon.$startwing to 8000F4
     - Pushed startpokemon.$givedex to 80016E
     - Pushed startpokemon.$putback to 800188
     - Pushed startpokemon.$noball to 80018F
     - Pushed startpokemon.$chick to 800195
     - Pushed startpokemon.$gotchick to 8001C3
     - Pushed startpokemon.$namechick to 8001DC
     - Pushed startpokemon.$shrew to 800205
     - Pushed startpokemon.$gotshrew to 800231
     - Pushed startpokemon.$nameshrew to 80024A
     - Pushed startpokemon.$wing to 800273
     - Pushed startpokemon.$gotgull to 80029E
     - Pushed startpokemon.$namegull to 8002B5
     - Pushed startpokemon.$pokedex to 8002DC
     - Pushed startpokemon.$gotdex to 8003E9
     - Pushed startpokemon.$lastball to 8001B8

    Those puch commands are listing the locations in the rom that each offset is written to. The values for $Startchik, $StartShrew and $StartWing are the ones we'll attach to the pokeball. These numbers go into the 'script offset' field, and the end of each of these scripts we've calles a setflag. That flag goes into the 'People Id' field as discussed in the vanishing sprites section. Here is a list of the flags for quick reference:
    $Offset = Flag
    $StartChik = 0x203
    $StartShrew = 0x204
    $StartWing = 0x204

    In the next tutorial we'll be modifing this script a little more using movement commands but before we do that I want to introduce two more commands.

    3.5 CountPokemon
    The countpokemon function doesn't take any properties. It's job is to return the number of pokemon in your party and can be used for a couple of purposes.
    Later on we'll use it in conjunction with the trainerbattle commands but right now I'm going to provide you with a straight up give pokemon command. In it we'll insert the following code snippet.
    countpokemon
    compare LASTRESULT 6
    if b_True goto $FullParty


    In the above script we're using the command to make sure there is room in your party for the new pokemon. The start pokemon scripts don't need this check because you can only do them once at the very beginning of the game. This script though will make sure you dont 'lose' the pokemon by marking the script as done even though you don't have room for the pokemon in your party.
    Using the other methods for the if statement it is also possible to do things like this:
    Must have more than one pokemon to enter
    compare LASTRESULT 1
    if b_>> goto $EnterRoom​
    Must have EXACTLY two pokemon to battle
    compare LASTRESULT 2
    if b_!= goto $DualBattle​
    Cant have more than 3 pokemon to enter
    compare LASTRESULT 3
    if b_<= goto $EnterBattle​

    etc etc...
    Here's the script in a handy spoiler tag to save room:
    Spoiler:


    3.6 SelectPokemon
    This is probably the least useful of pokemon related commands (at this point in time). This command displays the 'Select a pokemon' dialog that get's displayed before trading or when you talk to the name rater. At the moment not enouogh in known to use this command for anything other than renaming at the moment and the command has no properties so all I can show you is a completed script for renaming a selected pokemon.

    Spoiler:


    And that's it for this Tutorial
    See you Next time!
     
    Last edited:

    Irish Witch

    Office Jenny
    147
    Posts
    17
    Years
  • 4. In Motion!

    I'm going to continue on from the previous tutorial here with a motion tutorial. People seam to have a lot of trouble with this subject and really motion scripts seam to become necessary long before battle scripts anyhow.
    Before we start this we need to do some extra fore-planning. Open up advancedmap and open up Professor Birch's Labratory (Ruby/Saphire).
    For the purpose of this tutorial we will be using this map however the process can be adapted for any map.
    Later on you will also need Ruby-Move.txt or FR-Move.txt from the resouces section at the beginning of the thread.

    4.1 Preparing to Move

    Creating motion is whole dependant on the map you are using. Attached below is a screen capture of Professor birchs labratory for reference. For the purposes of this tutorial set up your map to resemble this.
    The boxes around the entrance are script objects, all the other boxes are 'signposts'. The difference between these are that signposts must be on a solid object and are interacted with like a person where script objects are intended to be walked on to trigger them.
    The three pokeballs are actually 'people' with their sprite number set to 59. The position of the signposts are irrelivent but the pokeballs and the script objects must be set up like in the map to work with this tutorial.
    You can change the number of each script objects etc using the event manager at the bottom right of the screen.


    During the course of our script we will be moving both Professor Birch and Brendan so before creating our script we are now going to go through and make notes on these two people. Click on each character and write down the following values (May differ from mine) If they do differ you'll have to modify these values to match yours:
    Professor Birch:
    - People No: 2
    - 8 Spaces from at entrance

    Brendan:
    - People No: 3
    - Also 8 spaces from at entrance
    - 4 spaces from next to pokeballs.


    While we're here we are also going to make sure of something. Set the field "Movement" for both characters to "None". This will stop the character moving around so that the movement commands work the same every time.
    Having moved the signposts around we can change the text they say at a later date using the methods used in tutorial 1. What well be focusing on right now is making the following happen.

    This Script will replace the one giving us the pokedex in the last tutorial.
    After we get the pokeball do this:
    1. Move the character back in front of professor oak and display the text giving us the pokedex.
    (Between 3 and 5 steps left, 1 step upward)
    2. Give us the pokedex.​

    Sound simple but in practice not so simple. We've already done the first step and made a script to give us the pokedex so what we need to do now is put the movement text in prior to displaying the text.
    To do this we must make make allowances for there being three pokeballs and therefore three possible movements. This is done using a series of checkflags and a really cool method referred to as a subroutine.

    4.2 Subroutines
    This is a subject I could have covered at an earlier date but we didn't have the need for it. Subroutines are the scripting equivelent of an if-and or if-else statement. the last line of a subroutine is Return not end and when you script reached this line it goes back to the line after the gosub. Here's an example of what I mean.
    Code:
    #org $IF_OR
    checkflag 0x203
    if b_True gosub $Move1
    checkflag 0x204
    if b_True gosub $Move2
    checkflag 0x205
    if b_True gosub $Move3
    end
    
    ' Each $Move script ends with a 'return' statement

    Code:
    #org $IF_AND
    checkflag 0x203
    if b_True gosub $TestFlag2
    end
    
    #ORG $TestFlag2
    checkflag 0x204
    if b_True gosub $DoMove
    return
    
    ' $DoMove script ends with a return statement

    These two methods above while dislexic compared to some programming languages allow you to perform a function at hand and then return to the original script. The GivePokemon script in the last tutorial could have easily utilised subroutines fo the rename section had we wanted to but it wouldn't have influenced the way the code worked, just the neatness of the script.
    This spoiler contains the equivelent code of the above script if written in something like BASIC. This is just for those of you curious about the methods because pokescript has nowhere near this flexibility as yet (I may figure out how to do this, but not yet.)
    Spoiler:


    In this case we're using the the code for an If_or statement which when plugged into our give-pokedex script looks like this:
    Spoiler:


    Now on to the actual movement scripts.

    4.3 ApplyMovement
    Alright. Believe it or not momvement isn't actually very difficult once you understand the commands. The trick is all in knowing the numbers your working with. The command itself to make the movement happen is this:
    Applymovement <People No> <Offset>
    pausemove 0


    Remember at the beginning of the tutorial we wrote down some figures from our map. Well the people number goes into the apropriate field here just like before, or if you want to control the player then use the value 0xFF.

    NOTE: Your character can NOT be locked for applymovement to work. If you called Lock then you must call release before using applymovement. If you are applying movement to a character it should not be able to move around on it's own (as per the setup) so you shouldn't need to lock the character.

    Offset refers to a section of script we'll write containing a list of the movements and Pausemove is a special command that has to be written that way every single time. This will allow the script to wait until the moments are over before doing anything else. You don't need to call it straight away but it will need to be called.

    In the case of our above scripts we will be placing these commands inside our subroutines we called earlier.
    #org $Move1
    applymovement 0xFF $Ball1Move
    pausemove 0
    return


    You will need to make one of these for each pokeball.

    Movement Data
    The offset on the other hand, that's different. Underneath our code we are now going to have to create a list of movements and unfortunately there is no shortcut for doing this.

    Since I'm operating in ruby I'll be using the values in ruby-move.txt but if your using Fire-REd/Leaf-Green or Saphhire then you need to use FR-Move.txt (both available in resources).

    The table should be easy enough to read, the only standard being this. If a word has a hunber next to it then that means the number of steps to take within one cycle. As an example:
    Left 0 = Turn left (no stepping)
    Left 1 = Step Left
    Left 2 = Take 2 steps quickly.
    Left 3 = Take 3 Steps REALLY quickly​

    This means that the number also acts like a speed control, but you need to keep in mind that a script reading
    left1` left1 left1 left1
    will take the same number of steps as:
    left2 left2
    but that the second script will take less time!

    That said you can't use the actual keywords. To make this script you have to use the table as a look up chart. To write these values we have to use the keyword #Binary

    Using the ruby chart this makes the above two commands look like this:
    #Binary 0x06 0x06 0x06 0x06 0xFE
    #Binary 0x0a 0x0a 0xFE

    Back to our script.
    The last value on each line is the 'end movement' marker. The end of your motion script must have this value. That said we're about to cheet with this script. The only difference between our three motion script is the number of steps left that we take at the beginning ofthe script so we're going to write it like this:

    #org $Ball3Move
    #Binary 0x06
    #org $Ball2Move
    #Binary 0x06
    #org $Ball1Move
    #Binary 0x06 0x06 0x06 0x01 0xFE

    That's it. The first two offsets will add on the extra steps needed to make up the distance between you and the professor. Without the 0xFE on the end of these it then runs on into the next motion script until 0xFE is found.

    And that polishes off the script from our last section. No matter what pokemon you choose you now go stand in front of BIRCH before being given your podedex.

    Code:
    #org $GiveDex
    setflag 0x800
    setflag 0x801
    checkflag 0x203
    if b_True gosub $Move1
    checkflag 0x204
    if b_True gosub $Move2
    checkflag 0x205
    if b_True gosub $Move3
    message $Pokedex
    $Pokedex 1 = I hope You like your new pokemon.\pWhile your on your journeys I have\la favour to ask you.\pProf OAK and I are trying to make an\lindex of everything pokemon.\pTake this pokedex with you and it\lwill log all the pokemon you see and catch.\pIt would greatly help our studies!
    boxset 6
    jingle
    message $GotDex
    $Gotdex 1 = You got the Pokedex!
    boxset 6
    end
    
    #org $Move1
    applymovement 0xFF $Ball1Move
    pausemove 0
    return
    #org $Move2
    applymovement 0xFF $Ball2Move
    pausemove 0
    return
    #org $Move3
    applymovement 0xFF $Ball3Move
    pausemove 0
    return
    
    #org $Ball3Move
    #Binary 0x06
    #org $Ball2Move
    #Binary 0x06
    #org $Ball1Move
    #Binary 0x06 0x06 0x06 0x01 0xFE
    Lets make a slightly longer motion script this time.

    4.3 Using SetVar

    Alright. Still inside professor oaks lab lets make a script to do the following.

    1. If you attempt to leave going straight down Brendan calls out to us.
    2. Brendan comes down and leads you to the box next to the pokeball.
    2b. Once there he gives you a GreatBall
    3. If you try to leave through the right side of the exit you are moved accross to the left side so the script works normally.
    4. Once you have recieved the ball you can't recieve another one.

    This script will be attached to the objects sitting over the exit. Just like the Pokeball scripts we'll be using a tiny script on each script points and then using subroutines in our common script. The difference is that here we'll be introducing the Setvar command.
    Unlike Flags, setvar commands are a case of simple check and uncheck. Instead setvar sets one of 60000 Intiger values allowing you to store a number instead of a yes/no.

    Here's script for our left object.
    #org $LeftExit
    setvar 0x4400 2
    checkflag 0x800
    if 0x0 gosub $UmPokemon
    checkflag 0x207
    if 0x0 goto $Followme
    end


    You can see clearly 0x4400 has been set to 2. $RightExit will set the same variable to 1.
    The first checkflag is to make sure you don't try to leave without a pokemon and the second one makes sure this script wont repeat itself.

    Let's move on to the main script:
    #org $Followme
    message $HeyWait
    $HeyWait 1 = Brendan: Hey Wait!\p
    boxset 6


    Easy beginning. Now comes the comparison. To check which script object triggered this script we are simply going to use the compare statement and an if-gosub similar when we make the pokeball scripts.
    compare 0x4400 1
    if 0x1 gosub $AdjustLeft
    compare 0x4400 2
    if 0x1 gosub $AdjustRight


    The adjust script we'll buid in a moment will be a simple script to move the player to the left. That way the stuff we're about to do will work regardless where the player was standing.

    4.4 Follow Me
    Making the player follow an npc isn't as difficult as it sounds. The only trick involved is making allowance for the characters being out of step. To do this we have to combine pausemove with the function pause. Pause, instead of waiting until all movements are over will wait for a specific time frame. You calculate this as 0x10 for each item in your movement script, plus 0x10 for the final 0xfe and another 0x10 for the initial applymovement command.
    In the following code snippet therefore we'll do the following.
    1. Start Brendan Moving.
    2. Move the Player left 1 then move the player using the same script as Brendans script.
    3. Wait until Brendan has finished moving.
    4. Move brendan one more step so the player wont bump into him!
    5. Wait till everybody stops moving

    And that looks something like this:
    applymovement 0x3 $Brendanwalk2
    applymovement 0xff $StepRight
    applymovement 0xff $Brendanwalk2
    ' This move set goes: Up0 Up2 Up2 Up2 Up1 left0 left1 left1 left1
    $BrendanWalk2 1 ; 0x05 0x09 0x09 0x09 0x05 0x02 0x07 0x07 0x07 0xfe
    pause 0x110

    applymovement 3 $StepRight
    $StepRight 1 ; #Binary 0x07 0xfe
    pausemove 0


    We've done something new here to. If you look at the script then we're no longer defining out motion script like this:
    #org $StepRight
    #Binary 0x07 0xfe


    This is cause we are now using the same technique that stops us from writing strings as:
    #org $MyText
    = Any old text we want!


    Both of the above would normally be placed at the end of your script after all the code but thanks to the power of inline offsets (or variable names) we can put both types of data with the script elements reffering to them. The only difference is that for movement data we use ; (semi-colon) instead of = (equals).
    The Pause 0x110 causes the script to wait just long enough for brendan to stop but lets the player keep moving and the final movement below moves Brendan one final putting him square in front of the box and stopping the player from standing on the same space.
    Please note that movements performed by applymovement will ignore solid objects and go straight through them.

    And all that remains is to polish the script off with some small movements, a giveitem command and a setflag.

    Here's our final script!
    Code:
    ' ENTRY SCRIPTS
    ' -------------
    #org $RightExit
    setvar 0x4400 1
    checkflag 0x800
    if 0x0 gosub $UmPokemon
    checkflag 0x207
    if 0x0 goto $Followme
    end
    
    #org $LeftExit
    setvar 0x4400 2
    checkflag 0x800
    if 0x0 gosub $UmPokemon
    checkflag 0x207
    if 0x0 goto $Followme
    end
    
    ' YOU DONT HAVE A POKEMON
    ' -----------------------
    #org $UmPokemon
    message $WhatNoPoke
    $WhatNoPoke 1 = BIRCH: Don't you want a Pokemon?
    boxset 6
    applymovement 0xff $TurnPlayer
    $TurnPlayer 1 ; #Binary 0x05 0x09 0xfe
    pausemove 0
    end
    
    ' MOVE PLAYER ASIDE
    ' -----------------
    #org $AdjustRight
    applymovement 0xFF $MoveLeft
    ' This move set goes: Alert Left0 Left1 Right0
    $MoveLeft ; #Binary 0x56 0x02 0x06 0x03
    return
    
    #org $AdjustLeft
    applymovement 0xFF $FaceRight
    ' This move set goes: Alert Up0 Right0
    $FaceRight ; #Binary 0x56 0x01 0x03
    return
    
    ' FOLLOW ME SCRIPT
    ' ----------------
    #org $Followme
    message $HeyWait
    $HeyWait 1 = Brendan: Hey Wait!\p
    boxset 6
    
    compare 0x4400 1
    if 0x1 gosub $AdjustLeft
    compare 0x4400 2
    if 0x1 gosub $AdjustRight
    
    applymovement 3 $BrendanWalk1
    ' This move set goes: Down2 Down2 Down2 Down2 Left0
    $BrendanWalk1 1 ; #Binary 0x08 0x08 0x08 0x08 0x02 0xfe
    pausemove 0
    
    Message $Parting
    $Parting 1 = Before you leave I have something\pThat might Help you later!
    boxset 6
    
    applymovement 0x3 $Brendanwalk2
    applymovement 0xff $StepRight
    applymovement 0xff $Brendanwalk2
    ' This move set goes: Up0 Up2 Up2 Up2 Up1 
    $BrendanWalk2 1 ; #Binary 0x05 0x09 0x09 0x09 0x05 0x02 0x07 0x07 0x07 0xfe
    pause 0x110
    
    applymovement 3 $StepRight
    $StepRight 1 ;#Binary  0x07 0xfe
    pausemove 0
    
    message $Rummage
    $Rummage 1 = Brendan Rummages in the box
    boxset 6
    
    applymovement 3 $FaceLeft
    $FaceLeft 1 ; #Binary 0x02 0xfe
    pausemove 0
    
    message $UltraBall
    $UltraBall 1 = Here it is!\nThis is an Ultra Ball!\pIt's one of the most powerful balls\lin existance and will catch just about\pAny pokemon. Use it wisely.
    boxset 6
    giveitem 0x2 1
    release
    end

    Congragulations....
    Now here's a couple of challenges for you.

    Challenge 1
    With all your knowledge make a script that allows the player to aproach a person from any side and still perform the same follow me script.
    Hint, Variables set with Setvar aren't cleared when a script ends. You can easily set the value and then call the script when you activate a person.
    Additional: Recent investigation shows this may require special commands not covered. Please watch this space!

    Challenge 2
    In the script list (if you go high enough) are sprites that take up more than one square such as boat sprites and truck sprites. If you move the player too close to these sprites then the sprite will cover the trainer hiding them. Use this knowledge to create a boat or truck script!

    Go on. Give it a go!
     
    Last edited:

    Irish Witch

    Office Jenny
    147
    Posts
    17
    Years
  • 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 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
    end

    And 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.
    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
    [i]trainerbattle 0 395 $MadChall $MadDefeat
    $MadChall 1 = Madeline: I am mighty... I hope!
    $MadDefeat 1 = Madeline: Oh poor Numel!!!![/i]
    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...
    
    [size="4"]5.5 Dual Battles[/size]
    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:
    [i]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![/i]
    
    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]
    
    [size="4"]5.6 Gym Leaders[/size]
    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
    end

    In 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.
     
    Last edited:

    ~Teh Panda~

    Back in hacktion
    918
    Posts
    16
    Years
    • Seen Jul 20, 2022
    Help!

    i added this script to a girl in littleRoot

    #ORG $ShowText
    Lock
    Faceplayer
    message $hi
    $hi 1 = hello, nice to meet ya!
    boxset 6
    release
    end

    when i begin to talk to her the screen turns red
    plz help Irish Witch
     

    O.G. Duke

    a.k.a OmegaGroudon
    974
    Posts
    17
    Years
    • Seen May 18, 2016
    A question! I want the sprite to vanish after battle with it ( Legendary pokemon), but I used the step in the tutorial ( Place the setflag value into the People ID ) it cant use for Legendary Battle...How can I do?
     
    1,104
    Posts
    16
    Years
  • This is because the map needs to be reloaded for the ID's to take place.

    There is a certain binary movement that allows a sprite to dissapear, it is #binary 0x60.

    Another option is to, do a fadescreen 0, right before the end of your script. If everything is released and done correctly, Fadescreen will in-essence reload the screen, which will make the ID take effect. It'll be a blink and they'll be gone.

    :)

    Don't worry you didn't miss this post, it's from the script discussion thread(sorry if this is not allowed, I'm not sure), sorry I just couldn't be bothered rewriting the answer.
    so try putting this after the wildbattle command.
    setflag 0x(???)
    fadescreen 0
    release
    end
     

    BOH

    31
    Posts
    16
    Years
    • Seen Jul 20, 2013
    i use the wild pokemon script

    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
    end

    but when i compile the rom appeard this error message:

    Code:
    Error of run-time '13'. Type not correspondent

    why?

    p.s. i translate it from italian sorry for the mistake
     

    Ooka

    [font=Maven Pro][color=#A75EE2]Cosmic[/color][/fon
    2,626
    Posts
    16
    Years
  • #org $StartChik
    checkflag 0x800
    if B_True goto $NoBall
    message $Chick
    $Chick 1 = Chikorita!\lThe Fire Bird.\pTake the Chikorita?
    boxset 5
    compare LASTRESULT 1
    if B_False goto $PutBack
    givepokemon 152 5 0
    jingle
    message $GotChick
    $GotChick 1 = You Recieved a Chikorita
    boxset 6
    message $NameChick
    $NameChick 1 = Would You like to give Chikorita a name?
    boxset 5
    compare LASTRESULT 1
    if b_False goto $GiveDex
    Namepokemon
    setflag 0x203
    goto $GiveDex

    #org $StartShrew
    checkflag 0x800
    if B_True goto $NoBall
    message $Shrew
    $Shrew 1 = SandShrew!\lDesert Mole.\pTake the Sandshrew?
    boxset 5
    compare LASTRESULT 1
    if B_False goto $PutBack
    givepokemon 27 5 0
    jingle
    message $GotChick
    $GotShrew 1 = You Recieved a Sandshrew
    boxset 6
    message $NameShrew
    $NameShrew 1 = Would You like to give Sandshrew a name?
    boxset 5
    compare LASTRESULT 1
    if b_False goto $GiveDex
    Namepokemon
    setflag 0x204
    goto $GiveDex

    #org $StartWing
    checkflag 0x800
    if B_True goto $NoBall
    message $Chick
    $Wing 1 = Wingull!\lThe Ocean Bird.\pTake the Wingull?
    boxset 5
    compare LASTRESULT 1
    if B_False goto $PutBack
    givepokemon 152 5 0
    jingle
    message $GotGull
    $GotGull 1 = You Recieved a Wingull
    boxset 6
    message $NameGull
    $NameGull 1 = Would You like to give Wingull a name?
    boxset 5
    compare LASTRESULT 1
    if b_False goto $GiveDex
    Namepokemon
    setflag 0x205
    goto $GiveDex

    #org $GiveDex
    setflag 0x800
    setflag 0x801
    message $Pokedex
    $Pokedex 1 = I hope You like your new pokemon.\pWhile your on your journeys I have\la favour to ask you.\pProf OAK and I are trying to make an\lindex of everything pokemon.\pTake this pokedex with you and it\lwill log all the pokemon you see and catch.\pIt would greatly help our studies!
    boxset 6
    jingle
    message $GotDex
    $Gotdex 1 = You got the Pokedex!
    boxset 6
    end

    #org $PutBack
    message $PutBack
    $PutBack 1 = You put the pokeball back.
    boxset 6
    end

    #org $NoBall
    message $Lastball
    $Lastball 1 = You already have your pokemon.\nDont be so greedy!
    boxset 6

    This has probably already been pointed out, I just wanted to say it just in case, but if you give this event to proffessor Oak's aid, he doesn't lock or faceplayer, and it puts you in safari zone mode so the rest of the game you go around like you are in a safari zone.

    goodsaafarizone.jpg


    And if you hit retire, it shows you leaving the safari zone in fushia city. How am I supposed to get out of fushia city without fighting anyone? It doesn't help to try to fight them either.
     
    1,104
    Posts
    16
    Years
  • This is because in Fire Red setflag 0x800 activates the Safari Menu. Change 0x800 to 0x828 for Fire Red, Leaf Green. Also change 0x801 to 0x829. This is for activating the Pokedex on the menu.
     
    Status
    Not open for further replies.
    Back
    Top