mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 06:04:59 +00:00
Added decent spacing to all scripts thanks to Rubocop
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
#
|
||||
#===============================================================================
|
||||
class Battle::Peer
|
||||
def pbStorePokemon(player,pkmn)
|
||||
def pbStorePokemon(player, pkmn)
|
||||
if !player.party_full?
|
||||
player.party[player.party.length] = pkmn
|
||||
return -1
|
||||
@@ -14,7 +14,7 @@ class Battle::Peer
|
||||
end
|
||||
oldCurBox = pbCurrentBox
|
||||
storedBox = $PokemonStorage.pbStoreCaught(pkmn)
|
||||
if storedBox<0
|
||||
if storedBox < 0
|
||||
# NOTE: Poké Balls can't be used if storage is full, so you shouldn't ever
|
||||
# see this message.
|
||||
pbDisplayPaused(_INTL("Can't catch any more..."))
|
||||
@@ -33,22 +33,22 @@ class Battle::Peer
|
||||
end
|
||||
|
||||
def pbBoxName(box)
|
||||
return (box<0) ? "" : $PokemonStorage[box].name
|
||||
return (box < 0) ? "" : $PokemonStorage[box].name
|
||||
end
|
||||
|
||||
def pbOnEnteringBattle(battle, battler, pkmn, wild = false)
|
||||
f = MultipleForms.call("getFormOnEnteringBattle",pkmn,wild)
|
||||
f = MultipleForms.call("getFormOnEnteringBattle", pkmn, wild)
|
||||
pkmn.form = f if f
|
||||
battler.form = pkmn.form if battler.form != pkmn.form
|
||||
MultipleForms.call("changePokemonOnEnteringBattle", battler, pkmn, battle)
|
||||
end
|
||||
|
||||
# For switching out, including due to fainting, and for the end of battle
|
||||
def pbOnLeavingBattle(battle,pkmn,usedInBattle,endBattle = false)
|
||||
def pbOnLeavingBattle(battle, pkmn, usedInBattle, endBattle = false)
|
||||
return if !pkmn
|
||||
f = MultipleForms.call("getFormOnLeavingBattle",pkmn,battle,usedInBattle,endBattle)
|
||||
pkmn.form = f if f && pkmn.form!=f
|
||||
pkmn.hp = pkmn.totalhp if pkmn.hp>pkmn.totalhp
|
||||
f = MultipleForms.call("getFormOnLeavingBattle", pkmn, battle, usedInBattle, endBattle)
|
||||
pkmn.form = f if f && pkmn.form != f
|
||||
pkmn.hp = pkmn.totalhp if pkmn.hp > pkmn.totalhp
|
||||
MultipleForms.call("changePokemonOnLeavingBattle", pkmn, battle, usedInBattle, endBattle)
|
||||
end
|
||||
end
|
||||
@@ -58,9 +58,9 @@ end
|
||||
#===============================================================================
|
||||
class Battle::NullPeer
|
||||
def pbOnEnteringBattle(battle, battler, pkmn, wild = false); end
|
||||
def pbOnLeavingBattle(battle,pkmn,usedInBattle,endBattle = false); end
|
||||
def pbOnLeavingBattle(battle, pkmn, usedInBattle, endBattle = false); end
|
||||
|
||||
def pbStorePokemon(player,pkmn)
|
||||
def pbStorePokemon(player, pkmn)
|
||||
player.party[player.party.length] = pkmn if !player.party_full?
|
||||
return -1
|
||||
end
|
||||
|
||||
@@ -31,7 +31,7 @@ module Battle::CatchAndStoreMixin
|
||||
if !pbPlayer.owned?(pkmn.species)
|
||||
pbPlayer.pokedex.set_owned(pkmn.species)
|
||||
if $player.has_pokedex
|
||||
pbDisplayPaused(_INTL("{1}'s data was added to the Pokédex.",pkmn.name))
|
||||
pbDisplayPaused(_INTL("{1}'s data was added to the Pokédex.", pkmn.name))
|
||||
pbPlayer.pokedex.register_last_seen(pkmn)
|
||||
@scene.pbShowPokedex(pkmn.species)
|
||||
end
|
||||
@@ -47,7 +47,7 @@ module Battle::CatchAndStoreMixin
|
||||
#=============================================================================
|
||||
# Throw a Poké Ball
|
||||
#=============================================================================
|
||||
def pbThrowPokeBall(idxBattler,ball,catch_rate = nil,showPlayer = false)
|
||||
def pbThrowPokeBall(idxBattler, ball, catch_rate = nil, showPlayer = false)
|
||||
# Determine which Pokémon you're throwing the Poké Ball at
|
||||
battler = nil
|
||||
if opposes?(idxBattler)
|
||||
@@ -60,32 +60,32 @@ module Battle::CatchAndStoreMixin
|
||||
itemName = GameData::Item.get(ball).name
|
||||
if battler.fainted?
|
||||
if itemName.starts_with_vowel?
|
||||
pbDisplay(_INTL("{1} threw an {2}!",pbPlayer.name,itemName))
|
||||
pbDisplay(_INTL("{1} threw an {2}!", pbPlayer.name, itemName))
|
||||
else
|
||||
pbDisplay(_INTL("{1} threw a {2}!",pbPlayer.name,itemName))
|
||||
pbDisplay(_INTL("{1} threw a {2}!", pbPlayer.name, itemName))
|
||||
end
|
||||
pbDisplay(_INTL("But there was no target..."))
|
||||
return
|
||||
end
|
||||
if itemName.starts_with_vowel?
|
||||
pbDisplayBrief(_INTL("{1} threw an {2}!",pbPlayer.name,itemName))
|
||||
pbDisplayBrief(_INTL("{1} threw an {2}!", pbPlayer.name, itemName))
|
||||
else
|
||||
pbDisplayBrief(_INTL("{1} threw a {2}!",pbPlayer.name,itemName))
|
||||
pbDisplayBrief(_INTL("{1} threw a {2}!", pbPlayer.name, itemName))
|
||||
end
|
||||
# Animation of opposing trainer blocking Poké Balls (unless it's a Snag Ball
|
||||
# at a Shadow Pokémon)
|
||||
if trainerBattle? && !(GameData::Item.get(ball).is_snag_ball? && battler.shadowPokemon?)
|
||||
@scene.pbThrowAndDeflect(ball,1)
|
||||
@scene.pbThrowAndDeflect(ball, 1)
|
||||
pbDisplay(_INTL("The Trainer blocked your Poké Ball! Don't be a thief!"))
|
||||
return
|
||||
end
|
||||
# Calculate the number of shakes (4=capture)
|
||||
pkmn = battler.pokemon
|
||||
@criticalCapture = false
|
||||
numShakes = pbCaptureCalc(pkmn,battler,catch_rate,ball)
|
||||
numShakes = pbCaptureCalc(pkmn, battler, catch_rate, ball)
|
||||
PBDebug.log("[Threw Poké Ball] #{itemName}, #{numShakes} shakes (4=capture)")
|
||||
# Animation of Ball throw, absorb, shake and capture/burst out
|
||||
@scene.pbThrow(ball,numShakes,@criticalCapture,battler.index,showPlayer)
|
||||
@scene.pbThrow(ball, numShakes, @criticalCapture, battler.index, showPlayer)
|
||||
# Outcome message
|
||||
case numShakes
|
||||
when 0
|
||||
@@ -101,9 +101,9 @@ module Battle::CatchAndStoreMixin
|
||||
pbDisplay(_INTL("Gah! It was so close, too!"))
|
||||
Battle::PokeBallEffects.onFailCatch(ball, self, battler)
|
||||
when 4
|
||||
pbDisplayBrief(_INTL("Gotcha! {1} was caught!",pkmn.name))
|
||||
pbDisplayBrief(_INTL("Gotcha! {1} was caught!", pkmn.name))
|
||||
@scene.pbThrowSuccess # Play capture success jingle
|
||||
pbRemoveFromParty(battler.index,battler.pokemonIndex)
|
||||
pbRemoveFromParty(battler.index, battler.pokemonIndex)
|
||||
# Gain Exp
|
||||
if Settings::GAIN_EXP_FOR_CAPTURE
|
||||
battler.captured = true
|
||||
@@ -125,8 +125,8 @@ module Battle::CatchAndStoreMixin
|
||||
pkmn.update_shadow_moves if pkmn.shadowPokemon?
|
||||
pkmn.record_first_moves
|
||||
# Reset form
|
||||
pkmn.forced_form = nil if MultipleForms.hasFunction?(pkmn.species,"getForm")
|
||||
@peer.pbOnLeavingBattle(self,pkmn,true,true)
|
||||
pkmn.forced_form = nil if MultipleForms.hasFunction?(pkmn.species, "getForm")
|
||||
@peer.pbOnLeavingBattle(self, pkmn, true, true)
|
||||
# Make the Poké Ball and data box disappear
|
||||
@scene.pbHideCaptureBall(idxBattler)
|
||||
# Save the Pokémon for storage at the end of battle
|
||||
@@ -141,7 +141,7 @@ module Battle::CatchAndStoreMixin
|
||||
#=============================================================================
|
||||
# Calculate how many shakes a thrown Poké Ball will make (4 = capture)
|
||||
#=============================================================================
|
||||
def pbCaptureCalc(pkmn,battler,catch_rate,ball)
|
||||
def pbCaptureCalc(pkmn, battler, catch_rate, ball)
|
||||
return 4 if $DEBUG && Input.press?(Input::CTRL)
|
||||
# Get a catch rate if one wasn't provided
|
||||
catch_rate = pkmn.species_data.catch_rate if !catch_rate
|
||||
@@ -154,7 +154,7 @@ module Battle::CatchAndStoreMixin
|
||||
# First half of the shakes calculation
|
||||
a = battler.totalhp
|
||||
b = battler.hp
|
||||
x = ((3*a-2*b)*catch_rate.to_f)/(3*a)
|
||||
x = ((3 * a - 2 * b) * catch_rate.to_f) / (3 * a)
|
||||
# Calculation modifiers
|
||||
if battler.status == :SLEEP || battler.status == :FROZEN
|
||||
x *= 2.5
|
||||
@@ -162,40 +162,40 @@ module Battle::CatchAndStoreMixin
|
||||
x *= 1.5
|
||||
end
|
||||
x = x.floor
|
||||
x = 1 if x<1
|
||||
x = 1 if x < 1
|
||||
# Definite capture, no need to perform randomness checks
|
||||
return 4 if x>=255 || Battle::PokeBallEffects.isUnconditional?(ball, self, battler)
|
||||
return 4 if x >= 255 || Battle::PokeBallEffects.isUnconditional?(ball, self, battler)
|
||||
# Second half of the shakes calculation
|
||||
y = (65536 / ((255.0/x)**0.1875)).floor
|
||||
y = (65536 / ((255.0 / x)**0.1875)).floor
|
||||
# Critical capture check
|
||||
if Settings::ENABLE_CRITICAL_CAPTURES
|
||||
dex_modifier = 0
|
||||
numOwned = $player.pokedex.owned_count
|
||||
if numOwned>600
|
||||
if numOwned > 600
|
||||
dex_modifier = 5
|
||||
elsif numOwned>450
|
||||
elsif numOwned > 450
|
||||
dex_modifier = 4
|
||||
elsif numOwned>300
|
||||
elsif numOwned > 300
|
||||
dex_modifier = 3
|
||||
elsif numOwned>150
|
||||
elsif numOwned > 150
|
||||
dex_modifier = 2
|
||||
elsif numOwned>30
|
||||
elsif numOwned > 30
|
||||
dex_modifier = 1
|
||||
end
|
||||
dex_modifier *= 2 if $bag.has?(:CATCHINGCHARM)
|
||||
c = x * dex_modifier / 12
|
||||
# Calculate the number of shakes
|
||||
if c>0 && pbRandom(256)<c
|
||||
if c > 0 && pbRandom(256) < c
|
||||
@criticalCapture = true
|
||||
return 4 if pbRandom(65536)<y
|
||||
return 4 if pbRandom(65536) < y
|
||||
return 0
|
||||
end
|
||||
end
|
||||
# Calculate the number of shakes
|
||||
numShakes = 0
|
||||
for i in 0...4
|
||||
break if numShakes<i
|
||||
numShakes += 1 if pbRandom(65536)<y
|
||||
break if numShakes < i
|
||||
numShakes += 1 if pbRandom(65536) < y
|
||||
end
|
||||
return numShakes
|
||||
end
|
||||
|
||||
@@ -10,7 +10,7 @@ class Battle
|
||||
|
||||
def pbDecisionOnDraw
|
||||
if @rules["selfkoclause"]
|
||||
if self.lastMoveUser<0
|
||||
if self.lastMoveUser < 0
|
||||
# in extreme cases there may be no last move user
|
||||
return 5 # game is a draw
|
||||
elsif opposes?(self.lastMoveUser)
|
||||
@@ -22,15 +22,15 @@ class Battle
|
||||
return __clauses__pbDecisionOnDraw
|
||||
end
|
||||
|
||||
def pbJudgeCheckpoint(user,move = nil)
|
||||
def pbJudgeCheckpoint(user, move = nil)
|
||||
if pbAllFainted?(0) && pbAllFainted?(1)
|
||||
if @rules["drawclause"] # NOTE: Also includes Life Orb (not implemented)
|
||||
if !(move && move.function=="HealUserByHalfOfDamageDone")
|
||||
if !(move && move.function == "HealUserByHalfOfDamageDone")
|
||||
# Not a draw if fainting occurred due to Liquid Ooze
|
||||
@decision = (user.opposes?) ? 1 : 2 # win / loss
|
||||
end
|
||||
elsif @rules["modifiedselfdestructclause"]
|
||||
if move && move.function=="UserFaintsExplosive" # Self-Destruct
|
||||
if move && move.function == "UserFaintsExplosive" # Self-Destruct
|
||||
@decision = (user.opposes?) ? 1 : 2 # win / loss
|
||||
end
|
||||
end
|
||||
@@ -39,12 +39,12 @@ class Battle
|
||||
|
||||
def pbEndOfRoundPhase
|
||||
__clauses__pbEndOfRoundPhase
|
||||
if @rules["suddendeath"] && @decision==0
|
||||
if @rules["suddendeath"] && @decision == 0
|
||||
p1able = pbAbleCount(0)
|
||||
p2able = pbAbleCount(1)
|
||||
if p1able>p2able
|
||||
if p1able > p2able
|
||||
@decision = 1 # loss
|
||||
elsif p1able<p2able
|
||||
elsif p1able < p2able
|
||||
@decision = 2 # win
|
||||
end
|
||||
end
|
||||
@@ -62,16 +62,16 @@ class Battle::Battler
|
||||
@__clauses__aliased = true
|
||||
end
|
||||
|
||||
def pbCanSleep?(user,showMessages,move = nil,ignoreStatus = false)
|
||||
selfsleep = (user && user.index==@index)
|
||||
def pbCanSleep?(user, showMessages, move = nil, ignoreStatus = false)
|
||||
selfsleep = (user && user.index == @index)
|
||||
if ((@battle.rules["modifiedsleepclause"]) || (!selfsleep && @battle.rules["sleepclause"])) &&
|
||||
pbHasStatusPokemon?(:SLEEP)
|
||||
if showMessages
|
||||
@battle.pbDisplay(_INTL("But {1} couldn't sleep!",pbThis(true)))
|
||||
@battle.pbDisplay(_INTL("But {1} couldn't sleep!", pbThis(true)))
|
||||
end
|
||||
return false
|
||||
end
|
||||
return __clauses__pbCanSleep?(user,showMessages,move,ignoreStatus)
|
||||
return __clauses__pbCanSleep?(user, showMessages, move, ignoreStatus)
|
||||
end
|
||||
|
||||
def pbCanSleepYawn?
|
||||
@@ -93,10 +93,10 @@ class Battle::Battler
|
||||
count = 0
|
||||
@battle.pbParty(@index).each do |pkmn|
|
||||
next if !pkmn || pkmn.egg?
|
||||
next if pkmn.status!=status
|
||||
next if pkmn.status != status
|
||||
count += 1
|
||||
end
|
||||
return count>0
|
||||
return count > 0
|
||||
end
|
||||
end
|
||||
|
||||
@@ -105,12 +105,12 @@ end
|
||||
class Battle::Move::RaiseUserEvasion1 # Double Team
|
||||
alias __clauses__pbMoveFailed? pbMoveFailed?
|
||||
|
||||
def pbMoveFailed?(user,targets)
|
||||
def pbMoveFailed?(user, targets)
|
||||
if !damagingMove? && @battle.rules["evasionclause"]
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
return __clauses__pbMoveFailed?(user,targets)
|
||||
return __clauses__pbMoveFailed?(user, targets)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -119,12 +119,12 @@ end
|
||||
class Battle::Move::RaiseUserEvasion2MinimizeUser # Minimize
|
||||
alias __clauses__pbMoveFailed? pbMoveFailed?
|
||||
|
||||
def pbMoveFailed?(user,targets)
|
||||
def pbMoveFailed?(user, targets)
|
||||
if !damagingMove? && @battle.rules["evasionclause"]
|
||||
@battle.pbDisplay(_INTL("But it failed!"))
|
||||
return true
|
||||
end
|
||||
return __clauses__pbMoveFailed?(user,targets)
|
||||
return __clauses__pbMoveFailed?(user, targets)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -220,12 +220,12 @@ class Battle::Move::UserFaintsExplosive # Self-Destruct
|
||||
@__clauses__aliased = true
|
||||
end
|
||||
|
||||
def pbMoveFailed?(user,targets)
|
||||
def pbMoveFailed?(user, targets)
|
||||
if @battle.rules["selfkoclause"]
|
||||
# Check whether no unfainted Pokemon remain in either party
|
||||
count = @battle.pbAbleNonActiveCount(user.idxOwnSide)
|
||||
count += @battle.pbAbleNonActiveCount(user.idxOpposingSide)
|
||||
if count==0
|
||||
if count == 0
|
||||
@battle.pbDisplay("But it failed!")
|
||||
return false
|
||||
end
|
||||
@@ -234,13 +234,13 @@ class Battle::Move::UserFaintsExplosive # Self-Destruct
|
||||
# Check whether no unfainted Pokemon remain in either party
|
||||
count = @battle.pbAbleNonActiveCount(user.idxOwnSide)
|
||||
count += @battle.pbAbleNonActiveCount(user.idxOpposingSide)
|
||||
if count==0
|
||||
@battle.pbDisplay(_INTL("{1}'s team was disqualified!",user.pbThis))
|
||||
if count == 0
|
||||
@battle.pbDisplay(_INTL("{1}'s team was disqualified!", user.pbThis))
|
||||
@battle.decision = (user.opposes?) ? 1 : 2
|
||||
return false
|
||||
end
|
||||
end
|
||||
return __clauses__pbMoveFailed?(user,targets)
|
||||
return __clauses__pbMoveFailed?(user, targets)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -251,7 +251,7 @@ class Battle::Move::StartPerishCountsForAllBattlers # Perish Song
|
||||
|
||||
def pbFailsAgainstTarget?(user, target, show_message)
|
||||
if @battle.rules["perishsongclause"] &&
|
||||
@battle.pbAbleNonActiveCount(user.idxOwnSide)==0
|
||||
@battle.pbAbleNonActiveCount(user.idxOwnSide) == 0
|
||||
@battle.pbDisplay(_INTL("But it failed!")) if show_message
|
||||
return true
|
||||
end
|
||||
@@ -266,7 +266,7 @@ class Battle::Move::AttackerFaintsIfUserFaints # Destiny Bond
|
||||
|
||||
def pbFailsAgainstTarget?(user, target, show_message)
|
||||
if @battle.rules["perishsongclause"] &&
|
||||
@battle.pbAbleNonActiveCount(user.idxOwnSide)==0
|
||||
@battle.pbAbleNonActiveCount(user.idxOwnSide) == 0
|
||||
@battle.pbDisplay(_INTL("But it failed!")) if show_message
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -34,47 +34,47 @@ end
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def yaxisIntersect(x1,y1,x2,y2,px,py)
|
||||
dx = x2-x1
|
||||
dy = y2-y1
|
||||
x = (dx==0) ? 0.0 : (px-x1).to_f/dx
|
||||
y = (dy==0) ? 0.0 : (py-y1).to_f/dy
|
||||
return [x,y]
|
||||
def yaxisIntersect(x1, y1, x2, y2, px, py)
|
||||
dx = x2 - x1
|
||||
dy = y2 - y1
|
||||
x = (dx == 0) ? 0.0 : (px - x1).to_f / dx
|
||||
y = (dy == 0) ? 0.0 : (py - y1).to_f / dy
|
||||
return [x, y]
|
||||
end
|
||||
|
||||
def repositionY(x1,y1,x2,y2,tx,ty)
|
||||
dx = x2-x1
|
||||
dy = y2-y1
|
||||
x = x1+tx*dx.to_f
|
||||
y = y1+ty*dy.to_f
|
||||
return [x,y]
|
||||
def repositionY(x1, y1, x2, y2, tx, ty)
|
||||
dx = x2 - x1
|
||||
dy = y2 - y1
|
||||
x = x1 + tx * dx.to_f
|
||||
y = y1 + ty * dy.to_f
|
||||
return [x, y]
|
||||
end
|
||||
|
||||
def transformPoint(x1,y1,x2,y2, # Source line
|
||||
x3,y3,x4,y4, # Destination line
|
||||
px,py) # Source point
|
||||
ret = yaxisIntersect(x1,y1,x2,y2,px,py)
|
||||
ret2 = repositionY(x3,y3,x4,y4,ret[0],ret[1])
|
||||
def transformPoint(x1, y1, x2, y2, # Source line
|
||||
x3, y3, x4, y4, # Destination line
|
||||
px, py) # Source point
|
||||
ret = yaxisIntersect(x1, y1, x2, y2, px, py)
|
||||
ret2 = repositionY(x3, y3, x4, y4, ret[0], ret[1])
|
||||
return ret2
|
||||
end
|
||||
|
||||
def getSpriteCenter(sprite)
|
||||
return [0,0] if !sprite || sprite.disposed?
|
||||
return [sprite.x,sprite.y] if !sprite.bitmap || sprite.bitmap.disposed?
|
||||
centerX = sprite.src_rect.width/2
|
||||
centerY = sprite.src_rect.height/2
|
||||
offsetX = (centerX-sprite.ox)*sprite.zoom_x
|
||||
offsetY = (centerY-sprite.oy)*sprite.zoom_y
|
||||
return [sprite.x+offsetX,sprite.y+offsetY]
|
||||
return [0, 0] if !sprite || sprite.disposed?
|
||||
return [sprite.x, sprite.y] if !sprite.bitmap || sprite.bitmap.disposed?
|
||||
centerX = sprite.src_rect.width / 2
|
||||
centerY = sprite.src_rect.height / 2
|
||||
offsetX = (centerX - sprite.ox) * sprite.zoom_x
|
||||
offsetY = (centerY - sprite.oy) * sprite.zoom_y
|
||||
return [sprite.x + offsetX, sprite.y + offsetY]
|
||||
end
|
||||
|
||||
def isReversed(src0,src1,dst0,dst1)
|
||||
return false if src0==src1
|
||||
return (dst0>dst1) if src0<src1
|
||||
return (dst0<dst1)
|
||||
def isReversed(src0, src1, dst0, dst1)
|
||||
return false if src0 == src1
|
||||
return (dst0 > dst1) if src0 < src1
|
||||
return (dst0 < dst1)
|
||||
end
|
||||
|
||||
def pbCreateCel(x,y,pattern,focus = 4)
|
||||
def pbCreateCel(x, y, pattern, focus = 4)
|
||||
frame = []
|
||||
frame[AnimFrame::X] = x
|
||||
frame[AnimFrame::Y] = y
|
||||
@@ -121,33 +121,33 @@ def pbConvertRPGAnimation(animation)
|
||||
pbAnim.array.clear
|
||||
yOffset = 0
|
||||
pbAnim.position = animation.position
|
||||
yOffset = -64 if animation.position==0
|
||||
yOffset = 64 if animation.position==2
|
||||
yOffset = -64 if animation.position == 0
|
||||
yOffset = 64 if animation.position == 2
|
||||
for i in 0...animation.frames.length
|
||||
frame = pbAnim.addFrame
|
||||
animFrame = animation.frames[i]
|
||||
for j in 0...animFrame.cell_max
|
||||
data = animFrame.cell_data
|
||||
if data[j,0]==-1
|
||||
if data[j, 0] == -1
|
||||
frame.push(nil)
|
||||
next
|
||||
end
|
||||
if animation.position==3 # Screen
|
||||
if animation.position == 3 # Screen
|
||||
point = transformPoint(
|
||||
-160,80,160,-80,
|
||||
Battle::Scene::FOCUSUSER_X,Battle::Scene::FOCUSUSER_Y,
|
||||
Battle::Scene::FOCUSTARGET_X,Battle::Scene::FOCUSTARGET_Y,
|
||||
data[j,1],data[j,2]
|
||||
-160, 80, 160, -80,
|
||||
Battle::Scene::FOCUSUSER_X, Battle::Scene::FOCUSUSER_Y,
|
||||
Battle::Scene::FOCUSTARGET_X, Battle::Scene::FOCUSTARGET_Y,
|
||||
data[j, 1], data[j, 2]
|
||||
)
|
||||
cel = pbCreateCel(point[0],point[1],data[j,0])
|
||||
cel = pbCreateCel(point[0], point[1], data[j, 0])
|
||||
else
|
||||
cel = pbCreateCel(data[j,1],data[j,2]+yOffset,data[j,0])
|
||||
cel = pbCreateCel(data[j, 1], data[j, 2] + yOffset, data[j, 0])
|
||||
end
|
||||
cel[AnimFrame::ZOOMX] = data[j,3]
|
||||
cel[AnimFrame::ZOOMY] = data[j,3]
|
||||
cel[AnimFrame::ANGLE] = data[j,4]
|
||||
cel[AnimFrame::MIRROR] = data[j,5]
|
||||
cel[AnimFrame::OPACITY] = data[j,6]
|
||||
cel[AnimFrame::ZOOMX] = data[j, 3]
|
||||
cel[AnimFrame::ZOOMY] = data[j, 3]
|
||||
cel[AnimFrame::ANGLE] = data[j, 4]
|
||||
cel[AnimFrame::MIRROR] = data[j, 5]
|
||||
cel[AnimFrame::OPACITY] = data[j, 6]
|
||||
cel[AnimFrame::BLENDTYPE] = 0
|
||||
frame.push(cel)
|
||||
end
|
||||
@@ -173,7 +173,7 @@ end
|
||||
#
|
||||
#===============================================================================
|
||||
class RPG::Animation
|
||||
def self.fromOther(otherAnim,id)
|
||||
def self.fromOther(otherAnim, id)
|
||||
ret = RPG::Animation.new
|
||||
ret.id = id
|
||||
ret.name = otherAnim.name.clone
|
||||
@@ -183,42 +183,42 @@ class RPG::Animation
|
||||
return ret
|
||||
end
|
||||
|
||||
def addSound(frame,se)
|
||||
def addSound(frame, se)
|
||||
timing = RPG::Animation::Timing.new
|
||||
timing.frame = frame
|
||||
timing.se = RPG::AudioFile.new(se,100)
|
||||
timing.se = RPG::AudioFile.new(se, 100)
|
||||
self.timings.push(timing)
|
||||
end
|
||||
|
||||
def addAnimation(otherAnim,frame,x,y) # frame is zero-based
|
||||
if frame+otherAnim.frames.length>=self.frames.length
|
||||
totalframes = frame+otherAnim.frames.length+1
|
||||
def addAnimation(otherAnim, frame, x, y) # frame is zero-based
|
||||
if frame + otherAnim.frames.length >= self.frames.length
|
||||
totalframes = frame + otherAnim.frames.length + 1
|
||||
for i in self.frames.length...totalframes
|
||||
self.frames.push(RPG::Animation::Frame.new)
|
||||
end
|
||||
end
|
||||
self.frame_max = self.frames.length
|
||||
for i in 0...otherAnim.frame_max
|
||||
thisframe = self.frames[frame+i]
|
||||
thisframe = self.frames[frame + i]
|
||||
otherframe = otherAnim.frames[i]
|
||||
cellStart = thisframe.cell_max
|
||||
thisframe.cell_max += otherframe.cell_max
|
||||
thisframe.cell_data.resize(thisframe.cell_max,8)
|
||||
thisframe.cell_data.resize(thisframe.cell_max, 8)
|
||||
for j in 0...otherframe.cell_max
|
||||
thisframe.cell_data[cellStart+j,0] = otherframe.cell_data[j,0]
|
||||
thisframe.cell_data[cellStart+j,1] = otherframe.cell_data[j,1]+x
|
||||
thisframe.cell_data[cellStart+j,2] = otherframe.cell_data[j,2]+y
|
||||
thisframe.cell_data[cellStart+j,3] = otherframe.cell_data[j,3]
|
||||
thisframe.cell_data[cellStart+j,4] = otherframe.cell_data[j,4]
|
||||
thisframe.cell_data[cellStart+j,5] = otherframe.cell_data[j,5]
|
||||
thisframe.cell_data[cellStart+j,6] = otherframe.cell_data[j,6]
|
||||
thisframe.cell_data[cellStart+j,7] = otherframe.cell_data[j,7]
|
||||
thisframe.cell_data[cellStart + j, 0] = otherframe.cell_data[j, 0]
|
||||
thisframe.cell_data[cellStart + j, 1] = otherframe.cell_data[j, 1] + x
|
||||
thisframe.cell_data[cellStart + j, 2] = otherframe.cell_data[j, 2] + y
|
||||
thisframe.cell_data[cellStart + j, 3] = otherframe.cell_data[j, 3]
|
||||
thisframe.cell_data[cellStart + j, 4] = otherframe.cell_data[j, 4]
|
||||
thisframe.cell_data[cellStart + j, 5] = otherframe.cell_data[j, 5]
|
||||
thisframe.cell_data[cellStart + j, 6] = otherframe.cell_data[j, 6]
|
||||
thisframe.cell_data[cellStart + j, 7] = otherframe.cell_data[j, 7]
|
||||
end
|
||||
end
|
||||
for i in 0...otherAnim.timings.length
|
||||
timing = RPG::Animation::Timing.new
|
||||
othertiming = otherAnim.timings[i]
|
||||
timing.frame = frame+othertiming.frame
|
||||
timing.frame = frame + othertiming.frame
|
||||
timing.se = RPG::AudioFile.new(
|
||||
othertiming.se.name.clone,
|
||||
othertiming.se.volume,
|
||||
@@ -229,7 +229,7 @@ class RPG::Animation
|
||||
timing.condition = othertiming.condition
|
||||
self.timings.push(timing)
|
||||
end
|
||||
self.timings.sort! { |a,b| a.frame<=>b.frame }
|
||||
self.timings.sort! { |a, b| a.frame <=> b.frame }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -271,7 +271,7 @@ class PBAnimTiming
|
||||
@colorAlpha = nil
|
||||
@duration = 5
|
||||
@flashScope = 0
|
||||
@flashColor = Color.new(255,255,255,255)
|
||||
@flashColor = Color.new(255, 255, 255, 255)
|
||||
@flashDuration = 5
|
||||
end
|
||||
|
||||
@@ -286,61 +286,61 @@ class PBAnimTiming
|
||||
def to_s
|
||||
case self.timingType
|
||||
when 0
|
||||
return "[#{@frame+1}] Play SE: #{name} (volume #{@volume}, pitch #{@pitch})"
|
||||
return "[#{@frame + 1}] Play SE: #{name} (volume #{@volume}, pitch #{@pitch})"
|
||||
when 1
|
||||
text = sprintf("[%d] Set BG: \"%s\"",@frame+1,name)
|
||||
text = sprintf("[%d] Set BG: \"%s\"", @frame + 1, name)
|
||||
text += sprintf(" (color=%s,%s,%s,%s)",
|
||||
(@colorRed!=nil) ? @colorRed.to_i : "-",
|
||||
(@colorGreen!=nil) ? @colorGreen.to_i : "-",
|
||||
(@colorBlue!=nil) ? @colorBlue.to_i : "-",
|
||||
(@colorAlpha!=nil) ? @colorAlpha.to_i : "-")
|
||||
text += sprintf(" (opacity=%s)",@opacity.to_i)
|
||||
(@colorRed != nil) ? @colorRed.to_i : "-",
|
||||
(@colorGreen != nil) ? @colorGreen.to_i : "-",
|
||||
(@colorBlue != nil) ? @colorBlue.to_i : "-",
|
||||
(@colorAlpha != nil) ? @colorAlpha.to_i : "-")
|
||||
text += sprintf(" (opacity=%s)", @opacity.to_i)
|
||||
text += sprintf(" (coords=%s,%s)",
|
||||
(@bgX!=nil) ? @bgX : "-",
|
||||
(@bgY!=nil) ? @bgY : "-")
|
||||
(@bgX != nil) ? @bgX : "-",
|
||||
(@bgY != nil) ? @bgY : "-")
|
||||
return text
|
||||
when 2
|
||||
text = sprintf("[%d] Change BG: @%d",@frame+1,duration)
|
||||
if @colorRed!=nil || @colorGreen!=nil || @colorBlue!=nil || @colorAlpha!=nil
|
||||
text = sprintf("[%d] Change BG: @%d", @frame + 1, duration)
|
||||
if @colorRed != nil || @colorGreen != nil || @colorBlue != nil || @colorAlpha != nil
|
||||
text += sprintf(" (color=%s,%s,%s,%s)",
|
||||
(@colorRed!=nil) ? @colorRed.to_i : "-",
|
||||
(@colorGreen!=nil) ? @colorGreen.to_i : "-",
|
||||
(@colorBlue!=nil) ? @colorBlue.to_i : "-",
|
||||
(@colorAlpha!=nil) ? @colorAlpha.to_i : "-")
|
||||
(@colorRed != nil) ? @colorRed.to_i : "-",
|
||||
(@colorGreen != nil) ? @colorGreen.to_i : "-",
|
||||
(@colorBlue != nil) ? @colorBlue.to_i : "-",
|
||||
(@colorAlpha != nil) ? @colorAlpha.to_i : "-")
|
||||
end
|
||||
text += sprintf(" (opacity=%s)",@opacity.to_i) if @opacity!=nil
|
||||
if @bgX!=nil || @bgY!=nil
|
||||
text += sprintf(" (opacity=%s)", @opacity.to_i) if @opacity != nil
|
||||
if @bgX != nil || @bgY != nil
|
||||
text += sprintf(" (coords=%s,%s)",
|
||||
(@bgX!=nil) ? @bgX : "-",
|
||||
(@bgY!=nil) ? @bgY : "-")
|
||||
(@bgX != nil) ? @bgX : "-",
|
||||
(@bgY != nil) ? @bgY : "-")
|
||||
end
|
||||
return text
|
||||
when 3
|
||||
text = sprintf("[%d] Set FG: \"%s\"",@frame+1,name)
|
||||
text = sprintf("[%d] Set FG: \"%s\"", @frame + 1, name)
|
||||
text += sprintf(" (color=%s,%s,%s,%s)",
|
||||
(@colorRed!=nil) ? @colorRed.to_i : "-",
|
||||
(@colorGreen!=nil) ? @colorGreen.to_i : "-",
|
||||
(@colorBlue!=nil) ? @colorBlue.to_i : "-",
|
||||
(@colorAlpha!=nil) ? @colorAlpha.to_i : "-")
|
||||
text += sprintf(" (opacity=%s)",@opacity.to_i)
|
||||
(@colorRed != nil) ? @colorRed.to_i : "-",
|
||||
(@colorGreen != nil) ? @colorGreen.to_i : "-",
|
||||
(@colorBlue != nil) ? @colorBlue.to_i : "-",
|
||||
(@colorAlpha != nil) ? @colorAlpha.to_i : "-")
|
||||
text += sprintf(" (opacity=%s)", @opacity.to_i)
|
||||
text += sprintf(" (coords=%s,%s)",
|
||||
(@bgX!=nil) ? @bgX : "-",
|
||||
(@bgY!=nil) ? @bgY : "-")
|
||||
(@bgX != nil) ? @bgX : "-",
|
||||
(@bgY != nil) ? @bgY : "-")
|
||||
return text
|
||||
when 4
|
||||
text = sprintf("[%d] Change FG: @%d",@frame+1,duration)
|
||||
if @colorRed!=nil || @colorGreen!=nil || @colorBlue!=nil || @colorAlpha!=nil
|
||||
text = sprintf("[%d] Change FG: @%d", @frame + 1, duration)
|
||||
if @colorRed != nil || @colorGreen != nil || @colorBlue != nil || @colorAlpha != nil
|
||||
text += sprintf(" (color=%s,%s,%s,%s)",
|
||||
(@colorRed!=nil) ? @colorRed.to_i : "-",
|
||||
(@colorGreen!=nil) ? @colorGreen.to_i : "-",
|
||||
(@colorBlue!=nil) ? @colorBlue.to_i : "-",
|
||||
(@colorAlpha!=nil) ? @colorAlpha.to_i : "-")
|
||||
(@colorRed != nil) ? @colorRed.to_i : "-",
|
||||
(@colorGreen != nil) ? @colorGreen.to_i : "-",
|
||||
(@colorBlue != nil) ? @colorBlue.to_i : "-",
|
||||
(@colorAlpha != nil) ? @colorAlpha.to_i : "-")
|
||||
end
|
||||
text += sprintf(" (opacity=%s)",@opacity.to_i) if @opacity!=nil
|
||||
if @bgX!=nil || @bgY!=nil
|
||||
text += sprintf(" (opacity=%s)", @opacity.to_i) if @opacity != nil
|
||||
if @bgX != nil || @bgY != nil
|
||||
text += sprintf(" (coords=%s,%s)",
|
||||
(@bgX!=nil) ? @bgX : "-",
|
||||
(@bgY!=nil) ? @bgY : "-")
|
||||
(@bgX != nil) ? @bgX : "-",
|
||||
(@bgY != nil) ? @bgY : "-")
|
||||
end
|
||||
return text
|
||||
end
|
||||
@@ -361,7 +361,7 @@ class PBAnimations < Array
|
||||
def initialize(size = 1)
|
||||
@array = []
|
||||
@selected = 0
|
||||
size = 1 if size<1 # Always create at least one animation
|
||||
size = 1 if size < 1 # Always create at least one animation
|
||||
size.times do
|
||||
@array.push(PBAnimation.new)
|
||||
end
|
||||
@@ -379,7 +379,7 @@ class PBAnimations < Array
|
||||
return @array[i]
|
||||
end
|
||||
|
||||
def []=(i,value)
|
||||
def []=(i, value)
|
||||
@array[i] = value
|
||||
end
|
||||
|
||||
@@ -387,8 +387,8 @@ class PBAnimations < Array
|
||||
@array.compact!
|
||||
end
|
||||
|
||||
def insert(index,val)
|
||||
@array.insert(index,val)
|
||||
def insert(index, val)
|
||||
@array.insert(index, val)
|
||||
end
|
||||
|
||||
def delete_at(index)
|
||||
@@ -398,7 +398,7 @@ class PBAnimations < Array
|
||||
def resize(len)
|
||||
idxStart = @array.length
|
||||
idxEnd = len
|
||||
if idxStart>idxEnd
|
||||
if idxStart > idxEnd
|
||||
for i in idxEnd...idxStart
|
||||
@array.pop
|
||||
end
|
||||
@@ -407,7 +407,7 @@ class PBAnimations < Array
|
||||
@array.push(PBAnimation.new)
|
||||
end
|
||||
end
|
||||
self.selected = len if self.selected>=len
|
||||
self.selected = len if self.selected >= len
|
||||
end
|
||||
end
|
||||
|
||||
@@ -440,7 +440,7 @@ class PBAnimation < Array
|
||||
@hue = 0
|
||||
@position = 4 # 1=target, 2=user, 3=user and target, 4=screen
|
||||
@array = []
|
||||
size = 1 if size<1 # Always create at least one frame
|
||||
size = 1 if size < 1 # Always create at least one frame
|
||||
size.times { addFrame }
|
||||
@timing = []
|
||||
@scope = 0
|
||||
@@ -458,7 +458,7 @@ class PBAnimation < Array
|
||||
return @array[i]
|
||||
end
|
||||
|
||||
def []=(i,value)
|
||||
def []=(i, value)
|
||||
@array[i] = value
|
||||
end
|
||||
|
||||
@@ -471,10 +471,10 @@ class PBAnimation < Array
|
||||
end
|
||||
|
||||
def resize(len)
|
||||
if len<@array.length
|
||||
@array[len,@array.length-len] = []
|
||||
elsif len>@array.length
|
||||
(len-@array.length).times do
|
||||
if len < @array.length
|
||||
@array[len, @array.length - len] = []
|
||||
elsif len > @array.length
|
||||
(len - @array.length).times do
|
||||
addFrame
|
||||
end
|
||||
end
|
||||
@@ -484,128 +484,128 @@ class PBAnimation < Array
|
||||
pos = @array.length
|
||||
@array[pos] = []
|
||||
# Move's user
|
||||
@array[pos][0] = pbCreateCel(Battle::Scene::FOCUSUSER_X, Battle::Scene::FOCUSUSER_Y,-1)
|
||||
@array[pos][0] = pbCreateCel(Battle::Scene::FOCUSUSER_X, Battle::Scene::FOCUSUSER_Y, -1)
|
||||
@array[pos][0][AnimFrame::FOCUS] = 2
|
||||
@array[pos][0][AnimFrame::LOCKED] = 1
|
||||
# Move's target
|
||||
@array[pos][1] = pbCreateCel(Battle::Scene::FOCUSTARGET_X, Battle::Scene::FOCUSTARGET_Y,-2)
|
||||
@array[pos][1] = pbCreateCel(Battle::Scene::FOCUSTARGET_X, Battle::Scene::FOCUSTARGET_Y, -2)
|
||||
@array[pos][1][AnimFrame::FOCUS] = 1
|
||||
@array[pos][1][AnimFrame::LOCKED] = 1
|
||||
return @array[pos]
|
||||
end
|
||||
|
||||
def playTiming(frame,bgGraphic,bgColor,foGraphic,foColor,oldbg = [],oldfo = [],user = nil)
|
||||
def playTiming(frame, bgGraphic, bgColor, foGraphic, foColor, oldbg = [], oldfo = [], user = nil)
|
||||
for i in @timing
|
||||
next if i.frame!=frame
|
||||
next if i.frame != frame
|
||||
case i.timingType
|
||||
when 0 # Play SE
|
||||
if i.name && i.name!=""
|
||||
pbSEPlay("Anim/"+i.name,i.volume,i.pitch)
|
||||
if i.name && i.name != ""
|
||||
pbSEPlay("Anim/" + i.name, i.volume, i.pitch)
|
||||
elsif user && user.pokemon
|
||||
name = GameData::Species.cry_filename_from_pokemon(user.pokemon)
|
||||
pbSEPlay(name,i.volume,i.pitch) if name
|
||||
pbSEPlay(name, i.volume, i.pitch) if name
|
||||
end
|
||||
# if sprite
|
||||
# sprite.flash(i.flashColor,i.flashDuration*2) if i.flashScope==1
|
||||
# sprite.flash(nil,i.flashDuration*2) if i.flashScope==3
|
||||
# end
|
||||
when 1 # Set background graphic (immediate)
|
||||
if i.name && i.name!=""
|
||||
bgGraphic.setBitmap("Graphics/Animations/"+i.name)
|
||||
if i.name && i.name != ""
|
||||
bgGraphic.setBitmap("Graphics/Animations/" + i.name)
|
||||
bgGraphic.ox = -i.bgX || 0
|
||||
bgGraphic.oy = -i.bgY || 0
|
||||
bgGraphic.color = Color.new(i.colorRed || 0,i.colorGreen || 0,i.colorBlue || 0,i.colorAlpha || 0)
|
||||
bgGraphic.color = Color.new(i.colorRed || 0, i.colorGreen || 0, i.colorBlue || 0, i.colorAlpha || 0)
|
||||
bgGraphic.opacity = i.opacity || 0
|
||||
bgColor.opacity = 0
|
||||
else
|
||||
bgGraphic.setBitmap(nil)
|
||||
bgGraphic.opacity = 0
|
||||
bgColor.color = Color.new(i.colorRed || 0,i.colorGreen || 0,i.colorBlue || 0,i.colorAlpha || 0)
|
||||
bgColor.color = Color.new(i.colorRed || 0, i.colorGreen || 0, i.colorBlue || 0, i.colorAlpha || 0)
|
||||
bgColor.opacity = i.opacity || 0
|
||||
end
|
||||
when 2 # Move/recolour background graphic
|
||||
if bgGraphic.bitmap!=nil
|
||||
if bgGraphic.bitmap != nil
|
||||
oldbg[0] = bgGraphic.ox || 0
|
||||
oldbg[1] = bgGraphic.oy || 0
|
||||
oldbg[2] = bgGraphic.opacity || 0
|
||||
oldbg[3] = bgGraphic.color.clone || Color.new(0,0,0,0)
|
||||
oldbg[3] = bgGraphic.color.clone || Color.new(0, 0, 0, 0)
|
||||
else
|
||||
oldbg[0] = 0
|
||||
oldbg[1] = 0
|
||||
oldbg[2] = bgColor.opacity || 0
|
||||
oldbg[3] = bgColor.color.clone || Color.new(0,0,0,0)
|
||||
oldbg[3] = bgColor.color.clone || Color.new(0, 0, 0, 0)
|
||||
end
|
||||
when 3 # Set foreground graphic (immediate)
|
||||
if i.name && i.name!=""
|
||||
foGraphic.setBitmap("Graphics/Animations/"+i.name)
|
||||
if i.name && i.name != ""
|
||||
foGraphic.setBitmap("Graphics/Animations/" + i.name)
|
||||
foGraphic.ox = -i.bgX || 0
|
||||
foGraphic.oy = -i.bgY || 0
|
||||
foGraphic.color = Color.new(i.colorRed || 0,i.colorGreen || 0,i.colorBlue || 0,i.colorAlpha || 0)
|
||||
foGraphic.color = Color.new(i.colorRed || 0, i.colorGreen || 0, i.colorBlue || 0, i.colorAlpha || 0)
|
||||
foGraphic.opacity = i.opacity || 0
|
||||
foColor.opacity = 0
|
||||
else
|
||||
foGraphic.setBitmap(nil)
|
||||
foGraphic.opacity = 0
|
||||
foColor.color = Color.new(i.colorRed || 0,i.colorGreen || 0,i.colorBlue || 0,i.colorAlpha || 0)
|
||||
foColor.color = Color.new(i.colorRed || 0, i.colorGreen || 0, i.colorBlue || 0, i.colorAlpha || 0)
|
||||
foColor.opacity = i.opacity || 0
|
||||
end
|
||||
when 4 # Move/recolour foreground graphic
|
||||
if foGraphic.bitmap!=nil
|
||||
if foGraphic.bitmap != nil
|
||||
oldfo[0] = foGraphic.ox || 0
|
||||
oldfo[1] = foGraphic.oy || 0
|
||||
oldfo[2] = foGraphic.opacity || 0
|
||||
oldfo[3] = foGraphic.color.clone || Color.new(0,0,0,0)
|
||||
oldfo[3] = foGraphic.color.clone || Color.new(0, 0, 0, 0)
|
||||
else
|
||||
oldfo[0] = 0
|
||||
oldfo[1] = 0
|
||||
oldfo[2] = foColor.opacity || 0
|
||||
oldfo[3] = foColor.color.clone || Color.new(0,0,0,0)
|
||||
oldfo[3] = foColor.color.clone || Color.new(0, 0, 0, 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
for i in @timing
|
||||
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
|
||||
bgGraphic.ox = oldbg[0]-(i.bgX-oldbg[0])*fraction if i.bgX!=nil
|
||||
bgGraphic.oy = oldbg[1]-(i.bgY-oldbg[1])*fraction if i.bgY!=nil
|
||||
bgGraphic.opacity = oldbg[2]+(i.opacity-oldbg[2])*fraction if i.opacity!=nil
|
||||
cr = (i.colorRed!=nil) ? oldbg[3].red+(i.colorRed-oldbg[3].red)*fraction : oldbg[3].red
|
||||
cg = (i.colorGreen!=nil) ? oldbg[3].green+(i.colorGreen-oldbg[3].green)*fraction : oldbg[3].green
|
||||
cb = (i.colorBlue!=nil) ? oldbg[3].blue+(i.colorBlue-oldbg[3].blue)*fraction : oldbg[3].blue
|
||||
ca = (i.colorAlpha!=nil) ? oldbg[3].alpha+(i.colorAlpha-oldbg[3].alpha)*fraction : oldbg[3].alpha
|
||||
bgGraphic.color = Color.new(cr,cg,cb,ca)
|
||||
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
|
||||
bgGraphic.ox = oldbg[0] - (i.bgX - oldbg[0]) * fraction if i.bgX != nil
|
||||
bgGraphic.oy = oldbg[1] - (i.bgY - oldbg[1]) * fraction if i.bgY != nil
|
||||
bgGraphic.opacity = oldbg[2] + (i.opacity - oldbg[2]) * fraction if i.opacity != nil
|
||||
cr = (i.colorRed != nil) ? oldbg[3].red + (i.colorRed - oldbg[3].red) * fraction : oldbg[3].red
|
||||
cg = (i.colorGreen != nil) ? oldbg[3].green + (i.colorGreen - oldbg[3].green) * fraction : oldbg[3].green
|
||||
cb = (i.colorBlue != nil) ? oldbg[3].blue + (i.colorBlue - oldbg[3].blue) * fraction : oldbg[3].blue
|
||||
ca = (i.colorAlpha != nil) ? oldbg[3].alpha + (i.colorAlpha - oldbg[3].alpha) * fraction : oldbg[3].alpha
|
||||
bgGraphic.color = Color.new(cr, cg, cb, ca)
|
||||
else
|
||||
bgColor.opacity = oldbg[2]+(i.opacity-oldbg[2])*fraction if i.opacity!=nil
|
||||
cr = (i.colorRed!=nil) ? oldbg[3].red+(i.colorRed-oldbg[3].red)*fraction : oldbg[3].red
|
||||
cg = (i.colorGreen!=nil) ? oldbg[3].green+(i.colorGreen-oldbg[3].green)*fraction : oldbg[3].green
|
||||
cb = (i.colorBlue!=nil) ? oldbg[3].blue+(i.colorBlue-oldbg[3].blue)*fraction : oldbg[3].blue
|
||||
ca = (i.colorAlpha!=nil) ? oldbg[3].alpha+(i.colorAlpha-oldbg[3].alpha)*fraction : oldbg[3].alpha
|
||||
bgColor.color = Color.new(cr,cg,cb,ca)
|
||||
bgColor.opacity = oldbg[2] + (i.opacity - oldbg[2]) * fraction if i.opacity != nil
|
||||
cr = (i.colorRed != nil) ? oldbg[3].red + (i.colorRed - oldbg[3].red) * fraction : oldbg[3].red
|
||||
cg = (i.colorGreen != nil) ? oldbg[3].green + (i.colorGreen - oldbg[3].green) * fraction : oldbg[3].green
|
||||
cb = (i.colorBlue != nil) ? oldbg[3].blue + (i.colorBlue - oldbg[3].blue) * fraction : oldbg[3].blue
|
||||
ca = (i.colorAlpha != nil) ? oldbg[3].alpha + (i.colorAlpha - oldbg[3].alpha) * fraction : oldbg[3].alpha
|
||||
bgColor.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
|
||||
foGraphic.ox = oldfo[0]-(i.bgX-oldfo[0])*fraction if i.bgX!=nil
|
||||
foGraphic.oy = oldfo[1]-(i.bgY-oldfo[1])*fraction if i.bgY!=nil
|
||||
foGraphic.opacity = oldfo[2]+(i.opacity-oldfo[2])*fraction if i.opacity!=nil
|
||||
cr = (i.colorRed!=nil) ? oldfo[3].red+(i.colorRed-oldfo[3].red)*fraction : oldfo[3].red
|
||||
cg = (i.colorGreen!=nil) ? oldfo[3].green+(i.colorGreen-oldfo[3].green)*fraction : oldfo[3].green
|
||||
cb = (i.colorBlue!=nil) ? oldfo[3].blue+(i.colorBlue-oldfo[3].blue)*fraction : oldfo[3].blue
|
||||
ca = (i.colorAlpha!=nil) ? oldfo[3].alpha+(i.colorAlpha-oldfo[3].alpha)*fraction : oldfo[3].alpha
|
||||
foGraphic.color = Color.new(cr,cg,cb,ca)
|
||||
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
|
||||
foGraphic.ox = oldfo[0] - (i.bgX - oldfo[0]) * fraction if i.bgX != nil
|
||||
foGraphic.oy = oldfo[1] - (i.bgY - oldfo[1]) * fraction if i.bgY != nil
|
||||
foGraphic.opacity = oldfo[2] + (i.opacity - oldfo[2]) * fraction if i.opacity != nil
|
||||
cr = (i.colorRed != nil) ? oldfo[3].red + (i.colorRed - oldfo[3].red) * fraction : oldfo[3].red
|
||||
cg = (i.colorGreen != nil) ? oldfo[3].green + (i.colorGreen - oldfo[3].green) * fraction : oldfo[3].green
|
||||
cb = (i.colorBlue != nil) ? oldfo[3].blue + (i.colorBlue - oldfo[3].blue) * fraction : oldfo[3].blue
|
||||
ca = (i.colorAlpha != nil) ? oldfo[3].alpha + (i.colorAlpha - oldfo[3].alpha) * fraction : oldfo[3].alpha
|
||||
foGraphic.color = Color.new(cr, cg, cb, ca)
|
||||
else
|
||||
foColor.opacity = oldfo[2]+(i.opacity-oldfo[2])*fraction if i.opacity!=nil
|
||||
cr = (i.colorRed!=nil) ? oldfo[3].red+(i.colorRed-oldfo[3].red)*fraction : oldfo[3].red
|
||||
cg = (i.colorGreen!=nil) ? oldfo[3].green+(i.colorGreen-oldfo[3].green)*fraction : oldfo[3].green
|
||||
cb = (i.colorBlue!=nil) ? oldfo[3].blue+(i.colorBlue-oldfo[3].blue)*fraction : oldfo[3].blue
|
||||
ca = (i.colorAlpha!=nil) ? oldfo[3].alpha+(i.colorAlpha-oldfo[3].alpha)*fraction : oldfo[3].alpha
|
||||
foColor.color = Color.new(cr,cg,cb,ca)
|
||||
foColor.opacity = oldfo[2] + (i.opacity - oldfo[2]) * fraction if i.opacity != nil
|
||||
cr = (i.colorRed != nil) ? oldfo[3].red + (i.colorRed - oldfo[3].red) * fraction : oldfo[3].red
|
||||
cg = (i.colorGreen != nil) ? oldfo[3].green + (i.colorGreen - oldfo[3].green) * fraction : oldfo[3].green
|
||||
cb = (i.colorBlue != nil) ? oldfo[3].blue + (i.colorBlue - oldfo[3].blue) * fraction : oldfo[3].blue
|
||||
ca = (i.colorAlpha != nil) ? oldfo[3].alpha + (i.colorAlpha - oldfo[3].alpha) * fraction : oldfo[3].alpha
|
||||
foColor.color = Color.new(cr, cg, cb, ca)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -617,35 +617,35 @@ end
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def pbSpriteSetAnimFrame(sprite,frame,user = nil,target = nil,inEditor = false)
|
||||
def pbSpriteSetAnimFrame(sprite, frame, user = nil, target = nil, inEditor = false)
|
||||
return if !sprite
|
||||
if !frame
|
||||
sprite.visible = false
|
||||
sprite.src_rect = Rect.new(0,0,1,1)
|
||||
sprite.src_rect = Rect.new(0, 0, 1, 1)
|
||||
return
|
||||
end
|
||||
sprite.blend_type = frame[AnimFrame::BLENDTYPE]
|
||||
sprite.angle = frame[AnimFrame::ANGLE]
|
||||
sprite.mirror = (frame[AnimFrame::MIRROR]>0)
|
||||
sprite.mirror = (frame[AnimFrame::MIRROR] > 0)
|
||||
sprite.opacity = frame[AnimFrame::OPACITY]
|
||||
sprite.visible = true
|
||||
if !frame[AnimFrame::VISIBLE]==1 && inEditor
|
||||
sprite.opacity /= 2
|
||||
if !frame[AnimFrame::VISIBLE] == 1 && inEditor
|
||||
sprite.opacity /= 2
|
||||
else
|
||||
sprite.visible = (frame[AnimFrame::VISIBLE]==1)
|
||||
sprite.visible = (frame[AnimFrame::VISIBLE] == 1)
|
||||
end
|
||||
pattern = frame[AnimFrame::PATTERN]
|
||||
if pattern>=0
|
||||
if pattern >= 0
|
||||
animwidth = 192
|
||||
sprite.src_rect.set((pattern%5)*animwidth,(pattern/5)*animwidth,
|
||||
animwidth,animwidth)
|
||||
sprite.src_rect.set((pattern % 5) * animwidth, (pattern / 5) * animwidth,
|
||||
animwidth, animwidth)
|
||||
else
|
||||
sprite.src_rect.set(0,0,
|
||||
sprite.src_rect.set(0, 0,
|
||||
(sprite.bitmap) ? sprite.bitmap.width : 128,
|
||||
(sprite.bitmap) ? sprite.bitmap.height : 128)
|
||||
end
|
||||
sprite.zoom_x = frame[AnimFrame::ZOOMX]/100.0
|
||||
sprite.zoom_y = frame[AnimFrame::ZOOMY]/100.0
|
||||
sprite.zoom_x = frame[AnimFrame::ZOOMX] / 100.0
|
||||
sprite.zoom_y = frame[AnimFrame::ZOOMY] / 100.0
|
||||
sprite.color.set(
|
||||
frame[AnimFrame::COLORRED],
|
||||
frame[AnimFrame::COLORGREEN],
|
||||
@@ -658,11 +658,11 @@ def pbSpriteSetAnimFrame(sprite,frame,user = nil,target = nil,inEditor = false)
|
||||
frame[AnimFrame::TONEBLUE],
|
||||
frame[AnimFrame::TONEGRAY]
|
||||
)
|
||||
sprite.ox = sprite.src_rect.width/2
|
||||
sprite.oy = sprite.src_rect.height/2
|
||||
sprite.ox = sprite.src_rect.width / 2
|
||||
sprite.oy = sprite.src_rect.height / 2
|
||||
sprite.x = frame[AnimFrame::X]
|
||||
sprite.y = frame[AnimFrame::Y]
|
||||
if sprite!=user && sprite!=target
|
||||
if sprite != user && sprite != target
|
||||
case frame[AnimFrame::PRIORITY]
|
||||
when 0 # Behind everything
|
||||
sprite.z = 10
|
||||
@@ -671,18 +671,18 @@ def pbSpriteSetAnimFrame(sprite,frame,user = nil,target = nil,inEditor = false)
|
||||
when 2 # Just behind focus
|
||||
case frame[AnimFrame::FOCUS]
|
||||
when 1 # Focused on target
|
||||
sprite.z = (target) ? target.z-1 : 20
|
||||
sprite.z = (target) ? target.z - 1 : 20
|
||||
when 2 # Focused on user
|
||||
sprite.z = (user) ? user.z-1 : 20
|
||||
sprite.z = (user) ? user.z - 1 : 20
|
||||
else # Focused on user and target, or screen
|
||||
sprite.z = 20
|
||||
end
|
||||
when 3 # Just in front of focus
|
||||
case frame[AnimFrame::FOCUS]
|
||||
when 1 # Focused on target
|
||||
sprite.z = (target) ? target.z+1 : 80
|
||||
sprite.z = (target) ? target.z + 1 : 80
|
||||
when 2 # Focused on user
|
||||
sprite.z = (user) ? user.z+1 : 80
|
||||
sprite.z = (user) ? user.z + 1 : 80
|
||||
else # Focused on user and target, or screen
|
||||
sprite.z = 80
|
||||
end
|
||||
@@ -702,7 +702,7 @@ class PBAnimationPlayerX
|
||||
|
||||
MAX_SPRITES = 60
|
||||
|
||||
def initialize(animation,user,target,scene = nil,oppMove = false,inEditor = false)
|
||||
def initialize(animation, user, target, scene = nil, oppMove = false, inEditor = false)
|
||||
@animation = animation
|
||||
@user = (oppMove) ? target : user # Just used for playing user's cry
|
||||
@usersprite = (user) ? scene.sprites["pokemon_#{user.index}"] : nil
|
||||
@@ -715,7 +715,7 @@ class PBAnimationPlayerX
|
||||
@looping = false
|
||||
@animbitmap = nil # Animation sheet graphic
|
||||
@frame = -1
|
||||
@framesPerTick = [Graphics.frame_rate/20,1].max # 20 ticks per second
|
||||
@framesPerTick = [Graphics.frame_rate / 20, 1].max # 20 ticks per second
|
||||
@srcLine = nil
|
||||
@dstLine = nil
|
||||
@userOrig = getSpriteCenter(@usersprite)
|
||||
@@ -727,7 +727,7 @@ class PBAnimationPlayerX
|
||||
|
||||
def initializeSprites
|
||||
# Create animation sprites (0=user's sprite, 1=target's sprite)
|
||||
@animsprites = []
|
||||
@animsprites = []
|
||||
@animsprites[0] = @usersprite
|
||||
@animsprites[1] = @targetsprite
|
||||
for i in 2...MAX_SPRITES
|
||||
@@ -736,7 +736,7 @@ class PBAnimationPlayerX
|
||||
@animsprites[i].visible = false
|
||||
end
|
||||
# Create background colour sprite
|
||||
@bgColor = ColoredPlane.new(Color.new(0,0,0),@viewport)
|
||||
@bgColor = ColoredPlane.new(Color.new(0, 0, 0), @viewport)
|
||||
@bgColor.borderX = 64 if @inEditor
|
||||
@bgColor.borderY = 64 if @inEditor
|
||||
@bgColor.z = 5
|
||||
@@ -751,7 +751,7 @@ class PBAnimationPlayerX
|
||||
@bgGraphic.opacity = 0
|
||||
@bgGraphic.refresh
|
||||
# Create foreground colour sprite
|
||||
@foColor = ColoredPlane.new(Color.new(0,0,0),@viewport)
|
||||
@foColor = ColoredPlane.new(Color.new(0, 0, 0), @viewport)
|
||||
@foColor.borderX = 64 if @inEditor
|
||||
@foColor.borderY = 64 if @inEditor
|
||||
@foColor.z = 85
|
||||
@@ -783,22 +783,22 @@ class PBAnimationPlayerX
|
||||
end
|
||||
|
||||
def animDone?
|
||||
return @frame<0
|
||||
return @frame < 0
|
||||
end
|
||||
|
||||
def setLineTransform(x1,y1,x2,y2,x3,y3,x4,y4)
|
||||
@srcLine = [x1,y1,x2,y2]
|
||||
@dstLine = [x3,y3,x4,y4]
|
||||
def setLineTransform(x1, y1, x2, y2, x3, y3, x4, y4)
|
||||
@srcLine = [x1, y1, x2, y2]
|
||||
@dstLine = [x3, y3, x4, y4]
|
||||
end
|
||||
|
||||
def update
|
||||
return if @frame<0
|
||||
animFrame = @frame/@framesPerTick
|
||||
return if @frame < 0
|
||||
animFrame = @frame / @framesPerTick
|
||||
|
||||
# Loop or end the animation if the animation has reached the end
|
||||
if animFrame >= @animation.length
|
||||
@frame = (@looping) ? 0 : -1
|
||||
if @frame<0
|
||||
if @frame < 0
|
||||
@animbitmap.dispose if @animbitmap
|
||||
@animbitmap = nil
|
||||
return
|
||||
@@ -806,7 +806,7 @@ class PBAnimationPlayerX
|
||||
end
|
||||
# Load the animation's spritesheet and assign it to all the sprites.
|
||||
if !@animbitmap || @animbitmap.disposed?
|
||||
@animbitmap = AnimatedBitmap.new("Graphics/Animations/"+@animation.graphic,
|
||||
@animbitmap = AnimatedBitmap.new("Graphics/Animations/" + @animation.graphic,
|
||||
@animation.hue).deanimate
|
||||
for i in 0...MAX_SPRITES
|
||||
@animsprites[i].bitmap = @animbitmap if @animsprites[i]
|
||||
@@ -819,7 +819,7 @@ class PBAnimationPlayerX
|
||||
@foColor.update
|
||||
|
||||
# Update all the sprites to depict the animation's next frame
|
||||
if @framesPerTick==1 || (@frame%@framesPerTick)==0
|
||||
if @framesPerTick == 1 || (@frame % @framesPerTick) == 0
|
||||
thisframe = @animation[animFrame]
|
||||
# Make all cel sprites invisible
|
||||
for i in 0...MAX_SPRITES
|
||||
@@ -841,7 +841,7 @@ class PBAnimationPlayerX
|
||||
sprite.bitmap = @animbitmap
|
||||
end
|
||||
# Apply settings to the cel sprite
|
||||
pbSpriteSetAnimFrame(sprite,cel,@usersprite,@targetsprite)
|
||||
pbSpriteSetAnimFrame(sprite, cel, @usersprite, @targetsprite)
|
||||
case cel[AnimFrame::FOCUS]
|
||||
when 1 # Focused on target
|
||||
sprite.x = cel[AnimFrame::X] + @targetOrig[0] - Battle::Scene::FOCUSTARGET_X
|
||||
@@ -852,13 +852,13 @@ class PBAnimationPlayerX
|
||||
when 3 # Focused on user and target
|
||||
next if !@srcLine || !@dstLine
|
||||
point = transformPoint(
|
||||
@srcLine[0],@srcLine[1],@srcLine[2],@srcLine[3],
|
||||
@dstLine[0],@dstLine[1],@dstLine[2],@dstLine[3],
|
||||
sprite.x,sprite.y)
|
||||
@srcLine[0], @srcLine[1], @srcLine[2], @srcLine[3],
|
||||
@dstLine[0], @dstLine[1], @dstLine[2], @dstLine[3],
|
||||
sprite.x, sprite.y)
|
||||
sprite.x = point[0]
|
||||
sprite.y = point[1]
|
||||
if isReversed(@srcLine[0],@srcLine[2],@dstLine[0],@dstLine[2]) &&
|
||||
cel[AnimFrame::PATTERN]>=0
|
||||
if isReversed(@srcLine[0], @srcLine[2], @dstLine[0], @dstLine[2]) &&
|
||||
cel[AnimFrame::PATTERN] >= 0
|
||||
# Reverse direction
|
||||
sprite.mirror = !sprite.mirror
|
||||
end
|
||||
@@ -867,7 +867,7 @@ class PBAnimationPlayerX
|
||||
sprite.y += 64 if @inEditor
|
||||
end
|
||||
# Play timings
|
||||
@animation.playTiming(animFrame,@bgGraphic,@bgColor,@foGraphic,@foColor,@oldbg,@oldfo,@user)
|
||||
@animation.playTiming(animFrame, @bgGraphic, @bgColor, @foGraphic, @foColor, @oldbg, @oldfo, @user)
|
||||
end
|
||||
@frame += 1
|
||||
end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user