mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-03-30 01:09:34 +01:00
opponent trainer theft config option. Clean up code a bit
This commit is contained in:
parent
64bcac4589
commit
435f928aa4
@ -1755,14 +1755,14 @@
|
|||||||
various \battler, VARIOUS_JUMP_IF_ABSENT
|
various \battler, VARIOUS_JUMP_IF_ABSENT
|
||||||
.4byte \ptr
|
.4byte \ptr
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro activateitemeffects battler:req
|
.macro activateitemeffects battler:req
|
||||||
various \battler, VARIOUS_MOVEEND_ITEM_EFFECTS
|
various \battler, VARIOUS_MOVEEND_ITEM_EFFECTS
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro pickpocketsteal
|
.macro pickpocketsteal
|
||||||
various 0, VARIOUS_PICKPOCKET
|
various 0, VARIOUS_PICKPOCKET
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
@ helpful macros
|
@ helpful macros
|
||||||
.macro setstatchanger stat:req, stages:req, down:req
|
.macro setstatchanger stat:req, stages:req, down:req
|
||||||
|
@ -541,6 +541,7 @@ struct BattleStruct
|
|||||||
u8 sameMoveTurns[MAX_BATTLERS_COUNT]; // For Metronome, number of times the same moves has been SUCCESFULLY used.
|
u8 sameMoveTurns[MAX_BATTLERS_COUNT]; // For Metronome, number of times the same moves has been SUCCESFULLY used.
|
||||||
u16 moveEffect2; // For Knock Off
|
u16 moveEffect2; // For Knock Off
|
||||||
u16 changedSpecies[PARTY_SIZE]; // For Zygarde or future forms when multiple mons can change into the same pokemon.
|
u16 changedSpecies[PARTY_SIZE]; // For Zygarde or future forms when multiple mons can change into the same pokemon.
|
||||||
|
u16 itemStolen[PARTY_SIZE]; //player's team that had items stolen (bit per party member)
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GET_MOVE_TYPE(move, typeArg) \
|
#define GET_MOVE_TYPE(move, typeArg) \
|
||||||
|
@ -132,6 +132,6 @@ bool8 ShouldGetStatBadgeBoost(u16 flagId, u8 battlerId);
|
|||||||
u8 GetBattleMoveSplit(u32 moveId);
|
u8 GetBattleMoveSplit(u32 moveId);
|
||||||
void SortBattlersBySpeed(u8 *battlers, bool8 slowToFast);
|
void SortBattlersBySpeed(u8 *battlers, bool8 slowToFast);
|
||||||
bool32 TestSheerForceFlag(u8 battler, u16 move);
|
bool32 TestSheerForceFlag(u8 battler, u16 move);
|
||||||
bool32 ItemCanBeStolen(u16 item, u8 battlerId);
|
void TryRestoreStolenItems(void);
|
||||||
|
|
||||||
#endif // GUARD_BATTLE_UTIL_H
|
#endif // GUARD_BATTLE_UTIL_H
|
||||||
|
@ -132,6 +132,7 @@
|
|||||||
#define B_SLEEP_TURNS GEN_6 // In Gen5+, sleep lasts for 1-3 turns instead of 2-5 turns.
|
#define B_SLEEP_TURNS GEN_6 // In Gen5+, sleep lasts for 1-3 turns instead of 2-5 turns.
|
||||||
#define B_PARALYZE_ELECTRIC GEN_6 // In Gen6+, Electric type Pokémon can't be paralyzed.
|
#define B_PARALYZE_ELECTRIC GEN_6 // In Gen6+, Electric type Pokémon can't be paralyzed.
|
||||||
#define B_POWDER_GRASS GEN_6 // In Gen6+, Grass type Pokémon are immune to powder and spore moves.
|
#define B_POWDER_GRASS GEN_6 // In Gen6+, Grass type Pokémon are immune to powder and spore moves.
|
||||||
|
#define B_TRAINERS_STEAL_ITEMS TRUE // If TRUE, trainer with thief/pickpocket will temporarily steal your items
|
||||||
|
|
||||||
// Animation Settings
|
// Animation Settings
|
||||||
#define B_NEW_SWORD_PARTICLE TRUE // If set to TRUE, it updates Swords Dance's particle.
|
#define B_NEW_SWORD_PARTICLE TRUE // If set to TRUE, it updates Swords Dance's particle.
|
||||||
|
@ -4819,6 +4819,10 @@ static void HandleEndTurn_FinishBattle(void)
|
|||||||
sub_8186444();
|
sub_8186444();
|
||||||
BeginFastPaletteFade(3);
|
BeginFastPaletteFade(3);
|
||||||
FadeOutMapMusic(5);
|
FadeOutMapMusic(5);
|
||||||
|
#if B_TRAINERS_STEAL_ITEMS
|
||||||
|
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
|
||||||
|
TryRestoreStolenItems();
|
||||||
|
#endif
|
||||||
for (i = 0; i < PARTY_SIZE; i++)
|
for (i = 0; i < PARTY_SIZE; i++)
|
||||||
{
|
{
|
||||||
UndoMegaEvolution(i);
|
UndoMegaEvolution(i);
|
||||||
@ -4837,7 +4841,7 @@ static void HandleEndTurn_FinishBattle(void)
|
|||||||
static void FreeResetData_ReturnToOvOrDoEvolutions(void)
|
static void FreeResetData_ReturnToOvOrDoEvolutions(void)
|
||||||
{
|
{
|
||||||
if (!gPaletteFade.active)
|
if (!gPaletteFade.active)
|
||||||
{
|
{
|
||||||
ResetSpriteData();
|
ResetSpriteData();
|
||||||
if (gLeveledUpInBattle && (gBattleOutcome == B_OUTCOME_WON || gBattleOutcome == B_OUTCOME_CAUGHT))
|
if (gLeveledUpInBattle && (gBattleOutcome == B_OUTCOME_WON || gBattleOutcome == B_OUTCOME_CAUGHT))
|
||||||
{
|
{
|
||||||
|
@ -2369,6 +2369,35 @@ static void CheckSetUnburden(u8 battlerId)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//slight difference in thief/pickpocket requires this
|
||||||
|
static void StealTargetItem(void)
|
||||||
|
{
|
||||||
|
gLastUsedItem = gBattleStruct->changedItems[gBattlerAttacker] = gBattleMons[gBattlerTarget].item;
|
||||||
|
gBattleMons[gBattlerTarget].item = 0;
|
||||||
|
|
||||||
|
RecordItemEffectBattle(gBattlerTarget, 0);
|
||||||
|
RecordItemEffectBattle(gBattlerAttacker, ItemId_GetHoldEffect(gLastUsedItem));
|
||||||
|
//item assignment doesn't happen yet for thief
|
||||||
|
|
||||||
|
CheckSetUnburden(gBattlerTarget);
|
||||||
|
gBattleResources->flags->flags[gBattlerAttacker] &= ~(RESOURCE_FLAG_UNBURDEN);
|
||||||
|
|
||||||
|
gActiveBattler = gBattlerAttacker;
|
||||||
|
BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gLastUsedItem);
|
||||||
|
MarkBattlerForControllerExec(gBattlerAttacker);
|
||||||
|
|
||||||
|
gActiveBattler = gBattlerTarget;
|
||||||
|
BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gBattlerTarget].item);
|
||||||
|
MarkBattlerForControllerExec(gBattlerTarget);
|
||||||
|
|
||||||
|
gBattleStruct->choicedMove[gBattlerTarget] = 0;
|
||||||
|
|
||||||
|
#if B_TRAINERS_STEAL_ITEMS
|
||||||
|
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && GetBattlerSide(gBattlerTarget) == B_SIDE_PLAYER)
|
||||||
|
gBattleStruct->itemStolen[gBattlerPartyIndexes[gBattlerTarget]] = gLastUsedItem;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#define INCREMENT_RESET_RETURN \
|
#define INCREMENT_RESET_RETURN \
|
||||||
{ \
|
{ \
|
||||||
gBattlescriptCurrInstr++; \
|
gBattlescriptCurrInstr++; \
|
||||||
@ -2922,7 +2951,7 @@ void SetMoveEffect(bool32 primary, u32 certain)
|
|||||||
break;
|
break;
|
||||||
case MOVE_EFFECT_STEAL_ITEM:
|
case MOVE_EFFECT_STEAL_ITEM:
|
||||||
{
|
{
|
||||||
if (!ItemCanBeStolen(gBattleMons[gBattlerTarget].item, gBattlerAttacker))
|
if (!CanBattlerGetOrLoseItem(gBattlerAttacker, gBattleMons[gBattlerTarget].item))
|
||||||
{
|
{
|
||||||
gBattlescriptCurrInstr++;
|
gBattlescriptCurrInstr++;
|
||||||
break;
|
break;
|
||||||
@ -2944,28 +2973,9 @@ void SetMoveEffect(bool32 primary, u32 certain)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gLastUsedItem = gBattleStruct->changedItems[gBattlerAttacker] = gBattleMons[gBattlerTarget].item;
|
StealTargetItem();
|
||||||
gBattleMons[gBattlerTarget].item = 0;
|
|
||||||
|
|
||||||
RecordItemEffectBattle(gBattlerTarget, 0);
|
|
||||||
RecordItemEffectBattle(gBattlerAttacker, ItemId_GetHoldEffect(gLastUsedItem));
|
|
||||||
//item assignment doesn't happen yet
|
|
||||||
|
|
||||||
CheckSetUnburden(gBattlerTarget);
|
|
||||||
gBattleResources->flags->flags[gBattlerAttacker] &= ~(RESOURCE_FLAG_UNBURDEN);
|
|
||||||
|
|
||||||
gActiveBattler = gBattlerAttacker;
|
|
||||||
BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gLastUsedItem);
|
|
||||||
MarkBattlerForControllerExec(gBattlerAttacker);
|
|
||||||
|
|
||||||
gActiveBattler = gBattlerTarget;
|
|
||||||
BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gBattlerTarget].item);
|
|
||||||
MarkBattlerForControllerExec(gBattlerTarget);
|
|
||||||
|
|
||||||
BattleScriptPush(gBattlescriptCurrInstr + 1);
|
BattleScriptPush(gBattlescriptCurrInstr + 1);
|
||||||
gBattlescriptCurrInstr = BattleScript_ItemSteal;
|
gBattlescriptCurrInstr = BattleScript_ItemSteal;
|
||||||
|
|
||||||
gBattleStruct->choicedMove[gBattlerTarget] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -5022,7 +5032,7 @@ static void Cmd_moveend(void)
|
|||||||
&& !DoesSubstituteBlockMove(gCurrentMove, gBattlerAttacker, battler) //subsitute unaffected
|
&& !DoesSubstituteBlockMove(gCurrentMove, gBattlerAttacker, battler) //subsitute unaffected
|
||||||
&& IsBattlerAlive(battler) //battler must be alive to be pickpocketed
|
&& IsBattlerAlive(battler) //battler must be alive to be pickpocketed
|
||||||
&& gBattleMons[battler].item == ITEM_NONE //pickpocketer can't have an item already
|
&& gBattleMons[battler].item == ITEM_NONE //pickpocketer can't have an item already
|
||||||
&& ItemCanBeStolen(gBattleMons[gBattlerAttacker].item, battler)) //cannot steal plates, mega stones, etc
|
&& CanBattlerGetOrLoseItem(battler, gBattleMons[gBattlerAttacker].item)) //cannot steal plates, mega stones, etc
|
||||||
{
|
{
|
||||||
gBattlerTarget = gBattlerAbility = battler;
|
gBattlerTarget = gBattlerAbility = battler;
|
||||||
BattleScriptPushCursor();
|
BattleScriptPushCursor();
|
||||||
@ -8316,28 +8326,9 @@ static void Cmd_various(void)
|
|||||||
break;
|
break;
|
||||||
case VARIOUS_PICKPOCKET:
|
case VARIOUS_PICKPOCKET:
|
||||||
{
|
{
|
||||||
// different from MOVE_EFFECT_STEAL_ITEM in that it immediately assigns the stolen item to the 'attacker'
|
|
||||||
gEffectBattler = gBattlerTarget;
|
|
||||||
gBattleScripting.battler = gBattlerAttacker;
|
gBattleScripting.battler = gBattlerAttacker;
|
||||||
gLastUsedItem = gBattleMons[gEffectBattler].item;
|
StealTargetItem();
|
||||||
gBattleMons[gEffectBattler].item = 0;
|
|
||||||
gBattleMons[gBattlerAttacker].item = gLastUsedItem;
|
gBattleMons[gBattlerAttacker].item = gLastUsedItem;
|
||||||
|
|
||||||
RecordItemEffectBattle(gBattlerTarget, 0);
|
|
||||||
RecordItemEffectBattle(gBattlerAttacker, ItemId_GetHoldEffect(gLastUsedItem));
|
|
||||||
|
|
||||||
CheckSetUnburden(gEffectBattler); //Give target Unburden boost
|
|
||||||
gBattleResources->flags->flags[gBattlerTarget] &= ~(RESOURCE_FLAG_UNBURDEN); //remove attacker boost
|
|
||||||
|
|
||||||
gActiveBattler = gBattlerAttacker;
|
|
||||||
BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gLastUsedItem);
|
|
||||||
MarkBattlerForControllerExec(gActiveBattler);
|
|
||||||
|
|
||||||
gActiveBattler = gEffectBattler;
|
|
||||||
BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gActiveBattler].item);
|
|
||||||
MarkBattlerForControllerExec(gActiveBattler);
|
|
||||||
|
|
||||||
gBattleStruct->choicedMove[gEffectBattler] = 0;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -11066,7 +11057,11 @@ static void Cmd_tryswapitems(void) // trick
|
|||||||
| BATTLE_TYPE_EREADER_TRAINER
|
| BATTLE_TYPE_EREADER_TRAINER
|
||||||
| BATTLE_TYPE_FRONTIER
|
| BATTLE_TYPE_FRONTIER
|
||||||
| BATTLE_TYPE_SECRET_BASE
|
| BATTLE_TYPE_SECRET_BASE
|
||||||
| BATTLE_TYPE_x2000000))))
|
| BATTLE_TYPE_x2000000
|
||||||
|
#if B_TRAINERS_STEAL_ITEMS
|
||||||
|
| BATTLE_TYPE_TRAINER
|
||||||
|
#endif
|
||||||
|
))))
|
||||||
{
|
{
|
||||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
|
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
|
||||||
}
|
}
|
||||||
@ -11130,6 +11125,16 @@ static void Cmd_tryswapitems(void) // trick
|
|||||||
|
|
||||||
PREPARE_ITEM_BUFFER(gBattleTextBuff1, *newItemAtk)
|
PREPARE_ITEM_BUFFER(gBattleTextBuff1, *newItemAtk)
|
||||||
PREPARE_ITEM_BUFFER(gBattleTextBuff2, oldItemAtk)
|
PREPARE_ITEM_BUFFER(gBattleTextBuff2, oldItemAtk)
|
||||||
|
|
||||||
|
#if B_TRAINERS_STEAL_ITEMS
|
||||||
|
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER)
|
||||||
|
{
|
||||||
|
if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER)
|
||||||
|
gBattleStruct->itemStolen[gBattlerPartyIndexes[gBattlerAttacker]] = oldItemAtk;
|
||||||
|
if (GetBattlerSide(gBattlerTarget) == B_SIDE_PLAYER)
|
||||||
|
gBattleStruct->itemStolen[gBattlerPartyIndexes[gBattlerTarget]] = *newItemAtk;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (oldItemAtk != 0 && *newItemAtk != 0)
|
if (oldItemAtk != 0 && *newItemAtk != 0)
|
||||||
gBattleCommunication[MULTISTRING_CHOOSER] = 2; // attacker's item -> <- target's item
|
gBattleCommunication[MULTISTRING_CHOOSER] = 2; // attacker's item -> <- target's item
|
||||||
|
@ -7793,61 +7793,16 @@ bool32 TestSheerForceFlag(u8 battler, u16 move)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool32 ItemCanBeStolen(u16 item, u8 battlerId)
|
void TryRestoreStolenItems(void)
|
||||||
{
|
{
|
||||||
u8 effect = ItemId_GetHoldEffect(item);
|
u32 i;
|
||||||
|
u16 stolenItem = ITEM_NONE;
|
||||||
|
|
||||||
if (item == ITEM_ENIGMA_BERRY)
|
for (i = 0; i < PARTY_SIZE; i++)
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (gBattleTypeFlags & BATTLE_TYPE_TRAINER_HILL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (GetBattlerSide(battlerId) == B_SIDE_OPPONENT
|
|
||||||
&& !(gBattleTypeFlags &
|
|
||||||
(BATTLE_TYPE_EREADER_TRAINER
|
|
||||||
| BATTLE_TYPE_FRONTIER
|
|
||||||
| BATTLE_TYPE_LINK
|
|
||||||
| BATTLE_TYPE_x2000000
|
|
||||||
| BATTLE_TYPE_SECRET_BASE)))
|
|
||||||
{
|
{
|
||||||
return FALSE;
|
stolenItem = gBattleStruct->itemStolen[i];
|
||||||
|
if (stolenItem != ITEM_NONE && ItemId_GetPocket(stolenItem) != POCKET_BERRIES)
|
||||||
|
SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &stolenItem); //restore stolen non-berry items
|
||||||
}
|
}
|
||||||
else if (!(gBattleTypeFlags &
|
|
||||||
(BATTLE_TYPE_EREADER_TRAINER
|
|
||||||
| BATTLE_TYPE_FRONTIER
|
|
||||||
| BATTLE_TYPE_LINK
|
|
||||||
| BATTLE_TYPE_x2000000
|
|
||||||
| BATTLE_TYPE_SECRET_BASE))
|
|
||||||
&& (gWishFutureKnock.knockedOffMons[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]]))
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IS_ITEM_MAIL(item))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
switch (effect)
|
|
||||||
{
|
|
||||||
case HOLD_EFFECT_MEGA_STONE:
|
|
||||||
#ifdef HOLD_EFFECT_MEMORY
|
|
||||||
case HOLD_EFFECT_MEMORY:
|
|
||||||
#endif
|
|
||||||
#ifdef HOLD_EFFECT_Z_CRYSTAL
|
|
||||||
case HOLD_EFFECT_Z_CRYSTAL:
|
|
||||||
#endif
|
|
||||||
#ifdef HOLD_EFFECT_DRIVE
|
|
||||||
case HOLD_EFFECT_DRIVE:
|
|
||||||
#endif
|
|
||||||
#ifdef HOLD_EFFECT_GEMS
|
|
||||||
case HOLD_EFFECT_GEMS:
|
|
||||||
#endif
|
|
||||||
#ifdef HOLD_EFFECT_GRISEOUS_ORB
|
|
||||||
case HOLD_EFFECT_GRISEOUS_ORB:
|
|
||||||
#endif
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user