Skip to content

Commit

Permalink
support 255 turns of confusion
Browse files Browse the repository at this point in the history
technically one short of the original duration but unless you want to sacrifice another bit for it its close enough to indefinit
  • Loading branch information
u8-Salem committed Apr 7, 2023
1 parent 32d5ccb commit 3363b5b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 27 deletions.
52 changes: 26 additions & 26 deletions include/constants/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,33 +120,33 @@

// Volatile status ailments
// These are removed after exiting the battle or switching out
#define STATUS2_CONFUSION (1 << 0 | 1 << 1 | 1 << 2)
#define STATUS2_CONFUSION (1 << 0 | 1 << 1 | 1 << 2 | 1 << 3 | 1 << 4 | 1 << 5 | 1 << 6 | 1 << 7 | 1 << 8) // 8 bits for 256 turns of confusion
#define STATUS2_CONFUSION_TURN(num) ((num) << 0)
#define STATUS2_FLINCHED (1 << 3)
#define STATUS2_UPROAR (1 << 4 | 1 << 5 | 1 << 6)
#define STATUS2_UPROAR_TURN(num) ((num) << 4)
#define STATUS2_UNUSED (1 << 7)
#define STATUS2_BIDE (1 << 8 | 1 << 9)
#define STATUS2_BIDE_TURN(num) (((num) << 8) & STATUS2_BIDE)
#define STATUS2_LOCK_CONFUSE (1 << 10 | 1 << 11) // e.g. Thrash
#define STATUS2_LOCK_CONFUSE_TURN(num)((num) << 10)
#define STATUS2_MULTIPLETURNS (1 << 12)
#define STATUS2_WRAPPED (1 << 13)
#define STATUS2_POWDER (1 << 14)
#define STATUS2_INFATUATION (1 << 16 | 1 << 17 | 1 << 18 | 1 << 19) // 4 bits, one for every battler
#define STATUS2_INFATUATED_WITH(battler) (gBitTable[battler] << 16)
#define STATUS2_FOCUS_ENERGY (1 << 20)
#define STATUS2_TRANSFORMED (1 << 21)
#define STATUS2_RECHARGE (1 << 22)
#define STATUS2_RAGE (1 << 23)
#define STATUS2_SUBSTITUTE (1 << 24)
#define STATUS2_DESTINY_BOND (1 << 25)
#define STATUS2_ESCAPE_PREVENTION (1 << 26)
#define STATUS2_NIGHTMARE (1 << 27)
#define STATUS2_CURSED (1 << 28)
#define STATUS2_FORESIGHT (1 << 29)
#define STATUS2_DEFENSE_CURL (1 << 30)
#define STATUS2_TORMENT (1 << 31)
#define STATUS2_FLINCHED (1 << 9)
#define STATUS2_UPROAR (1 << 10 | 1 << 11 | 1 << 12)
#define STATUS2_UPROAR_TURN(num) ((num) << 9)
#define STATUS2_UNUSED (1 << 13)
#define STATUS2_BIDE (1 << 14 | 1 << 15)
#define STATUS2_BIDE_TURN(num) (((num) << 15) & STATUS2_BIDE)
#define STATUS2_LOCK_CONFUSE (1 << 16 | 1 << 17) // e.g. Thrash
#define STATUS2_LOCK_CONFUSE_TURN(num)((num) << 16)
#define STATUS2_MULTIPLETURNS (1 << 18)
#define STATUS2_WRAPPED (1 << 19)
#define STATUS2_POWDER (1 << 20)
#define STATUS2_INFATUATION (1 << 21 | 1 << 22 | 1 << 23 | 1 << 24) // 4 bits, one for every battler
#define STATUS2_INFATUATED_WITH(battler) (gBitTable[battler] << 21)
#define STATUS2_FOCUS_ENERGY (1 << 25)
#define STATUS2_TRANSFORMED (1 << 26)
#define STATUS2_RECHARGE (1 << 27)
#define STATUS2_RAGE (1 << 28)
#define STATUS2_SUBSTITUTE (1 << 29)
#define STATUS2_DESTINY_BOND (1 << 30)
#define STATUS2_ESCAPE_PREVENTION (1 << 31)
#define STATUS2_NIGHTMARE (1ULL << 32)
#define STATUS2_CURSED (1ULL << 33)
#define STATUS2_FORESIGHT (1ULL << 34)
#define STATUS2_DEFENSE_CURL (1ULL << 35)
#define STATUS2_TORMENT (1ULL << 36)

#define STATUS3_LEECHSEED_BATTLER (1 << 0 | 1 << 1) // The battler to receive HP from Leech Seed
#define STATUS3_LEECHSEED (1 << 2)
Expand Down
5 changes: 4 additions & 1 deletion src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -3228,7 +3228,10 @@ void SetMoveEffect(bool32 primary, u32 certain)
}
else
{
gBattleMons[gEffectBattler].status2 |= STATUS2_CONFUSION_TURN(((Random()) % 4) + 2); // 2-5 turns
if (gLastUsedItem == ITEM_BERSERK_GENE)
gBattleMons[gEffectBattler].status2 |= STATUS2_CONFUSION_TURN(255); // Berserk Gene 255 Turns
else
gBattleMons[gEffectBattler].status2 |= STATUS2_CONFUSION_TURN(((Random()) % 4) + 2); // 2-5 turns

// If the confusion is activating due to being released from Sky Drop, go to "confused due to fatigue" script.
// Otherwise, do normal confusion script.
Expand Down
3 changes: 3 additions & 0 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -7063,6 +7063,7 @@ static u8 ItemEffectMoveEnd(u32 battlerId, u16 holdEffect)
{
BufferStatChange(battlerId, STAT_ATK, STRINGID_STATROSE);
gEffectBattler = battlerId;
gLastUsedItem = gBattleMons[battlerId].item;
SET_STATCHANGER(STAT_ATK, 2, FALSE);

gBattleScripting.animArg1 = 14 + STAT_ATK;
Expand Down Expand Up @@ -7317,6 +7318,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
{
BufferStatChange(battlerId, STAT_ATK, STRINGID_STATROSE);
gEffectBattler = battlerId;
gLastUsedItem = gBattleMons[battlerId].item;
SET_STATCHANGER(STAT_ATK, 2, FALSE);

gBattleScripting.animArg1 = 14 + STAT_ATK;
Expand Down Expand Up @@ -7614,6 +7616,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
{
BufferStatChange(battlerId, STAT_ATK, STRINGID_STATROSE);
gEffectBattler = battlerId;
gLastUsedItem = gBattleMons[battlerId].item;
SET_STATCHANGER(STAT_ATK, 2, FALSE);

gBattleScripting.animArg1 = 14 + STAT_ATK;
Expand Down

0 comments on commit 3363b5b

Please sign in to comment.