• 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.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Trading Card Game 2 protagonist in the poll by clicking here.
  • 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.

[Script✓] Fixed move effect duration

  • 4
    Posts
    3
    Years
    • Seen Feb 4, 2023
    Hi, I'm completely new to hacking and I'm trying to do some simple changes to practice.
    I want move effects to last a fixed duration instead of a random amount of turns.
    I think I found the lines that I have to change for each effect (src/battle_script_commands.c in FireRed), but I don't understand what's going on there with all that bit-shifting.
    Can someone explain to me, what this code does and how to make it so that Thrash always lasts two turns?
    Code:
    case MOVE_EFFECT_THRASH:
                    if (gBattleMons[gEffectBattler].status2 & STATUS2_LOCK_CONFUSE)
                    {
                        ++gBattlescriptCurrInstr;
                    }
                    else
                    {
                        gBattleMons[gEffectBattler].status2 |= STATUS2_MULTIPLETURNS;
                        gLockedMoves[gEffectBattler] = gCurrentMove;
                        gBattleMons[gEffectBattler].status2 |= (((Random() & 1) + 2) << 0xA);
                    }
                    break;
     
    Last edited:
    Can someone explain to me, what this code does and how to make it so that Thrash always lasts two turns?

    The code that you quoted checks to see first if the Pokémon is already using a move like Thrash/Outrage/etc. This is determined by seeing if they have the LOCK_CONFUSE status. If so, it progresses as normal. If not,, it locks the Pokémon into a multiturn move, sets whatever move that they're using as their locked move, and then randomly determines how long they will be locked. Random() & 1 will randomly produce either 1 or 0. This means that Thrash/Outrage/etc. will last either 2 or 3 turns due to the + 2 afterwards. The code that handles keeping track of how many turns the Pokémon has been locked into this move is in src/battle_util.c, in this section of code:
    Code:
                case ENDTURN_THRASH:  // thrash
                    if (gBattleMons[gActiveBattler].status2 & STATUS2_LOCK_CONFUSE)
                    {
                        gBattleMons[gActiveBattler].status2 -= 0x400;
                        if (WasUnableToUseMove(gActiveBattler))
                            CancelMultiTurnMoves(gActiveBattler);
                        else if (!(gBattleMons[gActiveBattler].status2 & STATUS2_LOCK_CONFUSE)
                              && (gBattleMons[gActiveBattler].status2 & STATUS2_MULTIPLETURNS))
                        {
                            gBattleMons[gActiveBattler].status2 &= ~(STATUS2_MULTIPLETURNS);
                            if (!(gBattleMons[gActiveBattler].status2 & STATUS2_CONFUSION))
                            {
                                gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_CONFUSION | MOVE_EFFECT_AFFECTS_USER;
                                SetMoveEffect(1, 0);
                                if (gBattleMons[gActiveBattler].status2 & STATUS2_CONFUSION)
                                    BattleScriptExecute(BattleScript_ThrashConfuses);
                                ++effect;
                            }
                        }
                    }
                    ++gBattleStruct->turnEffectsTracker;
                    break;
    It continues to decrement from the bits that represent STATUS2_LOCK_CONFUSE until all of those bits are 0. Once that happens, the Pokémon will be released from the move and, if possible, confused.


    To answer the main question, to make Thrash/Outrage/etc. always last exactly two turns, just remove that Random() & 1 section from that code you quoted, leaving just 2 << 0xA.
     
    Back
    Top