mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-13 07:54:59 +00:00
Some battle method refactoring, fixed typo
This commit is contained in:
@@ -496,162 +496,3 @@ module BattleHandlers
|
||||
return (ret!=nil) ? ret : false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
def pbBattleConfusionBerry(battler,battle,item,forced,flavor,confuseMsg)
|
||||
return false if !forced && !battler.canHeal?
|
||||
return false if !forced && !battler.canConsumePinchBerry?(Settings::MECHANICS_GENERATION >= 7)
|
||||
itemName = GameData::Item.get(item).name
|
||||
fraction_to_heal = 8 # Gens 6 and lower
|
||||
if Settings::MECHANICS_GENERATION == 7
|
||||
fraction_to_heal = 2
|
||||
elsif Settings::MECHANICS_GENERATION >= 8
|
||||
fraction_to_heal = 3
|
||||
end
|
||||
amt = battler.totalhp / fraction_to_heal
|
||||
ripening = false
|
||||
if battler.hasActiveAbility?(:RIPEN)
|
||||
battle.pbShowAbilitySplash(battler, forced)
|
||||
amt *= 2
|
||||
ripening = true
|
||||
end
|
||||
battle.pbCommonAnimation("EatBerry", battler) if !forced
|
||||
battle.pbHideAbilitySplash(battler) if ripening
|
||||
amt = battler.pbRecoverHP(amt)
|
||||
if amt>0
|
||||
if forced
|
||||
PBDebug.log("[Item triggered] Forced consuming of #{itemName}")
|
||||
battle.pbDisplay(_INTL("{1}'s HP was restored.",battler.pbThis))
|
||||
else
|
||||
battle.pbDisplay(_INTL("{1} restored its health using its {2}!",battler.pbThis,itemName))
|
||||
end
|
||||
end
|
||||
flavor_stat = [:ATTACK, :DEFENSE, :SPEED, :SPECIAL_ATTACK, :SPECIAL_DEFENSE][flavor]
|
||||
battler.nature.stat_changes.each do |change|
|
||||
next if change[1] > 0 || change[0] != flavor_stat
|
||||
battle.pbDisplay(confuseMsg)
|
||||
battler.pbConfuse if battler.pbCanConfuseSelf?(false)
|
||||
break
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
def pbBattleStatIncreasingBerry(battler,battle,item,forced,stat,increment=1)
|
||||
return false if !forced && !battler.canConsumePinchBerry?
|
||||
return false if !battler.pbCanRaiseStatStage?(stat,battler)
|
||||
itemName = GameData::Item.get(item).name
|
||||
ripening = false
|
||||
if battler.hasActiveAbility?(:RIPEN)
|
||||
battle.pbShowAbilitySplash(battler, forced)
|
||||
increment *= 2
|
||||
ripening = true
|
||||
end
|
||||
battle.pbCommonAnimation("EatBerry", battler) if !forced
|
||||
battle.pbHideAbilitySplash(battler) if ripening
|
||||
return battler.pbRaiseStatStageByCause(stat, increment, battler, itemName) if !forced
|
||||
PBDebug.log("[Item triggered] Forced consuming of #{itemName}")
|
||||
return battler.pbRaiseStatStage(stat, increment, battler)
|
||||
end
|
||||
|
||||
# For abilities that grant immunity to moves of a particular type, and raises
|
||||
# one of the ability's bearer's stats instead.
|
||||
def pbBattleMoveImmunityStatAbility(user, target, move, moveType, immuneType,
|
||||
stat, increment, battle, show_message)
|
||||
return false if user.index==target.index
|
||||
return false if moveType != immuneType
|
||||
# NOTE: If show_message is false (Dragon Darts only), the stat will not be
|
||||
# raised. This is not how the official games work, but I'm considering
|
||||
# that a bug because Dragon Darts won't be fired at target in the first
|
||||
# place if it's immune, so why would this ability be triggered by them?
|
||||
if show_message
|
||||
battle.pbShowAbilitySplash(target)
|
||||
if target.pbCanRaiseStatStage?(stat, target)
|
||||
if Battle::Scene::USE_ABILITY_SPLASH
|
||||
target.pbRaiseStatStage(stat, increment, target)
|
||||
else
|
||||
target.pbRaiseStatStageByCause(stat, increment, target, target.abilityName)
|
||||
end
|
||||
else
|
||||
if Battle::Scene::USE_ABILITY_SPLASH
|
||||
battle.pbDisplay(_INTL("It doesn't affect {1}...", target.pbThis(true)))
|
||||
else
|
||||
battle.pbDisplay(_INTL("{1}'s {2} made {3} ineffective!",
|
||||
target.pbThis, target.abilityName, move.name))
|
||||
end
|
||||
end
|
||||
battle.pbHideAbilitySplash(target)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
# For abilities that grant immunity to moves of a particular type, and heals the
|
||||
# ability's bearer by 1/4 of its total HP instead.
|
||||
def pbBattleMoveImmunityHealAbility(user, target, move, moveType, immuneType, battle, show_message)
|
||||
return false if user.index==target.index
|
||||
return false if moveType != immuneType
|
||||
# NOTE: If show_message is false (Dragon Darts only), HP will not be healed.
|
||||
# This is not how the official games work, but I'm considering that a
|
||||
# bug because Dragon Darts won't be fired at target in the first place
|
||||
# if it's immune, so why would this ability be triggered by them?
|
||||
if show_message
|
||||
battle.pbShowAbilitySplash(target)
|
||||
if target.canHeal? && target.pbRecoverHP(target.totalhp / 4) > 0
|
||||
if Battle::Scene::USE_ABILITY_SPLASH
|
||||
battle.pbDisplay(_INTL("{1}'s HP was restored.", target.pbThis))
|
||||
else
|
||||
battle.pbDisplay(_INTL("{1}'s {2} restored its HP.", target.pbThis, target.abilityName))
|
||||
end
|
||||
else
|
||||
if Battle::Scene::USE_ABILITY_SPLASH
|
||||
battle.pbDisplay(_INTL("It doesn't affect {1}...", target.pbThis(true)))
|
||||
else
|
||||
battle.pbDisplay(_INTL("{1}'s {2} made {3} ineffective!",
|
||||
target.pbThis, target.abilityName, move.name))
|
||||
end
|
||||
end
|
||||
battle.pbHideAbilitySplash(target)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
def pbBattleGem(user,type,move,mults,moveType)
|
||||
# Pledge moves never consume Gems
|
||||
return if move.is_a?(Battle::Move::PledgeMove)
|
||||
return if moveType != type
|
||||
user.effects[PBEffects::GemConsumed] = user.item_id
|
||||
if Settings::MECHANICS_GENERATION >= 6
|
||||
mults[:base_damage_multiplier] *= 1.3
|
||||
else
|
||||
mults[:base_damage_multiplier] *= 1.5
|
||||
end
|
||||
end
|
||||
|
||||
def pbBattleTypeWeakingBerry(type,moveType,target,mults)
|
||||
return if moveType != type
|
||||
return if !Effectiveness.super_effective?(target.damageState.typeMod) && moveType != :NORMAL
|
||||
mults[:final_damage_multiplier] /= 2
|
||||
target.damageState.berryWeakened = true
|
||||
ripening = false
|
||||
if target.hasActiveAbility?(:RIPEN)
|
||||
target.battle.pbShowAbilitySplash(target)
|
||||
mults[:final_damage_multiplier] /= 2
|
||||
ripening = true
|
||||
end
|
||||
target.battle.pbCommonAnimation("EatBerry",target)
|
||||
target.battle.pbHideAbilitySplash(target) if ripening
|
||||
end
|
||||
|
||||
def pbBattleWeatherAbility(weather,battler,battle,ignorePrimal=false)
|
||||
return if !ignorePrimal && [:HarshSun, :HeavyRain, :StrongWinds].include?(battle.field.weather)
|
||||
return if battle.field.weather==weather
|
||||
battle.pbShowAbilitySplash(battler)
|
||||
if !Battle::Scene::USE_ABILITY_SPLASH
|
||||
battle.pbDisplay(_INTL("{1}'s {2} activated!",battler.pbThis,battler.abilityName))
|
||||
end
|
||||
fixedDuration = false
|
||||
fixedDuration = true if Settings::FIXED_DURATION_WEATHER_FROM_ABILITY &&
|
||||
![:HarshSun, :HeavyRain, :StrongWinds].include?(weather)
|
||||
battle.pbStartWeather(battler,weather,fixedDuration)
|
||||
# NOTE: The ability splash is hidden again in def pbStartWeather.
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user