Merge branch 'dev' into ai

This commit is contained in:
Maruno17
2023-03-09 18:31:30 +00:00
30 changed files with 8535 additions and 8488 deletions

View File

@@ -256,8 +256,6 @@ class Battle::Battler
@battle.pbShowAbilitySplash(self, true)
@battle.pbHideAbilitySplash(self)
pbChangeForm(newForm, _INTL("{1} deactivated!", abilityName))
elsif !endOfRound
@battle.pbDisplay(_INTL("{1} deactivated!", abilityName))
end
elsif @form < 7 # Turn into Core form
@battle.pbShowAbilitySplash(self, true)

View File

@@ -692,7 +692,10 @@ class Battle::Battler
end
# HP-healing held items (checks all battlers rather than just targets
# because Flame Burst's splash damage affects non-targets)
@battle.pbPriority(true).each { |b| b.pbItemHPHealCheck }
@battle.pbPriority(true).each do |b|
next if move.preventsBattlerConsumingHealingBerry?(b, targets)
b.pbItemHPHealCheck
end
# Animate battlers fainting (checks all battlers rather than just targets
# because Flame Burst's splash damage affects non-targets)
@battle.pbPriority(true).each { |b| b.pbFaint if b&.fainted? }

View File

@@ -144,6 +144,7 @@ class Battle::Move
def tramplesMinimize?; return @flags.any? { |f| f[/^TramplesMinimize$/i] }; end
def nonLethal?(_user, _target); return false; end # For False Swipe
def preventsBattlerConsumingHealingBerry?(battler, targets); return false; end # For Bug Bite/Pluck
def ignoresSubstitute?(user) # user is the Pokémon using this move
if Settings::MECHANICS_GENERATION >= 6

View File

@@ -378,6 +378,11 @@ end
# User consumes target's berry and gains its effect. (Bug Bite, Pluck)
#===============================================================================
class Battle::Move::UserConsumeTargetBerry < Battle::Move
def preventsBattlerConsumingHealingBerry?(battler, targets)
return targets.any? { |b| b.index == battler.index } &&
battler.item&.is_berry? && Battle::ItemEffects::HPHeal[battler.item]
end
def pbEffectAfterAllHits(user, target)
return if user.fainted? || target.fainted?
return if target.damageState.unaffected || target.damageState.substitute

View File

