fixed evolution tracker for modern, fixed moved based evolution tracking, removed unused

This commit is contained in:
cawtds 2024-05-05 19:49:16 +02:00
parent c2e0ab5d73
commit cb86fbde05
10 changed files with 88 additions and 135 deletions

View File

@ -2224,6 +2224,16 @@
callnative BS_DamageNonTypes
.endm
.macro tryupdaterecoiltracker
callnative BS_TryUpdateRecoilTracker
.endm
.macro trytidyup clear:req, jumpInstr:req
callnative BS_TryTidyUp
.byte \clear
.4byte \jumpInstr
.endm
.macro trygulpmissile
callnative BS_TryGulpMissile
.endm

View File

@ -23,6 +23,23 @@
.section script_data, "aw", %progbits
.align 2
BattleScript_EffectTidyUp::
attackcanceler
attackstring
pause B_WAIT_TIME_MED
ppreduce
waitstate
trytidyup FALSE, BattleScript_EffectTidyUpDoMoveAnimation
goto BattleScript_EffectDragonDanceFromStatUp
BattleScript_EffectTidyUpDoMoveAnimation::
attackanimation
waitanimation
trytidyup TRUE, NULL
printstring STRINGID_TIDYINGUPCOMPLETE
waitmessage B_WAIT_TIME_LONG
goto BattleScript_EffectDragonDanceFromStatUp
BattleScript_EffectHit::
BattleScript_HitFromAtkCanceler::
attackcanceler
@ -2362,7 +2379,7 @@ BattleScript_CalmMindEnd::
BattleScript_CantRaiseMultipleStats::
pause B_WAIT_TIME_SHORT
orbyte gMoveResultFlags, MOVE_RESULT_FAILED
orhalfword gMoveResultFlags, MOVE_RESULT_FAILED
printstring STRINGID_STATSWONTINCREASE2
waitmessage B_WAIT_TIME_LONG
goto BattleScript_MoveEnd
@ -2371,6 +2388,7 @@ BattleScript_EffectDragonDance::
attackcanceler
attackstring
ppreduce
BattleScript_EffectDragonDanceFromStatUp::
jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_ATK, MAX_STAT_STAGE, BattleScript_DragonDanceDoMoveAnim
jumpifstat BS_ATTACKER, CMP_EQUAL, STAT_SPEED, MAX_STAT_STAGE, BattleScript_CantRaiseMultipleStats
BattleScript_DragonDanceDoMoveAnim::

View File

@ -201,28 +201,32 @@ BattleScript_SafariBallThrow::
handleballthrow
BattleScript_SuccessBallThrow::
jumpifhalfword CMP_EQUAL, gLastUsedItem, ITEM_SAFARI_BALL, BattleScript_SafariNoIncGameStat
setbyte sMON_CAUGHT, TRUE
incrementgamestat GAME_STAT_POKEMON_CAPTURES
BattleScript_SafariNoIncGameStat::
printstring STRINGID_GOTCHAPKMNCAUGHT
trysetcaughtmondexflags BattleScript_CaughtPokemonSkipNewDex
BattleScript_PrintCaughtMonInfo::
printstring STRINGID_GOTCHAPKMNCAUGHTPLAYER
jumpifbyte CMP_NOT_EQUAL, sEXP_CATCH, TRUE, BattleScript_TryPrintCaughtMonInfo
setbyte sGIVEEXP_STATE, 0
getexp BS_TARGET
sethword gBattle_BG2_X, 0
BattleScript_TryPrintCaughtMonInfo:
trysetcaughtmondexflags BattleScript_TryNicknameCaughtMon
printstring STRINGID_PKMNDATAADDEDTODEX
waitstate
setbyte gBattleCommunication, 0
displaydexinfo
BattleScript_CaughtPokemonSkipNewDex::
BattleScript_TryNicknameCaughtMon::
printstring STRINGID_GIVENICKNAMECAPTURED
waitstate
setbyte gBattleCommunication, 0
trygivecaughtmonnick BattleScript_CaughtPokemonSkipNickname
trygivecaughtmonnick BattleScript_GiveCaughtMonEnd
givecaughtmon
printfromtable gCaughtMonStringIds
waitmessage B_WAIT_TIME_LONG
goto BattleScript_CaughtPokemonDone
BattleScript_CaughtPokemonSkipNickname::
goto BattleScript_SuccessBallThrowEnd
BattleScript_GiveCaughtMonEnd::
givecaughtmon
BattleScript_CaughtPokemonDone::
BattleScript_SuccessBallThrowEnd::
setbyte gBattleOutcome, B_OUTCOME_CAUGHT
finishturn

