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

Fix safari run/mud/bait function names and variable names #363

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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: 2 additions & 2 deletions include/battle/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,8 @@ typedef struct BattleContext {
u16 unk_310C[4];
int flingData;
int flingScript;
u8 unk_311C;
u8 safariRunAttempts;
u8 safariCatchStage;
u8 safariFleeStage;
u8 runAttempts;
u8 battleEndFlag;
u8 magnitude;
Expand Down
4 changes: 2 additions & 2 deletions include/constants/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -618,8 +618,8 @@ typedef enum ControllerCommand {
CONTROLLER_COMMAND_RUN_INPUT,
CONTROLLER_COMMAND_SAFARI_THROW_BALL,
CONTROLLER_COMMAND_SAFARI_THROW_MUD,
CONTROLLER_COMMAND_SAFARI_RUN,
CONTROLLER_COMMAND_SAFARI_WATCHING, // 20
CONTROLLER_COMMAND_SAFARI_THROW_BAIT,
CONTROLLER_COMMAND_SAFARI_RUN, // 20
CONTROLLER_COMMAND_CATCHING_CONSTEST_THROW_BALL,
CONTROLLER_COMMAND_RUN_SCRIPT,
CONTROLLER_COMMAND_23,
Expand Down
34 changes: 19 additions & 15 deletions src/battle/battle_controller_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ static void BattleControllerPlayer_ItemInput(BattleSystem *bsys, BattleContext *
static void BattleControllerPlayer_PokemonInput(BattleSystem *bsys, BattleContext *ctx);
static void BattleControllerPlayer_RunInput(BattleSystem *bsys, BattleContext *ctx);
static void BattleControllerPlayer_SafariThrowBall(BattleSystem *bsys, BattleContext *ctx);
static void BattleControllerPlayer_SafariThrowBait(BattleSystem *bsys, BattleContext *ctx);
static void BattleControllerPlayer_SafariThrowMud(BattleSystem *bsys, BattleContext *ctx);
static void BattleControllerPlayer_SafariRun(BattleSystem *bsys, BattleContext *ctx);
static void BattleControllerPlayer_SafariWatching(BattleSystem *bsys, BattleContext *ctx);
static void BattleControllerPlayer_CatchingContestThrowBall(BattleSystem *bsys, BattleContext *ctx);
static u32 TryDisobedience(BattleSystem *bsys, BattleContext *ctx, int *script);
static BOOL ov12_0224B1FC(BattleSystem *bsys, BattleContext *ctx);
Expand Down Expand Up @@ -113,8 +113,8 @@ static const ControllerFunction sPlayerBattleCommands[CONTROLLER_COMMAND_MAX] =
[CONTROLLER_COMMAND_RUN_INPUT] = BattleControllerPlayer_RunInput,
[CONTROLLER_COMMAND_SAFARI_THROW_BALL] = BattleControllerPlayer_SafariThrowBall,
[CONTROLLER_COMMAND_SAFARI_THROW_MUD] = BattleControllerPlayer_SafariThrowMud,
[CONTROLLER_COMMAND_SAFARI_THROW_BAIT] = BattleControllerPlayer_SafariThrowBait,
[CONTROLLER_COMMAND_SAFARI_RUN] = BattleControllerPlayer_SafariRun,
[CONTROLLER_COMMAND_SAFARI_WATCHING] = BattleControllerPlayer_SafariWatching,
[CONTROLLER_COMMAND_CATCHING_CONSTEST_THROW_BALL] = BattleControllerPlayer_CatchingContestThrowBall,
[CONTROLLER_COMMAND_RUN_SCRIPT] = BattleControllerPlayer_RunScript,
[CONTROLLER_COMMAND_23] = ov12_0224C38C,
Expand Down Expand Up @@ -353,7 +353,7 @@ static void BattleControllerPlayer_SelectionScreenInput(BattleSystem *bsys, Batt
case 3:
ctx->unk_0[battlerId] = SSI_STATE_END;
ctx->unk_4[battlerId] = SSI_STATE_13;
ctx->playerActions[battlerId].command = CONTROLLER_COMMAND_SAFARI_RUN;
ctx->playerActions[battlerId].command = CONTROLLER_COMMAND_SAFARI_THROW_BAIT;
break;
case 4:
ctx->unk_0[battlerId] = SSI_STATE_END;
Expand All @@ -363,7 +363,7 @@ static void BattleControllerPlayer_SelectionScreenInput(BattleSystem *bsys, Batt
case 5:
ctx->unk_0[battlerId] = SSI_STATE_END;
ctx->unk_0[battlerId] = SSI_STATE_13;
ctx->playerActions[battlerId].command = CONTROLLER_COMMAND_SAFARI_WATCHING;
ctx->playerActions[battlerId].command = CONTROLLER_COMMAND_SAFARI_RUN;
break;
}
} else {
Expand Down Expand Up @@ -1820,40 +1820,44 @@ static void BattleControllerPlayer_SafariThrowBall(BattleSystem *bsys, BattleCon
ov12_02263A1C(bsys, ctx, BATTLER_PLAYER);
}

static void BattleControllerPlayer_SafariThrowMud(BattleSystem *bsys, BattleContext *ctx) {
static void BattleControllerPlayer_SafariThrowBait(BattleSystem *bsys, BattleContext *ctx) {
ReadBattleScriptFromNarc(ctx, NARC_a_0_0_1, 227);
ctx->battlerIdAttacker = 0;
ctx->battlerIdTarget = 1;
ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT;
ctx->commandNext = CONTROLLER_COMMAND_40;
ctx->tempData = BattleSystem_Random(bsys) % 10;
if (ctx->safariRunAttempts > 0) {
ctx->safariRunAttempts--;
if (ctx->safariFleeStage > 0) {
ctx->safariFleeStage--;
}

// 90% chance to decrease catch stage
if (ctx->tempData != 0) {
ctx->msgTemp = 1;
if (ctx->unk_311C > 0) {
ctx->unk_311C--;
if (ctx->safariCatchStage > 0) {
ctx->safariCatchStage--;
}
}
}

static void BattleControllerPlayer_SafariRun(BattleSystem *bsys, BattleContext *ctx) {
static void BattleControllerPlayer_SafariThrowMud(BattleSystem *bsys, BattleContext *ctx) {
ReadBattleScriptFromNarc(ctx, NARC_a_0_0_1, 228);
ctx->battlerIdAttacker = 0;
ctx->battlerIdTarget = 1;
ctx->command = CONTROLLER_COMMAND_RUN_SCRIPT;
ctx->commandNext = CONTROLLER_COMMAND_40;
ctx->tempData = BattleSystem_Random(bsys) % 10;
if (ctx->unk_311C < 12) {
ctx->unk_311C++;
if (ctx->safariCatchStage < 12) {
ctx->safariCatchStage++;
}
if (ctx->tempData != 0 && ctx->safariRunAttempts < 12) {
ctx->safariRunAttempts++;

// 90% Chance to increase flee stage
if (ctx->tempData != 0 && ctx->safariFleeStage < 12) {
ctx->safariFleeStage++;
}
}

static void BattleControllerPlayer_SafariWatching(BattleSystem *bsys, BattleContext *ctx) {
static void BattleControllerPlayer_SafariRun(BattleSystem *bsys, BattleContext *ctx) {
ReadBattleScriptFromNarc(ctx, NARC_a_0_0_1, BATTLE_SUBSCRIPT_SAFARI_ESCAPE);
ctx->battlerIdAttacker = 0;
ctx->battlerIdTarget = 1;
Expand Down
6 changes: 3 additions & 3 deletions src/battle/overlay_12_0224E4FC.c
Original file line number Diff line number Diff line change
Expand Up @@ -1764,8 +1764,8 @@ void ov12_02251038(BattleSystem *bsys, BattleContext *ctx) {
ctx->switchInFlag |= MaskOfFlagNo(3);
}

ctx->unk_311C = 6;
ctx->safariRunAttempts = 6;
ctx->safariCatchStage = 6;
ctx->safariFleeStage = 6;
}

void InitSwitchWork(BattleSystem *bsys, BattleContext *ctx, int battlerId) {
Expand Down Expand Up @@ -6228,7 +6228,7 @@ int ov12_022581D4(BattleSystem *bsys, BattleContext *ctx, int var, int battlerId
case 4:
return ctx->levelUpMons;
case 5:
return ctx->safariRunAttempts;
return ctx->safariFleeStage;
case 6:
return ctx->totalTimesFainted[battlerId];
case 7:
Expand Down
Loading