• 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.

Scripting Question

79
Posts
5
Years
  • I feel like I've asked too many questions at this point, but really, I might as well ask whatever I need to make my rom, right? As for my question, what kind of script would I need to trigger an event like the first rival battle in fr/lg? I mean, where once I pass a certain tile with a pokemon, my rival walks down and challenges me? And to follow up, if I'm using Hopeless Trainer Editor, how would I go about editing that battle? I'm honestly clueless when it's not just plain mapping:laugh-squinted:
     

    Karl

    Creator of [b]Pokémon Darkfire[/b]
    168
    Posts
    13
    Years
    • Seen May 8, 2024
    Assuming you're using AdvanceMap, you'll need to use green script tiles to initiate the event.

    Pick a safe var, and use the 'checkflag' command to determine whether the battle should play out or not.

    For example, if the player steps on the tile and has previously chosen a Pokémon, the script will check for that, and if it's true, the event will play. If not, the player is told to pick a Pokémon before he can leave, etc.

    Once the requirements have been met and the player is eligible to battle, use the 'trainerbattle' command to start a battle.

    Then afterwards set a new var value to ensure the script doesn't play again.

    I would strongly recommend using this guide if you're just starting out scripting. There's a section there dedicated to this kind of thing.
     
    79
    Posts
    5
    Years
  • Assuming you're using AdvanceMap, you'll need to use green script tiles to initiate the event.

    Pick a safe var, and use the 'checkflag' command to determine whether the battle should play out or not.

    For example, if the player steps on the tile and has previously chosen a Pokémon, the script will check for that, and if it's true, the event will play. If not, the player is told to pick a Pokémon before he can leave, etc.

    Once the requirements have been met and the player is eligible to battle, use the 'trainerbattle' command to start a battle.

    Then afterwards set a new var value to ensure the script doesn't play again.

    I would strongly recommend using this guide if you're just starting out scripting. There's a section there dedicated to this kind of thing.

    Thanks! I do use the guide for most of my scripting, but this was something not in the guide, and I'd rather not try to piece it together on my own, you know? Could you give an example of a var value so it doesn't start again? All I really understand is dialogue right now, flags and variables are still new to me:laugh-squinted:
     
    79
    Posts
    5
    Years
  • And another scripting question, because I tried it the way it was done in the guide and it didn't work. How do you get the nickname option to open up? I used the offset that the guide said brought up the window, but all that did was make freeze the text until you press a button, missing the rest of the dialogue I have scripted. There's no problem if you say no to nicknaming your starter, but a lot of people like to give nicknames, so I want to give the option.
     

    Karl

    Creator of [b]Pokémon Darkfire[/b]
    168
    Posts
    13
    Years
    • Seen May 8, 2024
    Thanks! I do use the guide for most of my scripting, but this was something not in the guide, and I'd rather not try to piece it together on my own, you know? Could you give an example of a var value so it doesn't start again? All I really understand is dialogue right now, flags and variables are still new to me:laugh-squinted:

    Use the 'setvar' command at the end of the script.

    Code:
    setvar 0x4011 0x1
    release
    end

    And fill in the fields of your green script tile(s) in AdvanceMap as so:
    Spoiler:


    Once the script ends, the new var value will change to 0001 and thus your script won't play again when you step on the tile.

    As far as nicknaming, that part of your script should look somewhat similar to this:

    Code:
    msgbox @givenickname 0x5
    compare 0x800D 0x1
    if 0x1 call @nickname
    release
    end
    
    #org @nickname
    setvar 0x8004 0x0
    fadescreen 0x1
    special 0x9E
    waitstate
    return
    
    #org @givenickname
    = Would you like to give a nickname\nto PIKACHU?

    setvar 0x8004 0x0 is needed in order to tell the game the party position of a Pokémon.
    fadescreen 0x1 is simply a fade effect
    special 0x9E, which is the command for the nickname event
    waitstate will make the game wait until you're done with the nickname
    and return is simply returning to your main script to finish
     
    Last edited:
    79
    Posts
    5
    Years
  • Use the 'setvar' command at the end of the script.

    Code:
    setvar 0x4011 0x1
    release
    end

    And fill in the fields of your green script tile(s) in AdvanceMap as so:
    Spoiler:


    Once the script ends, the new var value will change to 0001 and thus your script won't play again when you step on the tile.

    As far as nicknaming, that part of your script should look somewhat similar to this:

    Code:
    msgbox @givenickname 0x5
    compare 0x800D 0x1
    if 0x1 call @nickname
    setvar 0x4011 0x1
    release
    end
    
    #org @nickname
    setvar 0x8004 0x0
    fadescreen 0x1
    special 0x9E
    waitstate
    return
    
    #org @givenickname
    = Would you like to give a nickname\nto PIKACHU?

    setvar 0x8004 0x0 is needed in order to tell the game the party position of a Pokémon.
    fadescreen 0x1 is simply a fade effect
    special 0x9E, which is the command for the nickname event
    waitstate will make the game wait until you're done with the nickname
    and return is simply returning to your main script to finish

    Well that explains it, the nickname script I was given looked completely different from that lol
    Thanks a lot!!

    And while I'm probably being a bother with all my questions, I've got one more issue with my npcs and such. Two different npcs have decided to show up on top of the door to my house, instead of where I put them. Other than the weird positioning, they function exactly as they should be, so I don't know what's wrong. I know I didn't put them there
     
    Last edited by a moderator:

    Karl

    Creator of [b]Pokémon Darkfire[/b]
    168
    Posts
    13
    Years
    • Seen May 8, 2024
    Ah, yes. This can happen.

    Check your map level scripts for any interference or change their 'person event no' values in AdvanceMap.

    If that doesn't work delete them and add 2 fresh NPCs in the map. Be sure to assign them the proper script offsets again.
     
    79
    Posts
    5
    Years
  • Ah, yes. This can happen.

    Check your map level scripts for any interference or change their 'person event no' values in AdvanceMap.

    If that doesn't work delete them and add 2 fresh NPCs in the map. Be sure to assign them the proper script offsets again.

    I appear to be having a lot of npc related issues today. The new script for getting the starter and nicknaming works perfectly, but I had to test it on the wrong npc, because the npc I was supposed to use it on stopped showing up. I know it's not a problem with the script, because I put it onto an npc that I know works, and the script worked perfectly. I'll try to fix it on my own, but I'd like to get some input so I might be able to understand why:laugh-squinted:

    And to add to that, I have 2 npcs in the lab, and they were working just fine before I tried using this new script. Now, no matter where I put them in the lab, only one shows up, and sometimes they execute the script assigned to the other one
     
    Last edited by a moderator:

    DrFuji

    [I]Heiki Hecchara‌‌[/I]
    1,691
    Posts
    14
    Years
  • And to add to that, I have 2 npcs in the lab, and they were working just fine before I tried using this new script. Now, no matter where I put them in the lab, only one shows up, and sometimes they execute the script assigned to the other one

    It sounds like you've assigned the same 'person event number' to both NPCs. Each NPC should have their own so that the game doesn't get confused with which NPC is which. To fix this, go through all the NPCs on that map and make sure their event numbers are different - The best way to do this is to take the number assigned to them by AMap (at the very top of their information) and then add one to it.

    And don't be afraid to ask questions, the whole point of this sub forum is about getting help, so nobody is going to get annoyed :P
     
    40
    Posts
    6
    Years
  • You seem a bit confused at how exactly vars "work".

    Say for example you have a script tile in A-map, the var number is 4011 and the var value is 0000 (in script form, var value 0000 is displayed as 0x0)

    What this is saying, is the script will only activate if the var 4011 is set to 0 (and all vars are set to 0 at the start of the game)

    So when, at the end of the script, you use the command "setvar 4011 0x1". From this point on, the var 4011 will stay at value 0x1 (or 0001 in a-map terms) until you dictate otherwise.

    It's good to know this as vars can be used to make a sequence of events by just changing one var. So now that your script has changed var 4011 to 0x1, the first script tile will no longer trigger because var 4011 is no longer at value 0x0.

    So you can use another script tile that you intend to be launched later on in the game, but only after the rival battle, you would set that tile scipts var number to 4011 (same as before) but this time giving it a var value of 0001 (0x1 in script form). This script won't run from the beginning, but only after the initial rival battle, at the end of which you'll have set var 4011 to 0x1.

    I hope this rambling guide will help you understand better combined with KitSuv's.

    Another note on vars. It can be confusing that sometimes you'll see vars behave completely differently (such as when renaming Pokemon). This is because, like flags, some vars have very speficic uses. Have a look here: https://www.pokecommunity.com/showthread.php?t=302347 to see which flags and vars do what. You can also find out which ones are "safe" to use there.

    It's not just script tiles that can use vars effectively. Talking to people scripts can use them also. E.g.

    #dynamic 0x800000
    #org @start
    checkvar 4011 0x1
    if 0x1 goto @finished
    Msgbox "Hello I am an example"
    setvar 0x4011 0x1
    release
    end

    #org @finished
    Msgbox "Hey you already spoke to me"
    release
    end

    In this example, it checks if var 4011 is at value 0x1
    It sees that it isn't, as it is at value 0x0
    It then shows the first message, and sets the var 4011 to 0x1

    You talk to the npc again, it checks if 4011 is set to 0x1
    It is, because you told it to at the end of the script the first time you spoke to them
    It now goes to the script @finished and shows the second message instead.

    (note I was lazy writing the example and of course msgbox scripts don't look like that lol)

    This can be used for many story and "quest" purposes.
     
    Last edited:
    Back
    Top