View File

@ -1202,7 +1202,6 @@ extern const u8 BattleScript_EffectBulkUp[];
extern const u8 BattleScript_EffectPlaceholder[];
extern const u8 BattleScript_EffectWaterSport[];
extern const u8 BattleScript_EffectCalmMind[];
extern const u8 BattleScript_EffectDragonDance[];
extern const u8 BattleScript_EffectCamouflage[];
extern const u8 BattleScript_EffectPledge[];
extern const u8 BattleScript_EffectFling[];

View File

@ -13,7 +13,7 @@
// For (Set|Get)(Box)?MonData
// Property labels for Get(Box)MonData / Set(Box)MonData
enum {
MON_DATA_PERSONALITY,
MON_DATA_STATUS,

View File

@ -6476,11 +6476,15 @@ static void Cmd_moveend(void)
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)
const struct Evolution *evolutions = GetSpeciesEvolutions(gBattleMons[gBattlerAttacker].species);
if (evolutions->param == originallyUsedMove)
TryUpdateEvolutionTracker(EVO_LEVEL_MOVE_TWENTY_TIMES, 1);
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;
@ -16434,6 +16438,34 @@ static bool8 CanAbilityPreventStatLoss(u16 abilityDef, bool8 byIntimidate)
return FALSE;
}
void BS_TryUpdateRecoilTracker(void)
{
NATIVE_ARGS();
TryUpdateEvolutionTracker(EVO_LEVEL_RECOIL_DAMAGE_MALE, gBattleMoveDamage);
TryUpdateEvolutionTracker(EVO_LEVEL_RECOIL_DAMAGE_FEMALE, gBattleMoveDamage);
gBattlescriptCurrInstr = cmd->nextInstr;
}
void BS_TryTidyUp(void)
{
NATIVE_ARGS(u8 clear, const u8 *jumpInstr);
if (cmd->clear)
{
if (TryTidyUpClear(gEffectBattler, TRUE))
return;
else
gBattlescriptCurrInstr = cmd->nextInstr;
}
else
{
if (TryTidyUpClear(gBattlerAttacker, FALSE))
gBattlescriptCurrInstr = cmd->jumpInstr;
else
gBattlescriptCurrInstr = cmd->nextInstr;
}
}
void BS_TryGulpMissile(void)
{
NATIVE_ARGS();

View File

@ -2,12 +2,6 @@
#include "pokedex.h"
#include "pokedex_screen.h"
// Unused
const u8 *GetPokedexCategoryName(u16 dexNum)
{
return gSpeciesInfo[dexNum].categoryName;
}
u16 GetPokedexHeightWeight(u16 dexNum, u8 data)
{
switch (data)
@ -48,30 +42,6 @@ u16 GetNationalPokedexCount(u8 caseID)
return count;
}
/*
u16 GetHoennPokedexCount(u8 caseID)
{
u16 count = 0;
u16 i;
for (i = 0; i < HOENN_DEX_COUNT; i++)
{
switch (caseID)
{
case FLAG_GET_SEEN:
if (GetSetPokedexFlag(HoennToNationalOrder(i + 1), FLAG_GET_SEEN))
count++;
break;
case FLAG_GET_CAUGHT:
if (GetSetPokedexFlag(HoennToNationalOrder(i + 1), FLAG_GET_CAUGHT))
count++;
break;
}
}
return count;
}
*/
u16 GetKantoPokedexCount(u8 caseID)
{
u16 count = 0;

View File

@ -72,34 +72,18 @@ static void GiveBoxMonInitialMoveset(struct BoxPokemon *boxMon);
static u16 GiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move);
static u8 GetLevelFromMonExp(struct Pokemon *mon);
static u16 CalculateBoxMonChecksum(struct BoxPokemon *boxMon);
static u16 SpeciesToHoennPokedexNum(u16 species);
static bool8 ShouldSkipFriendshipChange(void);
static void RemoveIVIndexFromList(u8 *ivs, u8 selectedIv);
#include "data/moves_info.h"
#include "data/abilities.h"
// Used in an unreferenced function in RS.
// Unreferenced here and in Emerald.
struct CombinedMove
{
u16 move1;
u16 move2;
u16 newMove;
};
static const struct CombinedMove sCombinedMoves[2] =
{
{MOVE_EMBER, MOVE_GUST, MOVE_HEAT_WAVE},
{0xFFFF, 0xFFFF, 0xFFFF}
};
// NOTE: The order of the elements in the 3 arrays below is irrelevant.
// To reorder the pokedex, see the values in include/constants/pokedex.h.
// Assigns all species to the Hoenn Dex Index (Summary No. for Hoenn Dex)
// removed:
// static const u16 sSpeciesToHoennPokedexNum[NUM_SPECIES - 1] =
// static const u16 sKantoToNationalOrder[NUM_SPECIES - 1] =
// Assigns all species to the National Dex Index (Summary No. for National Dex)
@ -1083,12 +1067,12 @@ void ZeroEnemyPartyMons(void)
void CreateMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId)
{
u32 arg;
u32 mail;
ZeroMonData(mon);
CreateBoxMon(&mon->box, species, level, fixedIV, hasFixedPersonality, fixedPersonality, otIdType, fixedOtId);
SetMonData(mon, MON_DATA_LEVEL, &level);
arg = MAIL_NONE;
SetMonData(mon, MON_DATA_MAIL, &arg);
mail = MAIL_NONE;
SetMonData(mon, MON_DATA_MAIL, &mail);
CalculateMonStats(mon);
}
@ -1219,8 +1203,8 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV,
else if (P_LEGENDARY_PERFECT_IVS >= GEN_6
&& (gSpeciesInfo[species].isLegendary
|| gSpeciesInfo[species].isMythical
|| gSpeciesInfo[species].isUltraBeast)
/*|| gSpeciesInfo[species].isTotem)*/)
|| gSpeciesInfo[species].isUltraBeast
|| gSpeciesInfo[species].isTotem))
{
iv = MAX_PER_STAT_IVS;
// Initialize a list of IV indices.
@ -1275,7 +1259,7 @@ void CreateBoxMon(struct BoxPokemon *boxMon, u16 species, u8 level, u8 fixedIV,
void CreateMonWithNature(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 nature)
{
u32 personality;
u16 evolutionTracker = GetMonData(mon, MON_DATA_EVOLUTION_TRACKER);
do
{
personality = Random32();
@ -2536,6 +2520,7 @@ u32 GetBoxMonData3(struct BoxPokemon *boxMon, s32 field, u8 *data)
case MON_DATA_EVOLUTION_TRACKER:
evoTracker.asField.a = substruct1->evolutionTracker1;
evoTracker.asField.b = substruct1->evolutionTracker2;
evoTracker.asField.unused = 0; // fix for non-modern?
retVal = evoTracker.value;
break;
default:
@ -4451,24 +4436,6 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 mode, u16 evolutionItem, s
return targetSpecies;
}
static u16 HoennPokedexNumToSpecies(u16 hoennNum)
{
u16 species;
if (!hoennNum)
return 0;
species = 0;
while (species < NUM_SPECIES - 1 && SpeciesToHoennPokedexNum(species) != hoennNum)
species++;
if (species == NUM_SPECIES - 1)
return 0;
return species + 1;
}
u16 NationalPokedexNumToSpecies(u16 nationalNum)
{
u16 species;
@ -4521,20 +4488,6 @@ static u16 NationalToHoennOrder(u16 nationalNum)
return 0;
return hoennNum + 1;
// u16 hoennNum;
// if (!nationalNum)
// return 0;
// hoennNum = 0;
// while (hoennNum < NUM_SPECIES - 1 && sHoennToNationalOrder[hoennNum] != nationalNum)
// hoennNum++;
// if (hoennNum == NUM_SPECIES - 1)
// return 0;
// return hoennNum + 1;
}
u16 SpeciesToNationalPokedexNum(u16 species)
@ -4543,21 +4496,6 @@ u16 SpeciesToNationalPokedexNum(u16 species)
return NATIONAL_DEX_NONE;
return gSpeciesInfo[species].natDexNum;
// if (!species)
// return 0;
// return sSpeciesToNationalPokedexNum[species - 1];
}
static u16 SpeciesToHoennPokedexNum(u16 species)
{
if (!species)
return 0;
return NationalToHoennOrder(gSpeciesInfo[species].natDexNum);
// if (!species)
// return 0;
// return sSpeciesToHoennPokedexNum[species - 1];
}
u16 KantoToNationalOrder(u16 kantoNum)
@ -4574,11 +4512,6 @@ u16 HoennToNationalOrder(u16 hoennNum)
return 0;
return sHoennToNationalOrder[hoennNum - 1];
// if (!hoennNum)
// return 0;
// return sHoennToNationalOrder[hoennNum - 1];
}
u16 SpeciesToCryId(u16 species)

View File

@ -82,19 +82,6 @@ void CopyBoxMonAt(u8 boxId, u8 boxPosition, struct BoxPokemon * dst)
*dst = gPokemonStoragePtr->boxes[boxId][boxPosition];
}
void CreateBoxMonAt(u8 boxId, u8 boxPosition, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 personality, u8 otIDType, u32 otID)
{
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
{
CreateBoxMon(&gPokemonStoragePtr->boxes[boxId][boxPosition],
species,
level,
fixedIV,
hasFixedPersonality, personality,
otIDType, otID);
}
}
void ZeroBoxMonAt(u8 boxId, u8 boxPosition)
{
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)

