OW_SYNCHRONIZE_NATURE + scripted wild double battle

This commit is contained in:
cawtds
2024-07-31 22:14:03 +02:00
parent db82cdbff4
commit 86ba8a24fe
6 changed files with 80 additions and 9 deletions

View File

@@ -1536,13 +1536,19 @@
.2byte \count
.endm
@ Prepares to start a wild battle against a 'species' at 'level' holding 'item'. Running this command will not affect
@ normal wild battles. You start the prepared battle with dowildbattle.
.macro setwildbattle species:req, level:req, item=ITEM_NONE
@ Prepares to start a wild battle against a 'species' at 'level' holding 'item'.
@ If 'species2' is something other than SPECIES_NONE, then the battle is a double battle
@ that is also against 'species2' at 'level2' holding 'item2'.
@ Running this command will not affect normal wild battles. You start the prepared battle with dowildbattle.
@ If the player only has one Pokemon, a scripted double battle will be buggy.
.macro setwildbattle species:req, level:req, item=ITEM_NONE, species2=SPECIES_NONE, level2=0, item2=ITEM_NONE
.byte 0xb6
.2byte \species
.byte \level
.2byte \item
.2byte \species2
.byte \level2
.2byte \item2
.endm
@ Starts a wild battle against the Pokemon generated by setwildbattle. Blocks script execution until the battle finishes.

View File

@@ -9,7 +9,8 @@ void StartWildBattle(void);
void StartDoubleWildBattle(void);
void StartRoamerBattle(void);
void StartOldManTutorialBattle(void);
void StartScriptedWildBattle(void);
void BattleSetup_StartScriptedWildBattle(void);
void BattleSetup_StartScriptedDoubleWildBattle(void);
void StartMarowakBattle(void);
void StartSouthernIslandBattle(void);
void StartLegendaryBattle(void);

View File

@@ -7,5 +7,6 @@ void ScriptSetMonMoveSlot(u8 partyIdx, u16 move, u8 slot);
void HealPlayerParty(void);
void ReducePlayerPartyToThree(void);
void CreateScriptedWildMon(u16 species, u8 level, u16 item);
void CreateScriptedDoubleWildMon(u16 species1, u8 level1, u16 item1, u16 species2, u8 level2, u16 item2);
#endif //GUARD_SCRIPT_POKEMON_UTIL_H

View File

@@ -404,7 +404,7 @@ void StartOldManTutorialBattle(void)
CreateBattleStartTask(B_TRANSITION_SLICE, 0);
}
void StartScriptedWildBattle(void)
void BattleSetup_StartScriptedWildBattle(void)
{
LockPlayerFieldControls();
gMain.savedCallback = CB2_EndScriptedWildBattle;
@@ -414,6 +414,16 @@ void StartScriptedWildBattle(void)
IncrementGameStat(GAME_STAT_WILD_BATTLES);
}
void BattleSetup_StartScriptedDoubleWildBattle(void)
{
LockPlayerFieldControls();
gMain.savedCallback = CB2_EndScriptedWildBattle;
gBattleTypeFlags = BATTLE_TYPE_DOUBLE;
CreateBattleStartTask(GetWildBattleTransition(), 0);
IncrementGameStat(GAME_STAT_TOTAL_BATTLES);
IncrementGameStat(GAME_STAT_WILD_BATTLES);
}
void StartMarowakBattle(void)
{
LockPlayerFieldControls();

View File

@@ -61,6 +61,8 @@ static EWRAM_DATA u16 sMovingNpcMapGroup = 0;
static EWRAM_DATA u16 sMovingNpcMapNum = 0;
static EWRAM_DATA u16 sFieldEffectScriptId = 0;
static bool8 sIsScriptedWildDouble;
struct ScriptContext * sQuestLogScriptContextPtr;
u8 gSelectedObjectEvent;
@@ -1928,20 +1930,38 @@ bool8 ScrCmd_cleartrainerflag(struct ScriptContext * ctx)
return FALSE;
}
bool8 ScrCmd_setwildbattle(struct ScriptContext * ctx)
bool8 ScrCmd_setwildbattle(struct ScriptContext *ctx)
{
u16 species = ScriptReadHalfword(ctx);
u8 level = ScriptReadByte(ctx);
u16 item = ScriptReadHalfword(ctx);
u16 species2 = ScriptReadHalfword(ctx);
u8 level2 = ScriptReadByte(ctx);
u16 item2 = ScriptReadHalfword(ctx);
if(species2 == SPECIES_NONE)
{
CreateScriptedWildMon(species, level, item);
sIsScriptedWildDouble = FALSE;
}
else
{
CreateScriptedDoubleWildMon(species, level, item, species2, level2, item2);
sIsScriptedWildDouble = TRUE;
}
CreateScriptedWildMon(species, level, item);
return FALSE;
}
bool8 ScrCmd_dowildbattle(struct ScriptContext * ctx)
{
StartScriptedWildBattle();
if (sIsScriptedWildDouble == FALSE)
BattleSetup_StartScriptedWildBattle();
else
BattleSetup_StartScriptedDoubleWildBattle();
ScriptContext_Stop();
return TRUE;
}

View File

@@ -385,7 +385,10 @@ void CreateScriptedWildMon(u16 species, u8 level, u16 item)
u8 heldItem[2];
ZeroEnemyPartyMons();
CreateMon(&gEnemyParty[0], species, level, 32, 0, 0, OT_ID_PLAYER_ID, 0);
if (OW_SYNCHRONIZE_NATURE > GEN_3)
CreateMonWithNature(&gEnemyParty[0], species, level, USE_RANDOM_IVS, PickWildMonNature());
else
CreateMon(&gEnemyParty[0], species, level, 32, 0, 0, OT_ID_PLAYER_ID, 0);
if (item)
{
heldItem[0] = item;
@@ -394,6 +397,36 @@ void CreateScriptedWildMon(u16 species, u8 level, u16 item)
}
}
void CreateScriptedDoubleWildMon(u16 species1, u8 level1, u16 item1, u16 species2, u8 level2, u16 item2)
{
u8 heldItem1[2];
u8 heldItem2[2];
ZeroEnemyPartyMons();
if (OW_SYNCHRONIZE_NATURE > GEN_3)
CreateMonWithNature(&gEnemyParty[0], species1, level1, 32, PickWildMonNature());
else
CreateMon(&gEnemyParty[0], species1, level1, 32, 0, 0, OT_ID_PLAYER_ID, 0);
if (item1)
{
heldItem1[0] = item1;
heldItem1[1] = item1 >> 8;
SetMonData(&gEnemyParty[0], MON_DATA_HELD_ITEM, heldItem1);
}
if (OW_SYNCHRONIZE_NATURE > GEN_3)
CreateMonWithNature(&gEnemyParty[1], species2, level2, 32, PickWildMonNature());
else
CreateMon(&gEnemyParty[1], species2, level2, 32, 0, 0, OT_ID_PLAYER_ID, 0);
if (item2)
{
heldItem2[0] = item2;
heldItem2[1] = item2 >> 8;
SetMonData(&gEnemyParty[1], MON_DATA_HELD_ITEM, heldItem2);
}
}
void ScriptSetMonMoveSlot(u8 monIndex, u16 move, u8 slot)
{
if (monIndex > PARTY_SIZE)