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

[Battle] Forcing a specific level for pokemon when battling

bitKoder

completely unreasonable
36
Posts
7
Years
    • Seen Feb 28, 2024
    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.
     

    bitKoder

    completely unreasonable
    36
    Posts
    7
    Years
    • Seen Feb 28, 2024
    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