@@ -471,6 +471,49 @@ class PBAnimation < Array
end
def playTiming(frame, bgGraphic, bgColor, foGraphic, foColor, oldbg = [], oldfo = [], user = nil)
@timing.each do |i|
next if !i.duration || i.duration <= 0
next if i.frame + i.duration < frame || i.frame >= frame
fraction = (frame - i.frame).to_f / i.duration
case i.timingType
when 2
if bgGraphic.bitmap.nil?
bgColor.opacity = oldbg[2] + ((i.opacity - oldbg[2]) * fraction) if i.opacity
cr = (i.colorRed) ? oldbg[3].red + ((i.colorRed - oldbg[3].red) * fraction) : oldbg[3].red
cg = (i.colorGreen) ? oldbg[3].green + ((i.colorGreen - oldbg[3].green) * fraction) : oldbg[3].green
cb = (i.colorBlue) ? oldbg[3].blue + ((i.colorBlue - oldbg[3].blue) * fraction) : oldbg[3].blue
ca = (i.colorAlpha) ? oldbg[3].alpha + ((i.colorAlpha - oldbg[3].alpha) * fraction) : oldbg[3].alpha
bgColor.color = Color.new(cr, cg, cb, ca)
else
bgGraphic.ox = oldbg[0] - ((i.bgX - oldbg[0]) * fraction) if i.bgX
bgGraphic.oy = oldbg[1] - ((i.bgY - oldbg[1]) * fraction) if i.bgY
bgGraphic.opacity = oldbg[2] + ((i.opacity - oldbg[2]) * fraction) if i.opacity
cr = (i.colorRed) ? oldbg[3].red + ((i.colorRed - oldbg[3].red) * fraction) : oldbg[3].red
cg = (i.colorGreen) ? oldbg[3].green + ((i.colorGreen - oldbg[3].green) * fraction) : oldbg[3].green
cb = (i.colorBlue) ? oldbg[3].blue + ((i.colorBlue - oldbg[3].blue) * fraction) : oldbg[3].blue
ca = (i.colorAlpha) ? oldbg[3].alpha + ((i.colorAlpha - oldbg[3].alpha) * fraction) : oldbg[3].alpha
bgGraphic.color = Color.new(cr, cg, cb, ca)
end
when 4
if foGraphic.bitmap.nil?
foColor.opacity = oldfo[2] + ((i.opacity - oldfo[2]) * fraction) if i.opacity
cr = (i.colorRed) ? oldfo[3].red + ((i.colorRed - oldfo[3].red) * fraction) : oldfo[3].red
cg = (i.colorGreen) ? oldfo[3].green + ((i.colorGreen - oldfo[3].green) * fraction) : oldfo[3].green
cb = (i.colorBlue) ? oldfo[3].blue + ((i.colorBlue - oldfo[3].blue) * fraction) : oldfo[3].blue
ca = (i.colorAlpha) ? oldfo[3].alpha + ((i.colorAlpha - oldfo[3].alpha) * fraction) : oldfo[3].alpha
foColor.color = Color.new(cr, cg, cb, ca)
else
foGraphic.ox = oldfo[0] - ((i.bgX - oldfo[0]) * fraction) if i.bgX
foGraphic.oy = oldfo[1] - ((i.bgY - oldfo[1]) * fraction) if i.bgY
foGraphic.opacity = oldfo[2] + ((i.opacity - oldfo[2]) * fraction) if i.opacity
cr = (i.colorRed) ? oldfo[3].red + ((i.colorRed - oldfo[3].red) * fraction) : oldfo[3].red
cg = (i.colorGreen) ? oldfo[3].green + ((i.colorGreen - oldfo[3].green) * fraction) : oldfo[3].green
cb = (i.colorBlue) ? oldfo[3].blue + ((i.colorBlue - oldfo[3].blue) * fraction) : oldfo[3].blue
ca = (i.colorAlpha) ? oldfo[3].alpha + ((i.colorAlpha - oldfo[3].alpha) * fraction) : oldfo[3].alpha
foGraphic.color = Color.new(cr, cg, cb, ca)
end
end
end
@timing.each do |i|
next if i.frame != frame
case i.timingType
@@ -539,52 +582,6 @@ class PBAnimation < Array
end
end
end
@timing.each do |i|
case i.timingType
when 2
next if !i.duration || i.duration <= 0
next if frame < i.frame || frame > i.frame + i.duration
fraction = (frame - i.frame).to_f / i.duration
if bgGraphic.bitmap.nil?
bgColor.opacity = oldbg[2] + ((i.opacity - oldbg[2]) * fraction) if i.opacity
cr = (i.colorRed) ? oldbg[3].red + ((i.colorRed - oldbg[3].red) * fraction) : oldbg[3].red
cg = (i.colorGreen) ? oldbg[3].green + ((i.colorGreen - oldbg[3].green) * fraction) : oldbg[3].green
cb = (i.colorBlue) ? oldbg[3].blue + ((i.colorBlue - oldbg[3].blue) * fraction) : oldbg[3].blue
ca = (i.colorAlpha) ? oldbg[3].alpha + ((i.colorAlpha - oldbg[3].alpha) * fraction) : oldbg[3].alpha
bgColor.color = Color.new(cr, cg, cb, ca)
else
bgGraphic.ox = oldbg[0] - ((i.bgX - oldbg[0]) * fraction) if i.bgX
bgGraphic.oy = oldbg[1] - ((i.bgY - oldbg[1]) * fraction) if i.bgY
bgGraphic.opacity = oldbg[2] + ((i.opacity - oldbg[2]) * fraction) if i.opacity
cr = (i.colorRed) ? oldbg[3].red + ((i.colorRed - oldbg[3].red) * fraction) : oldbg[3].red
cg = (i.colorGreen) ? oldbg[3].green + ((i.colorGreen - oldbg[3].green) * fraction) : oldbg[3].green
cb = (i.colorBlue) ? oldbg[3].blue + ((i.colorBlue - oldbg[3].blue) * fraction) : oldbg[3].blue
ca = (i.colorAlpha) ? oldbg[3].alpha + ((i.colorAlpha - oldbg[3].alpha) * fraction) : oldbg[3].alpha
bgGraphic.color = Color.new(cr, cg, cb, ca)
end
when 4
next if !i.duration || i.duration <= 0
next if frame < i.frame || frame > i.frame + i.duration
fraction = (frame - i.frame).to_f / i.duration
if foGraphic.bitmap.nil?
foColor.opacity = oldfo[2] + ((i.opacity - oldfo[2]) * fraction) if i.opacity
cr = (i.colorRed) ? oldfo[3].red + ((i.colorRed - oldfo[3].red) * fraction) : oldfo[3].red
cg = (i.colorGreen) ? oldfo[3].green + ((i.colorGreen - oldfo[3].green) * fraction) : oldfo[3].green
cb = (i.colorBlue) ? oldfo[3].blue + ((i.colorBlue - oldfo[3].blue) * fraction) : oldfo[3].blue
ca = (i.colorAlpha) ? oldfo[3].alpha + ((i.colorAlpha - oldfo[3].alpha) * fraction) : oldfo[3].alpha
foColor.color = Color.new(cr, cg, cb, ca)
else
foGraphic.ox = oldfo[0] - ((i.bgX - oldfo[0]) * fraction) if i.bgX
foGraphic.oy = oldfo[1] - ((i.bgY - oldfo[1]) * fraction) if i.bgY
foGraphic.opacity = oldfo[2] + ((i.opacity - oldfo[2]) * fraction) if i.opacity
cr = (i.colorRed) ? oldfo[3].red + ((i.colorRed - oldfo[3].red) * fraction) : oldfo[3].red
cg = (i.colorGreen) ? oldfo[3].green + ((i.colorGreen - oldfo[3].green) * fraction) : oldfo[3].green
cb = (i.colorBlue) ? oldfo[3].blue + ((i.colorBlue - oldfo[3].blue) * fraction) : oldfo[3].blue
ca = (i.colorAlpha) ? oldfo[3].alpha + ((i.colorAlpha - oldfo[3].alpha) * fraction) : oldfo[3].alpha
foGraphic.color = Color.new(cr, cg, cb, ca)
end
end
end
end
end

View File

@@ -1708,10 +1708,10 @@ Battle::AbilityEffects::OnBeingHit.add(:ANGERPOINT,
Battle::AbilityEffects::OnBeingHit.add(:COTTONDOWN,
proc { |ability, user, target, move, battle|
next if battle.allBattlers.none? { |b| b.pbCanLowerStatStage?(:DEFENSE, target) }
next if battle.allBattlers.none? { |b| b.index != target.index && b.pbCanLowerStatStage?(:SPEED, target) }
battle.pbShowAbilitySplash(target)
battle.allBattlers.each do |b|
b.pbLowerStatStageByAbility(:SPEED, 1, target, false)
b.pbLowerStatStageByAbility(:SPEED, 1, target, false) if b.index != target.index
end
battle.pbHideAbilitySplash(target)
}