Added effect of Dragon Darts, fixed incorrect status icon being used in battle

This commit is contained in:
Maruno17
2021-09-04 20:53:43 +01:00
parent 423961e524
commit c7fd147040
14 changed files with 528 additions and 441 deletions

View File

@@ -393,7 +393,7 @@ class PokeBattle_Battler
targets.each do |b|
b.damageState.reset
b.damageState.initialHP = b.hp
if !pbSuccessCheckAgainstTarget(move,user,b)
if !pbSuccessCheckAgainstTarget(move, user, b, targets)
b.damageState.unaffected = true
end
end
@@ -583,12 +583,12 @@ class PokeBattle_Battler
# For two-turn attacks being used in a single turn
move.pbInitialEffect(user,targets,hitNum)
numTargets = 0 # Number of targets that are affected by this hit
targets.each { |b| b.damageState.resetPerHit }
# Count a hit for Parental Bond (if it applies)
user.effects[PBEffects::ParentalBond] -= 1 if user.effects[PBEffects::ParentalBond]>0
# Accuracy check (accuracy/evasion calc)
if hitNum==0 || move.successCheckPerHit?
targets.each do |b|
b.damageState.missed = false
next if b.damageState.unaffected
if pbSuccessCheckPerHit(move,user,b,skipAccuracyCheck)
numTargets += 1
@@ -602,6 +602,7 @@ class PokeBattle_Battler
targets.each do |b|
next if !b.damageState.missed || b.damageState.magicCoat
pbMissMessage(move,user,b)
break if move.pbRepeatHit? # Dragon Darts only shows one failure message
end
move.pbCrashDamage(user)
user.pbItemHPHealCheck
@@ -610,6 +611,9 @@ class PokeBattle_Battler
end
end
# If we get here, this hit will happen and do something
all_targets = targets
targets = move.pbDesignateTargetsForHit(targets, hitNum) # For Dragon Darts
targets.each { |b| b.damageState.resetPerHit }
#---------------------------------------------------------------------------
# Calculate damage to deal
if move.pbDamagingMove?
@@ -637,18 +641,14 @@ class PokeBattle_Battler
GameData::Item.get(user.effects[PBEffects::GemConsumed]).name,move.name))
end
# Messages about missed target(s) (relevant for multi-target moves only)
targets.each do |b|
next if !b.damageState.missed
pbMissMessage(move,user,b)
if !move.pbRepeatHit?
targets.each { |b| pbMissMessage(move, user, b) if b.damageState.missed }
end
# Deal the damage (to all allies first simultaneously, then all foes
# simultaneously)
if move.pbDamagingMove?
# This just changes the HP amounts and does nothing else
targets.each do |b|
next if b.damageState.unaffected
move.pbInflictHPDamage(b)
end
targets.each { |b| move.pbInflictHPDamage(b) if !b.damageState.unaffected }
# Animate the hit flashing and HP bar changes
move.pbAnimateHitAndHPLost(user,targets)
end
@@ -740,6 +740,12 @@ class PokeBattle_Battler
# Fainting
targets.each { |b| b.pbFaint if b && b.fainted? }
user.pbFaint if user.fainted?
# Dragon Darts' second half of attack
if move.pbRepeatHit? && hitNum == 0
if targets.any? { |b| !b.fainted? && !b.damageState.unaffected }
pbProcessMoveHit(move, user, all_targets, 1, skipAccuracyCheck)
end
end
return true
end
end

View File

