Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…expansion into castform_fix
  • Loading branch information
AgustinGDLV committed May 23, 2023
2 parents 6a92caa + 0ac203f commit 5a8715e
Show file tree
Hide file tree
Showing 17 changed files with 1,081 additions and 479 deletions.
13 changes: 9 additions & 4 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -6984,8 +6984,6 @@ BattleScript_TerrainEnds_Ret::
playanimation BS_ATTACKER, B_ANIM_RESTORE_BG
return

BattleScript_GrassyTerrainEnds:
setbyte cMULTISTRING_CHOOSER, B_MSG_TERRAINENDS_GRASS
BattleScript_TerrainEnds::
call BattleScript_TerrainEnds_Ret
end2
Expand Down Expand Up @@ -7182,8 +7180,10 @@ BattleScript_MistProtected::
return

BattleScript_RageIsBuilding::
statbuffchange STAT_CHANGE_ALLOW_PTR, BattleScript_RageIsBuildingEnd
printstring STRINGID_PKMNRAGEBUILDING
waitmessage B_WAIT_TIME_LONG
BattleScript_RageIsBuildingEnd:
return

BattleScript_MoveUsedIsDisabled::
Expand Down Expand Up @@ -8520,10 +8520,12 @@ BattleScript_AbilityPopUp:
return

BattleScript_SpeedBoostActivates::
statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_SpeedBoostActivatesEnd
call BattleScript_AbilityPopUp
playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1
printstring STRINGID_PKMNRAISEDSPEED
waitmessage B_WAIT_TIME_LONG
BattleScript_SpeedBoostActivatesEnd:
end3

@ Can't compare directly to a value, have to compare to value at pointer
Expand Down Expand Up @@ -9036,8 +9038,8 @@ BattleScript_MoveStatDrain::
setgraphicalstatchangevalues
playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1
waitanimation
.if B_ABSORBING_ABILITY_STRING >= GEN_5
statbuffchange STAT_CHANGE_ALLOW_PTR, BattleScript_MoveStatDrain_Cont
.if B_ABSORBING_ABILITY_STRING >= GEN_5
printfromtable gStatUpStringIds
waitmessage B_WAIT_TIME_LONG
.else
Expand Down Expand Up @@ -9176,7 +9178,6 @@ BattleScript_GrassyTerrainLoopIncrement::
BattleScript_GrassyTerrainLoopEnd::
bicword gHitMarker, HITMARKER_SKIP_DMG_TRACK | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_PASSIVE_DAMAGE
jumpifword CMP_COMMON_BITS, gFieldStatuses, STATUS_FIELD_TERRAIN_PERMANENT, BattleScript_GrassyTerrainHealEnd
jumpifbyte CMP_EQUAL, gFieldTimers + 5, 0, BattleScript_GrassyTerrainEnds
BattleScript_GrassyTerrainHealEnd:
end2

Expand Down Expand Up @@ -9317,23 +9318,27 @@ BattleScript_WeakArmorActivatesEnd:
return

BattleScript_RaiseStatOnFaintingTarget::
statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_RaiseStatOnFaintingTarget_End
copybyte gBattlerAbility, gBattlerAttacker
call BattleScript_AbilityPopUp
setgraphicalstatchangevalues
playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1
waitanimation
printstring STRINGID_LASTABILITYRAISEDSTAT
waitmessage B_WAIT_TIME_LONG
BattleScript_RaiseStatOnFaintingTarget_End:
return

BattleScript_AttackerAbilityStatRaise::
statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_ALLOW_PTR, BattleScript_AttackerAbilityStatRaise_End
copybyte gBattlerAbility, gBattlerAttacker
call BattleScript_AbilityPopUp
setgraphicalstatchangevalues
playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1
waitanimation
printstring STRINGID_ATTACKERABILITYSTATRAISE
waitmessage B_WAIT_TIME_LONG
BattleScript_AttackerAbilityStatRaise_End:
return

