• 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!
  • PokéCommunity supports the Stop Killing Games movement. If you're a resident of the UK or EU, consider signing one of the petitions to stop publishers from destroying games. Click here for more information!
  • 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

  • 8
    Posts
    1
    Years
    • Seen today
    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.
     
    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.
     
    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:
    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.
     
    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.
    Is there a way to do this for pokémon fire red
     
    Is there a way to do this for pokémon fire red
    Quick answer:
    No.

    long answer:
    In FireRed there are no basic rules that I used to implement this mechanic in combat system.
    So you have to create from scratch, then you can intervene on the combat system.

    Recreating all the rules is long and I think a bit complicated.
    Sure, you could always create a quick rule that takes a random move from those available... but well, that's a whole different thing from what I realized in Emerald with the existing rules.
     
    Back
    Top