No bag use flag changed to a varable (#7780)
Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com>
This commit is contained in:
parent
6267cef403
commit
2156651313
@ -87,6 +87,15 @@ Debug_FlagsNotSetBattleConfigMessage_Text:
|
||||
.string "Please define a usable flag in:\l"
|
||||
.string "'include/config/battle.h'!$"
|
||||
|
||||
Debug_VarsNotSetBattleConfigMessage::
|
||||
message Debug_VarsNotSetBattleConfigMessage_Text
|
||||
goto Debug_MessageEnd
|
||||
|
||||
Debug_VarsNotSetBattleConfigMessage_Text:
|
||||
.string "Feature unavailable!\n"
|
||||
.string "Please define a usable var in:\l"
|
||||
.string "'include/config/battle.h'!$"
|
||||
|
||||
Debug_BoxFilledMessage::
|
||||
message Debug_BoxFilledMessage_Text
|
||||
goto Debug_MessageEnd
|
||||
|
||||
@ -437,4 +437,5 @@ void BtlController_HandleSwitchInTryShinyAnim(u32 battler);
|
||||
void BtlController_HandleSwitchInSoundAndEnd(u32 battler);
|
||||
void BtlController_HandleSwitchInShowSubstitute(u32 battler);
|
||||
|
||||
bool32 ShouldBattleRestrictionsApply(u32 battler);
|
||||
#endif // GUARD_BATTLE_CONTROLLERS_H
|
||||
|
||||
@ -432,5 +432,6 @@ u32 GetNaturePowerMove(u32 battler);
|
||||
u32 GetNaturePowerMove(u32 battler);
|
||||
void RemoveAbilityFlags(u32 battler);
|
||||
bool32 IsDazzlingAbility(enum Ability ability);
|
||||
bool32 IsAllowedToUseBag(void);
|
||||
|
||||
#endif // GUARD_BATTLE_UTIL_H
|
||||
|
||||
@ -208,7 +208,6 @@
|
||||
#define B_FLAG_INVERSE_BATTLE 0 // If this flag is set, the battle's type effectiveness are inversed. For example, fire is super effective against water.
|
||||
#define B_FLAG_FORCE_DOUBLE_WILD 0 // If this flag is set, all land and surfing wild battles will be double battles.
|
||||
#define B_SMART_WILD_AI_FLAG 0 // If this flag is set, wild Pokémon will become smart, with all AI flags enabled.
|
||||
#define B_FLAG_NO_BAG_USE 0 // If this flag is set, the ability to use the bag in battle is disabled.
|
||||
#define B_FLAG_NO_CATCHING 0 // If this flag is set, the ability to catch wild Pokémon is disabled.
|
||||
#define B_FLAG_NO_RUNNING 0 // If this flag is set, the ability to escape from wild battles is disabled. Also makes Roar/Whirlwind and Teleport (under Gen8) fail.
|
||||
#define B_FLAG_AI_VS_AI_BATTLE 0 // If this flag is set, the player's mons will be controlled by the ai next battles.
|
||||
@ -230,6 +229,13 @@
|
||||
|
||||
#define B_VAR_DIFFICULTY 0 // If not 0, you can use this var to control which difficulty version of a Trainer is loaded. This should be manually set by the developer using Script_SetDifficulty AFTER NewGameInitData has run.
|
||||
|
||||
// No bag settings
|
||||
#define NO_BAG_RESTRICTION 0
|
||||
#define NO_BAG_AGAINST_TRAINER 1
|
||||
#define NO_BAG_IN_BATTLE 2
|
||||
|
||||
#define B_VAR_NO_BAG_USE 0 // If 1, the ability to use the bag in battle is disabled in trainer battles. If 2, it is also disabled in wild battles.
|
||||
|
||||
// Sky Battles
|
||||
#define B_FLAG_SKY_BATTLE 0 // If this flag has a value, the player will be able to engage in scripted Sky Battles.
|
||||
#define B_VAR_SKY_BATTLE 0 // If this var has a value, the game will remember the positions of Pokémon used in Sky Battles.
|
||||
|
||||
@ -3124,3 +3124,8 @@ void UpdateFriendshipFromXItem(u32 battler)
|
||||
SetBattlerMonData(battler, GetBattlerParty(battler), gBattlerPartyIndexes[battler]);
|
||||
}
|
||||
}
|
||||
|
||||
bool32 ShouldBattleRestrictionsApply(u32 battler)
|
||||
{
|
||||
return IsControllerPlayer(battler);
|
||||
}
|
||||
|
||||
@ -4307,7 +4307,7 @@ static void HandleTurnActionSelectionState(void)
|
||||
}
|
||||
break;
|
||||
case B_ACTION_USE_ITEM:
|
||||
if (FlagGet(B_FLAG_NO_BAG_USE))
|
||||
if (ShouldBattleRestrictionsApply(battler) && !IsAllowedToUseBag())
|
||||
{
|
||||
RecordedBattle_ClearBattlerAction(battler, 1);
|
||||
gSelectionBattleScripts[battler] = BattleScript_ActionSelectionItemsCantBeUsed;
|
||||
|
||||
@ -12419,3 +12419,18 @@ void RemoveAbilityFlags(u32 battler)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool32 IsAllowedToUseBag(void)
|
||||
{
|
||||
switch(VarGet(B_VAR_NO_BAG_USE))
|
||||
{
|
||||
case NO_BAG_RESTRICTION:
|
||||
return TRUE;
|
||||
case NO_BAG_AGAINST_TRAINER: //True in wild battle; False in trainer battle
|
||||
return (!(gBattleTypeFlags & BATTLE_TYPE_TRAINER));
|
||||
case NO_BAG_IN_BATTLE:
|
||||
return FALSE;
|
||||
default:
|
||||
return TRUE; // Undefined Behavior
|
||||
}
|
||||
}
|
||||
|
||||
36
src/debug.c
36
src/debug.c
@ -105,8 +105,8 @@ enum FlagsVarsDebugMenu
|
||||
DEBUG_FLAGVAR_MENU_ITEM_TOGGLE_COLLISION,
|
||||
DEBUG_FLAGVAR_MENU_ITEM_TOGGLE_ENCOUNTER,
|
||||
DEBUG_FLAGVAR_MENU_ITEM_TOGGLE_TRAINER_SEE,
|
||||
DEBUG_FLAGVAR_MENU_ITEM_TOGGLE_BAG_USE,
|
||||
DEBUG_FLAGVAR_MENU_ITEM_TOGGLE_CATCHING,
|
||||
DEBUG_FLAGVAR_MENU_ITEM_TOGGLE_BAG_USE,
|
||||
};
|
||||
|
||||
enum DebugBattleType
|
||||
@ -341,6 +341,7 @@ static void DebugAction_Player_Id(u8 taskId);
|
||||
|
||||
extern const u8 Debug_FlagsNotSetOverworldConfigMessage[];
|
||||
extern const u8 Debug_FlagsNotSetBattleConfigMessage[];
|
||||
extern const u8 Debug_VarsNotSetBattleConfigMessage[];
|
||||
extern const u8 Debug_FlagsAndVarNotSetBattleConfigMessage[];
|
||||
extern const u8 Debug_EventScript_FontTest[];
|
||||
extern const u8 Debug_EventScript_CheckEVs[];
|
||||
@ -650,11 +651,18 @@ static const struct DebugMenuOption sDebugMenu_Actions_Flags[] =
|
||||
[DEBUG_FLAGVAR_MENU_ITEM_TOGGLE_COLLISION] = { COMPOUND_STRING("Toggle {STR_VAR_1}Collision OFF"), DebugAction_ToggleFlag, DebugAction_FlagsVars_CollisionOnOff },
|
||||
[DEBUG_FLAGVAR_MENU_ITEM_TOGGLE_ENCOUNTER] = { COMPOUND_STRING("Toggle {STR_VAR_1}Encounter OFF"), DebugAction_ToggleFlag, DebugAction_FlagsVars_EncounterOnOff },
|
||||
[DEBUG_FLAGVAR_MENU_ITEM_TOGGLE_TRAINER_SEE] = { COMPOUND_STRING("Toggle {STR_VAR_1}Trainer See OFF"), DebugAction_ToggleFlag, DebugAction_FlagsVars_TrainerSeeOnOff },
|
||||
[DEBUG_FLAGVAR_MENU_ITEM_TOGGLE_BAG_USE] = { COMPOUND_STRING("Toggle {STR_VAR_1}Bag Use OFF"), DebugAction_ToggleFlag, DebugAction_FlagsVars_BagUseOnOff },
|
||||
[DEBUG_FLAGVAR_MENU_ITEM_TOGGLE_CATCHING] = { COMPOUND_STRING("Toggle {STR_VAR_1}Catching OFF"), DebugAction_ToggleFlag, DebugAction_FlagsVars_CatchingOnOff },
|
||||
[DEBUG_FLAGVAR_MENU_ITEM_TOGGLE_BAG_USE] = { COMPOUND_STRING("Toggle {STR_VAR_1}Bag Use OFF"), DebugAction_ToggleFlag, DebugAction_FlagsVars_BagUseOnOff },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static const u8 *sDebugMenu_Actions_BagUse_Options[] =
|
||||
{
|
||||
COMPOUND_STRING("No Bag: {STR_VAR_1}Inactive"),
|
||||
COMPOUND_STRING("No Bag: {STR_VAR_1}VS Trainers"),
|
||||
COMPOUND_STRING("No Bag: {STR_VAR_1}Active"),
|
||||
};
|
||||
|
||||
static const struct DebugMenuOption sDebugMenu_Actions_Main[] =
|
||||
{
|
||||
{ COMPOUND_STRING("Utilities…"), DebugAction_OpenSubMenu, sDebugMenu_Actions_Utilities, },
|
||||
@ -1017,16 +1025,14 @@ static u8 Debug_CheckToggleFlags(u8 id)
|
||||
result = FlagGet(OW_FLAG_NO_TRAINER_SEE);
|
||||
break;
|
||||
#endif
|
||||
#if B_FLAG_NO_BAG_USE != 0
|
||||
case DEBUG_FLAGVAR_MENU_ITEM_TOGGLE_BAG_USE:
|
||||
result = FlagGet(B_FLAG_NO_BAG_USE);
|
||||
break;
|
||||
#endif
|
||||
#if B_FLAG_NO_CATCHING != 0
|
||||
case DEBUG_FLAGVAR_MENU_ITEM_TOGGLE_CATCHING:
|
||||
result = FlagGet(B_FLAG_NO_CATCHING);
|
||||
break;
|
||||
#endif
|
||||
case DEBUG_FLAGVAR_MENU_ITEM_TOGGLE_BAG_USE:
|
||||
result = VarGet(B_VAR_NO_BAG_USE);
|
||||
break;
|
||||
default:
|
||||
result = 0xFF;
|
||||
break;
|
||||
@ -1053,7 +1059,10 @@ static u8 Debug_GenerateListMenuNames(void)
|
||||
if (sDebugMenuListData->listId == 1)
|
||||
{
|
||||
flagResult = Debug_CheckToggleFlags(i);
|
||||
name = sDebugMenu_Actions_Flags[i].text;
|
||||
if (i == DEBUG_FLAGVAR_MENU_ITEM_TOGGLE_BAG_USE)
|
||||
name = sDebugMenu_Actions_BagUse_Options[flagResult];
|
||||
else
|
||||
name = sDebugMenu_Actions_Flags[i].text;
|
||||
}
|
||||
|
||||
if (flagResult == 0xFF)
|
||||
@ -2005,14 +2014,11 @@ static void DebugAction_FlagsVars_TrainerSeeOnOff(u8 taskId)
|
||||
|
||||
static void DebugAction_FlagsVars_BagUseOnOff(u8 taskId)
|
||||
{
|
||||
#if B_FLAG_NO_BAG_USE == 0
|
||||
Debug_DestroyMenu_Full_Script(taskId, Debug_FlagsNotSetBattleConfigMessage);
|
||||
#if B_VAR_NO_BAG_USE < VARS_START || B_VAR_NO_BAG_USE > VARS_END
|
||||
Debug_DestroyMenu_Full_Script(taskId, Debug_VarsNotSetBattleConfigMessage);
|
||||
#else
|
||||
if (FlagGet(B_FLAG_NO_BAG_USE))
|
||||
PlaySE(SE_PC_OFF);
|
||||
else
|
||||
PlaySE(SE_PC_LOGIN);
|
||||
FlagToggle(B_FLAG_NO_BAG_USE);
|
||||
PlaySE(SE_SELECT);
|
||||
VarSet(B_VAR_NO_BAG_USE, (VarGet(B_VAR_NO_BAG_USE) + 1) % 3);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -1133,7 +1133,7 @@ static u32 GetBallThrowableState(void)
|
||||
return BALL_THROW_UNABLE_NO_ROOM;
|
||||
else if (B_SEMI_INVULNERABLE_CATCH >= GEN_4 && IsSemiInvulnerable(GetCatchingBattler(), CHECK_ALL))
|
||||
return BALL_THROW_UNABLE_SEMI_INVULNERABLE;
|
||||
else if (FlagGet(B_FLAG_NO_CATCHING))
|
||||
else if (FlagGet(B_FLAG_NO_CATCHING) || !IsAllowedToUseBag())
|
||||
return BALL_THROW_UNABLE_DISABLED_FLAG;
|
||||
|
||||
return BALL_THROW_ABLE;
|
||||
|
||||
@ -429,10 +429,13 @@ void Overworld_ResetBattleFlagsAndVars(void)
|
||||
VarSet(B_VAR_WILD_AI_FLAGS,0);
|
||||
#endif
|
||||
|
||||
#if B_VAR_NO_BAG_USE != 0
|
||||
VarSet(B_VAR_NO_BAG_USE, 0);
|
||||
#endif
|
||||
|
||||
FlagClear(B_FLAG_INVERSE_BATTLE);
|
||||
FlagClear(B_FLAG_FORCE_DOUBLE_WILD);
|
||||
FlagClear(B_SMART_WILD_AI_FLAG);
|
||||
FlagClear(B_FLAG_NO_BAG_USE);
|
||||
FlagClear(B_FLAG_NO_CATCHING);
|
||||
FlagClear(B_FLAG_NO_RUNNING);
|
||||
FlagClear(B_FLAG_DYNAMAX_BATTLE);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user