View File

@ -65,7 +65,7 @@ struct GFRomHeader
const u8 (* abilityNames)[];
const u8 *const * abilityDescriptions;
const struct Item * items;
const struct BattleMove * moves;
const struct MoveInfo * moves;
const struct CompressedSpriteSheet * ballGfx;
const struct CompressedSpritePalette * ballPalettes;
u32 gcnLinkFlagsOffset;
@ -104,7 +104,7 @@ static const struct GFRomHeader sGFRomHeader = {
// .monIconPaletteIds = gMonIconPaletteIndices,
.monIconPalettes = gMonIconPaletteTable,
// .monSpeciesNames = gSpeciesNames,
.moveNames = gMoveNames,
// .moveNames = gMoveNames,
.decorations = gDecorations,
.flagsOffset = offsetof(struct SaveBlock1, flags),
.varsOffset = offsetof(struct SaveBlock1, vars),
@ -150,7 +150,7 @@ static const struct GFRomHeader sGFRomHeader = {
// .abilityNames = gAbilityNames,
// .abilityDescriptions = gAbilityDescriptionPointers,
.items = gItems,
// .moves = gBattleMoves,
.moves = gMovesInfo,
.ballGfx = gBallSpriteSheets,
.ballPalettes = gBallSpritePalettes,
.gcnLinkFlagsOffset = offsetof(struct SaveBlock2, gcnLinkFlags),