add recycle hp berry logic
This commit is contained in:
parent
4566b5234f
commit
6f6e0d6baf
2 changed files with 10 additions and 3 deletions
|
@ -4111,10 +4111,14 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
|
||||||
if (AI_DATA->atkAbility == ABILITY_RIPEN)
|
if (AI_DATA->atkAbility == ABILITY_RIPEN)
|
||||||
{
|
{
|
||||||
u16 item = GetUsedHeldItem(battlerAtk);
|
u16 item = GetUsedHeldItem(battlerAtk);
|
||||||
|
u16 toHeal = (ItemId_GetHoldEffectParam(item) == 10) ? 10 : gBattleMons[battlerAtk].maxHP / ItemId_GetHoldEffectParam(item);
|
||||||
|
|
||||||
if (IsStatBoostingBerry(item) && atkHpPercent > 60)
|
if (IsStatBoostingBerry(item) && atkHpPercent > 60)
|
||||||
score++;
|
score++;
|
||||||
else if (IsHpRestoringBerry(item) && atkHpPercent < 60)
|
else if (IsHpRestoringBerry(item) && !CanAIFaintTarget(battlerAtk, battlerDef, 0)
|
||||||
score++; // TODO check if player can still faint us after we heal
|
&& ((GetWhoStrikesFirst(battlerAtk, battlerDef, TRUE) == 0 && CanTargetFaintAiWithMod(battlerDef, battlerAtk, 0, 0))
|
||||||
|
|| !CanTargetFaintAiWithMod(battlerDef, battlerAtk, toheal, 0)))
|
||||||
|
score++; // Recycle healing berry if we can't otherwise faint the target and the target wont kill us after we activate the berry
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EFFECT_BRICK_BREAK:
|
case EFFECT_BRICK_BREAK:
|
||||||
|
|
|
@ -3389,11 +3389,14 @@ bool32 IsStatBoostingBerry(u16 item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool32 IsHpRestoringBerry(u16 item)
|
bool32 IsHpRestoringBerry(u8 battlerAtk, u16 item)
|
||||||
{
|
{
|
||||||
switch (item)
|
switch (item)
|
||||||
{
|
{
|
||||||
case ITEM_ORAN_BERRY:
|
case ITEM_ORAN_BERRY:
|
||||||
|
if (gBattleMons[battlerAtk].maxHp <= 50)
|
||||||
|
return TRUE; // Only worth it in the early game
|
||||||
|
return FALSE;
|
||||||
case ITEM_SITRUS_BERRY:
|
case ITEM_SITRUS_BERRY:
|
||||||
case ITEM_FIGY_BERRY:
|
case ITEM_FIGY_BERRY:
|
||||||
case ITEM_WIKI_BERRY:
|
case ITEM_WIKI_BERRY:
|
||||||
|
|
Loading…
Reference in a new issue