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

Adds missing evolution methods #4087

Merged
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
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
4 changes: 4 additions & 0 deletions asm/macros/battle_script.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1583,6 +1583,10 @@
callnative BS_SetPhotonGeyserCategory
.endm

.macro tryupdaterecoiltracker
callnative BS_TryUpdateRecoilTracker
.endm

@ various command changed to more readable macros
.macro cancelmultiturnmoves battler:req
various \battler, VARIOUS_CANCEL_MULTI_TURN_MOVES
Expand Down
1 change: 1 addition & 0 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -7699,6 +7699,7 @@ BattleScript_DoRecoil::
datahpupdate BS_ATTACKER
printstring STRINGID_PKMNHITWITHRECOIL
waitmessage B_WAIT_TIME_LONG
tryupdaterecoiltracker
tryfaintmon BS_ATTACKER
BattleScript_RecoilEnd::
return
Expand Down
5 changes: 3 additions & 2 deletions include/constants/battle_script_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,9 @@
#define MOVEEND_SYMBIOSIS 34
#define MOVEEND_OPPORTUNIST 35 // Occurs after other stat change items/abilities to try and copy the boosts
#define MOVEEND_SAME_MOVE_TURNS 36
#define MOVEEND_CLEAR_BITS 37
#define MOVEEND_COUNT 38
#define MOVEEND_SET_EVOLUTION_TRACKER 37
#define MOVEEND_CLEAR_BITS 38
#define MOVEEND_COUNT 39

// switch cases
#define B_SWITCH_NORMAL 0
Expand Down
2 changes: 2 additions & 0 deletions include/constants/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@
#define EVO_MOVE_THREE_SEGMENT 44 // Pokémon levels up, knows specified move, has a personality value with a modulus of 1-99
#define EVO_LEVEL_FAMILY_OF_THREE 45 // Pokémon reaches the specified level with a personality value with a modulus of 0
#define EVO_LEVEL_FAMILY_OF_FOUR 46 // Pokémon reaches the specified level with a personality value with a modulus of 1-99
#define EVO_LEVEL_MOVE_TWENTY_TIMES 47 // Pokémon levels up after having used a move for at least 20 times
#define EVO_LEVEL_RECOIL_DAMAGE 48 // Pokémon levels up after having suffered specified amount of non-fainting recoil damage

// Evolution 'modes,' for GetEvolutionTargetSpecies
#define EVO_MODE_NORMAL 0
Expand Down
6 changes: 4 additions & 2 deletions include/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ enum {
MON_DATA_DYNAMAX_LEVEL,
MON_DATA_GIGANTAMAX_FACTOR,
MON_DATA_TERA_TYPE,
MON_DATA_EVOLUTION_TRACKER,
};

struct PokemonSubstruct0
Expand All @@ -134,9 +135,10 @@ struct PokemonSubstruct0
struct PokemonSubstruct1
{
u16 move1:11; // 2047 moves.
u16 unused_00:5;
u16 evolutionTracker1:5;
u16 move2:11; // 2047 moves.
u16 unused_02:5;
u16 evolutionTracker2:4;
u16 unused_02:1;
u16 move3:11; // 2047 moves.
u16 unused_04:5;
u16 move4:11; // 2047 moves.
Expand Down
76 changes: 76 additions & 0 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -6200,6 +6200,39 @@ static void Cmd_moveend(void)
gBattleStruct->sameMoveTurns[gBattlerAttacker]++;
gBattleScripting.moveendState++;
break;
case MOVEEND_SET_EVOLUTION_TRACKER:
// If the Pokémon needs to keep track of move usage for its evolutions, do it
if (originallyUsedMove != MOVE_NONE
&& GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER
&& !(gBattleTypeFlags & (BATTLE_TYPE_LINK
| BATTLE_TYPE_EREADER_TRAINER
| BATTLE_TYPE_RECORDED_LINK
| BATTLE_TYPE_TRAINER_HILL
| BATTLE_TYPE_FRONTIER)))
{
const struct Evolution *evolutions = GetSpeciesEvolutions(gBattleMons[gBattlerAttacker].species);
Bassoonian marked this conversation as resolved.
Show resolved Hide resolved
if (evolutions == NULL)
{
gBattleScripting.moveendState++;
break;
}
for (i = 0; evolutions[i].method != EVOLUTIONS_END; i++)
{
if (SanitizeSpeciesId(evolutions[i].targetSpecies) == SPECIES_NONE)
continue;
if (evolutions[i].method == EVO_LEVEL_MOVE_TWENTY_TIMES && evolutions[i].param == originallyUsedMove)
{
u16 val;
val = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]], MON_DATA_EVOLUTION_TRACKER);
if (val < 20)
val++;
SetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]], MON_DATA_EVOLUTION_TRACKER, &val);
break;
}
}
}
gBattleScripting.moveendState++;
break;
case MOVEEND_CLEAR_BITS: // Clear/Set bits for things like using a move for all targets and all hits.
if (gSpecialStatuses[gBattlerAttacker].instructedChosenTarget)
*(gBattleStruct->moveTarget + gBattlerAttacker) = gSpecialStatuses[gBattlerAttacker].instructedChosenTarget & 0x3;
Expand Down Expand Up @@ -16574,3 +16607,46 @@ void BS_SetPhotonGeyserCategory(void)
gBattleStruct->swapDamageCategory = (GetCategoryBasedOnStats(gBattlerAttacker) == DAMAGE_CATEGORY_PHYSICAL);
gBattlescriptCurrInstr = cmd->nextInstr;
}

