Skip to content

Commit

Permalink
Add Berserk Gene Item (#2893)
Browse files Browse the repository at this point in the history
Co-authored-by: Eduardo Quezada D'Ottone <[email protected]>
  • Loading branch information
u8-Salem and AsparagusEduardo committed Apr 25, 2023
1 parent 9562c7a commit 78c4d07
Show file tree
Hide file tree
Showing 17 changed files with 340 additions and 9 deletions.
27 changes: 27 additions & 0 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -10395,3 +10395,30 @@ BattleScript_CouldntFullyProtect::
printstring STRINGID_COULDNTFULLYPROTECT
waitmessage B_WAIT_TIME_LONG
return

BattleScript_BerserkGeneRet::
BattleScript_BerserkGeneRet_Anim:
statbuffchange STAT_CHANGE_ALLOW_PTR, BattleScript_BerserkGeneRet_TryConfuse
setgraphicalstatchangevalues
playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT, sB_ANIM_ARG1
setbyte cMULTISTRING_CHOOSER, B_MSG_STAT_ROSE_ITEM
call BattleScript_StatUp
BattleScript_BerserkGeneRet_TryConfuse:
jumpifability BS_SCRIPTING, ABILITY_OWN_TEMPO, BattleScript_BerserkGeneRet_OwnTempoPrevents
jumpifsafeguard BattleScript_BerserkGeneRet_SafeguardProtected
setmoveeffect MOVE_EFFECT_CONFUSION
seteffectprimary
goto BattleScript_BerserkGeneRet_End
BattleScript_BerserkGeneRet_SafeguardProtected::
pause B_WAIT_TIME_SHORT
printstring STRINGID_PKMNUSEDSAFEGUARD
waitmessage B_WAIT_TIME_LONG
goto BattleScript_BerserkGeneRet_End
BattleScript_BerserkGeneRet_OwnTempoPrevents:
pause B_WAIT_TIME_SHORT
call BattleScript_AbilityPopUp
printstring STRINGID_PKMNPREVENTSCONFUSIONWITH
waitmessage B_WAIT_TIME_LONG
BattleScript_BerserkGeneRet_End:
removeitem BS_SCRIPTING
end3
19 changes: 19 additions & 0 deletions graphics/items/icon_palettes/berserk_gene.pal
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
JASC-PAL
0100
16
212 146 75
49 49 49
131 123 131
98 90 98
74 65 74
164 90 222
230 180 255
255 230 238
255 230 106
255 189 74
255 171 32
238 148 0
255 246 189
123 82 32
0 0 0
0 0 0
Binary file added graphics/items/icons/berserk_gene.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions include/battle_scripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ extern const u8 BattleScript_CouldntFullyProtect[];
extern const u8 BattleScript_MoveEffectStockpileWoreOff[];
extern const u8 BattleScript_StealthRockActivates[];
extern const u8 BattleScript_SpikesActivates[];
extern const u8 BattleScript_BerserkGeneRet[];

// zmoves
extern const u8 BattleScript_ZMoveActivateDamaging[];
Expand Down
1 change: 1 addition & 0 deletions include/battle_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,5 +234,6 @@ u32 GetBattlerFriendshipScore(u8 battlerId);
u32 CountBattlerStatIncreases(u8 battlerId, bool32 countEvasionAcc);
bool32 IsMyceliumMightOnField(void);
bool8 ChangeTypeBasedOnTerrain(u8 battlerId);
void RemoveConfusionStatus(u8 battlerId);

#endif // GUARD_BATTLE_UTIL_H
1 change: 1 addition & 0 deletions include/constants/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
#define STATUS4_PLASMA_FISTS (1 << 1)
#define STATUS4_MUD_SPORT (1 << 2) // Only used if B_SPORT_TURNS < GEN_6
#define STATUS4_WATER_SPORT (1 << 3) // Only used if B_SPORT_TURNS < GEN_6
#define STATUS4_INFINITE_CONFUSION (1 << 4) // Used for Berserk Gene

#define HITMARKER_WAKE_UP_CLEAR (1 << 4) // Cleared when waking up. Never set or checked.
#define HITMARKER_SKIP_DMG_TRACK (1 << 5)
Expand Down
3 changes: 3 additions & 0 deletions include/constants/hold_effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@
#define HOLD_EFFECT_LOADED_DICE 180
#define HOLD_EFFECT_BOOSTER_ENERGY 181 // Not implemented.

// Gen2 hold effect
#define HOLD_EFFECT_BERSERK_GENE 182

#define HOLD_EFFECT_CHOICE(holdEffect)((holdEffect == HOLD_EFFECT_CHOICE_BAND || holdEffect == HOLD_EFFECT_CHOICE_SCARF || holdEffect == HOLD_EFFECT_CHOICE_SPECS))

// Terrain seed params
Expand Down
3 changes: 2 additions & 1 deletion include/constants/items.h
Original file line number Diff line number Diff line change
Expand Up @@ -972,8 +972,9 @@
#define ITEM_BLACK_AUGURITE 795
#define ITEM_LINKING_CORD 796
#define ITEM_PEAT_BLOCK 797
#define ITEM_BERSERK_GENE 798

#define ITEMS_COUNT 798
#define ITEMS_COUNT 799
#define ITEM_FIELD_ARROW ITEMS_COUNT

// A special item id associated with "Cancel"/"Exit" etc. in a list of items or decorations
Expand Down
2 changes: 2 additions & 0 deletions include/graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -8878,6 +8878,8 @@ extern const u32 gItemIcon_GriseousCore[];
extern const u32 gItemIconPalette_GriseousCore[];
extern const u32 gItemIcon_LustrousGlobe[];
extern const u32 gItemIconPalette_LustrousGlobe[];
extern const u32 gItemIcon_BerserkGene[];
extern const u32 gItemIconPalette_BerserkGene[];

extern const u32 gItemIcon_ReturnToFieldArrow[];
extern const u32 gItemIconPalette_ReturnToFieldArrow[];
Expand Down
2 changes: 1 addition & 1 deletion src/battle_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3227,7 +3227,7 @@ void SwitchInClearSetData(void)
gStatuses3[gActiveBattler] &= (STATUS3_LEECHSEED_BATTLER | STATUS3_LEECHSEED | STATUS3_ALWAYS_HITS | STATUS3_PERISH_SONG | STATUS3_ROOTED
| STATUS3_GASTRO_ACID | STATUS3_EMBARGO | STATUS3_TELEKINESIS | STATUS3_MAGNET_RISE | STATUS3_HEAL_BLOCK
| STATUS3_AQUA_RING | STATUS3_POWER_TRICK);
gStatuses4[gActiveBattler] &= (STATUS4_MUD_SPORT | STATUS4_WATER_SPORT);
gStatuses4[gActiveBattler] &= (STATUS4_MUD_SPORT | STATUS4_WATER_SPORT | STATUS4_INFINITE_CONFUSION);
for (i = 0; i < gBattlersCount; i++)
{
if (GetBattlerSide(gActiveBattler) != GetBattlerSide(i)
Expand Down
2 changes: 2 additions & 0 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -16583,6 +16583,8 @@ void BS_ItemCureStatus(void) {

if (GetItemStatus1Mask(gLastUsedItem) & STATUS1_SLEEP)
gBattleMons[gBattlerAttacker].status2 &= ~STATUS2_NIGHTMARE;
if (GetItemStatus2Mask(gLastUsedItem) & STATUS2_CONFUSION)
gStatuses4[gBattlerAttacker] &= ~STATUS4_INFINITE_CONFUSION;

PREPARE_SPECIES_BUFFER(gBattleTextBuff1, GetMonData(&party[gBattleStruct->itemPartyIndex[gBattlerAttacker]], MON_DATA_SPECIES));
gBattlescriptCurrInstr = cmd->nextInstr;
Expand Down
79 changes: 72 additions & 7 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ static void SetRandomMultiHitCounter();
static u32 GetBattlerItemHoldEffectParam(u8 battlerId, u16 item);
static u16 GetInverseTypeMultiplier(u16 multiplier);
static u16 GetSupremeOverlordModifier(u8 battlerId);
static bool8 CanBeInfinitelyConfused(u8 battlerId);

extern const u8 *const gBattleScriptsForMoveEffects[];
extern const u8 *const gBattlescriptsForRunningByItem[];
Expand Down Expand Up @@ -3526,7 +3527,8 @@ u8 AtkCanceller_UnableToUseMove(void)
case CANCELLER_CONFUSED: // confusion
if (gBattleMons[gBattlerAttacker].status2 & STATUS2_CONFUSION)
{
gBattleMons[gBattlerAttacker].status2 -= STATUS2_CONFUSION_TURN(1);
if (!(gStatuses4[gBattlerAttacker] & STATUS4_INFINITE_CONFUSION))
gBattleMons[gBattlerAttacker].status2 -= STATUS2_CONFUSION_TURN(1);
if (gBattleMons[gBattlerAttacker].status2 & STATUS2_CONFUSION)
{
// confusion dmg
Expand Down Expand Up @@ -5968,7 +5970,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
gBattlescriptCurrInstr = BattleScript_AbilityCuredStatus;
break;
case 2: // get rid of confusion
gBattleMons[battler].status2 &= ~STATUS2_CONFUSION;
RemoveConfusionStatus(battler);
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_AbilityCuredStatus;
break;
Expand Down Expand Up @@ -6906,7 +6908,7 @@ static u8 ItemEffectMoveEnd(u32 battlerId, u16 holdEffect)
case HOLD_EFFECT_CURE_CONFUSION:
if (gBattleMons[battlerId].status2 & STATUS2_CONFUSION && !UnnerveOn(battlerId, gLastUsedItem))
{
gBattleMons[battlerId].status2 &= ~STATUS2_CONFUSION;
RemoveConfusionStatus(battlerId);
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryCureConfusionRet;
effect = ITEM_EFFECT_OTHER;
Expand Down Expand Up @@ -6947,7 +6949,7 @@ static u8 ItemEffectMoveEnd(u32 battlerId, u16 holdEffect)
StringCopy(gBattleTextBuff1, gStatusConditionString_ConfusionJpn);

gBattleMons[battlerId].status1 = 0;
gBattleMons[battlerId].status2 &= ~STATUS2_CONFUSION;
RemoveConfusionStatus(battlerId);
BattleScriptPushCursor();
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_CURED_PROBLEM;
gBattlescriptCurrInstr = BattleScript_BerryCureChosenStatusRet;
Expand Down Expand Up @@ -6985,6 +6987,21 @@ static u8 ItemEffectMoveEnd(u32 battlerId, u16 holdEffect)
effect = ITEM_EFFECT_OTHER;
}
break;
case HOLD_EFFECT_BERSERK_GENE:
BufferStatChange(battlerId, STAT_ATK, STRINGID_STATROSE);
gEffectBattler = battlerId;
if (CanBeInfinitelyConfused(gEffectBattler))
{
gStatuses4[gEffectBattler] |= STATUS4_INFINITE_CONFUSION;
}
SET_STATCHANGER(STAT_ATK, 2, FALSE);

gBattleScripting.animArg1 = 14 + STAT_ATK;
gBattleScripting.animArg2 = 0;

BattleScriptPushCursorAndCallback(BattleScript_BerserkGeneRet);
effect = ITEM_STATS_CHANGE;
break;
}

return effect;
Expand Down Expand Up @@ -7163,7 +7180,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
else
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_NORMALIZED_STATUS;
gBattleMons[battlerId].status1 = 0;
gBattleMons[battlerId].status2 &= ~STATUS2_CONFUSION;
RemoveConfusionStatus(battlerId);
BattleScriptExecute(BattleScript_BerryCureChosenStatusEnd2);
effect = ITEM_STATUS_CHANGE;
}
Expand Down Expand Up @@ -7224,6 +7241,21 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
}
}
break;
case HOLD_EFFECT_BERSERK_GENE:
BufferStatChange(battlerId, STAT_ATK, STRINGID_STATROSE);
gEffectBattler = battlerId;
if (CanBeInfinitelyConfused(gEffectBattler))
{
gStatuses4[gEffectBattler] |= STATUS4_INFINITE_CONFUSION;
}
SET_STATCHANGER(STAT_ATK, 2, FALSE);

gBattleScripting.animArg1 = 14 + STAT_ATK;
gBattleScripting.animArg2 = 0;

BattleScriptPushCursorAndCallback(BattleScript_BerserkGeneRet);
effect = ITEM_STATS_CHANGE;
break;
}
if (effect != 0)
{
Expand Down Expand Up @@ -7444,7 +7476,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
case HOLD_EFFECT_CURE_CONFUSION:
if (gBattleMons[battlerId].status2 & STATUS2_CONFUSION && !UnnerveOn(battlerId, gLastUsedItem))
{
gBattleMons[battlerId].status2 &= ~STATUS2_CONFUSION;
RemoveConfusionStatus(battlerId);
BattleScriptExecute(BattleScript_BerryCureConfusionEnd2);
effect = ITEM_EFFECT_OTHER;
}
Expand Down Expand Up @@ -7489,7 +7521,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
else
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_NORMALIZED_STATUS;
gBattleMons[battlerId].status1 = 0;
gBattleMons[battlerId].status2 &= ~STATUS2_CONFUSION;
RemoveConfusionStatus(battlerId);
BattleScriptExecute(BattleScript_BerryCureChosenStatusEnd2);
effect = ITEM_STATUS_CHANGE;
}
Expand All @@ -7507,6 +7539,21 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
if (!moveTurn)
effect = TrySetMicleBerry(battlerId, gLastUsedItem, TRUE);
break;
case HOLD_EFFECT_BERSERK_GENE:
BufferStatChange(battlerId, STAT_ATK, STRINGID_STATROSE);
gEffectBattler = battlerId;
if (CanBeInfinitelyConfused(gEffectBattler))
{
gStatuses4[gEffectBattler] |= STATUS4_INFINITE_CONFUSION;
}
SET_STATCHANGER(STAT_ATK, 2, FALSE);

gBattleScripting.animArg1 = 14 + STAT_ATK;
gBattleScripting.animArg2 = 0;

BattleScriptPushCursorAndCallback(BattleScript_BerserkGeneRet);
effect = ITEM_STATS_CHANGE;
break;
}

