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

[pokeemerald] Need help "AI controls my pokemon" script

4
Posts
56
Days
    • Seen May 5, 2024
    Hi everyone, I recently became interested in decomp romhacking.
    I would like to do this:
    when you select "fight" during a battle, ai chooses the move to make.

    I think I found the point where I can insert the code:
    in battle_main_c
    case B_ACTION_USE_MOVE:
    ...


    and maybe can i copy the code from:
    battle_controller_opponent
    static void OpponentHandleChooseMove(void)
    {
    ....



    any suggestions?

    Thx.
     
    448
    Posts
    6
    Years
    • Seen May 6, 2024
    Hi everyone, I recently became interested in decomp romhacking.
    I would like to do this:
    when you select "fight" during a battle, ai chooses the move to make.

    I think I found the point where I can insert the code:
    in battle_main_c
    case B_ACTION_USE_MOVE:
    ...


    and maybe can i copy the code from:
    battle_controller_opponent
    static void OpponentHandleChooseMove(void)
    {
    ....



    any suggestions?

    Thx.
    The game already has the logic for doing that in battle palace. See PlayerHandleChooseMove in src/battle_controller_player.c.
     
    4
    Posts
    56
    Days
    • Seen May 5, 2024
    found, tested and....work! dude you changed my day.
    THX!

    edit:
    sorry, have this problem:
    sometimes (random) my pokemon hits itself.
    Is there any value to set to prevent this from happening?
     
    Last edited:
    4
    Posts
    56
    Days
    • Seen May 5, 2024
    update:
    I have to test more to be sure but...
    I think I found the problem:
    in the Battle Place when the pokemon does not find a move compatible with nature, use a random move. this used move is put in the list of moves "won't be used anymore".
    if that move is used again in the following turn, the "penalty" reaction is triggered and the pokemon hits itself.
    this happens especially in low level pokemon with only 2 moves to use.
    so to avoid this I eliminated the logic "won't be used anymore".
    Now I seem to have solved the problem.
     
    Back
    Top