Add configuration to prevent permanent item theft (Covet / Thief) from NPCs (#4605)
* feat: implement logic for gen5+ covet/thief * refactor: add define, misc. changes * fix: define parenthesises * fix: revert to bool32 * fix: formatting
This commit is contained in:
parent
bc9f09744d
commit
85ca0645a9
2 changed files with 14 additions and 5 deletions
|
@ -154,6 +154,7 @@
|
|||
#define B_X_ITEMS_BUFF GEN_LATEST // In Gen7+, the X Items raise a stat by 2 stages instead of 1.
|
||||
#define B_MENTAL_HERB GEN_LATEST // In Gen5+, the Mental Herb cures Taunt, Encore, Torment, Heal Block, and Disable in addition to Infatuation from before.
|
||||
#define B_TRAINERS_KNOCK_OFF_ITEMS TRUE // If TRUE, trainers can steal/swap your items (non-berries are restored after battle). In vanilla games trainers cannot steal items.
|
||||
#define B_RETURN_STOLEN_NPC_ITEMS GEN_LATEST // In Gen5+, Thief and Covet no longer steal items from NPCs.
|
||||
#define B_RESTORE_HELD_BATTLE_ITEMS GEN_LATEST // In Gen9, all non-berry items are restored after battle.
|
||||
#define B_SOUL_DEW_BOOST GEN_LATEST // In Gens3-6, Soul Dew boosts Latis' Sp. Atk and Sp. Def. In Gen7+ it boosts the power of their Psychic and Dragon type moves instead.
|
||||
#define B_NET_BALL_MODIFIER GEN_LATEST // In Gen7+, Net Ball's catch multiplier is x5 instead of x3.
|
||||
|
|
|
@ -10991,15 +10991,23 @@ void SortBattlersBySpeed(u8 *battlers, bool32 slowToFast)
|
|||
void TryRestoreHeldItems(void)
|
||||
{
|
||||
u32 i;
|
||||
u16 lostItem = ITEM_NONE;
|
||||
bool32 returnNPCItems = B_RETURN_STOLEN_NPC_ITEMS >= GEN_5 && gBattleTypeFlags & BATTLE_TYPE_TRAINER;
|
||||
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
{
|
||||
if (B_RESTORE_HELD_BATTLE_ITEMS >= GEN_9 || gBattleStruct->itemLost[i].stolen)
|
||||
// Check if held items should be restored after battle based on generation
|
||||
if (B_RESTORE_HELD_BATTLE_ITEMS >= GEN_9 || gBattleStruct->itemLost[i].stolen || returnNPCItems)
|
||||
{
|
||||
lostItem = gBattleStruct->itemLost[i].originalItem;
|
||||
if (lostItem != ITEM_NONE && ItemId_GetPocket(lostItem) != POCKET_BERRIES)
|
||||
SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &lostItem); // Restore stolen non-berry items
|
||||
u16 lostItem = gBattleStruct->itemLost[i].originalItem;
|
||||
|
||||
// Check if the lost item is a berry and the mon is not holding it
|
||||
if (ItemId_GetPocket(lostItem) == POCKET_BERRIES && GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM) != lostItem)
|
||||
lostItem = ITEM_NONE;
|
||||
|
||||
// Check if the lost item should be restored
|
||||
if ((lostItem != ITEM_NONE || returnNPCItems) && ItemId_GetPocket(lostItem) != POCKET_BERRIES)
|
||||
SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &lostItem);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue