Adds 1 vs 2 macro (#4741)

This commit is contained in:
Alex 2024-06-08 09:49:28 +02:00 committed by GitHub
parent 0a049ea6f7
commit 78f1da4131
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 34 additions and 1 deletions

View file

@ -776,6 +776,16 @@
trainerbattle TRAINER_BATTLE_SINGLE_NO_INTRO_TEXT, \trainer, 0, \lose_text
.endm
@ Starts a double battle with the player against two trainers
@ Takes two trainers and defeat text for each
.macro trainerbattle_two_trainers trainer_a:req, lose_text_a:req, trainer_b:req, lose_text_b:req
.byte 0x5c
.byte TRAINER_BATTLE_TWO_TRAINERS_NO_INTRO
.2byte \trainer_a
.4byte \lose_text_a
.2byte \trainer_b
.4byte \lose_text_b
.endm
@ Starts a trainer battle using the battle information stored in RAM (usually by the scripts in trainer_battle.inc, which
@ are run by trainerbattle), and blocks script execution until the battle finishes.
@ -2095,7 +2105,7 @@
setvar VAR_0x8002, \tryMultiple
special TrySpecialOverworldEvo
.endm
.macro ai_vs_ai_battle trainer1:req, trainer2:req
setflag B_FLAG_AI_VS_AI_BATTLE
setvar VAR_0x8004, \trainer1

View file

@ -14,5 +14,6 @@
#define TRAINER_BATTLE_SET_TRAINER_A 10
#define TRAINER_BATTLE_SET_TRAINER_B 11
#define TRAINER_BATTLE_HILL 12
#define TRAINER_BATTLE_TWO_TRAINERS_NO_INTRO 13
#endif // GUARD_CONSTANTS_BATTLE_SETUP_H

View file

@ -254,6 +254,23 @@ static const struct TrainerBattleParameter sTrainerBContinueScriptBattleParams[]
{&sTrainerBattleEndScript, TRAINER_PARAM_LOAD_SCRIPT_RET_ADDR},
};
// two trainers, each with a defeat speech
static const struct TrainerBattleParameter sTrainerTwoTrainerBattleParams[] =
{
{&sTrainerBattleMode, TRAINER_PARAM_LOAD_VAL_8BIT},
{&sTrainerObjectEventLocalId, TRAINER_PARAM_CLEAR_VAL_16BIT},
{&gTrainerBattleOpponent_A, TRAINER_PARAM_LOAD_VAL_16BIT},
{&sTrainerAIntroSpeech, TRAINER_PARAM_CLEAR_VAL_32BIT},
{&sTrainerADefeatSpeech, TRAINER_PARAM_LOAD_VAL_32BIT},
{&gTrainerBattleOpponent_B, TRAINER_PARAM_LOAD_VAL_16BIT},
{&sTrainerBIntroSpeech, TRAINER_PARAM_CLEAR_VAL_32BIT},
{&sTrainerBDefeatSpeech, TRAINER_PARAM_LOAD_VAL_32BIT},
{&sTrainerVictorySpeech, TRAINER_PARAM_CLEAR_VAL_32BIT},
{&sTrainerCannotBattleSpeech, TRAINER_PARAM_CLEAR_VAL_32BIT},
{&sTrainerBBattleScriptRetAddr, TRAINER_PARAM_CLEAR_VAL_32BIT},
{&sTrainerBattleEndScript, TRAINER_PARAM_LOAD_SCRIPT_RET_ADDR},
};
#define REMATCH(trainer1, trainer2, trainer3, trainer4, trainer5, map) \
{ \
.trainerIds = {trainer1, trainer2, trainer3, trainer4, trainer5}, \
@ -1230,6 +1247,11 @@ const u8 *BattleSetup_ConfigureTrainerBattle(const u8 *data)
gTrainerBattleOpponent_B = LocalIdToHillTrainerId(gSpecialVar_LastTalked);
}
return EventScript_TryDoNormalTrainerBattle;
case TRAINER_BATTLE_TWO_TRAINERS_NO_INTRO:
gNoOfApproachingTrainers = 2; // set TWO_OPPONENTS gBattleTypeFlags
gApproachingTrainerId = 1; // prevent trainer approach
TrainerBattleLoadArgs(sTrainerTwoTrainerBattleParams, data);
return EventScript_DoNoIntroTrainerBattle;
default:
if (gApproachingTrainerId == 0)
{