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

[Script✓] Fixed move effect duration

  • 4
    Posts
    2
    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:
  • 247
    Posts
    6
    Years
    • Seen May 28, 2024
    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