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

Development: Trainer interrupting battles

Blah

Free supporter
1,924
Posts
11
Years
  • R&D on Pokemon Trainer's Interrupting battles:


    Before I begin, skip to 5:50 and watch till 5:55 of this video to see what I'm talking about: https://www.youtube.com/watch?v=W609NJs9h-o

    I want to implement that in Fire Red. So recently I've been reading, researching and tracking down different routines in battles in FireRed to basically find a point in the game which is run once per turn. Well I found that point. The game seems to have a "turn counter" which is incremented once at the end of each turn at 0x8013CB0

    From there I need to call my own routine. A routine whose purpose was simply to check if the opponent was on their last Pokemon, and to check if their last Pokemon is lower than Half health.
    In the newer games this, "trainer interrupt" happens 100% in these two conditions vs important NPCs.
    So I should do an interrupt at those two stages.

    The next problem is knowing which text to execute. The solution to that imo is simple. I decided the best way to do it, is to make a table of pointers to strings, and just use a variable to browse these pointers. (Getting the battle to display this string is another issue in itself).

    The last, and probably the biggest problem is the trainer sliding in and out in both of these scenarios.

    So right now, what I have done is the main routine that does the check of whether or not to do the trainer sliding process, and a helper function which basically just gives information about the opponents team.

    Code for Main:

    Spoiler:


    Here's the checkPokemon used in the routine above:
    Spoiler:


    As you can tell, all I have to really do is to "Slide trainer" and "Unslide" the trainer in the battle. Followed by, fixing the text glitch I'm getting.

    Basically the text comes out at the same time as the normal battle text. And one is overwriting pieces of the other, which causes this:
    mKezo5B.png


    I have looked into battlescripts, but honestly, I don't know if I really even need to use one. Maybe using one would help with the text appearing, I haven't tested (and don't have experience on it to really know)

    The reason I'm making the thread is to seek help/expertise of someone who's done this kind of thing before. Or perhaps knows how. Currently I'm at a wall, and am not quite sure what to do.

    Things I've tried (though maybe unsuccessfully):
    calling 0803227C: trainer enter field
    Using Oak's tutorial text routines


    If you have questions, optimizations, suggestions or solutions please do voice them :)
     

    Derlo

    Tired....
    135
    Posts
    16
    Years
  • you could try to take a look at the kind of battle where the oak explain how to fight.
    in it, the texts are loaded when it afflicts / takes damage; when using the bag, trying to get out of the fight or decreases stats pokemon.
    about the trainer sprite... could try to see how the routine that ends the battle is, to be able to use as a base.

    edit: here a very, very old data of T.battle 0x09 that I researched. maybe help or not. xD
    => 080E837c (off the texts before starting the battle)
    => 08036114 (inflict damege text off)
    => 080ea5ec & 080ea5f0 (low stats)
    => 0812207e substitute 00 to 0812210f [92 bytes] (choose pokemon and stock menu when using potion)
    => 080E85a8 substitute 083fcdb3 [exit text]
    => 080ea5f4 until 080ea647 [00] mesnsagem when you win!
    => 0803853c put 0x00 (defeat message!) 1byte
     
    Last edited:

    kearnseyboy6

    Aussie's Toughest Mudder
    300
    Posts
    15
    Years
    • Seen Jun 22, 2019
    On a broader more scale you might need to implement if the variable is 0x0 then skip entirely, so this doesn't occur with every single trainer.

    Might it also be worth researching on the battle string "It's super effective!"?

    Edit: Found a battle string table at 0x3FDF3C and really contains heaps of pointers to text strings. "It's super effective!" appears to be pointer 207 (0xCF). Also the table goes past a byte and reaches up to 0x175 so limits is not a problem.

    I think finding how these are called will give you your answer.

    Also 0x0751C4 seems to be possibly the trainer slide function? See the IDA file by knizz labelled battle_side_get_owner
     
    Last edited:

    Blah

    Free supporter
    1,924
    Posts
    11
    Years
  • you could try to take a look at the kind of battle where the oak explain how to fight.
    in it, the texts are loaded when it afflicts / takes damage; when using the bag, trying to get out of the fight or decreases stats pokemon.
    about the trainer sprite... could try to see how the routine that ends the battle is, to be able to use as a base.

    edit: here a very, very old data of T.battle 0x09 that I researched. maybe help or not. xD

    Hmm, I don't think we need to use the Oak text. The reason it creates this text error is because it's overlapping somewhere. I'm not sure where :D

    On a broader more scale you might need to implement if the variable is 0x0 then skip entirely, so this doesn't occur with every single trainer.

    Might it also be worth researching on the battle string "It's super effective!"?

    Edit: Found a battle string table at 0x3FDF3C and really contains heaps of pointers to text strings. "It's super effective!" appears to be pointer 207 (0xCF). Also the table goes past a byte and reaches up to 0x175 so limits is not a problem.

    I think finding how these are called will give you your answer.

    Also 0x0751C4 seems to be possibly the trainer slide function? See the IDA file by knizz labelled battle_side_get_owner

    I've tried calling those functions, the game freezes in place. I'm probably calling incorrectly or maybe there are some assumptions set in place when that function is called. It'll take some investigating.
     

    Touched

    Resident ASMAGICIAN
    625
    Posts
    9
    Years
    • Age 122
    • Seen Feb 1, 2018
    I did like a thing which added an extra trainer to the screen at the start and then slid them out. So like, maybe that'll help. :P
     

    Zehn

    [color=red][font=Foto Serif]Sacred[/font][/color][
    988
    Posts
    9
    Years
  • You could try displaying text as if you where in the old Man tut
     

    daniilS

    busy trying to do stuff not done yet
    409
    Posts
    10
    Years
    • Seen Jan 29, 2024
    You could try displaying text as if you where in the old Man tut

    It's better to use a regular text printing function, and that isn't a problem at all. The only real problem left is sliding the trainer out in a way that won't glitch everything.
     

    Blah

    Free supporter
    1,924
    Posts
    11
    Years
  • Oh dear, I started working on this project again. The initial direction of young, FBI Agent of November 24th, 2014 (07:52 PM) seems to be an incorrect way to tackle this problem. I'm now in the works of researching and polishing up a potential solution.

    So far, I've learned to slide the trainer in and out. Currently fixing a text spawn solution as well as a few glitches with the tiles. Once all of that is finished (maybe within the next 24 hours) I'll post an update.
     
    218
    Posts
    10
    Years
    • Seen Nov 12, 2021
    Oh dear, I started working on this project again. The initial direction of young, FBI Agent of November 24th, 2014 (07:52 PM) seems to be an incorrect way to tackle this problem. I'm now in the works of researching and polishing up a potential solution.

    So far, I've learned to slide the trainer in and out. Currently fixing a text spawn solution as well as a few glitches with the tiles. Once all of that is finished (maybe within the next 24 hours) I'll post an update.

    To display the text, you can simply use the setword command, used for many abilities/moves
     
    Back
    Top