@@ -98,6 +98,7 @@ class PokeBattle_Battler
return targets if @battle.switching # For Pursuit interrupting a switch
return targets if move.cannotRedirect? || move.targetsPosition?
return targets if !target_data.can_target_one_foe? || targets.length != 1
move.pbModifyTargets(targets, user) # For Dragon Darts
return targets if user.hasActiveAbility?([:PROPELLERTAIL, :STALWART])
priority = @battle.pbPriority(true)
nearOnly = !target_data.can_choose_distant_target?
@@ -171,31 +172,32 @@ class PokeBattle_Battler
#=============================================================================
def pbAddTarget(targets,user,target,move,nearOnly=true,allowUser=false)
return false if !target || (target.fainted? && !move.targetsPosition?)
return false if !(allowUser && user==target) && nearOnly && !user.near?(target)
return false if !allowUser && target == user
return false if nearOnly && !user.near?(target) && target != user
targets.each { |b| return true if b.index==target.index } # Already added
targets.push(target)
return true
end
def pbAddTargetRandomAlly(targets,user,_move,nearOnly=true)
def pbAddTargetRandomAlly(targets, user, move, nearOnly = true)
choices = []
user.eachAlly do |b|
next if nearOnly && !user.near?(b)
pbAddTarget(choices,user,b,nearOnly)
pbAddTarget(choices, user, b, move, nearOnly)
end
if choices.length>0
pbAddTarget(targets,user,choices[@battle.pbRandom(choices.length)],nearOnly)
pbAddTarget(targets, user, choices[@battle.pbRandom(choices.length)], move, nearOnly)
end
end
def pbAddTargetRandomFoe(targets,user,_move,nearOnly=true)
def pbAddTargetRandomFoe(targets, user, move, nearOnly =true)
choices = []
user.eachOpposing do |b|
next if nearOnly && !user.near?(b)
pbAddTarget(choices,user,b,nearOnly)
pbAddTarget(choices, user, b, move, nearOnly)
end
if choices.length>0
pbAddTarget(targets,user,choices[@battle.pbRandom(choices.length)],nearOnly)
pbAddTarget(targets, user, choices[@battle.pbRandom(choices.length)], move, nearOnly)
end
end
end

View File

