Merge pull request #519 from Pyredrid/doublescriptedwilds
Added commands for scripted double wild battles
This commit is contained in:
commit
fdfe330330
6 changed files with 72 additions and 6 deletions
|
@ -1327,13 +1327,19 @@
|
||||||
.2byte \count
|
.2byte \count
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
@ Prepares to start a wild battle against a species at Level level holding item. Running this command will not affect
|
@ Prepares to start a wild battle against a species at Level level holding item.
|
||||||
@ normal wild battles. You start the prepared battle with dowildbattle.
|
@ If species2 is something other than SPECIES_NONE, then the battle is a double battle with another pokemon
|
||||||
.macro setwildbattle species:req, level:req, item:req
|
@ with species species2 at Level 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:req, species2=SPECIES_NONE, level2=0, item2=ITEM_NONE
|
||||||
.byte 0xb6
|
.byte 0xb6
|
||||||
.2byte \species
|
.2byte \species
|
||||||
.byte \level
|
.byte \level
|
||||||
.2byte \item
|
.2byte \item
|
||||||
|
.2byte \species2
|
||||||
|
.byte \level2
|
||||||
|
.2byte \item2
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
@ Starts a wild battle against the Pokemon generated by setwildbattle. Blocks script execution until the battle finishes.
|
@ Starts a wild battle against the Pokemon generated by setwildbattle. Blocks script execution until the battle finishes.
|
||||||
|
|
|
@ -24,6 +24,7 @@ void BattleSetup_StartBattlePikeWildBattle(void);
|
||||||
void BattleSetup_StartRoamerBattle(void);
|
void BattleSetup_StartRoamerBattle(void);
|
||||||
void StartWallyTutorialBattle(void);
|
void StartWallyTutorialBattle(void);
|
||||||
void BattleSetup_StartScriptedWildBattle(void);
|
void BattleSetup_StartScriptedWildBattle(void);
|
||||||
|
void BattleSetup_StartScriptedDoubleWildBattle(void);
|
||||||
void BattleSetup_StartLatiBattle(void);
|
void BattleSetup_StartLatiBattle(void);
|
||||||
void BattleSetup_StartLegendaryBattle(void);
|
void BattleSetup_StartLegendaryBattle(void);
|
||||||
void StartGroudonKyogreBattle(void);
|
void StartGroudonKyogreBattle(void);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
u8 ScriptGiveMon(u16, u8, u16, u32, u32, u8);
|
u8 ScriptGiveMon(u16, u8, u16, u32, u32, u8);
|
||||||
u8 ScriptGiveEgg(u16);
|
u8 ScriptGiveEgg(u16);
|
||||||
void CreateScriptedWildMon(u16, u8, u16);
|
void CreateScriptedWildMon(u16, u8, u16);
|
||||||
|
void CreateScriptedDoubleWildMon(u16, u8, u16, u16, u8, u16);
|
||||||
void ScriptSetMonMoveSlot(u8, u16, u8);
|
void ScriptSetMonMoveSlot(u8, u16, u8);
|
||||||
void ReducePlayerPartyToSelectedMons(void);
|
void ReducePlayerPartyToSelectedMons(void);
|
||||||
void HealPlayerParty(void);
|
void HealPlayerParty(void);
|
||||||
|
|
|
@ -499,6 +499,18 @@ void BattleSetup_StartScriptedWildBattle(void)
|
||||||
TryUpdateGymLeaderRematchFromWild();
|
TryUpdateGymLeaderRematchFromWild();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BattleSetup_StartScriptedDoubleWildBattle(void)
|
||||||
|
{
|
||||||
|
ScriptContext2_Enable();
|
||||||
|
gMain.savedCallback = CB2_EndScriptedWildBattle;
|
||||||
|
gBattleTypeFlags = BATTLE_TYPE_DOUBLE;
|
||||||
|
CreateBattleStartTask(GetWildBattleTransition(), 0);
|
||||||
|
IncrementGameStat(GAME_STAT_TOTAL_BATTLES);
|
||||||
|
IncrementGameStat(GAME_STAT_WILD_BATTLES);
|
||||||
|
IncrementDailyWildBattles();
|
||||||
|
TryUpdateGymLeaderRematchFromWild();
|
||||||
|
}
|
||||||
|
|
||||||
void BattleSetup_StartLatiBattle(void)
|
void BattleSetup_StartLatiBattle(void)
|
||||||
{
|
{
|
||||||
ScriptContext2_Enable();
|
ScriptContext2_Enable();
|
||||||
|
|
29
src/scrcmd.c
29
src/scrcmd.c
|
@ -62,6 +62,7 @@ static EWRAM_DATA u16 sMovingNpcMapId = 0;
|
||||||
static EWRAM_DATA u16 sFieldEffectScriptId = 0;
|
static EWRAM_DATA u16 sFieldEffectScriptId = 0;
|
||||||
|
|
||||||
static u8 gBrailleWindowId;
|
static u8 gBrailleWindowId;
|
||||||
|
static bool8 gIsScriptedWildDouble;
|
||||||
|
|
||||||
extern const SpecialFunc gSpecials[];
|
extern const SpecialFunc gSpecials[];
|
||||||
extern const u8 *gStdScripts[];
|
extern const u8 *gStdScripts[];
|
||||||
|
@ -1870,15 +1871,37 @@ bool8 ScrCmd_setwildbattle(struct ScriptContext *ctx)
|
||||||
u16 species = ScriptReadHalfword(ctx);
|
u16 species = ScriptReadHalfword(ctx);
|
||||||
u8 level = ScriptReadByte(ctx);
|
u8 level = ScriptReadByte(ctx);
|
||||||
u16 item = ScriptReadHalfword(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);
|
||||||
|
gIsScriptedWildDouble = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CreateScriptedDoubleWildMon(species, level, item, species2, level2, item2);
|
||||||
|
gIsScriptedWildDouble = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
CreateScriptedWildMon(species, level, item);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool8 ScrCmd_dowildbattle(struct ScriptContext *ctx)
|
bool8 ScrCmd_dowildbattle(struct ScriptContext *ctx)
|
||||||
{
|
{
|
||||||
BattleSetup_StartScriptedWildBattle();
|
if(gIsScriptedWildDouble == FALSE)
|
||||||
ScriptContext1_Stop();
|
{
|
||||||
|
BattleSetup_StartScriptedWildBattle();
|
||||||
|
ScriptContext1_Stop();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BattleSetup_StartScriptedDoubleWildBattle();
|
||||||
|
ScriptContext1_Stop();
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,6 +147,29 @@ void CreateScriptedWildMon(u16 species, u8 level, u16 item)
|
||||||
SetMonData(&gEnemyParty[0], MON_DATA_HELD_ITEM, heldItem);
|
SetMonData(&gEnemyParty[0], MON_DATA_HELD_ITEM, heldItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void CreateScriptedDoubleWildMon(u16 species1, u8 level1, u16 item1, u16 species2, u8 level2, u16 item2)
|
||||||
|
{
|
||||||
|
u8 heldItem1[2];
|
||||||
|
u8 heldItem2[2];
|
||||||
|
|
||||||
|
ZeroEnemyPartyMons();
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateMon(&gEnemyParty[3], species2, level2, 32, 0, 0, OT_ID_PLAYER_ID, 0);
|
||||||
|
if (item2)
|
||||||
|
{
|
||||||
|
heldItem2[0] = item2;
|
||||||
|
heldItem2[1] = item2 >> 8;
|
||||||
|
SetMonData(&gEnemyParty[3], MON_DATA_HELD_ITEM, heldItem2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptSetMonMoveSlot(u8 monIndex, u16 move, u8 slot)
|
void ScriptSetMonMoveSlot(u8 monIndex, u16 move, u8 slot)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue