Fixed not getting berry's effect at full HP or under Heal Block when using Bug Bite/Pluck

This commit is contained in:
Maruno17
2020-09-09 21:37:37 +01:00
parent 9c808d4c86
commit 891cc2791f
4 changed files with 26 additions and 22 deletions

View File

@@ -8,7 +8,7 @@ class PokeBattle_Battler
amt = 1 if amt<1 && !fainted? amt = 1 if amt<1 && !fainted?
oldHP = @hp oldHP = @hp
self.hp -= amt self.hp -= amt
PBDebug.log("[HP change] #{pbThis} lost #{amt} HP (#{oldHP}=>#{@hp})") PBDebug.log("[HP change] #{pbThis} lost #{amt} HP (#{oldHP}=>#{@hp})") if amt>0
raise _INTL("HP less than 0") if @hp<0 raise _INTL("HP less than 0") if @hp<0
raise _INTL("HP greater than total HP") if @hp>@totalhp raise _INTL("HP greater than total HP") if @hp>@totalhp
@battle.scene.pbHPChanged(self,oldHP,anim) if anyAnim && amt>0 @battle.scene.pbHPChanged(self,oldHP,anim) if anyAnim && amt>0
@@ -22,7 +22,7 @@ class PokeBattle_Battler
amt = 1 if amt<1 && @hp<@totalhp amt = 1 if amt<1 && @hp<@totalhp
oldHP = @hp oldHP = @hp
self.hp += amt self.hp += amt
PBDebug.log("[HP change] #{pbThis} gained #{amt} HP (#{oldHP}=>#{@hp})") PBDebug.log("[HP change] #{pbThis} gained #{amt} HP (#{oldHP}=>#{@hp})") if amt>0
raise _INTL("HP less than 0") if @hp<0 raise _INTL("HP less than 0") if @hp<0
raise _INTL("HP greater than total HP") if @hp>@totalhp raise _INTL("HP greater than total HP") if @hp>@totalhp
@battle.scene.pbHPChanged(self,oldHP,anim) if anyAnim && amt>0 @battle.scene.pbHPChanged(self,oldHP,anim) if anyAnim && amt>0

View File

@@ -245,10 +245,9 @@ class PokeBattle_Battler
end end
end end
# forcedItem is an item ID for Pluck/Fling, and 0 otherwise. fling is for # forcedItem is an item ID for Bug Bite/Pluck/Fling, and 0 otherwise.
# Fling only. # fling is for Fling only.
def pbItemHPHealCheck(forcedItem=0,fling=false) def pbItemHPHealCheck(forcedItem=0,fling=false)
return if !canHeal?
return if forcedItem==0 && !itemActive? return if forcedItem==0 && !itemActive?
thisItem = (forcedItem>0) ? forcedItem : @item thisItem = (forcedItem>0) ? forcedItem : @item
if BattleHandlers.triggerHPHealItem(thisItem,self,@battle,(forcedItem!=0)) if BattleHandlers.triggerHPHealItem(thisItem,self,@battle,(forcedItem!=0))

View File

@@ -490,13 +490,14 @@ DEF_MULT = 2
FINAL_DMG_MULT = 3 FINAL_DMG_MULT = 3
def pbBattleConfusionBerry(battler,battle,item,forced,flavor,confuseMsg) def pbBattleConfusionBerry(battler,battle,item,forced,flavor,confuseMsg)
return false if !forced && !battler.canHeal?
return false if !forced && !battler.pbCanConsumeBerry?(item,false) return false if !forced && !battler.pbCanConsumeBerry?(item,false)
itemName = PBItems.getName(item) itemName = PBItems.getName(item)
battle.pbCommonAnimation("EatBerry",battler) if !forced battle.pbCommonAnimation("EatBerry",battler) if !forced
amt = (NEWEST_BATTLE_MECHANICS) ? battler.pbRecoverHP(battler.totalhp/2) : battler.pbRecoverHP(battler.totalhp/8) amt = (NEWEST_BATTLE_MECHANICS) ? battler.pbRecoverHP(battler.totalhp/2) : battler.pbRecoverHP(battler.totalhp/8)
if amt>0 if amt>0
if forced if forced
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") PBDebug.log("[Item triggered] Forced consuming of #{itemName}")
battle.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis)) battle.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
else else
battle.pbDisplay(_INTL("{1} restored its health using its {2}!",battler.pbThis,itemName)) battle.pbDisplay(_INTL("{1} restored its health using its {2}!",battler.pbThis,itemName))
@@ -515,13 +516,13 @@ def pbBattleStatIncreasingBerry(battler,battle,item,forced,stat,increment=1)
return false if !forced && !battler.pbCanConsumeBerry?(item) return false if !forced && !battler.pbCanConsumeBerry?(item)
return false if !battler.pbCanRaiseStatStage?(stat,battler) return false if !battler.pbCanRaiseStatStage?(stat,battler)
itemName = PBItems.getName(item) itemName = PBItems.getName(item)
if !forced if forced
PBDebug.log("[Item triggered] Forced consuming of #{itemName}")
return battler.pbRaiseStatStage(stat,increment,battler)
end
battle.pbCommonAnimation("EatBerry",battler) battle.pbCommonAnimation("EatBerry",battler)
return battler.pbRaiseStatStageByCause(stat,increment,battler,itemName) return battler.pbRaiseStatStageByCause(stat,increment,battler,itemName)
end end
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}")
return battler.pbRaiseStatStage(stat,increment,battler)
end
# For abilities that grant immunity to moves of a particular type, and raises # For abilities that grant immunity to moves of a particular type, and raises
# one of the ability's bearer's stats instead. # one of the ability's bearer's stats instead.