void BS_TryUpdateRecoilTracker(void)
{
NATIVE_ARGS();
u32 i;

if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER
&& !(gBattleTypeFlags & (BATTLE_TYPE_LINK
| BATTLE_TYPE_EREADER_TRAINER
| BATTLE_TYPE_RECORDED_LINK
| BATTLE_TYPE_TRAINER_HILL
| BATTLE_TYPE_FRONTIER)))
{
const struct Evolution *evolutions = GetSpeciesEvolutions(gBattleMons[gBattlerAttacker].species);
if (evolutions == NULL)
{
gBattlescriptCurrInstr = cmd->nextInstr;
return;
}
for (i = 0; evolutions[i].method != EVOLUTIONS_END; i++)
{
if (SanitizeSpeciesId(evolutions[i].targetSpecies) == SPECIES_NONE)
continue;
if (evolutions[i].method == EVO_LEVEL_RECOIL_DAMAGE)
{
u16 val;
val = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]], MON_DATA_EVOLUTION_TRACKER);
if (val == 512) // to account for the fact we only have 10 bits
break;
if ((val + gBattleMoveDamage) > 512)
val = 512;
else
val += gBattleMoveDamage;
Bassoonian marked this conversation as resolved.
Show resolved Hide resolved
if (gBattleMons[gBattlerAttacker].hp == 0) // reset progress if you faint
val = 0;
SetMonData(&gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]], MON_DATA_EVOLUTION_TRACKER, &val);
break;
}
}
}

gBattlescriptCurrInstr = cmd->nextInstr;
}
2 changes: 1 addition & 1 deletion src/data/pokemon/species_info/gen_1.h
Original file line number Diff line number Diff line change
Expand Up @@ -4508,7 +4508,7 @@ const struct SpeciesInfo gSpeciesInfoGen1[] =
ICON(Primeape, 2),
FOOTPRINT(Primeape)
LEARNSETS(Primeape),
.evolutions = EVOLUTION({EVO_MOVE, MOVE_RAGE_FIST, SPECIES_ANNIHILAPE}),
.evolutions = EVOLUTION({EVO_LEVEL_MOVE_TWENTY_TIMES, MOVE_RAGE_FIST, SPECIES_ANNIHILAPE}),
},

#if P_GEN_9_CROSS_EVOS
Expand Down
2 changes: 1 addition & 1 deletion src/data/pokemon/species_info/gen_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -5170,7 +5170,7 @@ const struct SpeciesInfo gSpeciesInfoGen2[] =
ICON(Stantler, 2),
FOOTPRINT(Stantler)
LEARNSETS(Stantler),
.evolutions = EVOLUTION({EVO_MOVE, MOVE_PSYSHIELD_BASH, SPECIES_WYRDEER}),
.evolutions = EVOLUTION({EVO_LEVEL_MOVE_TWENTY_TIMES, MOVE_PSYSHIELD_BASH, SPECIES_WYRDEER}),
},

#if P_GEN_8_CROSS_EVOS
Expand Down
4 changes: 2 additions & 2 deletions src/data/pokemon/species_info/gen_5.h
Original file line number Diff line number Diff line change
Expand Up @@ -3036,8 +3036,8 @@ const struct SpeciesInfo gSpeciesInfoGen5[] =
PALETTES(BasculinWhiteStriped),
ICON(BasculinWhiteStriped, 0),
LEARNSETS(BasculinWhiteStriped),
.evolutions = EVOLUTION({EVO_NONE, 0, SPECIES_BASCULEGION_MALE},
{EVO_NONE, 0, SPECIES_BASCULEGION_FEMALE}),
.evolutions = EVOLUTION({EVO_LEVEL_RECOIL_DAMAGE, 294, SPECIES_BASCULEGION_MALE},
{EVO_LEVEL_RECOIL_DAMAGE, 294, SPECIES_BASCULEGION_FEMALE}),
Bassoonian marked this conversation as resolved.
Show resolved Hide resolved
},