if (effect != 0)
Expand Down Expand Up @@ -10870,3 +10917,21 @@ static void SetRandomMultiHitCounter()
gMultiHitCounter = 5 - (Random() & 1);
}
}

void RemoveConfusionStatus(u8 battlerId)
{
gBattleMons[battlerId].status2 &= ~STATUS2_CONFUSION;
gStatuses4[battlerId] &= ~STATUS4_INFINITE_CONFUSION;
}

static bool8 CanBeInfinitelyConfused(u8 battlerId)
{
if (gBattleMons[battlerId].ability == ABILITY_OWN_TEMPO
|| IsBattlerTerrainAffected(battlerId, STATUS_FIELD_MISTY_TERRAIN)
|| gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_SAFEGUARD)
{
return FALSE;
}
return TRUE;
}

3 changes: 3 additions & 0 deletions src/data/graphics/items.h
Original file line number Diff line number Diff line change
Expand Up @@ -1998,3 +1998,6 @@ const u32 gItemIconPalette_GriseousCore[] = INCBIN_U32("graphics/items/icon_pale

const u32 gItemIcon_LustrousGlobe[] = INCBIN_U32("graphics/items/icons/lustrous_globe.4bpp.lz");
const u32 gItemIconPalette_LustrousGlobe[] = INCBIN_U32("graphics/items/icon_palettes/lustrous_globe.gbapal.lz");

const u32 gItemIcon_BerserkGene[] = INCBIN_U32("graphics/items/icons/berserk_gene.4bpp.lz");
const u32 gItemIconPalette_BerserkGene[] = INCBIN_U32("graphics/items/icon_palettes/berserk_gene.gbapal.lz");
1 change: 1 addition & 0 deletions src/data/item_icon_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@ const u32 *const gItemIconTable[ITEMS_COUNT + 1][2] =
[ITEM_BLACK_AUGURITE] = {gItemIcon_BlackAugurite, gItemIconPalette_BlackAugurite},
[ITEM_LINKING_CORD] = {gItemIcon_LinkingCord, gItemIconPalette_LinkingCord},
[ITEM_PEAT_BLOCK] = {gItemIcon_PeatBlock, gItemIconPalette_PeatBlock},
[ITEM_BERSERK_GENE] = {gItemIcon_BerserkGene, gItemIconPalette_BerserkGene},
// Return to field arrow
[ITEMS_COUNT] = {gItemIcon_ReturnToFieldArrow, gItemIconPalette_ReturnToFieldArrow},
};
13 changes: 13 additions & 0 deletions src/data/items.h
Original file line number Diff line number Diff line change
Expand Up @@ -10340,4 +10340,17 @@ const struct Item gItems[] =
.fieldUseFunc = ItemUseOutOfBattle_EvolutionStone,
.flingPower = 30,
},

[ITEM_BERSERK_GENE] =
{
.name = _("Berserk Gene"),
.itemId = ITEM_BERSERK_GENE,
.price = 20,
.holdEffect = HOLD_EFFECT_BERSERK_GENE,
.description = sBerserkGene,
.pocket = POCKET_ITEMS,
.type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_CannotUse,
.flingPower = 10,
},
};
5 changes: 5 additions & 0 deletions src/data/text/item_descriptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -3907,3 +3907,8 @@ static const u8 sLustrousGlobeDesc[] = _(
"A large, glowing gem\n"
"that lets Palkia\n"
"change form.");

static const u8 sBerserkGene[] = _(
"Sharply boosts\n"
"Attack, but causes\n"
"lasting confusion.");
Loading

0 comments on commit 78c4d07

Please sign in to comment.