• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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.

[Script] Issues scripting a trainer battle

  • 157
    Posts
    8
    Years
    • Seen Nov 19, 2023
    Been toying around with adding in some trainer battles to pokemon emerald but have ran into an issue. Basically, whatever script I write for the trainer to say before the battle, if its longer than say 20 characters, cuts off and the defeated script will show up overlapping it. just to clarify that I'm making sure to have enough space in the dialogue box and always use \n \l and \p when appropriate. Also when I re-open the script in XSE, it has been altered to how it appears in game. Any help would be appreciated.
     
    Last edited:
    Would you mind showing the script? Kind of hard to fix what can't be seen. Would be nice to see both what you're typing and the compiled version.
     
    Last edited:
    For FR:
    Code:
     #dynamic 0x800000
    #org @battle
    trainerbattle 0x0 0xbattle 0x0 @intro @defeat
    msgbox @beaten 0x6
    release
    end
    
    #org @intro
    = I'll say this at the start.
    
    #org @defeat
    = I'll say this at the end/lof the battle.
    
    #org @beaten
    = After you fought me I'll/lsay this when we talk.
    For EM:
    Code:
     #dynamic 0x800000
    #freespace 0xFF
    #org @battle
    trainerbattle 0x0 0xbattle 0x0 @intro @defeat
    msgbox @beaten 0x6
    release
    end
    
    #org @intro
    = I'll say this at the start.
    
    #org @defeat
    = I'll say this at the end/lof the battle.
    
    #org @beaten
    = After you fought me I'll/lsay this when we talk.

    The only thing I can think of is that you're overwriting stuff due to not using dynamic offsets.
    The above are examples that should work, I've given both for FR and EM though EM is superior.

    Try filling in the blank to see if it works, also if any of this is unfimiliar then check out diegoisawesome's xse tutorial.
     
    Still having the same issue as before.
    Before compiling the script looks like this:
    Spoiler:

    But once it's been compiled I open it back up and it looks like this:
    Spoiler:


    As you can see, the text from before the battle is continually overwritten. No clue why.
     
    Last edited:
    Still having the same issue as before.
    Before compiling the script looks like this:
    Spoiler:

    But once it's been compiled I open it back up and it looks like this:
    Spoiler:


    As you can see, the text from before the battle is continually overwritten. No clue why.

    You're trying to put in text that is too long.

    The text for "I'm confident in my skills" is stored immediately before "Wow I lost". If you do the math, 0xE3E654 - 0xE3E63A = 26. So you only have room for 26 characters (actually 25, because there's an implicit string terminator byte too that you'll need). Your text is significantly longer than that.

    Repoint your "I'm confident in my skills" text somewhere else.

    If you're going to use static offsets, you need to make sure you double check the sizes involved so you don't accidentally overwrite whatever happens to be after the thing you're modifying in the ROM. Never overwrite X with Y if Y uses more bytes than X.
     
    Still having the same issue as before.
    Before compiling the script looks like this:
    Spoiler:

    But once it's been compiled I open it back up and it looks like this:
    Spoiler:


    As you can see, the text from before the battle is continually overwritten. No clue why.

    Use dynamic offsets lmao
     
    As I speculated, your problem was not using dynamic offsets.
    Let's explain your problem thoroughly:
    Offsets:
    Whenever you type the line "#org [anything]" you're specifying an offset. That means, where the code to run the script will be written in the game's memory.
    You can write "#org 0xE3E63A" and that would work fine with careful planning.
    However, dynamic offsets are when you use XSE's free space function instead.

    Using dynamic offsets is easy. Look at my example from the last post.
    Basically instead of writing 0xE3E63A you type @intro
    And whenever you would reference the message box there you would again type @intro
    You of course do this whenever you would write "#org something"
    Look here for more info:
    https://www.pokecommunity.com/threads/164276
    It's the thread I suggested last time, unfortunately you haven't done what I said last time because otherwise you problem would have been solved.

    Last but not least, I have no idea what trainerbattle 0x2 is
    If I'm not mistaken:
    0x0 is regular trainer
    0x1 is with a script after you win
    0x4 double battle
    0x6 double battle with script after you win

    All in all your problems are annoying yet minimal. The thread I've supplied should be able to supply answers to all of your questions within the next month only by itself if you look for long enough.

    Hope this fixes your problem, good luck.
     
    Back
    Top