#define BASCULEGION_MISC_INFO \
Expand Down
10 changes: 10 additions & 0 deletions src/pokedex_plus_hgss.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ static const u8 sText_EVO_WATER_SCROLL[] = _("ScrollOfWatrs is used");
static const u8 sText_EVO_ITEM_NIGHT[] = _("{STR_VAR_2} is used, night");
static const u8 sText_EVO_ITEM_DAY[] = _("{STR_VAR_2} is used, day");
static const u8 sText_EVO_ITEM_HOLD[] = _("{LV}{UP_ARROW}, holds {STR_VAR_2}");
static const u8 sText_EVO_LEVEL_MOVE_TWENTY_TIMES[] = _("{LV}{UP_ARROW} after 20x {STR_VAR_2}");
static const u8 sText_EVO_LEVEL_RECOIL_DAMAGE[] = _("{LV}{UP_ARROW} with {STR_VAR_2} recoil");
static const u8 sText_EVO_UNKNOWN[] = _("Method unknown");
static const u8 sText_EVO_NONE[] = _("{STR_VAR_1} has no evolution.");

Expand Down Expand Up @@ -6770,6 +6772,14 @@ static u8 PrintEvolutionTargetSpeciesAndMethod(u8 taskId, u16 species, u8 depth,
CopyItemName(item, gStringVar2);
StringExpandPlaceholders(gStringVar4, sText_EVO_ITEM_HOLD );
break;
case EVO_LEVEL_MOVE_TWENTY_TIMES:
StringCopy(gStringVar2, GetMoveName(evolutions[i].param));
StringExpandPlaceholders(gStringVar4, sText_EVO_LEVEL_MOVE_TWENTY_TIMES );
break;
case EVO_LEVEL_RECOIL_DAMAGE:
ConvertIntToDecimalStringN(gStringVar2, evolutions[i].param, STR_CONV_MODE_LEADING_ZEROS, 3);
StringExpandPlaceholders(gStringVar4, sText_EVO_LEVEL_RECOIL_DAMAGE);
break;
default:
StringExpandPlaceholders(gStringVar4, sText_EVO_UNKNOWN );
break;
Expand Down
36 changes: 36 additions & 0 deletions src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -2087,6 +2087,17 @@ u32 GetMonData2(struct Pokemon *mon, s32 field)
return GetMonData3(mon, field, NULL);
}

struct EvolutionTrackerBitfield {
u16 a: 5;
u16 b: 4;
u16 unused: 7;
};

union EvolutionTracker {
u16 value;
struct EvolutionTrackerBitfield asField;
};
Bassoonian marked this conversation as resolved.
Show resolved Hide resolved

/* GameFreak called GetBoxMonData with either 2 or 3 arguments, for type
* safety we have a GetBoxMonData macro (in include/pokemon.h) which
* dispatches to either GetBoxMonData2 or GetBoxMonData3 based on the
Expand All @@ -2099,6 +2110,7 @@ u32 GetBoxMonData3(struct BoxPokemon *boxMon, s32 field, u8 *data)
struct PokemonSubstruct1 *substruct1 = NULL;
struct PokemonSubstruct2 *substruct2 = NULL;
struct PokemonSubstruct3 *substruct3 = NULL;
union EvolutionTracker evoTracker;

// Any field greater than MON_DATA_ENCRYPT_SEPARATOR is encrypted and must be treated as such
if (field > MON_DATA_ENCRYPT_SEPARATOR)
Expand Down Expand Up @@ -2479,6 +2491,11 @@ u32 GetBoxMonData3(struct BoxPokemon *boxMon, s32 field, u8 *data)
}
break;
}
case MON_DATA_EVOLUTION_TRACKER:
evoTracker.asField.a = substruct1->evolutionTracker1;
evoTracker.asField.b = substruct1->evolutionTracker2;
retVal = evoTracker.value;
break;
default:
break;
}
Expand Down Expand Up @@ -2894,6 +2911,16 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg)
substruct0->teraType = 1 + teraType;
break;
}
case MON_DATA_EVOLUTION_TRACKER:
{
union EvolutionTracker evoTracker;
u32 evoTrackerValue;
SET32(evoTrackerValue);
evoTracker.value = evoTrackerValue;
substruct1->evolutionTracker1 = evoTracker.asField.a;
substruct1->evolutionTracker2 = evoTracker.asField.b;
break;
}
default:
break;
}
Expand Down Expand Up @@ -4047,6 +4074,7 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem, s
u16 upperPersonality = personality >> 16;
u32 holdEffect, currentMap, partnerSpecies, partnerHeldItem, partnerHoldEffect;
bool32 consumeItem = FALSE;
u16 evolutionTracker = GetMonData(mon, MON_DATA_EVOLUTION_TRACKER, 0);
const struct Evolution *evolutions = GetSpeciesEvolutions(species);

if (evolutions == NULL)
Expand Down Expand Up @@ -4307,6 +4335,14 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem, s
consumeItem = TRUE;
}
break;
case EVO_LEVEL_MOVE_TWENTY_TIMES:
if (evolutionTracker >= 20)
targetSpecies = evolutions[i].targetSpecies;
break;
case EVO_LEVEL_RECOIL_DAMAGE:
if (evolutionTracker >= evolutions[i].param)
targetSpecies = evolutions[i].targetSpecies;
break;
}
}
break;
Expand Down
Loading