mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-01-19 09:54:19 +01:00
Unnerve
This commit is contained in:
parent
ec4c73711e
commit
60d5d00dba
@ -4226,12 +4226,17 @@ enum
|
||||
// second argument is 1/X of current hp compared to max hp
|
||||
static bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId)
|
||||
{
|
||||
bool32 isBerry = (ItemId_GetPocket(itemId) == POCKET_BERRIES);
|
||||
|
||||
if (gBattleMons[battlerId].hp == 0)
|
||||
return FALSE;
|
||||
// Unnerve prevents consumption of opponents' berries.
|
||||
if (isBerry && IsAbilityOnOpposingSide(battlerId, ABILITY_UNNERVE))
|
||||
return FALSE;
|
||||
if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / hpFraction)
|
||||
return TRUE;
|
||||
|
||||
if (hpFraction <= 4 && GetBattlerAbility(battlerId) == ABILITY_GLUTTONY && ItemId_GetPocket(itemId) == POCKET_BERRIES
|
||||
if (hpFraction <= 4 && GetBattlerAbility(battlerId) == ABILITY_GLUTTONY && isBerry
|
||||
&& gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / 2)
|
||||
{
|
||||
RecordAbilityBattle(battlerId, ABILITY_GLUTTONY);
|
||||
@ -4338,6 +4343,13 @@ static u8 ItemHealHp(u32 battlerId, u32 itemId, bool32 end2, bool32 percentHeal)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool32 UnnerveOn(u32 battlerId, u32 itemId)
|
||||
{
|
||||
if (ItemId_GetPocket(itemId) == POCKET_BERRIES && IsAbilityOnOpposingSide(battlerId, ABILITY_UNNERVE))
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
{
|
||||
int i = 0, moveType;
|
||||
@ -4435,7 +4447,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
effect = RandomStatRaiseBerry(battlerId, gLastUsedItem);
|
||||
break;
|
||||
case HOLD_EFFECT_CURE_PAR:
|
||||
if (B_BERRIES_INSTANT >= GEN_4 && gBattleMons[battlerId].status1 & STATUS1_PARALYSIS)
|
||||
if (B_BERRIES_INSTANT >= GEN_4 && gBattleMons[battlerId].status1 & STATUS1_PARALYSIS && !UnnerveOn(battlerId, gLastUsedItem))
|
||||
{
|
||||
gBattleMons[battlerId].status1 &= ~(STATUS1_PARALYSIS);
|
||||
BattleScriptExecute(BattleScript_BerryCurePrlzEnd2);
|
||||
@ -4443,7 +4455,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
}
|
||||
break;
|
||||
case HOLD_EFFECT_CURE_PSN:
|
||||
if (B_BERRIES_INSTANT >= GEN_4 && gBattleMons[battlerId].status1 & STATUS1_PSN_ANY)
|
||||
if (B_BERRIES_INSTANT >= GEN_4 && gBattleMons[battlerId].status1 & STATUS1_PSN_ANY && !UnnerveOn(battlerId, gLastUsedItem))
|
||||
{
|
||||
gBattleMons[battlerId].status1 &= ~(STATUS1_PSN_ANY | STATUS1_TOXIC_COUNTER);
|
||||
BattleScriptExecute(BattleScript_BerryCurePsnEnd2);
|
||||
@ -4451,7 +4463,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
}
|
||||
break;
|
||||
case HOLD_EFFECT_CURE_BRN:
|
||||
if (B_BERRIES_INSTANT >= GEN_4 && gBattleMons[battlerId].status1 & STATUS1_BURN)
|
||||
if (B_BERRIES_INSTANT >= GEN_4 && gBattleMons[battlerId].status1 & STATUS1_BURN && !UnnerveOn(battlerId, gLastUsedItem))
|
||||
{
|
||||
gBattleMons[battlerId].status1 &= ~(STATUS1_BURN);
|
||||
BattleScriptExecute(BattleScript_BerryCureBrnEnd2);
|
||||
@ -4459,7 +4471,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
}
|
||||
break;
|
||||
case HOLD_EFFECT_CURE_FRZ:
|
||||
if (B_BERRIES_INSTANT >= GEN_4 && gBattleMons[battlerId].status1 & STATUS1_FREEZE)
|
||||
if (B_BERRIES_INSTANT >= GEN_4 && gBattleMons[battlerId].status1 & STATUS1_FREEZE && !UnnerveOn(battlerId, gLastUsedItem))
|
||||
{
|
||||
gBattleMons[battlerId].status1 &= ~(STATUS1_FREEZE);
|
||||
BattleScriptExecute(BattleScript_BerryCureFrzEnd2);
|
||||
@ -4467,7 +4479,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
}
|
||||
break;
|
||||
case HOLD_EFFECT_CURE_SLP:
|
||||
if (B_BERRIES_INSTANT >= GEN_4 && gBattleMons[battlerId].status1 & STATUS1_SLEEP)
|
||||
if (B_BERRIES_INSTANT >= GEN_4 && gBattleMons[battlerId].status1 & STATUS1_SLEEP && !UnnerveOn(battlerId, gLastUsedItem))
|
||||
{
|
||||
gBattleMons[battlerId].status1 &= ~(STATUS1_SLEEP);
|
||||
gBattleMons[battlerId].status2 &= ~(STATUS2_NIGHTMARE);
|
||||
@ -4476,7 +4488,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
}
|
||||
break;
|
||||
case HOLD_EFFECT_CURE_STATUS:
|
||||
if (B_BERRIES_INSTANT >= GEN_4 && gBattleMons[battlerId].status1 & STATUS1_ANY || gBattleMons[battlerId].status2 & STATUS2_CONFUSION)
|
||||
if (B_BERRIES_INSTANT >= GEN_4 && (gBattleMons[battlerId].status1 & STATUS1_ANY || gBattleMons[battlerId].status2 & STATUS2_CONFUSION) && !UnnerveOn(battlerId, gLastUsedItem))
|
||||
{
|
||||
i = 0;
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_PSN_ANY)
|
||||
@ -4701,7 +4713,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
effect = RandomStatRaiseBerry(battlerId, gLastUsedItem);
|
||||
break;
|
||||
case HOLD_EFFECT_CURE_PAR:
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_PARALYSIS)
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_PARALYSIS && !UnnerveOn(battlerId, gLastUsedItem))
|
||||
{
|
||||
gBattleMons[battlerId].status1 &= ~(STATUS1_PARALYSIS);
|
||||
BattleScriptExecute(BattleScript_BerryCurePrlzEnd2);
|
||||
@ -4709,7 +4721,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
}
|
||||
break;
|
||||
case HOLD_EFFECT_CURE_PSN:
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_PSN_ANY)
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_PSN_ANY && !UnnerveOn(battlerId, gLastUsedItem))
|
||||
{
|
||||
gBattleMons[battlerId].status1 &= ~(STATUS1_PSN_ANY | STATUS1_TOXIC_COUNTER);
|
||||
BattleScriptExecute(BattleScript_BerryCurePsnEnd2);
|
||||
@ -4717,7 +4729,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
}
|
||||
break;
|
||||
case HOLD_EFFECT_CURE_BRN:
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_BURN)
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_BURN && !UnnerveOn(battlerId, gLastUsedItem))
|
||||
{
|
||||
gBattleMons[battlerId].status1 &= ~(STATUS1_BURN);
|
||||
BattleScriptExecute(BattleScript_BerryCureBrnEnd2);
|
||||
@ -4725,7 +4737,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
}
|
||||
break;
|
||||
case HOLD_EFFECT_CURE_FRZ:
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_FREEZE)
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_FREEZE && !UnnerveOn(battlerId, gLastUsedItem))
|
||||
{
|
||||
gBattleMons[battlerId].status1 &= ~(STATUS1_FREEZE);
|
||||
BattleScriptExecute(BattleScript_BerryCureFrzEnd2);
|
||||
@ -4733,7 +4745,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
}
|
||||
break;
|
||||
case HOLD_EFFECT_CURE_SLP:
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_SLEEP)
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_SLEEP && !UnnerveOn(battlerId, gLastUsedItem))
|
||||
{
|
||||
gBattleMons[battlerId].status1 &= ~(STATUS1_SLEEP);
|
||||
gBattleMons[battlerId].status2 &= ~(STATUS2_NIGHTMARE);
|
||||
@ -4742,7 +4754,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
}
|
||||
break;
|
||||
case HOLD_EFFECT_CURE_CONFUSION:
|
||||
if (gBattleMons[battlerId].status2 & STATUS2_CONFUSION)
|
||||
if (gBattleMons[battlerId].status2 & STATUS2_CONFUSION && !UnnerveOn(battlerId, gLastUsedItem))
|
||||
{
|
||||
gBattleMons[battlerId].status2 &= ~(STATUS2_CONFUSION);
|
||||
BattleScriptExecute(BattleScript_BerryCureConfusionEnd2);
|
||||
@ -4750,7 +4762,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
}
|
||||
break;
|
||||
case HOLD_EFFECT_CURE_STATUS:
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_ANY || gBattleMons[battlerId].status2 & STATUS2_CONFUSION)
|
||||
if ((gBattleMons[battlerId].status1 & STATUS1_ANY || gBattleMons[battlerId].status2 & STATUS2_CONFUSION) && !UnnerveOn(battlerId, gLastUsedItem))
|
||||
{
|
||||
i = 0;
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_PSN_ANY)
|
||||
@ -4839,7 +4851,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
effect = ItemHealHp(battlerId, gLastUsedItem, FALSE, TRUE);
|
||||
break;
|
||||
case HOLD_EFFECT_CURE_PAR:
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_PARALYSIS)
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_PARALYSIS && !UnnerveOn(battlerId, gLastUsedItem))
|
||||
{
|
||||
gBattleMons[battlerId].status1 &= ~(STATUS1_PARALYSIS);
|
||||
BattleScriptPushCursor();
|
||||
@ -4848,7 +4860,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
}
|
||||
break;
|
||||
case HOLD_EFFECT_CURE_PSN:
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_PSN_ANY)
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_PSN_ANY && !UnnerveOn(battlerId, gLastUsedItem))
|
||||
{
|
||||
gBattleMons[battlerId].status1 &= ~(STATUS1_PSN_ANY | STATUS1_TOXIC_COUNTER);
|
||||
BattleScriptPushCursor();
|
||||
@ -4857,7 +4869,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
}
|
||||
break;
|
||||
case HOLD_EFFECT_CURE_BRN:
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_BURN)
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_BURN && !UnnerveOn(battlerId, gLastUsedItem))
|
||||
{
|
||||
gBattleMons[battlerId].status1 &= ~(STATUS1_BURN);
|
||||
BattleScriptPushCursor();
|
||||
@ -4866,7 +4878,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
}
|
||||
break;
|
||||
case HOLD_EFFECT_CURE_FRZ:
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_FREEZE)
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_FREEZE && !UnnerveOn(battlerId, gLastUsedItem))
|
||||
{
|
||||
gBattleMons[battlerId].status1 &= ~(STATUS1_FREEZE);
|
||||
BattleScriptPushCursor();
|
||||
@ -4875,7 +4887,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
}
|
||||
break;
|
||||
case HOLD_EFFECT_CURE_SLP:
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_SLEEP)
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_SLEEP && !UnnerveOn(battlerId, gLastUsedItem))
|
||||
{
|
||||
gBattleMons[battlerId].status1 &= ~(STATUS1_SLEEP);
|
||||
gBattleMons[battlerId].status2 &= ~(STATUS2_NIGHTMARE);
|
||||
@ -4885,7 +4897,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
}
|
||||
break;
|
||||
case HOLD_EFFECT_CURE_CONFUSION:
|
||||
if (gBattleMons[battlerId].status2 & STATUS2_CONFUSION)
|
||||
if (gBattleMons[battlerId].status2 & STATUS2_CONFUSION && !UnnerveOn(battlerId, gLastUsedItem))
|
||||
{
|
||||
gBattleMons[battlerId].status2 &= ~(STATUS2_CONFUSION);
|
||||
BattleScriptPushCursor();
|
||||
@ -4905,7 +4917,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
||||
}
|
||||
break;
|
||||
case HOLD_EFFECT_CURE_STATUS:
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_ANY || gBattleMons[battlerId].status2 & STATUS2_CONFUSION)
|
||||
if ((gBattleMons[battlerId].status1 & STATUS1_ANY || gBattleMons[battlerId].status2 & STATUS2_CONFUSION) && !UnnerveOn(battlerId, gLastUsedItem))
|
||||
{
|
||||
if (gBattleMons[battlerId].status1 & STATUS1_PSN_ANY)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user