BattleScript_FellStingerRaisesStat::
Expand Down
19 changes: 19 additions & 0 deletions data/scripts/debug.inc
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,22 @@ Debug_Script_7::

Debug_Script_8::
end

Debug_CheckSaveBlock::
callnative CheckSaveBlock1Size
msgbox Debug_SaveBlock1Size, MSGBOX_DEFAULT
callnative CheckSaveBlock2Size
msgbox Debug_SaveBlock2Size, MSGBOX_DEFAULT
callnative CheckPokemonStorageSize
msgbox Debug_PokemonStorageSize, MSGBOX_DEFAULT
release
end

Debug_SaveBlock1Size::
.string "SaveBlock1 size: {STR_VAR_1}/{STR_VAR_2}.$"

Debug_SaveBlock2Size::
.string "SaveBlock2 size: {STR_VAR_1}/{STR_VAR_2}.$"

Debug_PokemonStorageSize::
.string "{PKMN}Storage size: {STR_VAR_1}/{STR_VAR_2}.$"
2 changes: 1 addition & 1 deletion include/config/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
#define B_WILD_NATURAL_ENEMIES TRUE // If set to TRUE, certain wild mon species will attack other species when partnered in double wild battles (eg. Zangoose vs Seviper)
#define B_AFFECTION_MECHANICS FALSE // In Gen6+, there's a stat called affection that can trigger different effects in battle. From LGPE onwards, those effects use friendship instead.
#define B_TRAINER_CLASS_POKE_BALLS GEN_LATEST // In Gen7+, trainers will use certain types of Poké Balls depending on their trainer class.
#define B_OBEDIENCE_MECHANICS GEN_LATEST // In PLA+ (here Gen8+), obedience restrictions also apply to non-outsider Pokémon, albeit based on their level met rather than actual level
#define B_OBEDIENCE_MECHANICS GEN_7 // In PLA+ (here Gen8+), obedience restrictions also apply to non-outsider Pokémon, albeit based on their level met rather than actual level
#define B_USE_FROSTBITE FALSE // In PLA, Frostbite replaces Freeze. Enabling this flag does the same here. Moves can still be cherry-picked to either Freeze or Frostbite. Freeze-Dry, Secret Power & Tri Attack depend on this config.

// Animation Settings
Expand Down
1 change: 1 addition & 0 deletions include/config/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define I_VITAMIN_EV_CAP GEN_LATEST // In Gen8+, the Vitamins no longer have a cap of 100 EV per stat.
#define I_BERRY_EV_JUMP GEN_LATEST // In Gen4 only, EV-lowering Berries lower a stat's EV to 100 if it is above 100.
#define I_GRISEOUS_ORB_FORM_CHANGE GEN_LATEST // In Gen9+, the Griseous Orb no longer changes Giratina's form when held.
#define I_USE_EVO_HELD_ITEMS_FROM_BAG FALSE // If TRUE, items such as Razor Claw or Electirizer will be usable from the bag to evolve a Pokémon just like in LA.

// TM config
#define I_REUSABLE_TMS FALSE // In Gen5-8, TMs are reusable. Setting this to TRUE will make all vanilla TMs reusable, though they can also be cherry-picked by setting their importance to 1.
Expand Down
4 changes: 3 additions & 1 deletion include/constants/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,9 @@
#define EVO_SCRIPT_TRIGGER_DMG 36 // Pokémon has specified HP below max, then player interacts trigger
#define EVO_DARK_SCROLL 37 // interacts with Scroll of Darkness
#define EVO_WATER_SCROLL 38 // interacts with Scroll of Waters
#define EVO_ITEM_NIGHT 39 // specified item is used on Pokémon at night
#define EVO_ITEM_NIGHT 39 // specified item is used on Pokémon, is night
#define EVO_ITEM_DAY 40 // specified item is used on Pokémon, is day
#define EVO_ITEM_HOLD 41 // Pokémon levels up, holds specified item

#define EVOS_PER_MON 10