@@ -292,24 +292,27 @@ class PokeBattle_Battler
# Initial success check against the target. Done once before the first hit.
# Includes move-specific failure conditions, protections and type immunities.
#=============================================================================
def pbSuccessCheckAgainstTarget(move,user,target)
def pbSuccessCheckAgainstTarget(move, user, target, targets)
show_message = move.pbShowFailMessages?(targets)
typeMod = move.pbCalcTypeMod(move.calcType,user,target)
target.damageState.typeMod = typeMod
# Two-turn attacks can't fail here in the charging turn
return true if user.effects[PBEffects::TwoTurnAttack]
# Move-specific failures
return false if move.pbFailsAgainstTarget?(user,target)
return false if move.pbFailsAgainstTarget?(user, target, show_message)
# Immunity to priority moves because of Psychic Terrain
if @battle.field.terrain == :Psychic && target.affectedByTerrain? && target.opposes?(user) &&
@battle.choices[user.index][4]>0 # Move priority saved from pbCalculatePriority
@battle.pbDisplay(_INTL("{1} surrounds itself with psychic terrain!",target.pbThis))
@battle.pbDisplay(_INTL("{1} surrounds itself with psychic terrain!", target.pbThis)) if show_message
return false
end
# Crafty Shield
if target.pbOwnSide.effects[PBEffects::CraftyShield] && user.index!=target.index &&
move.statusMove? && !move.pbTarget(user).targets_all
@battle.pbCommonAnimation("CraftyShield",target)
@battle.pbDisplay(_INTL("Crafty Shield protected {1}!",target.pbThis(true)))
if show_message
@battle.pbCommonAnimation("CraftyShield", target)
@battle.pbDisplay(_INTL("Crafty Shield protected {1}!", target.pbThis(true)))
end
target.damageState.protected = true
@battle.successStates[user.index].protected = true
return false
@@ -319,8 +322,10 @@ class PokeBattle_Battler
if target.pbOwnSide.effects[PBEffects::WideGuard] && user.index!=target.index &&
move.pbTarget(user).num_targets > 1 &&
(Settings::MECHANICS_GENERATION >= 7 || move.damagingMove?)
@battle.pbCommonAnimation("WideGuard",target)
@battle.pbDisplay(_INTL("Wide Guard protected {1}!",target.pbThis(true)))
if show_message
@battle.pbCommonAnimation("WideGuard", target)
@battle.pbDisplay(_INTL("Wide Guard protected {1}!", target.pbThis(true)))
end
target.damageState.protected = true
@battle.successStates[user.index].protected = true
return false
@@ -329,24 +334,30 @@ class PokeBattle_Battler
# Quick Guard
if target.pbOwnSide.effects[PBEffects::QuickGuard] &&
@battle.choices[user.index][4]>0 # Move priority saved from pbCalculatePriority
@battle.pbCommonAnimation("QuickGuard",target)
@battle.pbDisplay(_INTL("Quick Guard protected {1}!",target.pbThis(true)))
if show_message
@battle.pbCommonAnimation("QuickGuard", target)
@battle.pbDisplay(_INTL("Quick Guard protected {1}!", target.pbThis(true)))
end
target.damageState.protected = true
@battle.successStates[user.index].protected = true
return false
end
# Protect
if target.effects[PBEffects::Protect]
@battle.pbCommonAnimation("Protect",target)
@battle.pbDisplay(_INTL("{1} protected itself!",target.pbThis))
if show_message
@battle.pbCommonAnimation("Protect", target)
@battle.pbDisplay(_INTL("{1} protected itself!", target.pbThis))
end
target.damageState.protected = true
@battle.successStates[user.index].protected = true
return false
end
# King's Shield
if target.effects[PBEffects::KingsShield] && move.damagingMove?
@battle.pbCommonAnimation("KingsShield",target)
@battle.pbDisplay(_INTL("{1} protected itself!",target.pbThis))
if show_message
@battle.pbCommonAnimation("KingsShield", target)
@battle.pbDisplay(_INTL("{1} protected itself!", target.pbThis))
end
target.damageState.protected = true
@battle.successStates[user.index].protected = true
if move.pbContactMove?(user) && user.affectedByContactEffect?
@@ -358,8 +369,10 @@ class PokeBattle_Battler
end
# Spiky Shield
if target.effects[PBEffects::SpikyShield]
@battle.pbCommonAnimation("SpikyShield",target)
@battle.pbDisplay(_INTL("{1} protected itself!",target.pbThis))
if show_message
@battle.pbCommonAnimation("SpikyShield", target)
@battle.pbDisplay(_INTL("{1} protected itself!", target.pbThis))
end
target.damageState.protected = true
@battle.successStates[user.index].protected = true
if move.pbContactMove?(user) && user.affectedByContactEffect?
@@ -372,8 +385,10 @@ class PokeBattle_Battler
end
# Baneful Bunker
if target.effects[PBEffects::BanefulBunker]
@battle.pbCommonAnimation("BanefulBunker",target)
@battle.pbDisplay(_INTL("{1} protected itself!",target.pbThis))
if show_message
@battle.pbCommonAnimation("BanefulBunker", target)
@battle.pbDisplay(_INTL("{1} protected itself!", target.pbThis))
end
target.damageState.protected = true
@battle.successStates[user.index].protected = true
if move.pbContactMove?(user) && user.affectedByContactEffect?
@@ -383,8 +398,10 @@ class PokeBattle_Battler
end
# Obstruct
if target.effects[PBEffects::Obstruct] && move.damagingMove?
@battle.pbCommonAnimation("Obstruct",target)
@battle.pbDisplay(_INTL("{1} protected itself!", target.pbThis))
if show_message
@battle.pbCommonAnimation("Obstruct",target)
@battle.pbDisplay(_INTL("{1} protected itself!", target.pbThis))
end
target.damageState.protected = true
@battle.successStates[user.index].protected = true
if move.pbContactMove?(user) && user.affectedByContactEffect?
@@ -397,7 +414,7 @@ class PokeBattle_Battler
# Mat Block
if target.pbOwnSide.effects[PBEffects::MatBlock] && move.damagingMove?
# NOTE: Confirmed no common animation for this effect.
@battle.pbDisplay(_INTL("{1} was blocked by the kicked-up mat!",move.name))
@battle.pbDisplay(_INTL("{1} was blocked by the kicked-up mat!", move.name)) if show_message
target.damageState.protected = true
@battle.successStates[user.index].protected = true
return false
@@ -419,43 +436,45 @@ class PokeBattle_Battler
end
end
# Immunity because of ability (intentionally before type immunity check)
return false if move.pbImmunityByAbility(user,target)
return false if move.pbImmunityByAbility(user, target, show_message)
# Type immunity
if move.pbDamagingMove? && Effectiveness.ineffective?(typeMod)
PBDebug.log("[Target immune] #{target.pbThis}'s type immunity")
@battle.pbDisplay(_INTL("It doesn't affect {1}...",target.pbThis(true)))
@battle.pbDisplay(_INTL("It doesn't affect {1}...", target.pbThis(true))) if show_message
return false
end
# Dark-type immunity to moves made faster by Prankster
if Settings::MECHANICS_GENERATION >= 7 && user.effects[PBEffects::Prankster] &&
target.pbHasType?(:DARK) && target.opposes?(user)
PBDebug.log("[Target immune] #{target.pbThis} is Dark-type and immune to Prankster-boosted moves")
@battle.pbDisplay(_INTL("It doesn't affect {1}...",target.pbThis(true)))
@battle.pbDisplay(_INTL("It doesn't affect {1}...", target.pbThis(true))) if show_message
return false
end
# Airborne-based immunity to Ground moves
if move.damagingMove? && move.calcType == :GROUND &&
target.airborne? && !move.hitsFlyingTargets?
if target.hasActiveAbility?(:LEVITATE) && !@battle.moldBreaker
@battle.pbShowAbilitySplash(target)
if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} avoided the attack!",target.pbThis))
else
@battle.pbDisplay(_INTL("{1} avoided the attack with {2}!",target.pbThis,target.abilityName))
if show_message
@battle.pbShowAbilitySplash(target)
if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("{1} avoided the attack!", target.pbThis))
else
@battle.pbDisplay(_INTL("{1} avoided the attack with {2}!", target.pbThis, target.abilityName))
end
@battle.pbHideAbilitySplash(target)
end
@battle.pbHideAbilitySplash(target)
return false
end
if target.hasActiveItem?(:AIRBALLOON)
@battle.pbDisplay(_INTL("{1}'s {2} makes Ground moves miss!",target.pbThis,target.itemName))
@battle.pbDisplay(_INTL("{1}'s {2} makes Ground moves miss!", target.pbThis, target.itemName)) if show_message
return false
end
if target.effects[PBEffects::MagnetRise]>0
@battle.pbDisplay(_INTL("{1} makes Ground moves miss with Magnet Rise!",target.pbThis))
@battle.pbDisplay(_INTL("{1} makes Ground moves miss with Magnet Rise!", target.pbThis)) if show_message
return false
end
if target.effects[PBEffects::Telekinesis]>0
@battle.pbDisplay(_INTL("{1} makes Ground moves miss with Telekinesis!",target.pbThis))
@battle.pbDisplay(_INTL("{1} makes Ground moves miss with Telekinesis!", target.pbThis)) if show_message
return false
end
end
@@ -463,23 +482,25 @@ class PokeBattle_Battler
if move.powderMove?
if target.pbHasType?(:GRASS) && Settings::MORE_TYPE_EFFECTS
PBDebug.log("[Target immune] #{target.pbThis} is Grass-type and immune to powder-based moves")
@battle.pbDisplay(_INTL("It doesn't affect {1}...",target.pbThis(true)))
@battle.pbDisplay(_INTL("It doesn't affect {1}...", target.pbThis(true))) if show_message
return false
end
if Settings::MECHANICS_GENERATION >= 6
if target.hasActiveAbility?(:OVERCOAT) && !@battle.moldBreaker
@battle.pbShowAbilitySplash(target)
if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("It doesn't affect {1}...",target.pbThis(true)))
else
@battle.pbDisplay(_INTL("It doesn't affect {1} because of its {2}.",target.pbThis(true),target.abilityName))
if show_message
@battle.pbShowAbilitySplash(target)
if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
@battle.pbDisplay(_INTL("It doesn't affect {1}...", target.pbThis(true)))
else
@battle.pbDisplay(_INTL("It doesn't affect {1} because of its {2}.", target.pbThis(true), target.abilityName))
end
@battle.pbHideAbilitySplash(target)
end
@battle.pbHideAbilitySplash(target)
return false
end
if target.hasActiveItem?(:SAFETYGOGGLES)
PBDebug.log("[Item triggered] #{target.pbThis} has Safety Goggles and is immune to powder-based moves")
@battle.pbDisplay(_INTL("It doesn't affect {1}...",target.pbThis(true)))
@battle.pbDisplay(_INTL("It doesn't affect {1}...", target.pbThis(true))) if show_message
return false
end
end
@@ -488,7 +509,7 @@ class PokeBattle_Battler
if target.effects[PBEffects::Substitute]>0 && move.statusMove? &&
!move.ignoresSubstitute?(user) && user.index!=target.index
PBDebug.log("[Target immune] #{target.pbThis} is protected by its Substitute")
@battle.pbDisplay(_INTL("{1} avoided the attack!",target.pbThis(true)))
@battle.pbDisplay(_INTL("{1} avoided the attack!", target.pbThis(true))) if show_message
return false
end
return true