• 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.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Serena, Kris, Dawn, Red - which Pokémon protagonist is your favorite? Let us know by voting in our grand final favorite protagonist 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.

[Battle] Forcing a specific level for pokemon when battling

bitKoder

completely unreasonable
  • 36
    Posts
    8
    Years
    • Seen Jun 22, 2025
    I'm trying to implement a feature where there is an "effective level" cap, meaning you can continue to level your pokemon up past that number, but when you're in a battle your pokemon are locked to that level (meaning their stats are also calculated for that level). Anyone know how I might go about doing this?
    What I'm hoping is that somewhere there's a function that loads the player's party into a temporary variable, and I can just force those values before the battle itself starts referencing them, but at this point I'm starting to suspect that middle step doesn't exist.
     
    This ended up being a pretty complex one, but I thought I'd share my findings.
    - CopyPlayerMonData in src/battle_controller_player.c does most of the heavy lifting, loading in the stats
    - In order to recalculate these stats at the capped level, I had to create some new functions to recreate the stat calculation done in CalculateMonStats and CALC_STAT in src/pokemon.c
    - I had to use these new functions in src/battle_interface.c as well, in the UpdateHealthboxAttribute function, and in PlayerHandleHealthBarUpdate in src/battle_controller_player.c
    - I also put an extra check in case 4 of Cmd_getexp in src/battle_script_commands to make sure that a leveled-up pokemon wasn't above the level cap before recalculating their stats (which I'm not 100% sure is working since the current HP still increases)

    There's probably an absolute stack of bugs with this system. I'll work my way through and see what I find.
     
    Back
    Top