mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 11:44:17 +01:00
workaround for GetBattlerHoldEffectParam to handle bug bite different battler id
This commit is contained in:
parent
1e6903840a
commit
7a0e541413
@ -9278,11 +9278,15 @@ BattleScript_BerryStatRaiseRet_Anim:
|
|||||||
BattleScript_BerryStatRaiseRet_End:
|
BattleScript_BerryStatRaiseRet_End:
|
||||||
return
|
return
|
||||||
|
|
||||||
BattleScript_BerryFocusEnergyEnd2::
|
BattleScript_BerryFocusEnergyRet::
|
||||||
playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT
|
playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT
|
||||||
printstring STRINGID_PKMNUSEDXTOGETPUMPED
|
printstring STRINGID_PKMNUSEDXTOGETPUMPED
|
||||||
waitmessage B_WAIT_TIME_LONG
|
waitmessage B_WAIT_TIME_LONG
|
||||||
removeitem BS_ATTACKER
|
removeitem BS_SCRIPTING
|
||||||
|
return
|
||||||
|
|
||||||
|
BattleScript_BerryFocusEnergyEnd2::
|
||||||
|
call BattleScript_BerryFocusEnergyRet
|
||||||
end2
|
end2
|
||||||
|
|
||||||
BattleScript_ActionSelectionItemsCantBeUsed::
|
BattleScript_ActionSelectionItemsCantBeUsed::
|
||||||
|
@ -216,6 +216,7 @@ extern const u8 BattleScript_BerryConfuseHealEnd2[];
|
|||||||
extern const u8 BattleScript_BerryConfuseHealRet[];
|
extern const u8 BattleScript_BerryConfuseHealRet[];
|
||||||
extern const u8 BattleScript_BerryStatRaiseEnd2[];
|
extern const u8 BattleScript_BerryStatRaiseEnd2[];
|
||||||
extern const u8 BattleScript_BerryStatRaiseRet[];
|
extern const u8 BattleScript_BerryStatRaiseRet[];
|
||||||
|
extern const u8 BattleScript_BerryFocusEnergyRet[];
|
||||||
extern const u8 BattleScript_BerryFocusEnergyEnd2[];
|
extern const u8 BattleScript_BerryFocusEnergyEnd2[];
|
||||||
extern const u8 BattleScript_ActionSelectionItemsCantBeUsed[];
|
extern const u8 BattleScript_ActionSelectionItemsCantBeUsed[];
|
||||||
extern const u8 BattleScript_ArenaTurnBeginning[];
|
extern const u8 BattleScript_ArenaTurnBeginning[];
|
||||||
|
@ -271,6 +271,7 @@ static const struct BitfieldInfo sStatus2Bitfield[] =
|
|||||||
{/*Multiple Turns*/ 1, 12},
|
{/*Multiple Turns*/ 1, 12},
|
||||||
// Wrap bits are omitted. Done in various.
|
// Wrap bits are omitted. Done in various.
|
||||||
// In Love bits are omitted. Done in various.
|
// In Love bits are omitted. Done in various.
|
||||||
|
{/*(Focus Energy*/ 1, 20},
|
||||||
{/*Transformed*/ 1, 21},
|
{/*Transformed*/ 1, 21},
|
||||||
{/*Recharge*/ 1, 22},
|
{/*Recharge*/ 1, 22},
|
||||||
{/*Rage*/ 1, 23},
|
{/*Rage*/ 1, 23},
|
||||||
|
@ -60,6 +60,7 @@ static bool32 TryRemoveScreens(u8 battler);
|
|||||||
static bool32 IsUnnerveAbilityOnOpposingSide(u8 battlerId);
|
static bool32 IsUnnerveAbilityOnOpposingSide(u8 battlerId);
|
||||||
static u8 GetFlingPowerFromItemId(u16 itemId);
|
static u8 GetFlingPowerFromItemId(u16 itemId);
|
||||||
static void SetRandomMultiHitCounter();
|
static void SetRandomMultiHitCounter();
|
||||||
|
static u32 GetBattlerItemHoldEffectParam(u8 battlerId, u16 item);
|
||||||
|
|
||||||
extern const u8 *const gBattleScriptsForMoveEffects[];
|
extern const u8 *const gBattleScriptsForMoveEffects[];
|
||||||
extern const u8 *const gBattlescriptsForRunningByItem[];
|
extern const u8 *const gBattlescriptsForRunningByItem[];
|
||||||
@ -6397,7 +6398,7 @@ static u8 HealConfuseBerry(u32 battlerId, u32 itemId, u8 flavorId, bool32 end2)
|
|||||||
{
|
{
|
||||||
PREPARE_FLAVOR_BUFFER(gBattleTextBuff1, flavorId);
|
PREPARE_FLAVOR_BUFFER(gBattleTextBuff1, flavorId);
|
||||||
|
|
||||||
gBattleMoveDamage = gBattleMons[battlerId].maxHP / GetBattlerHoldEffectParam(battlerId);
|
gBattleMoveDamage = gBattleMons[battlerId].maxHP / GetBattlerItemHoldEffectParam(battlerId, itemId);
|
||||||
if (gBattleMoveDamage == 0)
|
if (gBattleMoveDamage == 0)
|
||||||
gBattleMoveDamage = 1;
|
gBattleMoveDamage = 1;
|
||||||
gBattleMoveDamage *= -1;
|
gBattleMoveDamage *= -1;
|
||||||
@ -6433,7 +6434,7 @@ static u8 HealConfuseBerry(u32 battlerId, u32 itemId, u8 flavorId, bool32 end2)
|
|||||||
|
|
||||||
static u8 StatRaiseBerry(u32 battlerId, u32 itemId, u32 statId, bool32 end2)
|
static u8 StatRaiseBerry(u32 battlerId, u32 itemId, u32 statId, bool32 end2)
|
||||||
{
|
{
|
||||||
if (CompareStat(battlerId, statId, MAX_STAT_STAGE, CMP_LESS_THAN) && HasEnoughHpToEatBerry(battlerId, GetBattlerHoldEffectParam(battlerId), itemId))
|
if (CompareStat(battlerId, statId, MAX_STAT_STAGE, CMP_LESS_THAN) && HasEnoughHpToEatBerry(battlerId, GetBattlerItemHoldEffectParam(battlerId, itemId), itemId))
|
||||||
{
|
{
|
||||||
BufferStatChange(battlerId, statId, STRINGID_STATROSE);
|
BufferStatChange(battlerId, statId, STRINGID_STATROSE);
|
||||||
gEffectBattler = battlerId;
|
gEffectBattler = battlerId;
|
||||||
@ -6469,7 +6470,7 @@ static u8 RandomStatRaiseBerry(u32 battlerId, u32 itemId, bool32 end2)
|
|||||||
if (CompareStat(battlerId, STAT_ATK + i, MAX_STAT_STAGE, CMP_LESS_THAN))
|
if (CompareStat(battlerId, STAT_ATK + i, MAX_STAT_STAGE, CMP_LESS_THAN))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i != NUM_STATS - 1 && HasEnoughHpToEatBerry(battlerId, GetBattlerHoldEffectParam(battlerId), itemId))
|
if (i != NUM_STATS - 1 && HasEnoughHpToEatBerry(battlerId, GetBattlerItemHoldEffectParam(battlerId, itemId), itemId))
|
||||||
{
|
{
|
||||||
u16 battlerAbility = GetBattlerAbility(battlerId);
|
u16 battlerAbility = GetBattlerAbility(battlerId);
|
||||||
do
|
do
|
||||||
@ -6588,9 +6589,9 @@ static u8 ItemHealHp(u32 battlerId, u32 itemId, bool32 end2, bool32 percentHeal)
|
|||||||
&& HasEnoughHpToEatBerry(battlerId, 2, itemId))
|
&& HasEnoughHpToEatBerry(battlerId, 2, itemId))
|
||||||
{
|
{
|
||||||
if (percentHeal)
|
if (percentHeal)
|
||||||
gBattleMoveDamage = (gBattleMons[battlerId].maxHP * GetBattlerHoldEffectParam(battlerId) / 100) * -1;
|
gBattleMoveDamage = (gBattleMons[battlerId].maxHP * GetBattlerItemHoldEffectParam(battlerId, itemId) / 100) * -1;
|
||||||
else
|
else
|
||||||
gBattleMoveDamage = GetBattlerHoldEffectParam(battlerId) * -1;
|
gBattleMoveDamage = GetBattlerItemHoldEffectParam(battlerId, itemId) * -1;
|
||||||
|
|
||||||
// check ripen
|
// check ripen
|
||||||
if (ItemId_GetPocket(itemId) == POCKET_BERRIES && GetBattlerAbility(battlerId) == ABILITY_RIPEN)
|
if (ItemId_GetPocket(itemId) == POCKET_BERRIES && GetBattlerAbility(battlerId) == ABILITY_RIPEN)
|
||||||
@ -6841,6 +6842,19 @@ static u8 ItemEffectMoveEnd(u32 battlerId, u16 holdEffect)
|
|||||||
return effect;
|
return effect;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case HOLD_EFFECT_CRITICAL_UP: // lansat berry
|
||||||
|
if (B_BERRIES_INSTANT >= GEN_4
|
||||||
|
&& !(gBattleMons[battlerId].status2 & STATUS2_FOCUS_ENERGY)
|
||||||
|
&& HasEnoughHpToEatBerry(battlerId, GetBattlerItemHoldEffectParam(battlerId, gLastUsedItem), gLastUsedItem))
|
||||||
|
{
|
||||||
|
gBattleMons[battlerId].status2 |= STATUS2_FOCUS_ENERGY;
|
||||||
|
gBattleScripting.battler = battlerId;
|
||||||
|
gPotentialItemEffectBattler = battlerId;
|
||||||
|
BattleScriptPushCursor();
|
||||||
|
gBattlescriptCurrInstr = BattleScript_BerryFocusEnergyRet;
|
||||||
|
effect = ITEM_EFFECT_OTHER;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return effect;
|
return effect;
|
||||||
@ -6927,9 +6941,10 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
|||||||
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPDEF, TRUE);
|
effect = StatRaiseBerry(battlerId, gLastUsedItem, STAT_SPDEF, TRUE);
|
||||||
break;
|
break;
|
||||||
case HOLD_EFFECT_CRITICAL_UP:
|
case HOLD_EFFECT_CRITICAL_UP:
|
||||||
if (!(gBattleMons[battlerId].status2 & STATUS2_FOCUS_ENERGY) && HasEnoughHpToEatBerry(battlerId, GetBattlerHoldEffectParam(battlerId), gLastUsedItem))
|
if (!(gBattleMons[battlerId].status2 & STATUS2_FOCUS_ENERGY) && HasEnoughHpToEatBerry(battlerId, GetBattlerItemHoldEffectParam(battlerId, gLastUsedItem), gLastUsedItem))
|
||||||
{
|
{
|
||||||
gBattleMons[battlerId].status2 |= STATUS2_FOCUS_ENERGY;
|
gBattleMons[battlerId].status2 |= STATUS2_FOCUS_ENERGY;
|
||||||
|
gBattleScripting.battler = battlerId;
|
||||||
BattleScriptExecute(BattleScript_BerryFocusEnergyEnd2);
|
BattleScriptExecute(BattleScript_BerryFocusEnergyEnd2);
|
||||||
effect = ITEM_EFFECT_OTHER;
|
effect = ITEM_EFFECT_OTHER;
|
||||||
}
|
}
|
||||||
@ -7243,9 +7258,10 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
|
|||||||
break;
|
break;
|
||||||
case HOLD_EFFECT_CRITICAL_UP:
|
case HOLD_EFFECT_CRITICAL_UP:
|
||||||
if (!moveTurn && !(gBattleMons[battlerId].status2 & STATUS2_FOCUS_ENERGY)
|
if (!moveTurn && !(gBattleMons[battlerId].status2 & STATUS2_FOCUS_ENERGY)
|
||||||
&& HasEnoughHpToEatBerry(battlerId, GetBattlerHoldEffectParam(battlerId), gLastUsedItem))
|
&& HasEnoughHpToEatBerry(battlerId, GetBattlerItemHoldEffectParam(battlerId, gLastUsedItem), gLastUsedItem))
|
||||||
{
|
{
|
||||||
gBattleMons[battlerId].status2 |= STATUS2_FOCUS_ENERGY;
|
gBattleMons[battlerId].status2 |= STATUS2_FOCUS_ENERGY;
|
||||||
|
gBattleScripting.battler = battlerId;
|
||||||
BattleScriptExecute(BattleScript_BerryFocusEnergyEnd2);
|
BattleScriptExecute(BattleScript_BerryFocusEnergyEnd2);
|
||||||
effect = ITEM_EFFECT_OTHER;
|
effect = ITEM_EFFECT_OTHER;
|
||||||
}
|
}
|
||||||
@ -7975,6 +7991,15 @@ u32 GetBattlerHoldEffect(u8 battlerId, bool32 checkNegating)
|
|||||||
return ItemId_GetHoldEffect(gBattleMons[battlerId].item);
|
return ItemId_GetHoldEffect(gBattleMons[battlerId].item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
static u32 GetBattlerItemHoldEffectParam(u8 battlerId, u16 item)
|
||||||
|
{
|
||||||
|
if (item == ITEM_ENIGMA_BERRY)
|
||||||
|
return gEnigmaBerries[battlerId].holdEffectParam;
|
||||||
|
else
|
||||||
|
return ItemId_GetHoldEffectParam(item);
|
||||||
|
}
|
||||||
|
|
||||||
u32 GetBattlerHoldEffectParam(u8 battlerId)
|
u32 GetBattlerHoldEffectParam(u8 battlerId)
|
||||||
{
|
{
|
||||||
if (gBattleMons[battlerId].item == ITEM_ENIGMA_BERRY)
|
if (gBattleMons[battlerId].item == ITEM_ENIGMA_BERRY)
|
||||||
|
Loading…
Reference in New Issue
Block a user