mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 13:15:01 +00:00
A lot of FPS agnosticism, added def lerp
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
# Location signpost
|
||||
#===============================================================================
|
||||
class LocationWindow
|
||||
APPEAR_TIME = 0.4 # In seconds; is also the disappear time
|
||||
LINGER_TIME = 1.6 # In seconds; time during which self is fully visible
|
||||
|
||||
def initialize(name)
|
||||
@window = Window_AdvancedTextPokemon.new(name)
|
||||
@window.resizeToFit(name, Graphics.width)
|
||||
@@ -10,11 +13,11 @@ class LocationWindow
|
||||
@window.viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@window.viewport.z = 99999
|
||||
@currentmap = $game_map.map_id
|
||||
@frames = 0
|
||||
@timer_start = System.uptime
|
||||
end
|
||||
|
||||
def disposed?
|
||||
@window.disposed?
|
||||
return @window.disposed?
|
||||
end
|
||||
|
||||
def dispose
|
||||
@@ -28,12 +31,11 @@ class LocationWindow
|
||||
@window.dispose
|
||||
return
|
||||
end
|
||||
if @frames > Graphics.frame_rate * 2
|
||||
@window.y -= 4
|
||||
@window.dispose if @window.y + @window.height < 0
|
||||
if System.uptime - @timer_start >= APPEAR_TIME + LINGER_TIME
|
||||
@window.y = lerp(0, -@window.height, APPEAR_TIME, @timer_start + APPEAR_TIME + LINGER_TIME, System.uptime)
|
||||
@window.dispose if @window.y + @window.height <= 0
|
||||
else
|
||||
@window.y += 4 if @window.y < 0
|
||||
@frames += 1
|
||||
@window.y = lerp(-@window.height, 0, APPEAR_TIME, @timer_start, System.uptime)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -62,7 +64,7 @@ class DarknessSprite < Sprite
|
||||
def radiusMax; return 176; end # After using Flash
|
||||
|
||||
def radius=(value)
|
||||
@radius = value
|
||||
@radius = value.round
|
||||
refresh
|
||||
end
|
||||
|
||||
|
||||
@@ -6,24 +6,22 @@ def pbCaveEntranceEx(exiting)
|
||||
sprite = BitmapSprite.new(Graphics.width, Graphics.height)
|
||||
sprite.z = 100000
|
||||
# Define values used for the animation
|
||||
totalFrames = (Graphics.frame_rate * 0.4).floor
|
||||
increment = (255.0 / totalFrames).ceil
|
||||
duration = 0.4
|
||||
totalBands = 15
|
||||
bandheight = ((Graphics.height / 2.0) - 10) / totalBands
|
||||
bandwidth = ((Graphics.width / 2.0) - 12) / totalBands
|
||||
start_gray = (exiting) ? 0 : 255
|
||||
end_gray = (exiting) ? 255 : 0
|
||||
# Create initial array of band colors (black if exiting, white if entering)
|
||||
grays = Array.new(totalBands) { |i| (exiting) ? 0 : 255 }
|
||||
grays = Array.new(totalBands) { |i| start_gray }
|
||||
# Animate bands changing color
|
||||
totalFrames.times do |j|
|
||||
timer_start = System.uptime
|
||||
until System.uptime - timer_start >= duration
|
||||
x = 0
|
||||
y = 0
|
||||
# Calculate color of each band
|
||||
totalBands.times do |k|
|
||||
next if k >= totalBands * j / totalFrames
|
||||
inc = increment
|
||||
inc *= -1 if exiting
|
||||
grays[k] -= inc
|
||||
grays[k] = 0 if grays[k] < 0
|
||||
grays[k] = lerp(start_gray, end_gray, duration, timer_start + k * duration / totalBands, System.uptime)
|
||||
end
|
||||
# Draw gray rectangles
|
||||
rectwidth = Graphics.width
|
||||
@@ -47,19 +45,19 @@ def pbCaveEntranceEx(exiting)
|
||||
pbToneChangeAll(Tone.new(-255, -255, -255), 0)
|
||||
end
|
||||
# Animate fade to white (if exiting) or black (if entering)
|
||||
totalFrames.times do |j|
|
||||
if exiting
|
||||
sprite.color = Color.new(255, 255, 255, j * increment)
|
||||
else
|
||||
sprite.color = Color.new(0, 0, 0, j * increment)
|
||||
end
|
||||
timer_start = System.uptime
|
||||
loop do
|
||||
sprite.color = Color.new(end_gray, end_gray, end_gray,
|
||||
lerp(0, 255, duration, timer_start, System.uptime))
|
||||
Graphics.update
|
||||
Input.update
|
||||
break if sprite.color.alpha >= 255
|
||||
end
|
||||
# Set the tone at end of fading animation
|
||||
pbToneChangeAll(Tone.new(0, 0, 0), 8)
|
||||
# Pause briefly
|
||||
(Graphics.frame_rate / 10).times do
|
||||
timer_start = System.uptime
|
||||
until System.uptime - timer_start >= 0.1
|
||||
Graphics.update
|
||||
Input.update
|
||||
end
|
||||
|
||||
@@ -28,7 +28,8 @@ end
|
||||
class Game_Temp
|
||||
attr_accessor :warned_low_battery
|
||||
attr_accessor :cue_bgm
|
||||
attr_accessor :cue_bgm_frame_delay
|
||||
attr_accessor :cue_bgm_timer_start
|
||||
attr_accessor :cue_bgm_delay
|
||||
end
|
||||
|
||||
def pbBatteryLow?
|
||||
@@ -56,10 +57,9 @@ EventHandlers.add(:on_frame_update, :low_battery_warning,
|
||||
|
||||
EventHandlers.add(:on_frame_update, :cue_bgm_after_delay,
|
||||
proc {
|
||||
next if $game_temp.cue_bgm_frame_delay.nil?
|
||||
$game_temp.cue_bgm_frame_delay -= 1
|
||||
next if $game_temp.cue_bgm_frame_delay > 0
|
||||
$game_temp.cue_bgm_frame_delay = nil
|
||||
next if $game_temp.cue_bgm_delay.nil?
|
||||
next if System.uptime - $game_temp.cue_bgm_timer_start < $game_temp.cue_bgm_delay
|
||||
$game_temp.cue_bgm_delay = nil
|
||||
pbBGMPlay($game_temp.cue_bgm) if $game_system.getPlayingBGM.nil?
|
||||
}
|
||||
)
|
||||
@@ -413,14 +413,15 @@ end
|
||||
#===============================================================================
|
||||
def pbCueBGM(bgm, seconds, volume = nil, pitch = nil)
|
||||
return if !bgm
|
||||
bgm = pbResolveAudioFile(bgm, volume, pitch)
|
||||
bgm = pbResolveAudioFile(bgm, volume, pitch)
|
||||
playingBGM = $game_system.playing_bgm
|
||||
if !playingBGM || playingBGM.name != bgm.name || playingBGM.pitch != bgm.pitch
|
||||
pbBGMFade(seconds)
|
||||
if !$game_temp.cue_bgm_frame_delay
|
||||
$game_temp.cue_bgm_frame_delay = (seconds * Graphics.frame_rate) * 3 / 5
|
||||
end
|
||||
$game_temp.cue_bgm = bgm
|
||||
if !$game_temp.cue_bgm_delay
|
||||
$game_temp.cue_bgm_delay = seconds * 0.6
|
||||
$game_temp.cue_bgm_timer_start = System.uptime
|
||||
end
|
||||
elsif playingBGM
|
||||
pbBGMPlay(bgm)
|
||||
end
|
||||
@@ -533,8 +534,11 @@ def pbMoveRoute(event, commands, waitComplete = false)
|
||||
return route
|
||||
end
|
||||
|
||||
def pbWait(numFrames)
|
||||
numFrames.times do
|
||||
# duration is in seconds
|
||||
def pbWait(duration)
|
||||
timer_start = System.uptime
|
||||
until System.uptime - timer_start >= duration
|
||||
yield System.uptime - timer_start if block_given?
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdateSceneMap
|
||||
|
||||
@@ -314,7 +314,10 @@ module BattleCreationHelperMethods
|
||||
end
|
||||
if [2, 5].include?(outcome) && can_lose # if loss or draw
|
||||
$player.party.each { |pkmn| pkmn.heal }
|
||||
(Graphics.frame_rate / 4).times { Graphics.update }
|
||||
timer_start = System.uptime
|
||||
until System.uptime - timer_start >= 0.25
|
||||
Graphics.update
|
||||
end
|
||||
end
|
||||
EventHandlers.trigger(:on_end_battle, outcome, can_lose)
|
||||
$game_player.straighten
|
||||
|
||||
@@ -158,19 +158,23 @@ def pbBattleAnimationCore(anim, viewport, location, num_flashes = 2)
|
||||
viewport.color = Color.new(c, c, c) # Fade to black/white a few times
|
||||
half_flash_time = 0.2 # seconds
|
||||
num_flashes.times do # 2 flashes
|
||||
fade_out = false
|
||||
timer_start = System.uptime
|
||||
loop do
|
||||
if System.uptime - timer_start < half_flash_time
|
||||
viewport.color.alpha = 255 * (System.uptime - timer_start) / half_flash_time
|
||||
if fade_out
|
||||
viewport.color.alpha = lerp(255, 0, half_flash_time, timer_start, System.uptime)
|
||||
else
|
||||
viewport.color.alpha = 255 * (2 - ((System.uptime - timer_start) / half_flash_time))
|
||||
viewport.color.alpha = lerp(0, 255, half_flash_time, timer_start, System.uptime)
|
||||
end
|
||||
Graphics.update
|
||||
pbUpdateSceneMap
|
||||
break if System.uptime - timer_start >= half_flash_time * 2
|
||||
break if fade_out && viewport.color.alpha <= 0
|
||||
if !fade_out && viewport.color.alpha >= 255
|
||||
fade_out = true
|
||||
timer_start = System.uptime
|
||||
end
|
||||
end
|
||||
end
|
||||
viewport.color.alpha = 0
|
||||
end
|
||||
# Take screenshot of game, for use in some animations
|
||||
$game_temp.background_bitmap&.dispose
|
||||
@@ -180,7 +184,7 @@ def pbBattleAnimationCore(anim, viewport, location, num_flashes = 2)
|
||||
viewport.color = Color.black # Ensure screen is black
|
||||
Graphics.transition(25, "Graphics/Transitions/" + anim)
|
||||
# Slight pause after animation before starting up the battle scene
|
||||
pbWait(Graphics.frame_rate / 10)
|
||||
pbWait(0.1)
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
@@ -314,22 +318,22 @@ SpecialBattleIntroAnimations.register("alternate_vs_trainer_animation", 50, #
|
||||
bar2 = Sprite.new(viewopp)
|
||||
bar2.bitmap = RPG::Cache.transition(trainer_bar_graphic)
|
||||
bar2.x = xoffset
|
||||
vs_x = Graphics.width / 2
|
||||
vs_y = Graphics.height / 1.5
|
||||
vs = Sprite.new(viewvs)
|
||||
vs.bitmap = RPG::Cache.transition("vs")
|
||||
vs.ox = vs.bitmap.width / 2
|
||||
vs.oy = vs.bitmap.height / 2
|
||||
vs.x = Graphics.width / 2
|
||||
vs.y = Graphics.height / 1.5
|
||||
vs.x = vs_x
|
||||
vs.y = vs_y
|
||||
vs.visible = false
|
||||
flash = Sprite.new(viewvs)
|
||||
flash.bitmap = RPG::Cache.transition("vsFlash")
|
||||
flash.opacity = 0
|
||||
# Animate bars sliding in from either side
|
||||
slideInTime = (Graphics.frame_rate * 0.25).floor
|
||||
slideInTime.times do |i|
|
||||
bar1.x = xoffset * (i + 1 - slideInTime) / slideInTime
|
||||
bar2.x = xoffset * (slideInTime - i - 1) / slideInTime
|
||||
pbWait(1)
|
||||
pbWait(0.25) do |delta_t|
|
||||
bar1.x = lerp(-xoffset, 0, 0.25, delta_t)
|
||||
bar2.x = lerp(xoffset, 0, 0.25, delta_t)
|
||||
end
|
||||
bar1.dispose
|
||||
bar2.dispose
|
||||
@@ -350,16 +354,12 @@ SpecialBattleIntroAnimations.register("alternate_vs_trainer_animation", 50, #
|
||||
trainer.x = xoffset
|
||||
trainer.tone = Tone.new(-255, -255, -255)
|
||||
# Dim the flash and make the trainer sprites appear, while animating bars
|
||||
animTime = (Graphics.frame_rate * 1.2).floor
|
||||
animTime.times do |i|
|
||||
flash.opacity -= 52 * 20 / Graphics.frame_rate if flash.opacity > 0
|
||||
bar1.ox -= 32 * 20 / Graphics.frame_rate
|
||||
bar2.ox += 32 * 20 / Graphics.frame_rate
|
||||
if i >= animTime / 2 && i < slideInTime + (animTime / 2)
|
||||
player.x = xoffset * (i + 1 - slideInTime - (animTime / 2)) / slideInTime
|
||||
trainer.x = xoffset * (slideInTime - i - 1 + (animTime / 2)) / slideInTime
|
||||
end
|
||||
pbWait(1)
|
||||
pbWait(1.2) do |delta_t|
|
||||
flash.opacity = lerp(255, 0, 0.25, delta_t)
|
||||
bar1.ox = lerp(0, -bar1.bitmap.width * 3, 1.2, delta_t)
|
||||
bar2.ox = lerp(0, bar2.bitmap.width * 3, 1.2, delta_t)
|
||||
player.x = lerp(-xoffset, 0, 0.25, delta_t - 0.6)
|
||||
trainer.x = lerp(xoffset, 0, 0.25, delta_t - 0.6)
|
||||
end
|
||||
player.x = 0
|
||||
trainer.x = 0
|
||||
@@ -378,34 +378,27 @@ SpecialBattleIntroAnimations.register("alternate_vs_trainer_animation", 50, #
|
||||
]
|
||||
pbDrawTextPositions(overlay.bitmap, textpos)
|
||||
# Fade out flash, shudder Vs logo and expand it, and then fade to black
|
||||
animTime = (Graphics.frame_rate * 2.75).floor
|
||||
shudderTime = (Graphics.frame_rate * 1.75).floor
|
||||
zoomTime = (Graphics.frame_rate * 2.5).floor
|
||||
shudderDelta = [4 * 20 / Graphics.frame_rate, 1].max
|
||||
animTime.times do |i|
|
||||
if i < shudderTime # Fade out the white flash
|
||||
flash.opacity -= 52 * 20 / Graphics.frame_rate if flash.opacity > 0
|
||||
elsif i == shudderTime # Make the flash black
|
||||
flash.tone = Tone.new(-255, -255, -255)
|
||||
elsif i >= zoomTime # Fade to black
|
||||
flash.opacity += 52 * 20 / Graphics.frame_rate if flash.opacity < 255
|
||||
shudder_time = 1.75
|
||||
zoom_time = 2.5
|
||||
pbWait(2.8) do |delta_t|
|
||||
if delta_t <= shudder_time
|
||||
flash.opacity = lerp(255, 0, 0.25, delta_t) # Fade out the white flash
|
||||
elsif delta_t >= zoom_time
|
||||
flash.tone = Tone.new(-255, -255, -255) # Make the flash black
|
||||
flash.opacity = lerp(0, 255, 0.25, delta_t - zoom_time) # Fade to black
|
||||
end
|
||||
bar1.ox -= 32 * 20 / Graphics.frame_rate
|
||||
bar2.ox += 32 * 20 / Graphics.frame_rate
|
||||
if i < shudderTime
|
||||
j = i % (2 * Graphics.frame_rate / 20)
|
||||
if j >= 0.5 * Graphics.frame_rate / 20 && j < 1.5 * Graphics.frame_rate / 20
|
||||
vs.x += shudderDelta
|
||||
vs.y -= shudderDelta
|
||||
else
|
||||
vs.x -= shudderDelta
|
||||
vs.y += shudderDelta
|
||||
end
|
||||
elsif i < zoomTime
|
||||
vs.zoom_x += 0.4 * 20 / Graphics.frame_rate
|
||||
vs.zoom_y += 0.4 * 20 / Graphics.frame_rate
|
||||
bar1.ox = lerp(0, -bar1.bitmap.width * 7, 2.8, delta_t)
|
||||
bar2.ox = lerp(0, bar2.bitmap.width * 7, 2.8, delta_t)
|
||||
if delta_t <= shudder_time
|
||||
# +2, -2, -2, +2, repeat
|
||||
period = (delta_t / 0.025).to_i % 4
|
||||
shudder_delta = [2, 0 , -2, 0][period]
|
||||
vs.x = vs_x + shudder_delta
|
||||
vs.y = vs_y - shudder_delta
|
||||
elsif delta_t <= zoom_time
|
||||
vs.zoom_x = lerp(1.0, 7.0, zoom_time - shudder_time, delta_t - shudder_time)
|
||||
vs.zoom_y = vs.zoom_x
|
||||
end
|
||||
pbWait(1)
|
||||
end
|
||||
# End of animation
|
||||
player.dispose
|
||||
|
||||
@@ -35,6 +35,7 @@ module PBDayNight
|
||||
Tone.new(-70, -90, 15, 55), # Night
|
||||
Tone.new(-70, -90, 15, 55) # Night
|
||||
]
|
||||
CACHED_TONE_LIFETIME = 30 # In seconds; recalculates overworld tone once per this time
|
||||
@cachedTone = nil
|
||||
@dayNightToneLastUpdate = nil
|
||||
@oneOverSixty = 1 / 60.0
|
||||
@@ -81,10 +82,9 @@ module PBDayNight
|
||||
def self.getTone
|
||||
@cachedTone = Tone.new(0, 0, 0) if !@cachedTone
|
||||
return @cachedTone if !Settings::TIME_SHADING
|
||||
if !@dayNightToneLastUpdate ||
|
||||
Graphics.frame_count - @dayNightToneLastUpdate >= Graphics.frame_rate * 30
|
||||
if !@dayNightToneLastUpdate || (System.uptime - @dayNightToneLastUpdate >= CACHED_TONE_LIFETIME)
|
||||
getToneInternal
|
||||
@dayNightToneLastUpdate = Graphics.frame_count
|
||||
@dayNightToneLastUpdate = System.uptime
|
||||
end
|
||||
return @cachedTone
|
||||
end
|
||||
|
||||
@@ -174,9 +174,7 @@ def pbHiddenMoveAnimation(pokemon)
|
||||
break if phase == 6
|
||||
end
|
||||
sprite.dispose
|
||||
strobes.each do |strobe|
|
||||
strobe.dispose
|
||||
end
|
||||
strobes.each { |strobe| strobe.dispose }
|
||||
strobes.clear
|
||||
bg.dispose
|
||||
viewport.dispose
|
||||
@@ -234,7 +232,7 @@ def pbSmashEvent(event)
|
||||
PBMoveRoute::TURN_LEFT, PBMoveRoute::WAIT, 2,
|
||||
PBMoveRoute::TURN_RIGHT, PBMoveRoute::WAIT, 2,
|
||||
PBMoveRoute::TURN_UP, PBMoveRoute::WAIT, 2])
|
||||
pbWait(Graphics.frame_rate * 4 / 10)
|
||||
pbWait(0.4)
|
||||
event.erase
|
||||
$PokemonMap&.addErasedEvent(event.id)
|
||||
end
|
||||
@@ -458,14 +456,11 @@ HiddenMoveHandlers::UseMove.add(:FLASH, proc { |move, pokemon|
|
||||
end
|
||||
$PokemonGlobal.flashUsed = true
|
||||
$stats.flash_count += 1
|
||||
radiusDiff = 8 * 20 / Graphics.frame_rate
|
||||
while darkness.radius < darkness.radiusMax
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdateSceneMap
|
||||
darkness.radius += radiusDiff
|
||||
darkness.radius = darkness.radiusMax if darkness.radius > darkness.radiusMax
|
||||
duration = 0.7
|
||||
pbWait(duration) do |delta_t|
|
||||
darkness.radius = lerp(darkness.radiusMin, darkness.radiusMax, duration, delta_t)
|
||||
end
|
||||
darkness.radius = darkness.radiusMax
|
||||
next true
|
||||
})
|
||||
|
||||
@@ -511,7 +506,7 @@ def pbFlyToNewLocation(pkmn = nil, move = :FLY)
|
||||
$game_map.autoplay
|
||||
$game_map.refresh
|
||||
yield if block_given?
|
||||
pbWait(Graphics.frame_rate / 4)
|
||||
pbWait(0.25)
|
||||
end
|
||||
pbEraseEscapePoint
|
||||
return true
|
||||
@@ -812,24 +807,19 @@ def pbSweetScent
|
||||
end
|
||||
viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
viewport.z = 99999
|
||||
count = 0
|
||||
viewport.color.red = 255
|
||||
viewport.color.green = 0
|
||||
viewport.color.blue = 0
|
||||
viewport.color.green = 32
|
||||
viewport.color.blue = 32
|
||||
viewport.color.alpha -= 10
|
||||
alphaDiff = 12 * 20 / Graphics.frame_rate
|
||||
loop do
|
||||
if count == 0 && viewport.color.alpha < 128
|
||||
viewport.color.alpha += alphaDiff
|
||||
elsif count > Graphics.frame_rate / 4
|
||||
viewport.color.alpha -= alphaDiff
|
||||
start_alpha = viewport.color.alpha
|
||||
duration = 1.1
|
||||
fade_time = 0.4
|
||||
pbWait(duration) do |delta_t|
|
||||
if delta_t < duration / 2
|
||||
viewport.color.alpha = lerp(start_alpha, start_alpha + 128, fade_time, delta_t)
|
||||
else
|
||||
count += 1
|
||||
viewport.color.alpha = lerp(start_alpha + 128, start_alpha, fade_time, delta_t - duration + fade_time)
|
||||
end
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdateSceneMap
|
||||
break if viewport.color.alpha <= 0
|
||||
end
|
||||
viewport.dispose
|
||||
enctype = $PokemonEncounters.encounter_type
|
||||
|
||||
@@ -8,11 +8,7 @@ def pbFishingBegin
|
||||
$game_player.lock_pattern = true
|
||||
4.times do |pattern|
|
||||
$game_player.pattern = 3 - pattern
|
||||
(Graphics.frame_rate / 20).times do
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdateSceneMap
|
||||
end
|
||||
pbWait(0.05)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -21,11 +17,7 @@ def pbFishingEnd
|
||||
if !pbCommonEvent(Settings::FISHING_END_COMMON_EVENT)
|
||||
4.times do |pattern|
|
||||
$game_player.pattern = pattern
|
||||
(Graphics.frame_rate / 20).times do
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdateSceneMap
|
||||
end
|
||||
pbWait(0.05)
|
||||
end
|
||||
end
|
||||
yield if block_given?
|
||||
@@ -55,8 +47,8 @@ def pbFishing(hasEncounter, rodType = 1)
|
||||
end
|
||||
if hasEncounter && rand(100) < biteChance
|
||||
$scene.spriteset.addUserAnimation(Settings::EXCLAMATION_ANIMATION_ID, $game_player.x, $game_player.y, true, 3)
|
||||
frames = Graphics.frame_rate - rand(Graphics.frame_rate / 2) # 0.5-1 second
|
||||
if !pbWaitForInput(msgWindow, message + "\n" + _INTL("Oh! A bite!"), frames)
|
||||
duration = rand(5..10) / 10.0 # 0.5-1 seconds
|
||||
if !pbWaitForInput(msgWindow, message + "\n" + _INTL("Oh! A bite!"), duration)
|
||||
pbFishingEnd { pbMessageDisplay(msgWindow, _INTL("The Pokémon got away...")) }
|
||||
break
|
||||
end
|
||||
@@ -81,35 +73,28 @@ end
|
||||
# Show waiting dots before a Pokémon bites
|
||||
def pbWaitMessage(msgWindow, time)
|
||||
message = ""
|
||||
periodTime = Graphics.frame_rate * 4 / 10 # 0.4 seconds, 16 frames per dot
|
||||
(time + 1).times do |i|
|
||||
message += ". " if i > 0
|
||||
pbMessageDisplay(msgWindow, message, false)
|
||||
periodTime.times do
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdateSceneMap
|
||||
if Input.trigger?(Input::USE) || Input.trigger?(Input::BACK)
|
||||
return true
|
||||
end
|
||||
pbWait(0.4) do |delta_t|
|
||||
return true if Input.trigger?(Input::USE) || Input.trigger?(Input::BACK)
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
# A Pokémon is biting, reflex test to reel it in
|
||||
def pbWaitForInput(msgWindow, message, frames)
|
||||
def pbWaitForInput(msgWindow, message, duration)
|
||||
pbMessageDisplay(msgWindow, message, false)
|
||||
numFrame = 0
|
||||
twitchFrame = 0
|
||||
twitchFrameTime = Graphics.frame_rate * 2 / 10 # 0.2 seconds, 8 frames
|
||||
twitch_frame_duration = 0.2 # 0.2 seconds
|
||||
timer_start = System.uptime
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdateSceneMap
|
||||
# Twitch cycle: 1,0,1,0,0,0,0,0
|
||||
twitchFrame = (twitchFrame + 1) % (twitchFrameTime * 8)
|
||||
case twitchFrame % twitchFrameTime
|
||||
twitch_frame = ((System.uptime - timer_start) / twitch_frame_duration).to_i % 8
|
||||
case twitch_frame
|
||||
when 0, 2
|
||||
$game_player.pattern = 1
|
||||
else
|
||||
@@ -119,8 +104,7 @@ def pbWaitForInput(msgWindow, message, frames)
|
||||
$game_player.pattern = 0
|
||||
return true
|
||||
end
|
||||
break if !Settings::FISHING_AUTO_HOOK && numFrame > frames
|
||||
numFrame += 1
|
||||
break if !Settings::FISHING_AUTO_HOOK && System.uptime - timer_start > duration
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user