Expand Down
2 changes: 2 additions & 0 deletions include/money.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef GUARD_MONEY_H
#define GUARD_MONEY_H

#define MAX_MONEY 999999

u32 GetMoney(u32 *moneyPtr);
void SetMoney(u32 *moneyPtr, u32 newValue);
bool8 IsEnoughMoney(u32 *moneyPtr, u32 cost);
Expand Down
15 changes: 8 additions & 7 deletions src/battle_ai_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,8 @@ void SetBattlerData(u8 battlerId)
{
if (!BattlerHasAi(battlerId))
{
u32 i, species, illusionSpecies;
u32 i, species, illusionSpecies, side;
side = GetBattlerSide(battlerId);

// Simulate Illusion
species = gBattleMons[battlerId].species;
Expand All @@ -609,22 +610,22 @@ void SetBattlerData(u8 battlerId)
}

// Use the known battler's ability.
if (BATTLE_HISTORY->abilities[battlerId] != ABILITY_NONE)
gBattleMons[battlerId].ability = BATTLE_HISTORY->abilities[battlerId];
if (AI_PARTY->mons[side][gBattlerPartyIndexes[battlerId]].ability != ABILITY_NONE)
gBattleMons[battlerId].ability = AI_PARTY->mons[side][gBattlerPartyIndexes[battlerId]].ability;
// Check if mon can only have one ability.
else if (gSpeciesInfo[species].abilities[1] == ABILITY_NONE
|| gSpeciesInfo[species].abilities[1] == gSpeciesInfo[species].abilities[0])
|| gSpeciesInfo[species].abilities[1] == gSpeciesInfo[species].abilities[0])
gBattleMons[battlerId].ability = gSpeciesInfo[species].abilities[0];
// The ability is unknown.
else
gBattleMons[battlerId].ability = ABILITY_NONE;

if (BATTLE_HISTORY->itemEffects[battlerId] == 0)
if (AI_PARTY->mons[side][gBattlerPartyIndexes[battlerId]].heldEffect == 0)
gBattleMons[battlerId].item = 0;

