Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Berserk Gene Item #2893

Merged
merged 28 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
fc18adb
added berserk gene item
u8-Salem Mar 31, 2023
cfcc405
fixed item not activating on battle start
u8-Salem Apr 2, 2023
ec47958
added graphics
u8-Salem Apr 6, 2023
32d5ccb
extend some u32 status2 to u64
u8-Salem Apr 6, 2023
3363b5b
support 255 turns of confusion
u8-Salem Apr 7, 2023
eea21a4
Revert "support 255 turns of confusion"
u8-Salem Apr 7, 2023
583d8e6
Revert "extend some u32 status2 to u64"
u8-Salem Apr 7, 2023
7a5706d
Add Infinite confusion bit
u8-Salem Apr 7, 2023
1050d6d
requested changes + fix to BS call
u8-Salem Apr 10, 2023
3a0bfd4
Merge branch 'upcoming' into berserkGene
u8-Salem Apr 10, 2023
ecd15d1
prevent inf. conf. being set when conf. is prevented.
u8-Salem Apr 10, 2023
0b7d86e
Merge branch 'upcoming' into berserkGene
u8-Salem Apr 10, 2023
9393899
update item description
u8-Salem Apr 12, 2023
31568d5
additional inf. confusion heal instances
u8-Salem Apr 13, 2023
0a8abaa
extract removing confusion status
u8-Salem Apr 13, 2023
13425c4
Merge branch 'upcoming' into berserkGene
u8-Salem Apr 15, 2023
c8fb26e
Merge branch 'upcoming' into berserkGene
u8-Salem Apr 18, 2023
72816d8
cure infinite confusion with battle items
u8-Salem Apr 18, 2023
bbc3c4d
cleanup
u8-Salem Apr 18, 2023
3a5df79
Tests for Berserk Gene
u8-Salem Apr 19, 2023
6d5dec5
fix a test
u8-Salem Apr 20, 2023
3689135
Merge branch 'upcoming' into berserkGene
u8-Salem Apr 21, 2023
78878dc
just when you think youre smart, you turn out to be dumber than that
u8-Salem Apr 21, 2023
79517c3
Merge branch 'upcoming' into berserkGene
u8-Salem Apr 21, 2023
7d441b3
extract infinite confusion conditions
u8-Salem Apr 21, 2023
b883bf3
safeguard test
u8-Salem Apr 21, 2023
85842d6
Update test/hold_effect_berserk_gene.c
u8-Salem Apr 25, 2023
03652ba
Apply suggestions from code review
u8-Salem Apr 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -10368,3 +10368,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/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
AsparagusEduardo marked this conversation as resolved.
Show resolved Hide resolved

#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 @@ -3225,7 +3225,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
53 changes: 52 additions & 1 deletion src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -3599,7 +3599,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 @@ -6980,6 +6981,7 @@ static u8 ItemEffectMoveEnd(u32 battlerId, u16 holdEffect)
if (gBattleMons[battlerId].status2 & STATUS2_CONFUSION && !UnnerveOn(battlerId, gLastUsedItem))
{
gBattleMons[battlerId].status2 &= ~STATUS2_CONFUSION;
gStatuses4[battlerId] &= ~STATUS4_INFINITE_CONFUSION;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryCureConfusionRet;
effect = ITEM_EFFECT_OTHER;
Expand Down Expand Up @@ -7058,6 +7060,22 @@ 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 (gBattleMons[gEffectBattler].ability != ABILITY_OWN_TEMPO
|| IsBattlerTerrainAffected(battlerId, STATUS_FIELD_MISTY_TERRAIN))
u8-Salem marked this conversation as resolved.
Show resolved Hide resolved
{
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 @@ -7297,6 +7315,22 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
}
}
break;
case HOLD_EFFECT_BERSERK_GENE:
BufferStatChange(battlerId, STAT_ATK, STRINGID_STATROSE);
gEffectBattler = battlerId;
if (gBattleMons[gEffectBattler].ability != ABILITY_OWN_TEMPO
|| IsBattlerTerrainAffected(battlerId, STATUS_FIELD_MISTY_TERRAIN))
{
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 @@ -7518,6 +7552,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
if (gBattleMons[battlerId].status2 & STATUS2_CONFUSION && !UnnerveOn(battlerId, gLastUsedItem))
{
gBattleMons[battlerId].status2 &= ~STATUS2_CONFUSION;
gStatuses4[battlerId] &= ~STATUS4_INFINITE_CONFUSION;
BattleScriptExecute(BattleScript_BerryCureConfusionEnd2);
effect = ITEM_EFFECT_OTHER;
}
Expand Down Expand Up @@ -7580,6 +7615,22 @@ 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 (gBattleMons[gEffectBattler].ability != ABILITY_OWN_TEMPO
|| IsBattlerTerrainAffected(battlerId, STATUS_FIELD_MISTY_TERRAIN))
{
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
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 @@ -10319,4 +10319,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[] = _(
"Boosts Attack\n"
"but causes\n"
"confusion.");
u8-Salem marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -5934,6 +5934,7 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
&& gMain.inBattle && battlerId != MAX_BATTLERS_COUNT && (gBattleMons[battlerId].status2 & STATUS2_CONFUSION))
{
gBattleMons[battlerId].status2 &= ~STATUS2_CONFUSION;
gStatuses4[battlerId] &= ~STATUS4_INFINITE_CONFUSION;
u8-Salem marked this conversation as resolved.
Show resolved Hide resolved
retVal = FALSE;
}
break;
Expand Down