View File

@@ -60,16 +60,16 @@ BattleHandlers::HPHealItem.add(:APICOTBERRY,
BattleHandlers::HPHealItem.add(:BERRYJUICE, BattleHandlers::HPHealItem.add(:BERRYJUICE,
proc { |item,battler,battle,forced| proc { |item,battler,battle,forced|
next false if !battler.canHeal?
next false if !forced && battler.hp>battler.totalhp/2 next false if !forced && battler.hp>battler.totalhp/2
itemName = PBItems.getName(item) itemName = PBItems.getName(item)
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") if forced PBDebug.log("[Item triggered] Forced consuming of #{itemName}") if forced
battle.pbCommonAnimation("UseItem",battler) if !forced battle.pbCommonAnimation("UseItem",battler) if !forced
battler.pbRecoverHP(20) battler.pbRecoverHP(20)
if forced if forced
battle.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis)) battle.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
else else
battle.pbDisplay(_INTL("{1} restored its health using its {2}!",battler.pbThis, battle.pbDisplay(_INTL("{1} restored its health using its {2}!",battler.pbThis,itemName))
itemName))
end end
next true next true
} }
@@ -102,7 +102,11 @@ BattleHandlers::HPHealItem.add(:LANSATBERRY,
battle.pbCommonAnimation("EatBerry",battler) if !forced battle.pbCommonAnimation("EatBerry",battler) if !forced
battler.effects[PBEffects::FocusEnergy] = 2 battler.effects[PBEffects::FocusEnergy] = 2
itemName = PBItems.getName(item) itemName = PBItems.getName(item)
if forced
battle.pbDisplay(_INTL("{1} got pumped from the {2}!",battler.pbThis,itemName))
else
battle.pbDisplay(_INTL("{1} used its {2} to get pumped!",battler.pbThis,itemName)) battle.pbDisplay(_INTL("{1} used its {2} to get pumped!",battler.pbThis,itemName))
end
next true next true
} }
) )
@@ -128,7 +132,7 @@ BattleHandlers::HPHealItem.add(:MICLEBERRY,
battler.effects[PBEffects::MicleBerry] = true battler.effects[PBEffects::MicleBerry] = true
itemName = PBItems.getName(item) itemName = PBItems.getName(item)
if forced if forced
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") PBDebug.log("[Item triggered] Forced consuming of #{itemName}")
battle.pbDisplay(_INTL("{1} boosted the accuracy of its next move!",battler.pbThis)) battle.pbDisplay(_INTL("{1} boosted the accuracy of its next move!",battler.pbThis))
else else
battle.pbDisplay(_INTL("{1} boosted the accuracy of its next move using its {2}!", battle.pbDisplay(_INTL("{1} boosted the accuracy of its next move using its {2}!",
@@ -140,17 +144,17 @@ BattleHandlers::HPHealItem.add(:MICLEBERRY,
BattleHandlers::HPHealItem.add(:ORANBERRY, BattleHandlers::HPHealItem.add(:ORANBERRY,
proc { |item,battler,battle,forced| proc { |item,battler,battle,forced|
next false if !battler.canHeal?
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index) next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
next false if !forced && battler.hp>battler.totalhp/2 next false if !forced && battler.hp>battler.totalhp/2
battle.pbCommonAnimation("EatBerry",battler) if !forced battle.pbCommonAnimation("EatBerry",battler) if !forced
battler.pbRecoverHP(10) battler.pbRecoverHP(10)
itemName = PBItems.getName(item) itemName = PBItems.getName(item)
if forced if forced
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") PBDebug.log("[Item triggered] Forced consuming of #{itemName}")
battle.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis)) battle.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
else else
battle.pbDisplay(_INTL("{1} restored a little HP using its {2}!",battler.pbThis, battle.pbDisplay(_INTL("{1} restored a little HP using its {2}!",battler.pbThis,itemName))
itemName))
end end
next true next true
} }
@@ -170,17 +174,17 @@ BattleHandlers::HPHealItem.add(:SALACBERRY,
BattleHandlers::HPHealItem.add(:SITRUSBERRY, BattleHandlers::HPHealItem.add(:SITRUSBERRY,
proc { |item,battler,battle,forced| proc { |item,battler,battle,forced|
next false if !battler.canHeal?
next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index) next false if !forced && battle.pbCheckOpposingAbility(:UNNERVE,battler.index)
next false if !forced && battler.hp>battler.totalhp/2 next false if !forced && battler.hp>battler.totalhp/2
battle.pbCommonAnimation("EatBerry",battler) if !forced battle.pbCommonAnimation("EatBerry",battler) if !forced
battler.pbRecoverHP(battler.totalhp/4) battler.pbRecoverHP(battler.totalhp/4)
itemName = PBItems.getName(item) itemName = PBItems.getName(item)
if forced if forced
PBDebug.log("[Item triggered] #{battler.pbThis}'s #{itemName}") PBDebug.log("[Item triggered] Forced consuming of #{itemName}")
battle.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis)) battle.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
else else
battle.pbDisplay(_INTL("{1} restored its health using its {2}!",battler.pbThis, battle.pbDisplay(_INTL("{1} restored its health using its {2}!",battler.pbThis,itemName))
itemName))
end end
next true next true
} }