for (i = 0; i < 4; i++)
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (BATTLE_HISTORY->usedMoves[battlerId][i] == 0)
if (AI_PARTY->mons[side][gBattlerPartyIndexes[battlerId]].moves[i] == 0)
gBattleMons[battlerId].moves[i] = 0;
}
}
Expand Down
6 changes: 1 addition & 5 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -5582,7 +5582,7 @@ static void Cmd_moveend(void)
&& gBattleMoves[gCurrentMove].power != 0
&& CompareStat(gBattlerTarget, STAT_ATK, MAX_STAT_STAGE, CMP_LESS_THAN))
{
gBattleMons[gBattlerTarget].statStages[STAT_ATK]++;
SET_STATCHANGER(STAT_ATK, 1, FALSE);
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_RageIsBuilding;
effect = TRUE;
Expand Down Expand Up @@ -9494,7 +9494,6 @@ static void Cmd_various(void)
&& !NoAliveMonsForEitherParty()
&& CompareStat(gBattlerAttacker, STAT_ATK, MAX_STAT_STAGE, CMP_LESS_THAN))
{
gBattleMons[gBattlerAttacker].statStages[STAT_ATK]++;
SET_STATCHANGER(STAT_ATK, 1, FALSE);
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_ATK);
BattleScriptPush(cmd->nextInstr);
Expand All @@ -9518,7 +9517,6 @@ static void Cmd_various(void)
&& !NoAliveMonsForEitherParty()
&& CompareStat(gBattlerAttacker, STAT_SPATK, MAX_STAT_STAGE, CMP_LESS_THAN))
{
gBattleMons[gBattlerAttacker].statStages[STAT_SPATK]++;
SET_STATCHANGER(STAT_SPATK, 1, FALSE);
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_SPATK);
BattleScriptPush(cmd->nextInstr);
Expand Down Expand Up @@ -9570,7 +9568,6 @@ static void Cmd_various(void)
&& !NoAliveMonsForEitherParty()
&& CompareStat(gBattlerAttacker, i, MAX_STAT_STAGE, CMP_LESS_THAN))
{
gBattleMons[gBattlerAttacker].statStages[i]++;
SET_STATCHANGER(i, 1, FALSE);
PREPARE_STAT_BUFFER(gBattleTextBuff1, i);
BattleScriptPush(cmd->nextInstr);
Expand All @@ -9590,7 +9587,6 @@ static void Cmd_various(void)
&& !NoAliveMonsForEitherParty()
&& CompareStat(gBattleScripting.battler, STAT_SPATK, MAX_STAT_STAGE, CMP_LESS_THAN))
{
gBattleMons[gBattleScripting.battler].statStages[STAT_SPATK]++;
SET_STATCHANGER(STAT_SPATK, 1, FALSE);
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_SPATK);
BattleScriptPushCursor();
Expand Down
21 changes: 7 additions & 14 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -2056,19 +2056,16 @@ static bool32 EndTurnTerrain(u32 terrainFlag, u32 stringTableId)
{
if (gFieldStatuses & terrainFlag)
{
if (terrainFlag & STATUS_FIELD_GRASSY_TERRAIN)
BattleScriptExecute(BattleScript_GrassyTerrainHeals);
if (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.terrainTimer == 0)
{
gFieldStatuses &= ~terrainFlag;
TryToRevertMimicry();
if (!(terrainFlag & STATUS_FIELD_GRASSY_TERRAIN))
{
gBattleCommunication[MULTISTRING_CHOOSER] = stringTableId;
BattleScriptExecute(BattleScript_TerrainEnds);
}
gBattleCommunication[MULTISTRING_CHOOSER] = stringTableId;
BattleScriptExecute(BattleScript_TerrainEnds);
return TRUE;
}
if (terrainFlag & STATUS_FIELD_GRASSY_TERRAIN)
BattleScriptExecute(BattleScript_GrassyTerrainHeals);
return TRUE;
}
return FALSE;
}
Expand Down Expand Up @@ -4462,7 +4459,6 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move

if (CompareStat(battler, statId, MAX_STAT_STAGE, CMP_LESS_THAN))
{
gBattleMons[battler].statStages[statId]++;
SET_STATCHANGER(statId, 1, FALSE);
gBattlerAttacker = battler;
PREPARE_STAT_BUFFER(gBattleTextBuff1, statId);
Expand Down Expand Up @@ -4829,9 +4825,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
case ABILITY_SPEED_BOOST:
if (CompareStat(battler, STAT_SPEED, MAX_STAT_STAGE, CMP_LESS_THAN) && gDisableStructs[battler].isFirstTurn != 2)
{
gBattleMons[battler].statStages[STAT_SPEED]++;
gBattleScripting.animArg1 = 14 + STAT_SPEED;
gBattleScripting.animArg2 = 0;
SET_STATCHANGER(STAT_SPEED, 1, FALSE);
BattleScriptPushCursorAndCallback(BattleScript_SpeedBoostActivates);
gBattleScripting.battler = battler;
effect++;
Expand Down Expand Up @@ -5126,7 +5120,6 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move

SET_STATCHANGER(statId, statAmount, FALSE);
#if B_ABSORBING_ABILITY_STRING < GEN_5
gBattleMons[battler].statStages[statId]++;
PREPARE_STAT_BUFFER(gBattleTextBuff1, statId);
#endif
}
Expand Down Expand Up @@ -6713,7 +6706,7 @@ static bool32 GetMentalHerbEffect(u8 battlerId)
static u8 TryConsumeMirrorHerb(u8 battlerId, bool32 execute)
{
u8 effect = 0;

if (gProtectStructs[battlerId].eatMirrorHerb) {
gLastUsedItem = gBattleMons[battlerId].item;
gBattleScripting.savedBattler = gBattlerAttacker;
Expand Down
Loading

0 comments on commit 5a8715e

Please sign in to comment.