Refactoring of code relating to switching, effect damage and effects that trigger after a move is used

This commit is contained in:
Maruno17
2021-09-19 19:03:17 +01:00
parent f00f030825
commit 1fb3ff5408
24 changed files with 345 additions and 343 deletions

View File

@@ -12,7 +12,10 @@ class PokeBattle_Battler
raise _INTL("HP less than 0") if @hp<0
raise _INTL("HP greater than total HP") if @hp>@totalhp
@battle.scene.pbHPChanged(self,oldHP,anim) if anyAnim && amt>0
@tookDamage = true if amt>0 && registerDamage
if amt > 0 && registerDamage
@droppedBelowHalfHP = true if @hp < @totalhp / 2 && @hp + amt >= @totalhp / 2
@tookDamageThisRound = true
end
return amt
end
@@ -26,6 +29,7 @@ class PokeBattle_Battler
raise _INTL("HP less than 0") if @hp<0
raise _INTL("HP greater than total HP") if @hp>@totalhp
@battle.scene.pbHPChanged(self,oldHP,anim) if anyAnim && amt>0
@droppedBelowHalfHP = false if @hp >= @totalhp / 2
return amt
end
@@ -46,6 +50,14 @@ class PokeBattle_Battler
end
end
def pbTakeEffectDamage(amt, show_anim = true)
hp_lost = pbReduceHP(amt, show_anim)
yield hp_lost if block_given? # Show message
pbItemHPHealCheck
pbAbilitiesOnDamageTaken
pbFaint if fainted?
end
def pbFaint(showMessage=true)
if !fainted?
PBDebug.log("!!!***Can't faint with HP greater than 0")
@@ -310,7 +322,7 @@ class PokeBattle_Battler
@effects[PBEffects::WeightChange] = target.effects[PBEffects::WeightChange]
@battle.scene.pbRefreshOne(@index)
@battle.pbDisplay(_INTL("{1} transformed into {2}!",pbThis,target.pbThis(true)))
pbOnAbilityChanged(oldAbil)
pbOnLosingAbility(oldAbil)
end
def pbHyperMode; end