diff --git a/Data/Scripts/001_Settings.rb b/Data/Scripts/001_Settings.rb index 0e37493bc..e6c5f9247 100644 --- a/Data/Scripts/001_Settings.rb +++ b/Data/Scripts/001_Settings.rb @@ -446,5 +446,5 @@ end module Essentials VERSION = "20.1.dev" ERROR_TEXT = "" - MKXPZ_VERSION = "2.4.2/b0d8e0b" + MKXPZ_VERSION = "2.4.2/ee8dc7e" end diff --git a/Data/Scripts/001_Technical/001_MKXP_Compatibility.rb b/Data/Scripts/001_Technical/001_MKXP_Compatibility.rb index f8332fe95..0ea435890 100644 --- a/Data/Scripts/001_Technical/001_MKXP_Compatibility.rb +++ b/Data/Scripts/001_Technical/001_MKXP_Compatibility.rb @@ -1,4 +1,5 @@ -# Using mkxp-z v2.4.2/b0d8e0b - https://github.com/mkxp-z/mkxp-z/actions/runs/5033679007 +# Using mkxp-z v2.4.2/ee8dc7e - built 2023-05-28 +# https://github.com/mkxp-z/mkxp-z/actions/runs/5107184579 $VERBOSE = nil Font.default_shadow = false if Font.respond_to?(:default_shadow) Graphics.frame_rate = 40 diff --git a/Data/Scripts/001_Technical/002_RubyUtilities.rb b/Data/Scripts/001_Technical/002_RubyUtilities.rb index 1b796b039..dfbed4a78 100644 --- a/Data/Scripts/001_Technical/002_RubyUtilities.rb +++ b/Data/Scripts/001_Technical/002_RubyUtilities.rb @@ -389,3 +389,17 @@ end def nil_or_empty?(string) return string.nil? || !string.is_a?(String) || string.size == 0 end + +#=============================================================================== +# Linear interpolation between two values, given the duration of the change and +# either: +# - the time passed since the start of the change (delta), or +# - the start time of the change (delta) and the current time (now) +#=============================================================================== +def lerp(start_val, end_val, duration, delta, now = nil) + return end_val if duration <= 0 + delta = now - delta if now + return start_val if delta <= 0 + return end_val if delta >= duration + return start_val + (end_val - start_val) * delta / duration.to_f +end diff --git a/Data/Scripts/001_Technical/006_RPG_Sprite.rb b/Data/Scripts/001_Technical/006_RPG_Sprite.rb index 3522328de..37e524f9a 100644 --- a/Data/Scripts/001_Technical/006_RPG_Sprite.rb +++ b/Data/Scripts/001_Technical/006_RPG_Sprite.rb @@ -260,100 +260,38 @@ module RPG class Sprite < ::Sprite def initialize(viewport = nil) super(viewport) - @_whiten_duration = 0 - @_appear_duration = 0 - @_escape_duration = 0 - @_collapse_duration = 0 - @_damage_duration = 0 @_animation_duration = 0 - @_animation_frame = 0 - @_blink = false - @animations = [] + @_animation_frame = 0 + @animations = [] @loopAnimations = [] end def dispose - dispose_damage dispose_animation dispose_loop_animation super end - def whiten - self.blend_type = 0 - self.color.set(255, 255, 255, 128) - self.opacity = 255 - @_whiten_duration = 16 - @_appear_duration = 0 - @_escape_duration = 0 - @_collapse_duration = 0 + def dispose_animation + @animations.each { |a| a&.dispose_animation } + @animations.clear end - def appear - self.blend_type = 0 - self.color.set(0, 0, 0, 0) - self.opacity = 0 - @_appear_duration = 16 - @_whiten_duration = 0 - @_escape_duration = 0 - @_collapse_duration = 0 + def dispose_loop_animation + @loopAnimations.each { |a| a&.dispose_loop_animation } + @loopAnimations.clear end - def escape - self.blend_type = 0 - self.color.set(0, 0, 0, 0) - self.opacity = 255 - @_escape_duration = 32 - @_whiten_duration = 0 - @_appear_duration = 0 - @_collapse_duration = 0 + def x=(x) + @animations.each { |a| a.x = x if a } + @loopAnimations.each { |a| a.x = x if a } + super end - def collapse - self.blend_type = 1 - self.color.set(255, 64, 64, 255) - self.opacity = 255 - @_collapse_duration = 48 - @_whiten_duration = 0 - @_appear_duration = 0 - @_escape_duration = 0 - end - - def damage(value, critical) - dispose_damage - damage_string = (value.is_a?(Numeric)) ? value.abs.to_s : value.to_s - bitmap = Bitmap.new(160, 48) - bitmap.font.name = "Arial Black" - bitmap.font.size = 32 - bitmap.font.color.set(0, 0, 0) - bitmap.draw_text(-1, 12 - 1, 160, 36, damage_string, 1) - bitmap.draw_text(+1, 12 - 1, 160, 36, damage_string, 1) - bitmap.draw_text(-1, 12 + 1, 160, 36, damage_string, 1) - bitmap.draw_text(+1, 12 + 1, 160, 36, damage_string, 1) - if value.is_a?(Numeric) && value < 0 - bitmap.font.color.set(176, 255, 144) - else - bitmap.font.color.set(255, 255, 255) - end - bitmap.draw_text(0, 12, 160, 36, damage_string, 1) - if critical - bitmap.font.size = 20 - bitmap.font.color.set(0, 0, 0) - bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1) - bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1) - bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1) - bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1) - bitmap.font.color.set(255, 255, 255) - bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1) - end - @_damage_sprite = ::Sprite.new(self.viewport) - @_damage_sprite.bitmap = bitmap - @_damage_sprite.ox = 80 - @_damage_sprite.oy = 20 - @_damage_sprite.x = self.x - @_damage_sprite.y = self.y - (self.oy / 2) - @_damage_sprite.z = 3000 - @_damage_duration = 40 + def y=(y) + @animations.each { |a| a.y = y if a } + @loopAnimations.each { |a| a.y = y if a } + super end def pushAnimation(array, anim) @@ -377,97 +315,11 @@ module RPG pushAnimation(@loopAnimations, anim) end - def dispose_damage - return if @_damage_sprite.nil? - @_damage_sprite.bitmap.dispose - @_damage_sprite.dispose - @_damage_sprite = nil - @_damage_duration = 0 - end - - def dispose_animation - @animations.each { |a| a&.dispose_animation } - @animations.clear - end - - def dispose_loop_animation - @loopAnimations.each { |a| a&.dispose_loop_animation } - @loopAnimations.clear - end - - def blink_on - return if @_blink - @_blink = true - @_blink_count = 0 - end - - def blink_off - return unless @_blink - @_blink = false - self.color.set(0, 0, 0, 0) - end - - def blink? - return @_blink - end - def effect? - return true if @_whiten_duration > 0 - return true if @_appear_duration > 0 - return true if @_escape_duration > 0 - return true if @_collapse_duration > 0 - return true if @_damage_duration > 0 @animations.each { |a| return true if a.effect? } return false end - def update - super - if @_whiten_duration > 0 - @_whiten_duration -= 1 - self.color.alpha = 128 - ((16 - @_whiten_duration) * 10) - end - if @_appear_duration > 0 - @_appear_duration -= 1 - self.opacity = (16 - @_appear_duration) * 16 - end - if @_escape_duration > 0 - @_escape_duration -= 1 - self.opacity = 256 - ((32 - @_escape_duration) * 10) - end - if @_collapse_duration > 0 - @_collapse_duration -= 1 - self.opacity = 256 - ((48 - @_collapse_duration) * 6) - end - if @_damage_duration > 0 - @_damage_duration -= 1 - case @_damage_duration - when 38..39 - @_damage_sprite.y -= 4 - when 36..37 - @_damage_sprite.y -= 2 - when 34..35 - @_damage_sprite.y += 2 - when 28..33 - @_damage_sprite.y += 4 - end - @_damage_sprite.opacity = 256 - ((12 - @_damage_duration) * 32) - dispose_damage if @_damage_duration == 0 - end - @animations.each { |a| a.update } - @loopAnimations.each { |a| a.update } - if @_blink - @_blink_count = (@_blink_count + 1) % 32 - if @_blink_count < 16 - alpha = (16 - @_blink_count) * 6 - else - alpha = (@_blink_count - 16) * 6 - end - self.color.set(255, 255, 255, alpha) - end - SpriteAnimation.clear - end - def update_animation @animations.each { |a| a.update_animation if a&.active? } end @@ -476,16 +328,11 @@ module RPG @loopAnimations.each { |a| a.update_loop_animation if a&.active? } end - def x=(x) - @animations.each { |a| a.x = x if a } - @loopAnimations.each { |a| a.x = x if a } - super - end - - def y=(y) - @animations.each { |a| a.y = y if a } - @loopAnimations.each { |a| a.y = y if a } + def update super + @animations.each { |a| a.update } + @loopAnimations.each { |a| a.update } + SpriteAnimation.clear end end end diff --git a/Data/Scripts/001_Technical/007_Interpolators.rb b/Data/Scripts/001_Technical/007_Interpolators.rb deleted file mode 100644 index 211135634..000000000 --- a/Data/Scripts/001_Technical/007_Interpolators.rb +++ /dev/null @@ -1,186 +0,0 @@ -#=============================================================================== -# Linear interpolation between two values, given the duration of the change and -# either: -# - the time passed since the start of the change (delta), or -# - the start time of the change (delta) and the current time (now) -#=============================================================================== -def lerp(start_val, end_val, duration, delta, now = nil) - delta = now - delta if now - return start_val if delta <= 0 - return end_val if delta >= duration - return start_val + (end_val - start_val) * delta / duration.to_f -end - -#=============================================================================== -# -#=============================================================================== -class PointInterpolator - attr_reader :x - attr_reader :y - - def initialize(oldx, oldy, newx, newy, frames) - restart(oldx, oldy, newx, newy, frames) - end - - def restart(oldx, oldy, newx, newy, frames) - @oldx = oldx - @oldy = oldy - @newx = newx - @newy = newy - @frames = frames - @curframe = 0 - @x = oldx - @y = oldy - end - - def done? - @curframe > @frames - end - - def update - return if done? - t = @curframe.to_f / @frames - rx1 = @oldx - rx2 = @newx - @x = rx1 + (t * (rx2 - rx1)) - ry1 = @oldy - ry2 = @newy - @y = ry1 + (t * (ry2 - ry1)) - @curframe += 1 - end -end - -#=============================================================================== -# -#=============================================================================== -class RectInterpolator - def initialize(oldrect, newrect, frames) - restart(oldrect, newrect, frames) - end - - def restart(oldrect, newrect, frames) - @oldrect = oldrect - @newrect = newrect - @frames = [frames, 1].max - @curframe = 0 - @rect = oldrect.clone - end - - def set(rect) - rect.set(@rect.x, @rect.y, @rect.width, @rect.height) - end - - def done? - @curframe > @frames - end - - def update - return if done? - t = @curframe.to_f / @frames - x1 = @oldrect.x - x2 = @newrect.x - x = x1 + (t * (x2 - x1)) - y1 = @oldrect.y - y2 = @newrect.y - y = y1 + (t * (y2 - y1)) - rx1 = @oldrect.x + @oldrect.width - rx2 = @newrect.x + @newrect.width - rx = rx1 + (t * (rx2 - rx1)) - ry1 = @oldrect.y + @oldrect.height - ry2 = @newrect.y + @newrect.height - ry = ry1 + (t * (ry2 - ry1)) - minx = x < rx ? x : rx - maxx = x > rx ? x : rx - miny = y < ry ? y : ry - maxy = y > ry ? y : ry - @rect.set(minx, miny, maxx - minx, maxy - miny) - @curframe += 1 - end -end - -#=============================================================================== -# -#=============================================================================== -class SpriteInterpolator - X = 1 - Y = 2 - ZOOM_X = 3 - ZOOM_Y = 4 - COLOR = 5 - OPACITY = 6 - - def initialize - @tweening = false - @tweensteps = [] - @sprite = nil - @frames = 0 - @step = 0 - end - - def tweening? - return @tweening - end - - def tween(sprite, items, frames) - @tweensteps = [] - if sprite && !sprite.disposed? && frames > 0 - @frames = frames - @step = 0 - @sprite = sprite - items.each do |item| - case item[0] - when X - @tweensteps[item[0]] = [sprite.x, item[1] - sprite.x] - when Y - @tweensteps[item[0]] = [sprite.y, item[1] - sprite.y] - when ZOOM_X - @tweensteps[item[0]] = [sprite.zoom_x, item[1] - sprite.zoom_x] - when ZOOM_Y - @tweensteps[item[0]] = [sprite.zoom_y, item[1] - sprite.zoom_y] - when COLOR - @tweensteps[item[0]] = [sprite.color.clone, - Color.new(item[1].red - sprite.color.red, - item[1].green - sprite.color.green, - item[1].blue - sprite.color.blue, - item[1].alpha - sprite.color.alpha)] - when OPACITY - @tweensteps[item[0]] = [sprite.opacity, item[1] - sprite.opacity] - end - end - @tweening = true - end - end - - def update - if @tweening - t = @step.to_f / @frames - @tweensteps.length.times do |i| - item = @tweensteps[i] - next if !item - case i - when X - @sprite.x = item[0] + (item[1] * t) - when Y - @sprite.y = item[0] + (item[1] * t) - when ZOOM_X - @sprite.zoom_x = item[0] + (item[1] * t) - when ZOOM_Y - @sprite.zoom_y = item[0] + (item[1] * t) - when COLOR - @sprite.color = Color.new(item[0].red + (item[1].red * t), - item[0].green + (item[1].green * t), - item[0].blue + (item[1].blue * t), - item[0].alpha + (item[1].alpha * t)) - when OPACITY - @sprite.opacity = item[0] + (item[1] * t) - end - end - @step += 1 - if @step == @frames - @step = 0 - @frames = 0 - @tweening = false - end - end - end -end diff --git a/Data/Scripts/003_Game processing/003_Interpreter.rb b/Data/Scripts/003_Game processing/003_Interpreter.rb index 74081865b..5b68eb6d3 100644 --- a/Data/Scripts/003_Game processing/003_Interpreter.rb +++ b/Data/Scripts/003_Game processing/003_Interpreter.rb @@ -84,6 +84,7 @@ class Interpreter def update @loop_count = 0 loop do + # TODO: Possibly not needed? @loop_count += 1 if @loop_count > 100 # Call Graphics.update for freeze prevention Graphics.update diff --git a/Data/Scripts/004_Game classes/001_Game_Screen.rb b/Data/Scripts/004_Game classes/001_Game_Screen.rb index cd871db49..ff62915f2 100644 --- a/Data/Scripts/004_Game classes/001_Game_Screen.rb +++ b/Data/Scripts/004_Game classes/001_Game_Screen.rb @@ -16,8 +16,6 @@ class Game_Screen def initialize @brightness = 255 - @fadeout_duration = 0 - @fadein_duration = 0 @tone = Tone.new(0, 0, 0, 0) @tone_target = Tone.new(0, 0, 0, 0) @tone_duration = 0 @@ -72,16 +70,6 @@ class Game_Screen end def update - if @fadeout_duration && @fadeout_duration >= 1 - d = @fadeout_duration - @brightness = (@brightness * (d - 1)) / d - @fadeout_duration -= 1 - end - if @fadein_duration && @fadein_duration >= 1 - d = @fadein_duration - @brightness = ((@brightness * (d - 1)) + 255) / d - @fadein_duration -= 1 - end now = $stats.play_time if @tone_timer_start @tone.red = lerp(@tone_initial.red, @tone_target.red, @tone_duration, @tone_timer_start, now) diff --git a/Data/Scripts/004_Game classes/004_Game_Map.rb b/Data/Scripts/004_Game classes/004_Game_Map.rb index 0c14da27c..1505a940b 100644 --- a/Data/Scripts/004_Game classes/004_Game_Map.rb +++ b/Data/Scripts/004_Game classes/004_Game_Map.rb @@ -437,6 +437,8 @@ class Game_Map end def update + uptime_now = System.uptime + play_now = $stats.play_time # Refresh maps if necessary if $map_factory $map_factory.maps.each { |i| i.refresh if i.need_refresh } @@ -445,13 +447,13 @@ class Game_Map # If scrolling if (@scroll_distance_x || 0) != 0 duration = @scroll_distance_x.abs * TILE_WIDTH.to_f / (10 * (2**@scroll_speed)) - scroll_offset = lerp(0, @scroll_distance_x, duration, @scroll_timer_start, System.uptime) + scroll_offset = lerp(0, @scroll_distance_x, duration, @scroll_timer_start, uptime_now) self.display_x = @scroll_start_x + scroll_offset * REAL_RES_X @scroll_distance_x = 0 if scroll_offset == @scroll_distance_x end if (@scroll_distance_y || 0) != 0 duration = @scroll_distance_y.abs * TILE_HEIGHT.to_f / (10 * (2**@scroll_speed)) - scroll_offset = lerp(0, @scroll_distance_y, duration, @scroll_timer_start, System.uptime) + scroll_offset = lerp(0, @scroll_distance_y, duration, @scroll_timer_start, uptime_now) self.display_y = @scroll_start_y + scroll_offset * REAL_RES_Y @scroll_distance_y = 0 if scroll_offset == @scroll_distance_y end @@ -462,22 +464,24 @@ class Game_Map # Update common events @common_events.each_value { |common_event| common_event.update } # Update fog - now = $stats.play_time - @fog_ox -= @fog_sx / 8.0 - @fog_oy -= @fog_sy / 8.0 + @fog_scroll_last_update_timer = uptime_now if !@fog_scroll_last_update_timer + scroll_mult = (uptime_now - @fog_scroll_last_update_timer) * 5 + @fog_ox -= @fog_sx * scroll_mult + @fog_oy -= @fog_sy * scroll_mult + @fog_scroll_last_update_timer = uptime_now if @fog_tone_timer_start - @fog_tone.red = lerp(@fog_tone_initial.red, @fog_tone_target.red, @fog_tone_duration, @fog_tone_timer_start, now) - @fog_tone.green = lerp(@fog_tone_initial.green, @fog_tone_target.green, @fog_tone_duration, @fog_tone_timer_start, now) - @fog_tone.blue = lerp(@fog_tone_initial.blue, @fog_tone_target.blue, @fog_tone_duration, @fog_tone_timer_start, now) - @fog_tone.gray = lerp(@fog_tone_initial.gray, @fog_tone_target.gray, @fog_tone_duration, @fog_tone_timer_start, now) - if now - @fog_tone_timer_start >= @fog_tone_duration + @fog_tone.red = lerp(@fog_tone_initial.red, @fog_tone_target.red, @fog_tone_duration, @fog_tone_timer_start, play_now) + @fog_tone.green = lerp(@fog_tone_initial.green, @fog_tone_target.green, @fog_tone_duration, @fog_tone_timer_start, play_now) + @fog_tone.blue = lerp(@fog_tone_initial.blue, @fog_tone_target.blue, @fog_tone_duration, @fog_tone_timer_start, play_now) + @fog_tone.gray = lerp(@fog_tone_initial.gray, @fog_tone_target.gray, @fog_tone_duration, @fog_tone_timer_start, play_now) + if play_now - @fog_tone_timer_start >= @fog_tone_duration @fog_tone_initial = nil @fog_tone_timer_start = nil end end if @fog_opacity_timer_start - @fog_opacity = lerp(@fog_opacity_initial, @fog_opacity_target, @fog_opacity_duration, @fog_opacity_timer_start, now) - if now - @fog_opacity_timer_start >= @fog_opacity_duration + @fog_opacity = lerp(@fog_opacity_initial, @fog_opacity_target, @fog_opacity_duration, @fog_opacity_timer_start, play_now) + if play_now - @fog_opacity_timer_start >= @fog_opacity_duration @fog_opacity_initial = nil @fog_opacity_timer_start = nil end diff --git a/Data/Scripts/005_Sprites/010_ParticleEngine.rb b/Data/Scripts/005_Sprites/010_ParticleEngine.rb deleted file mode 100644 index c218fcd87..000000000 --- a/Data/Scripts/005_Sprites/010_ParticleEngine.rb +++ /dev/null @@ -1,605 +0,0 @@ -#=============================================================================== -# Particle Engine, Peter O., 2007-11-03 -# Based on version 2 by Near Fantastica, 04.01.06 -# In turn based on the Particle Engine designed by PinkMan -#=============================================================================== -class Particle_Engine - def initialize(viewport = nil, map = nil) - @map = (map) ? map : $game_map - @viewport = viewport - @effect = [] - @disposed = false - @firsttime = true - @effects = { - # PinkMan's Effects - "fire" => Particle_Engine::Fire, - "smoke" => Particle_Engine::Smoke, - "teleport" => Particle_Engine::Teleport, - "spirit" => Particle_Engine::Spirit, - "explosion" => Particle_Engine::Explosion, - "aura" => Particle_Engine::Aura, - # BlueScope's Effects - "soot" => Particle_Engine::Soot, - "sootsmoke" => Particle_Engine::SootSmoke, - "rocket" => Particle_Engine::Rocket, - "fixteleport" => Particle_Engine::FixedTeleport, - "smokescreen" => Particle_Engine::Smokescreen, - "flare" => Particle_Engine::Flare, - "splash" => Particle_Engine::Splash, - # By Peter O. - "starteleport" => Particle_Engine::StarTeleport - } - end - - def dispose - return if disposed? - @effect.each do |particle| - next if particle.nil? - particle.dispose - end - @effect.clear - @map = nil - @disposed = true - end - - def disposed? - return @disposed - end - - def add_effect(event) - @effect[event.id] = pbParticleEffect(event) - end - - def remove_effect(event) - return if @effect[event.id].nil? - @effect[event.id].dispose - @effect.delete_at(event.id) - end - - def realloc_effect(event, particle) - type = pbEventCommentInput(event, 1, "Particle Engine Type") - if type.nil? - particle&.dispose - return nil - end - type = type[0].downcase - cls = @effects[type] - if cls.nil? - particle&.dispose - return nil - end - if !particle || !particle.is_a?(cls) - particle&.dispose - particle = cls.new(event, @viewport) - end - return particle - end - - def pbParticleEffect(event) - return realloc_effect(event, nil) - end - - def update - if @firsttime - @firsttime = false - @map.events.each_value do |event| - remove_effect(event) - add_effect(event) - end - end - @effect.each_with_index do |particle, i| - next if particle.nil? - if particle.event.pe_refresh - event = particle.event - event.pe_refresh = false - particle = realloc_effect(event, particle) - @effect[i] = particle - end - particle&.update - end - end -end - -#=============================================================================== -# -#=============================================================================== -class ParticleEffect - attr_accessor :x, :y, :z - - def initialize - @x = 0 - @y = 0 - @z = 0 - end - - def update; end - def dispose; end -end - -#=============================================================================== -# -#=============================================================================== -class ParticleSprite - attr_accessor :x, :y, :z, :ox, :oy, :opacity, :blend_type - attr_reader :bitmap - - def initialize(viewport) - @viewport = viewport - @sprite = nil - @x = 0 - @y = 0 - @z = 0 - @ox = 0 - @oy = 0 - @opacity = 255 - @bitmap = nil - @blend_type = 0 - @minleft = 0 - @mintop = 0 - end - - def dispose - @sprite&.dispose - end - - def bitmap=(value) - @bitmap = value - if value - @minleft = -value.width - @mintop = -value.height - else - @minleft = 0 - @mintop = 0 - end - end - - def update - w = Graphics.width - h = Graphics.height - if !@sprite && @x >= @minleft && @y >= @mintop && @x < w && @y < h - @sprite = Sprite.new(@viewport) - elsif @sprite && (@x < @minleft || @y < @mintop || @x >= w || @y >= h) - @sprite.dispose - @sprite = nil - end - if @sprite - @sprite.x = @x if @sprite.x != @x - @sprite.x -= @ox - @sprite.y = @y if @sprite.y != @y - @sprite.y -= @oy - @sprite.z = @z if @sprite.z != @z - @sprite.opacity = @opacity if @sprite.opacity != @opacity - @sprite.blend_type = @blend_type if @sprite.blend_type != @blend_type - @sprite.bitmap = @bitmap if @sprite.bitmap != @bitmap - end - end -end - -#=============================================================================== -# -#=============================================================================== -class ParticleEffect_Event < ParticleEffect - attr_accessor :event - - def initialize(event, viewport = nil) - @event = event - @viewport = viewport - @particles = [] - @bitmaps = {} - end - - def setParameters(params) - @randomhue, @leftright, @fade, - @maxparticless, @hue, @slowdown, - @ytop, @ybottom, @xleft, @xright, - @xgravity, @ygravity, @xoffset, @yoffset, - @opacityvar, @originalopacity = params - end - - def loadBitmap(filename, hue) - key = [filename, hue] - bitmap = @bitmaps[key] - if !bitmap || bitmap.disposed? - bitmap = AnimatedBitmap.new("Graphics/Fogs/" + filename, hue).deanimate - @bitmaps[key] = bitmap - end - return bitmap - end - - def initParticles(filename, opacity, zOffset = 0, blendtype = 1) - @particles = [] - @particlex = [] - @particley = [] - @opacity = [] - @startingx = self.x + @xoffset - @startingy = self.y + @yoffset - @screen_x = self.x - @screen_y = self.y - @real_x = @event.real_x - @real_y = @event.real_y - @filename = filename - @zoffset = zOffset - @bmwidth = 32 - @bmheight = 32 - @maxparticless.times do |i| - @particlex[i] = -@xoffset - @particley[i] = -@yoffset - @particles[i] = ParticleSprite.new(@viewport) - @particles[i].bitmap = loadBitmap(filename, @hue) if filename - if i == 0 && @particles[i].bitmap - @bmwidth = @particles[i].bitmap.width - @bmheight = @particles[i].bitmap.height - end - @particles[i].blend_type = blendtype - @particles[i].y = @startingy - @particles[i].x = @startingx - @particles[i].z = self.z + zOffset - @opacity[i] = rand(opacity / 4) - @particles[i].opacity = @opacity[i] - @particles[i].update - end - end - - def x; return ScreenPosHelper.pbScreenX(@event); end - def y; return ScreenPosHelper.pbScreenY(@event); end - def z; return ScreenPosHelper.pbScreenZ(@event); end - - def update - if @viewport && - (@viewport.rect.x >= Graphics.width || - @viewport.rect.y >= Graphics.height) - return - end - selfX = self.x - selfY = self.y - selfZ = self.z - newRealX = @event.real_x - newRealY = @event.real_y - @startingx = selfX + @xoffset - @startingy = selfY + @yoffset - @__offsetx = (@real_x == newRealX) ? 0 : selfX - @screen_x - @__offsety = (@real_y == newRealY) ? 0 : selfY - @screen_y - @screen_x = selfX - @screen_y = selfY - @real_x = newRealX - @real_y = newRealY - if @opacityvar > 0 && @viewport - opac = 255.0 / @opacityvar - minX = (opac * (-@xgravity.to_f / @slowdown).floor) + @startingx - maxX = (opac * (@xgravity.to_f / @slowdown).floor) + @startingx - minY = (opac * (-@ygravity.to_f / @slowdown).floor) + @startingy - maxY = @startingy - minX -= @bmwidth - minY -= @bmheight - maxX += @bmwidth - maxY += @bmheight - if maxX < 0 || maxY < 0 || minX >= Graphics.width || minY >= Graphics.height -# echo "skipped" - return - end - end - particleZ = selfZ + @zoffset - @maxparticless.times do |i| - @particles[i].z = particleZ - if @particles[i].y <= @ytop - @particles[i].y = @startingy + @yoffset - @particles[i].x = @startingx + @xoffset - @particlex[i] = 0.0 - @particley[i] = 0.0 - end - if @particles[i].x <= @xleft - @particles[i].y = @startingy + @yoffset - @particles[i].x = @startingx + @xoffset - @particlex[i] = 0.0 - @particley[i] = 0.0 - end - if @particles[i].y >= @ybottom - @particles[i].y = @startingy + @yoffset - @particles[i].x = @startingx + @xoffset - @particlex[i] = 0.0 - @particley[i] = 0.0 - end - if @particles[i].x >= @xright - @particles[i].y = @startingy + @yoffset - @particles[i].x = @startingx + @xoffset - @particlex[i] = 0.0 - @particley[i] = 0.0 - end - if @fade == 0 - if @opacity[i] <= 0 - @opacity[i] = @originalopacity - @particles[i].y = @startingy + @yoffset - @particles[i].x = @startingx + @xoffset - @particlex[i] = 0.0 - @particley[i] = 0.0 - end - elsif @opacity[i] <= 0 - @opacity[i] = 250 - @particles[i].y = @startingy + @yoffset - @particles[i].x = @startingx + @xoffset - @particlex[i] = 0.0 - @particley[i] = 0.0 - end - calcParticlePos(i) - if @randomhue == 1 - @hue += 0.5 - @hue = 0 if @hue >= 360 - @particles[i].bitmap = loadBitmap(@filename, @hue) if @filename - end - @opacity[i] = @opacity[i] - rand(@opacityvar) - @particles[i].opacity = @opacity[i] - @particles[i].update - end - end - - def calcParticlePos(i) - @leftright = rand(2) - if @leftright == 1 - xo = -@xgravity.to_f / @slowdown - else - xo = @xgravity.to_f / @slowdown - end - yo = -@ygravity.to_f / @slowdown - @particlex[i] += xo - @particley[i] += yo - @particlex[i] -= @__offsetx - @particley[i] -= @__offsety - @particlex[i] = @particlex[i].floor - @particley[i] = @particley[i].floor - @particles[i].x = @particlex[i] + @startingx + @xoffset - @particles[i].y = @particley[i] + @startingy + @yoffset - end - - def dispose - @particles.each do |particle| - particle.dispose - end - @bitmaps.each_value do |bitmap| - bitmap.dispose - end - @particles.clear - @bitmaps.clear - end -end - -#=============================================================================== -# -#=============================================================================== -class Particle_Engine::Fire < ParticleEffect_Event - def initialize(event, viewport) - super - setParameters([0, 0, 1, 20, 40, 0.5, -64, - Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -13, 30, 0]) - initParticles("particle", 250) - end -end - -#=============================================================================== -# -#=============================================================================== -class Particle_Engine::Smoke < ParticleEffect_Event - def initialize(event, viewport) - super - setParameters([0, 0, 0, 80, 20, 0.5, -64, - Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -15, 5, 80]) - initParticles("smoke", 250) - end -end - -#=============================================================================== -# -#=============================================================================== -class Particle_Engine::Teleport < ParticleEffect_Event - def initialize(event, viewport) - super - setParameters([1, 1, 1, 10, rand(360), 1, -64, - Graphics.height, -64, Graphics.width, 0, 3, -8, -15, 20, 0]) - initParticles("wideportal", 250) - @maxparticless.times do |i| - @particles[i].ox = 16 - @particles[i].oy = 16 - end - end -end - -#=============================================================================== -# -#=============================================================================== -class Particle_Engine::Spirit < ParticleEffect_Event - def initialize(event, viewport) - super - setParameters([1, 0, 1, 20, rand(360), 0.5, -64, - Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -13, 30, 0]) - initParticles("particle", 250) - end -end - -#=============================================================================== -# -#=============================================================================== -class Particle_Engine::Explosion < ParticleEffect_Event - def initialize(event, viewport) - super - setParameters([0, 0, 1, 20, 0, 0.5, -64, - Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -13, 30, 0]) - initParticles("explosion", 250) - end -end - -#=============================================================================== -# -#=============================================================================== -class Particle_Engine::Aura < ParticleEffect_Event - def initialize(event, viewport) - super - setParameters([0, 0, 1, 20, 0, 1, -64, - Graphics.height, -64, Graphics.width, 2, 2, -5, -13, 30, 0]) - initParticles("particle", 250) - end -end - -#=============================================================================== -# -#=============================================================================== -class Particle_Engine::Soot < ParticleEffect_Event - def initialize(event, viewport) - super - setParameters([0, 0, 0, 20, 0, 0.5, -64, - Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -15, 5, 80]) - initParticles("smoke", 100, 0, 2) - end -end - -#=============================================================================== -# -#=============================================================================== -class Particle_Engine::SootSmoke < ParticleEffect_Event - def initialize(event, viewport) - super - setParameters([0, 0, 0, 30, 0, 0.5, -64, - Graphics.height, -64, Graphics.width, 0.5, 0.10, -5, -15, 5, 80]) - initParticles("smoke", 100, 0) - @maxparticless.times do |i| - @particles[i].blend_type = rand(6) < 3 ? 1 : 2 - end - end -end - -#=============================================================================== -# -#=============================================================================== -class Particle_Engine::Rocket < ParticleEffect_Event - def initialize(event, viewport) - super - setParameters([0, 0, 0, 60, 0, 0.5, -64, - Graphics.height, -64, Graphics.width, 0.5, 0, -5, -15, 5, 80]) - initParticles("smoke", 100, -1) - end -end - -#=============================================================================== -# -#=============================================================================== -class Particle_Engine::FixedTeleport < ParticleEffect_Event - def initialize(event, viewport) - super - setParameters([1, 0, 1, 10, rand(360), 1, - -Graphics.height, Graphics.height, 0, Graphics.width, 0, 3, -8, -15, 20, 0]) - initParticles("wideportal", 250) - @maxparticless.times do |i| - @particles[i].ox = 16 - @particles[i].oy = 16 - end - end -end - -#=============================================================================== -# By Peter O. -#=============================================================================== -class Particle_Engine::StarTeleport < ParticleEffect_Event - def initialize(event, viewport) - super - setParameters([0, 0, 1, 10, 0, 1, - -Graphics.height, Graphics.height, 0, Graphics.width, 0, 3, -8, -15, 10, 0]) - initParticles("star", 250) - @maxparticless.times do |i| - @particles[i].ox = 48 - @particles[i].oy = 48 - end - end -end - -#=============================================================================== -# -#=============================================================================== -class Particle_Engine::Smokescreen < ParticleEffect_Event - def initialize(event, viewport) - super - setParameters([0, 0, 0, 250, 0, 0.2, -64, - Graphics.height, -64, Graphics.width, 0.8, 0.8, -5, -15, 5, 80]) - initParticles(nil, 100) - @maxparticless.times do |i| - rnd = rand(3) - @opacity[i] = (rnd == 0) ? 1 : 100 - filename = (rnd == 0) ? "explosionsmoke" : "smoke" - @particles[i].bitmap = loadBitmap(filename, @hue) - end - end - - def calcParticlePos(i) - if @randomhue == 1 - filename = (rand(3) == 0) ? "explosionsmoke" : "smoke" - @particles[i].bitmap = loadBitmap(filename, @hue) - end - multiple = 1.7 - xgrav = @xgravity * multiple / @slowdown - xgrav = -xgrav if rand(2) == 1 - ygrav = @ygravity * multiple / @slowdown - ygrav = -ygrav if rand(2) == 1 - @particlex[i] += xgrav - @particley[i] += ygrav - @particlex[i] -= @__offsetx - @particley[i] -= @__offsety - @particlex[i] = @particlex[i].floor - @particley[i] = @particley[i].floor - @particles[i].x = @particlex[i] + @startingx + @xoffset - @particles[i].y = @particley[i] + @startingy + @yoffset - end -end - -#=============================================================================== -# -#=============================================================================== -class Particle_Engine::Flare < ParticleEffect_Event - def initialize(event, viewport) - super - setParameters([0, 0, 1, 30, 10, 1, -64, - Graphics.height, -64, Graphics.width, 2, 2, -5, -12, 30, 0]) - initParticles("particle", 255) - end -end - -#=============================================================================== -# -#=============================================================================== -class Particle_Engine::Splash < ParticleEffect_Event - def initialize(event, viewport) - super - setParameters([0, 0, 1, 30, 255, 1, -64, - Graphics.height, -64, Graphics.width, 4, 2, -5, -12, 30, 0]) - initParticles("smoke", 50) - end - - def update - super - @maxparticless.times do |i| - @particles[i].opacity = 50 - @particles[i].update - end - end -end - -#=============================================================================== -# -#=============================================================================== -class Game_Event < Game_Character - attr_accessor :pe_refresh - - alias nf_particles_game_map_initialize initialize unless private_method_defined?(:nf_particles_game_map_initialize) - - def initialize(map_id, event, map = nil) - @pe_refresh = false - begin - nf_particles_game_map_initialize(map_id, event, map) - rescue ArgumentError - nf_particles_game_map_initialize(map_id, event) - end - end - - alias nf_particles_game_map_refresh refresh unless method_defined?(:nf_particles_game_map_refresh) - - def refresh - nf_particles_game_map_refresh - @pe_refresh = true - end -end diff --git a/Data/Scripts/005_Sprites/011_PictureEx.rb b/Data/Scripts/005_Sprites/010_PictureEx.rb similarity index 92% rename from Data/Scripts/005_Sprites/011_PictureEx.rb rename to Data/Scripts/005_Sprites/010_PictureEx.rb index b5329b609..059cca115 100644 --- a/Data/Scripts/005_Sprites/011_PictureEx.rb +++ b/Data/Scripts/005_Sprites/010_PictureEx.rb @@ -99,6 +99,27 @@ class PictureEx attr_reader :cropBottom # crops sprite to above this y-coordinate attr_reader :frameUpdates # Array of processes updated in a frame + def move_processes + ret = [] + @processes.each do |p| + next if ![Processes::XY, Processes::DELTA_XY].include?(p[0]) + pro = [] + pro.push(p[0] == Processes::XY ? "XY" : "DELTA") + if p[1] == 0 && p[2] == 0 + pro.push("start " + p[7].to_i.to_s + ", " + p[8].to_i.to_s) + else + pro.push("for " + p[2].to_s) if p[2] > 0 + if p[0] == Processes::XY + pro.push("go to " + p[7].to_i.to_s + ", " + p[8].to_i.to_s) + else + pro.push("move by " + p[7].to_i.to_s + ", " + p[8].to_i.to_s) + end + end + ret.push(pro) + end + return ret + end + def initialize(z) # process: [type, delay, total_duration, frame_counter, cb, etc.] @processes = [] @@ -338,8 +359,9 @@ class PictureEx end def update - @timer_start = System.uptime if !@timer_start - this_frame = ((System.uptime - @timer_start) * 20).to_i # 20 frames per second + time_now = System.uptime + @timer_start = time_now if !@timer_start + this_frame = ((time_now - @timer_start) * 20).to_i # 20 frames per second procEnded = false @frameUpdates.clear @processes.each_with_index do |process, i| @@ -379,35 +401,35 @@ class PictureEx end # Update process @frameUpdates.push(process[0]) if !@frameUpdates.include?(process[0]) - start_time = @timer_start + process[1] / 20.0 + start_time = @timer_start + (process[1] / 20.0) duration = process[2] / 20.0 case process[0] when Processes::XY, Processes::DELTA_XY - @x = lerp(process[5], process[7], duration, start_time, System.uptime) - @y = lerp(process[6], process[8], duration, start_time, System.uptime) + @x = lerp(process[5], process[7], duration, start_time, time_now) + @y = lerp(process[6], process[8], duration, start_time, time_now) when Processes::CURVE - @x, @y = getCubicPoint2(process[5], (System.uptime - start_time) / duration) + @x, @y = getCubicPoint2(process[5], (time_now - start_time) / duration) when Processes::Z - @z = lerp(process[5], process[6], duration, start_time, System.uptime) + @z = lerp(process[5], process[6], duration, start_time, time_now) when Processes::ZOOM - @zoom_x = lerp(process[5], process[7], duration, start_time, System.uptime) - @zoom_y = lerp(process[6], process[8], duration, start_time, System.uptime) + @zoom_x = lerp(process[5], process[7], duration, start_time, time_now) + @zoom_y = lerp(process[6], process[8], duration, start_time, time_now) when Processes::ANGLE - @angle = lerp(process[5], process[6], duration, start_time, System.uptime) + @angle = lerp(process[5], process[6], duration, start_time, time_now) when Processes::TONE - @tone.red = lerp(process[5].red, process[6].red, duration, start_time, System.uptime) - @tone.green = lerp(process[5].green, process[6].green, duration, start_time, System.uptime) - @tone.blue = lerp(process[5].blue, process[6].blue, duration, start_time, System.uptime) - @tone.gray = lerp(process[5].gray, process[6].gray, duration, start_time, System.uptime) + @tone.red = lerp(process[5].red, process[6].red, duration, start_time, time_now) + @tone.green = lerp(process[5].green, process[6].green, duration, start_time, time_now) + @tone.blue = lerp(process[5].blue, process[6].blue, duration, start_time, time_now) + @tone.gray = lerp(process[5].gray, process[6].gray, duration, start_time, time_now) when Processes::COLOR - @color.red = lerp(process[5].red, process[6].red, duration, start_time, System.uptime) - @color.green = lerp(process[5].green, process[6].green, duration, start_time, System.uptime) - @color.blue = lerp(process[5].blue, process[6].blue, duration, start_time, System.uptime) - @color.alpha = lerp(process[5].alpha, process[6].alpha, duration, start_time, System.uptime) + @color.red = lerp(process[5].red, process[6].red, duration, start_time, time_now) + @color.green = lerp(process[5].green, process[6].green, duration, start_time, time_now) + @color.blue = lerp(process[5].blue, process[6].blue, duration, start_time, time_now) + @color.alpha = lerp(process[5].alpha, process[6].alpha, duration, start_time, time_now) when Processes::HUE - @hue = lerp(process[5], process[6], duration, start_time, System.uptime) + @hue = lerp(process[5], process[6], duration, start_time, time_now) when Processes::OPACITY - @opacity = lerp(process[5], process[6], duration, start_time, System.uptime) + @opacity = lerp(process[5], process[6], duration, start_time, time_now) when Processes::VISIBLE @visible = process[5] when Processes::BLEND_TYPE @@ -439,7 +461,7 @@ class PictureEx # Add the constant rotation speed if @rotate_speed != 0 @frameUpdates.push(Processes::ANGLE) if !@frameUpdates.include?(Processes::ANGLE) - @auto_angle = @rotate_speed * (System.uptime - @timer_start) + @auto_angle = @rotate_speed * (time_now - @timer_start) while @auto_angle < 0 @auto_angle += 360 end diff --git a/Data/Scripts/005_Sprites/012_ScreenPosHelper.rb b/Data/Scripts/005_Sprites/011_ScreenPosHelper.rb similarity index 100% rename from Data/Scripts/005_Sprites/012_ScreenPosHelper.rb rename to Data/Scripts/005_Sprites/011_ScreenPosHelper.rb diff --git a/Data/Scripts/006_Map renderer/001_TilemapRenderer.rb b/Data/Scripts/006_Map renderer/001_TilemapRenderer.rb index f182bca20..3d556b40d 100644 --- a/Data/Scripts/006_Map renderer/001_TilemapRenderer.rb +++ b/Data/Scripts/006_Map renderer/001_TilemapRenderer.rb @@ -538,7 +538,7 @@ class TilemapRenderer if @old_color != @color @tiles.each do |col| col.each do |coord| - coord.each { |tile| tile.color = @tone } + coord.each { |tile| tile.color = @color } end end @old_color = @color.clone diff --git a/Data/Scripts/007_Objects and windows/002_MessageConfig.rb b/Data/Scripts/007_Objects and windows/002_MessageConfig.rb index a5fc2b1a0..8183d8bfe 100644 --- a/Data/Scripts/007_Objects and windows/002_MessageConfig.rb +++ b/Data/Scripts/007_Objects and windows/002_MessageConfig.rb @@ -24,8 +24,7 @@ module MessageConfig # 2 = Pause cursor is displayed at lower middle side CURSOR_POSITION = 1 WINDOW_OPACITY = 255 - TEXT_SPEED = nil # can be positive to wait frames, or negative - # to show multiple characters in a single frame + TEXT_SPEED = nil # Time in seconds between two characters @@systemFrame = nil @@defaultTextSkin = nil @@textSpeed = nil @@ -100,13 +99,16 @@ module MessageConfig @@textSpeed = value end + # Text speed is the delay in seconds between two adjacent characters being + # shown. def self.pbSettingToTextSpeed(speed) case speed - when 0 then return 2 - when 1 then return 1 - when 2 then return -2 + when 0 then return 4 / 80.0 # Slow + when 1 then return 2 / 80.0 # Medium + when 2 then return 1 / 80.0 # Fast + when 3 then return 0 # Instant end - return TEXT_SPEED || 1 + return TEXT_SPEED || 2 / 80.0 # Normal end #----------------------------------------------------------------------------- diff --git a/Data/Scripts/007_Objects and windows/003_Window.rb b/Data/Scripts/007_Objects and windows/003_Window.rb index c1bb080c4..97ac83f9a 100644 --- a/Data/Scripts/007_Objects and windows/003_Window.rb +++ b/Data/Scripts/007_Objects and windows/003_Window.rb @@ -123,7 +123,6 @@ class Window @back_opacity = 255 @contents_opacity = 255 @cursor_rect = WindowCursorRect.new(self) - @cursorblink = 0 @cursoropacity = 255 @pause = false @pauseopacity = 255 @@ -302,12 +301,11 @@ class Window return if disposed? mustchange = false if @active - if @cursorblink == 0 - @cursoropacity -= 8 - @cursorblink = 1 if @cursoropacity <= 128 + cursor_time = System.uptime / 0.4 + if cursor_time.to_i % 2 == 0 + @cursoropacity = lerp(255, 128, 0.4, cursor_time % 2) else - @cursoropacity += 8 - @cursorblink = 0 if @cursoropacity >= 255 + @cursoropacity = lerp(128, 255, 0.4, (cursor_time - 1) % 2) end mustchange = true if !@cursor_rect.empty? else diff --git a/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb b/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb index 131469836..46091b4bc 100644 --- a/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb +++ b/Data/Scripts/007_Objects and windows/004_SpriteWindow.rb @@ -99,11 +99,10 @@ class SpriteWindow < Window @contents_blend_type = 0 @contents_opacity = 255 @cursor_rect = WindowCursorRect.new(self) - @cursorblink = 0 @cursoropacity = 255 @pause = false @pauseframe = 0 - @flash = 0 + @flash_duration = 0 @pauseopacity = 0 @skinformat = 0 @skinrect = Rect.new(0, 0, 0, 0) @@ -286,11 +285,13 @@ class SpriteWindow < Window privRefresh if @visible end + # duration is in 1/20ths of a second def flash(color, duration) return if disposed? - @flash = duration + 1 + @flash_duration = duration / 20.0 + @flash_timer_start = System.uptime @sprites.each do |i| - i[1].flash(color, duration) + i[1].flash(color, (@flash_duration * Graphics.frame_rate).to_i) # Must be in frames end end @@ -298,12 +299,11 @@ class SpriteWindow < Window return if disposed? mustchange = false if @active - if @cursorblink == 0 - @cursoropacity -= 8 - @cursorblink = 1 if @cursoropacity <= 128 + cursor_time = System.uptime / 0.4 + if cursor_time.to_i % 2 == 0 + @cursoropacity = lerp(255, 128, 0.4, cursor_time % 2) else - @cursoropacity += 8 - @cursorblink = 0 if @cursoropacity >= 255 + @cursoropacity = lerp(128, 255, 0.4, (cursor_time - 1) % 2) end else @cursoropacity = 128 @@ -312,16 +312,14 @@ class SpriteWindow < Window if @pause oldpauseframe = @pauseframe oldpauseopacity = @pauseopacity - @pauseframe = (System.uptime * 5) % 4 # 4 frames, 5 frames per second + @pauseframe = (System.uptime * 5).to_i % 4 # 4 frames, 5 frames per second @pauseopacity = [@pauseopacity + 64, 255].min mustchange = @pauseframe != oldpauseframe || @pauseopacity != oldpauseopacity end privRefresh if mustchange - if @flash > 0 - @sprites.each_value do |i| - i.update - end - @flash -= 1 + if @flash_timer_start + @sprites.each_value { |i| i.update } + @flash_timer_start = nil if System.uptime - @flash_timer_start >= @flash_duration end end diff --git a/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb b/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb index aad8028c9..ee38af09e 100644 --- a/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb +++ b/Data/Scripts/007_Objects and windows/005_SpriteWindow_text.rb @@ -116,33 +116,34 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base attr_reader :waitcount def initialize(text = "") - @cursorMode = MessageConfig::CURSOR_POSITION - @endOfText = nil - @scrollstate = 0 - @realframes = 0 - @scrollY = 0 - @nodraw = false - @lineHeight = 32 - @linesdrawn = 0 - @bufferbitmap = nil - @letterbyletter = false - @starting = true - @displaying = false - @lastDrawnChar = -1 - @fmtchars = [] - @frameskipChanged = false - @frameskip = MessageConfig.pbGetTextSpeed + @cursorMode = MessageConfig::CURSOR_POSITION + @endOfText = nil + @scrollstate = 0 + @scrollY = 0 + @scroll_timer_start = nil + @realframes = 0 + @nodraw = false + @lineHeight = 32 + @linesdrawn = 0 + @bufferbitmap = nil + @letterbyletter = false + @starting = true + @displaying = false + @lastDrawnChar = -1 + @fmtchars = [] + @text_delay_changed = false + @text_delay = MessageConfig.pbGetTextSpeed super(0, 0, 33, 33) - @pausesprite = nil - @text = "" + @pausesprite = nil + @text = "" self.contents = Bitmap.new(1, 1) pbSetSystemFont(self.contents) self.resizeToFit(text, Graphics.width) colors = getDefaultTextColors(self.windowskin) - @baseColor = colors[0] - @shadowColor = colors[1] - self.text = text - @starting = false + @baseColor = colors[0] + @shadowColor = colors[1] + self.text = text + @starting = false end def self.newWithSize(text, x, y, width, height, viewport = nil) @@ -189,13 +190,14 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base refresh end + # Delay in seconds between two adjacent characters appearing. def textspeed - @frameskip + return @text_delay end def textspeed=(value) - @frameskipChanged = true if @frameskip != value - @frameskip = value + @text_delay_changed = true if @text_delay != value + @text_delay = value end def width=(value) @@ -285,6 +287,8 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base def setText(value) @waitcount = 0 @wait_timer_start = nil + @display_timer = 0.0 + @display_last_updated = System.uptime @curchar = 0 @drawncurchar = -1 @lastDrawnChar = -1 @@ -292,6 +296,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base @textlength = unformattedTextLength(value) @scrollstate = 0 @scrollY = 0 + @scroll_timer_start = nil @linesdrawn = 0 @realframes = 0 @textchars = [] @@ -400,7 +405,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base resume visiblelines = (self.height - self.borderY) / @lineHeight loop do - curcharSkip(999) + curcharSkip(true) break if @curchar >= @fmtchars.length # End of message if @textchars[@curchar] == "\1" # Pause message @pausing = true if @curchar < @numtextchars - 1 @@ -462,7 +467,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base self.oy = @scrollY numchars = @numtextchars numchars = [@curchar, @numtextchars].min if self.letterbyletter - return if busy? && @drawncurchar == @curchar && @scrollstate == 0 + return if busy? && @drawncurchar == @curchar && !@scroll_timer_start if !self.letterbyletter || !oldcontents.equal?(self.contents) @drawncurchar = -1 @needclear = true @@ -508,7 +513,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base def redrawText if @letterbyletter oldPosition = self.position - self.text = self.text + self.text = self.text # Clears the text already drawn oldPosition = @numtextchars if oldPosition > @numtextchars while self.position != oldPosition refresh @@ -520,55 +525,56 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base end def updateInternal - curcharskip = @frameskip < 0 ? @frameskip.abs : 1 + time_now = System.uptime + @display_last_updated = time_now if !@display_last_updated + delta_t = time_now - @display_last_updated + @display_last_updated = time_now visiblelines = (self.height - self.borderY) / @lineHeight - if @textchars[@curchar] == "\1" - if !@pausing - @realframes += 1 - if @realframes >= @frameskip || @frameskip < 0 - curcharSkip(curcharskip) - @realframes = 0 - end - end - elsif @textchars[@curchar] == "\n" - if @linesdrawn >= visiblelines - 1 - if @scrollstate < @lineHeight - @scrollstate += [(@lineHeight / 4), 1].max - @scrollY += [(@lineHeight / 4), 1].max - end - if @scrollstate >= @lineHeight - @realframes += 1 - if @realframes >= @frameskip || @frameskip < 0 - curcharSkip(curcharskip) - @linesdrawn += 1 - @realframes = 0 + show_more_characters = false + # Pauses and new lines + if @textchars[@curchar] == "\1" # Waiting + show_more_characters = true if !@pausing + elsif @textchars[@curchar] == "\n" # Move to new line + if @linesdrawn >= visiblelines - 1 # Need to scroll text to show new line + if @scroll_timer_start + old_y = @scrollstate + new_y = lerp(0, @lineHeight, 0.1, @scroll_timer_start, time_now) + @scrollstate = new_y + @scrollY += new_y - old_y + if @scrollstate >= @lineHeight @scrollstate = 0 + @scroll_timer_start = nil + @linesdrawn += 1 + show_more_characters = true end + else + show_more_characters = true end - else - @realframes += 1 - if @realframes >= @frameskip || @frameskip < 0 - curcharSkip(curcharskip) - @linesdrawn += 1 - @realframes = 0 - end - end - elsif @curchar <= @numtextchars - @realframes += 1 - if @realframes >= @frameskip || @frameskip < 0 - curcharSkip(curcharskip) - @realframes = 0 - end - if @textchars[@curchar] == "\1" - @pausing = true if @curchar < @numtextchars - 1 - self.startPause - refresh + else # New line but the next line can be shown without scrolling to it + @linesdrawn += 1 + show_more_characters = true end + elsif @curchar <= @numtextchars # Displaying more text + show_more_characters = true else - @displaying = false + @displaying = false @scrollstate = 0 - @scrollY = 0 - @linesdrawn = 0 + @scrollY = 0 + @scroll_timer_start = nil + @linesdrawn = 0 + end + # Keep displaying more text + if show_more_characters + @display_timer += delta_t + if curcharSkip + if @textchars[@curchar] == "\n" && @linesdrawn >= visiblelines - 1 + @scroll_timer_start = time_now + elsif @textchars[@curchar] == "\1" + @pausing = true if @curchar < @numtextchars - 1 + self.startPause + refresh + end + end end end @@ -583,26 +589,33 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base return if @wait_timer_start end if busy? - refresh if !@frameskipChanged + refresh if !@text_delay_changed updateInternal - # following line needed to allow "textspeed=-999" to work seamlessly - refresh if @frameskipChanged + # following line needed to allow "textspeed=0" to work seamlessly + # TODO: I don't think this is needed any more, but I don't know where to + # look to confirm it'd work properly without this line. + refresh if @text_delay_changed end - @frameskipChanged = false + @text_delay_changed = false end #----------------------------------------------------------------------------- private - def curcharSkip(skip) - skip.times do + def curcharSkip(instant = false) + ret = false + loop do + break if @display_timer < @text_delay && !instant + @display_timer -= @text_delay if !instant + ret = true @curchar += 1 break if @textchars[@curchar] == "\n" || # newline @textchars[@curchar] == "\1" || # pause @textchars[@curchar] == "\2" || # letter-by-letter break @textchars[@curchar].nil? end + return ret end end @@ -615,7 +628,8 @@ class Window_InputNumberPokemon < SpriteWindow_Base def initialize(digits_max) @digits_max = digits_max @number = 0 - @frame = 0 + @cursor_timer_start = System.uptime + @cursor_shown = true @sign = false @negative = false super(0, 0, 32, 32) @@ -674,7 +688,11 @@ class Window_InputNumberPokemon < SpriteWindow_Base def update super digits = @digits_max + (@sign ? 1 : 0) - refresh if @frame % 15 == 0 + cursor_to_show = ((System.uptime - @cursor_timer_start) / 0.35).to_i % 2 == 0 + if cursor_to_show != @cursor_shown + @cursor_shown = cursor_to_show + refresh + end if self.active if Input.repeat?(Input::UP) || Input.repeat?(Input::DOWN) pbPlayCursorSE @@ -696,19 +714,20 @@ class Window_InputNumberPokemon < SpriteWindow_Base if digits >= 2 pbPlayCursorSE @index = (@index + 1) % digits - @frame = 0 + @cursor_timer_start = System.uptime + @cursor_shown = true refresh end elsif Input.repeat?(Input::LEFT) if digits >= 2 pbPlayCursorSE @index = (@index + digits - 1) % digits - @frame = 0 + @cursor_timer_start = System.uptime + @cursor_shown = true refresh end end end - @frame = (@frame + 1) % 30 end #----------------------------------------------------------------------------- @@ -721,8 +740,10 @@ class Window_InputNumberPokemon < SpriteWindow_Base x + (12 - (textwidth / 2)), y - 2 + (self.contents.text_offset_y || 0), # TEXT OFFSET (the - 2) textwidth + 4, 32, text, @baseColor, @shadowColor) - if @index == i && @active && @frame / 15 == 0 - self.contents.fill_rect(x + (12 - (textwidth / 2)), y + 30, textwidth, 2, @baseColor) + # Draw cursor + if @index == i && @active && @cursor_shown + self.contents.fill_rect(x + (12 - (textwidth / 2)), y + 28, textwidth, 4, @shadowColor) + self.contents.fill_rect(x + (12 - (textwidth / 2)), y + 28, textwidth - 2, 2, @baseColor) end end end diff --git a/Data/Scripts/007_Objects and windows/008_AnimatedBitmap.rb b/Data/Scripts/007_Objects and windows/008_AnimatedBitmap.rb index cab09e8ef..dbb3761f0 100644 --- a/Data/Scripts/007_Objects and windows/008_AnimatedBitmap.rb +++ b/Data/Scripts/007_Objects and windows/008_AnimatedBitmap.rb @@ -43,19 +43,19 @@ class PngAnimatedBitmap def initialize(dir, filename, hue = 0) @frames = [] @currentFrame = 0 - @framecount = 0 + @timer_start = System.uptime panorama = RPG::Cache.load_bitmap(dir, filename, hue) if filename[/^\[(\d+)(?:,(\d+))?\]/] # Starts with 1 or 2 numbers in brackets # File has a frame count numFrames = $1.to_i - delay = $2.to_i - delay = 10 if delay == 0 + duration = $2.to_i + duration = 5 if duration == 0 raise "Invalid frame count in #{filename}" if numFrames <= 0 - raise "Invalid frame delay in #{filename}" if delay <= 0 + raise "Invalid frame duration in #{filename}" if duration <= 0 if panorama.width % numFrames != 0 raise "Bitmap's width (#{panorama.width}) is not divisible by frame count: #{filename}" end - @frameDelay = delay + @frame_duration = duration subWidth = panorama.width / numFrames numFrames.times do |i| subBitmap = Bitmap.new(subWidth, panorama.height) @@ -68,6 +68,16 @@ class PngAnimatedBitmap end end + def dispose + return if @disposed + @frames.each { |f| f.dispose } + @disposed = true + end + + def disposed? + return @disposed + end + def [](index) return @frames[index] end @@ -75,15 +85,6 @@ class PngAnimatedBitmap def width; self.bitmap.width; end def height; self.bitmap.height; end - def deanimate - (1...@frames.length).each do |i| - @frames[i].dispose - end - @frames = [@frames[0]] - @currentFrame = 0 - return @frames[0] - end - def bitmap return @frames[@currentFrame] end @@ -92,43 +93,27 @@ class PngAnimatedBitmap return @currentFrame end - def frameDelay(_index) - return @frameDelay - end - def length return @frames.length end + # Actually returns the total number of 1/20ths of a second this animation lasts. + def totalFrames + return @frame_duration * @frames.length + end + def each @frames.each { |item| yield item } end - def totalFrames - return @frameDelay * @frames.length - end - - def disposed? - return @disposed - end - - def update - return if disposed? - if @frames.length > 1 - @framecount += 1 - if @framecount >= @frameDelay - @framecount = 0 - @currentFrame += 1 - @currentFrame %= @frames.length - end + def deanimate + (1...@frames.length).each do |i| + @frames[i].dispose end - end - - def dispose - if !@disposed - @frames.each { |f| f.dispose } - end - @disposed = true + @frames = [@frames[0]] + @currentFrame = 0 + @frame_duration = 0 + return @frames[0] end def copy @@ -137,6 +122,13 @@ class PngAnimatedBitmap x.frames.each_with_index { |frame, i| x.frames[i] = frame.copy } return x end + + def update + return if disposed? + if @frames.length > 1 + @currentFrame = ((System.uptime - @timer_start) / @frame_duration).to_i % @frames.length + end + end end #=============================================================================== diff --git a/Data/Scripts/007_Objects and windows/011_Messages.rb b/Data/Scripts/007_Objects and windows/011_Messages.rb index 7273df6b9..5547042d8 100644 --- a/Data/Scripts/007_Objects and windows/011_Messages.rb +++ b/Data/Scripts/007_Objects and windows/011_Messages.rb @@ -613,7 +613,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni msgwindow.y = lerp(y_start, y_end, appear_duration, appear_timer_start, System.uptime) end when "ts" # Change text speed - msgwindow.textspeed = (param == "") ? -999 : param.to_i + msgwindow.textspeed = (param == "") ? 0 : param.to_i / 80.0 when "." # Wait 0.25 seconds msgwindow.waitcount += 0.25 when "|" # Wait 1 second diff --git a/Data/Scripts/007_Objects and windows/012_TextEntry.rb b/Data/Scripts/007_Objects and windows/012_TextEntry.rb index 076dca94e..14de3bff9 100644 --- a/Data/Scripts/007_Objects and windows/012_TextEntry.rb +++ b/Data/Scripts/007_Objects and windows/012_TextEntry.rb @@ -94,8 +94,9 @@ class Window_TextEntry < SpriteWindow_Base end @helper = CharacterEntryHelper.new(text) @heading = heading + @cursor_timer_start = System.uptime + @cursor_shown = true self.active = true - @frame = 0 refresh end @@ -128,7 +129,8 @@ class Window_TextEntry < SpriteWindow_Base def insert(ch) if @helper.insert(ch) - @frame = 0 + @cursor_timer_start = System.uptime + @cursor_shown = true self.refresh return true end @@ -137,7 +139,8 @@ class Window_TextEntry < SpriteWindow_Base def delete if @helper.delete - @frame = 0 + @cursor_timer_start = System.uptime + @cursor_shown = true self.refresh return true end @@ -145,21 +148,25 @@ class Window_TextEntry < SpriteWindow_Base end def update - @frame += 1 - @frame %= 20 - self.refresh if (@frame % 10) == 0 + cursor_to_show = ((System.uptime - @cursor_timer_start) / 0.35).to_i % 2 == 0 + if cursor_to_show != @cursor_shown + @cursor_shown = cursor_to_show + refresh + end return if !self.active # Moving cursor if Input.repeat?(Input::LEFT) && Input.press?(Input::ACTION) if @helper.cursor > 0 @helper.cursor -= 1 - @frame = 0 + @cursor_timer_start = System.uptime + @cursor_shown = true self.refresh end elsif Input.repeat?(Input::RIGHT) && Input.press?(Input::ACTION) if @helper.cursor < self.text.scan(/./m).length @helper.cursor += 1 - @frame = 0 + @cursor_timer_start = System.uptime + @cursor_shown = true self.refresh end elsif Input.repeat?(Input::BACK) # Backspace @@ -201,13 +208,13 @@ class Window_TextEntry < SpriteWindow_Base # Draw text pbDrawShadowText(bitmap, x, y, textwidth + 4, 32, c, @baseColor, @shadowColor) # Draw cursor if necessary - if ((@frame / 10) & 1) == 0 && i == @helper.cursor + if i == @helper.cursor && @cursor_shown bitmap.fill_rect(x, y + 4, 2, 24, cursorcolor) end # Add x to drawn text width x += textwidth end - if ((@frame / 10) & 1) == 0 && textscan.length == @helper.cursor + if textscan.length == @helper.cursor && @cursor_shown bitmap.fill_rect(x, y + 4, 2, 24, cursorcolor) end end @@ -218,22 +225,26 @@ end #=============================================================================== class Window_TextEntry_Keyboard < Window_TextEntry def update - @frame += 1 - @frame %= 20 - self.refresh if (@frame % 10) == 0 + cursor_to_show = ((System.uptime - @cursor_timer_start) / 0.35).to_i % 2 == 0 + if cursor_to_show != @cursor_shown + @cursor_shown = cursor_to_show + refresh + end return if !self.active # Moving cursor if Input.triggerex?(:LEFT) || Input.repeatex?(:LEFT) if @helper.cursor > 0 @helper.cursor -= 1 - @frame = 0 + @cursor_timer_start = System.uptime + @cursor_shown = true self.refresh end return elsif Input.triggerex?(:RIGHT) || Input.repeatex?(:RIGHT) if @helper.cursor < self.text.scan(/./m).length @helper.cursor += 1 - @frame = 0 + @cursor_timer_start = System.uptime + @cursor_shown = true self.refresh end return @@ -260,7 +271,8 @@ class Window_MultilineTextEntry < SpriteWindow_Base @firstline = 0 @cursorLine = 0 @cursorColumn = 0 - @frame = 0 + @cursor_timer_start = System.uptime + @cursor_shown = true self.active = true refresh end @@ -301,7 +313,8 @@ class Window_MultilineTextEntry < SpriteWindow_Base def insert(ch) @helper.cursor = getPosFromLineAndColumn(@cursorLine, @cursorColumn) if @helper.insert(ch) - @frame = 0 + @cursor_timer_start = System.uptime + @cursor_shown = true @textchars = nil moveCursor(0, 1) self.refresh @@ -313,7 +326,8 @@ class Window_MultilineTextEntry < SpriteWindow_Base def delete @helper.cursor = getPosFromLineAndColumn(@cursorLine, @cursorColumn) if @helper.delete - @frame = 0 + @cursor_timer_start = System.uptime + @cursor_shown = true moveCursor(0, -1) # use old textchars @textchars = nil self.refresh @@ -407,7 +421,8 @@ class Window_MultilineTextEntry < SpriteWindow_Base # Calculate new cursor position @helper.cursor = getPosFromLineAndColumn(@cursorLine, @cursorColumn) if doRefresh - @frame = 0 + @cursor_timer_start = System.uptime + @cursor_shown = true self.refresh end @firstline = @cursorLine if @cursorLine < @firstline @@ -450,9 +465,11 @@ class Window_MultilineTextEntry < SpriteWindow_Base end def update - @frame += 1 - @frame %= 20 - self.refresh if (@frame % 10) == 0 + cursor_to_show = ((System.uptime - @cursor_timer_start) / 0.35).to_i % 2 == 0 + if cursor_to_show != @cursor_shown + @cursor_shown = cursor_to_show + refresh + end return if !self.active # Moving cursor if Input.triggerex?(:UP) || Input.repeatex?(:UP) @@ -519,7 +536,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base pbDrawShadowText(bitmap, text[1], textY, textwidth, textheight, c, @baseColor, @shadowColor) end # Draw cursor - if ((@frame / 10) & 1) == 0 + if @cursor_shown textheight = bitmap.text_size("X").height cursorY = (textheight * @cursorLine) - startY cursorX = 0 diff --git a/Data/Scripts/009_Scenes/002_EventScene.rb b/Data/Scripts/009_Scenes/002_EventScene.rb index 58f3ff78d..07f1c5948 100644 --- a/Data/Scripts/009_Scenes/002_EventScene.rb +++ b/Data/Scripts/009_Scenes/002_EventScene.rb @@ -131,18 +131,25 @@ class EventScene return @pictures[num] end - def wait(frames) - frames.times { update } + # ticks is in 1/20ths of a second. + def wait(ticks) + return if ticks <= 0 + timer_start = System.uptime + loop do + update + break if System.uptime - timer_start >= ticks / 20.0 + end end - def pictureWait(extraframes = 0) + # extra_ticks is in 1/20ths of a second. + def pictureWait(extra_ticks = 0) loop do hasRunning = false @pictures.each { |pic| hasRunning = true if pic.running? } break if !hasRunning update end - extraframes.times { update } + wait(extra_ticks) end def update @@ -164,8 +171,9 @@ class EventScene end def main - until disposed? + loop do update + break if disposed? end end end diff --git a/Data/Scripts/012_Overworld/001_Overworld visuals/001_Overworld_Weather.rb b/Data/Scripts/012_Overworld/001_Overworld visuals/001_Overworld_Weather.rb index ebe48bfb8..f7563400e 100644 --- a/Data/Scripts/012_Overworld/001_Overworld visuals/001_Overworld_Weather.rb +++ b/Data/Scripts/012_Overworld/001_Overworld visuals/001_Overworld_Weather.rb @@ -271,6 +271,7 @@ module RPG def update_sprite_position(sprite, index, is_new_sprite = false) return if !sprite || !sprite.bitmap || !sprite.visible + # TODO: FPS. delta_t = Graphics.delta lifetimes = (is_new_sprite) ? @new_sprite_lifetimes : @sprite_lifetimes if lifetimes[index] >= 0 @@ -286,6 +287,7 @@ module RPG if @weatherTypes[weather_type][0].category == :Rain && index.odd? # Splash sprite.opacity = (lifetimes[index] < 0.2) ? 255 : 0 # 0.2 seconds else + # TODO: FPS. dist_x = @weatherTypes[weather_type][0].particle_delta_x * delta_t dist_y = @weatherTypes[weather_type][0].particle_delta_y * delta_t sprite.x += dist_x @@ -299,6 +301,7 @@ module RPG sprite.x += Graphics.width if sprite.x - @ox < -sprite.width sprite.y -= Graphics.height if sprite.y - @oy > Graphics.height sprite.y += Graphics.height if sprite.y - @oy < -sprite.height + # TODO: FPS. sprite.opacity += @weatherTypes[weather_type][0].particle_delta_opacity * delta_t x = sprite.x - @ox y = sprite.y - @oy @@ -310,11 +313,13 @@ module RPG end def recalculate_tile_positions + # TODO: FPS. delta_t = Graphics.delta weather_type = @type if @fading && @fade_time >= [FADE_OLD_TONE_END - @time_shift, 0].max weather_type = @target_type end + # TODO: FPS. @tile_x += @weatherTypes[weather_type][0].tile_delta_x * delta_t @tile_y += @weatherTypes[weather_type][0].tile_delta_y * delta_t while @tile_x < @ox - @weatherTypes[weather_type][2][0].width @@ -411,6 +416,7 @@ module RPG @sun_magnitude = weather_max if @sun_magnitude != weather_max && @sun_magnitude != -weather_max @sun_magnitude *= -1 if (@sun_magnitude > 0 && @sun_strength > @sun_magnitude) || (@sun_magnitude < 0 && @sun_strength < 0) + # TODO: FPS. @sun_strength += @sun_magnitude.to_f * Graphics.delta / 0.4 # 0.4 seconds per half flash tone_red += @sun_strength tone_green += @sun_strength @@ -424,6 +430,7 @@ module RPG def update_fading return if !@fading old_fade_time = @fade_time + # TODO: FPS. @fade_time += Graphics.delta # Change tile bitmaps if @type != @target_type @@ -482,6 +489,7 @@ module RPG update_screen_tone # Storm flashes if @type == :Storm && !@fading + # TODO: FPS. if @time_until_flash > 0 @time_until_flash -= Graphics.delta if @time_until_flash <= 0 diff --git a/Data/Scripts/012_Overworld/001_Overworld visuals/002_Overworld_Overlays.rb b/Data/Scripts/012_Overworld/001_Overworld visuals/002_Overworld_Overlays.rb index 3867276aa..bdad86c90 100644 --- a/Data/Scripts/012_Overworld/001_Overworld visuals/002_Overworld_Overlays.rb +++ b/Data/Scripts/012_Overworld/001_Overworld visuals/002_Overworld_Overlays.rb @@ -223,6 +223,5 @@ EventHandlers.add(:on_new_spriteset_map, :add_light_effects, spriteset.addUserSprite(LightEffect_Basic.new(map.events[i], viewport, map)) end end - spriteset.addUserSprite(Particle_Engine.new(viewport, map)) } ) diff --git a/Data/Scripts/013_Items/004_Item_Phone.rb b/Data/Scripts/013_Items/004_Item_Phone.rb index 85a2185de..53d324950 100644 --- a/Data/Scripts/013_Items/004_Item_Phone.rb +++ b/Data/Scripts/013_Items/004_Item_Phone.rb @@ -574,6 +574,7 @@ EventHandlers.add(:on_frame_update, :phone_call_counter, if $PokemonGlobal.phone.time_to_next_call <= 0 $PokemonGlobal.phone.time_to_next_call = rand(20...40) * 60.0 # 20-40 minutes end + # TODO: FPS. Can probably leave this alone. $PokemonGlobal.phone.time_to_next_call -= Graphics.delta next if $PokemonGlobal.phone.time_to_next_call > 0 # Time for a random phone call; generate one diff --git a/Data/Scripts/016_UI/001_Non-interactive UI/006_UI_HallOfFame.rb b/Data/Scripts/016_UI/001_Non-interactive UI/006_UI_HallOfFame.rb index 941298428..d0deb1c4e 100644 --- a/Data/Scripts/016_UI/001_Non-interactive UI/006_UI_HallOfFame.rb +++ b/Data/Scripts/016_UI/001_Non-interactive UI/006_UI_HallOfFame.rb @@ -15,30 +15,31 @@ # #=============================================================================== class HallOfFame_Scene - # When true, all pokémon will be in one line - # When false, all pokémon will be in two lines + # When true, all pokémon will be in one line. + # When false, all pokémon will be in two lines. SINGLE_ROW_OF_POKEMON = false - # Make the pokémon movement ON in hall entry + # Make the pokémon movement ON in hall entry. ANIMATION = true - # Speed in pokémon movement in hall entry. Don't use less than 2! - ANIMATIONSPEED = 32 + # Time in seconds for a Pokémon to slide to its position from off-screen. + APPEAR_SPEED = 0.4 # Entry wait time (in seconds) between showing each Pokémon (and trainer). - # Waits for twice this tme when showing "Welcome to the Hall of Fame!". ENTRY_WAIT_TIME = 3.0 + # Wait time (in seconds) when showing "Welcome to the Hall of Fame!". + WELCOME_WAIT_TIME = 4.0 # Maximum number limit of simultaneous hall entries saved. # 0 = Doesn't save any hall. -1 = no limit - # Prefer to use larger numbers (like 500 and 1000) than don't put a limit - # If a player exceed this limit, the first one will be removed + # Prefer to use larger numbers (like 500 and 1000) than don't put a limit. + # If a player exceed this limit, the first one will be removed. HALL_ENTRIES_LIMIT = 50 - # The entry music name. Put "" to doesn't play anything + # The entry music name. Put "" to doesn't play anything. HALL_OF_FAME_BGM = "Hall of Fame" - # Allow eggs to be show and saved in hall + # Allow eggs to be show and saved in hall. ALLOW_EGGS = true - # Remove the hallbars when the trainer sprite appears + # Remove the hallbars when the trainer sprite appears. REMOVE_BARS_WHEN_SHOWING_TRAINER = true - # The final fade speed on entry + # The final fade speed on entry. FINAL_FADE_DURATION = 1.0 - # Sprite's opacity value when it isn't selected + # Sprite's opacity value when it isn't selected. OPACITY = 64 TEXT_BASE_COLOR = Color.new(248, 248, 248) TEXT_SHADOW_COLOR = Color.new(0, 0, 0) @@ -68,8 +69,7 @@ class HallOfFame_Scene @useMusic = (HALL_OF_FAME_BGM && HALL_OF_FAME_BGM != "") pbBGMPlay(HALL_OF_FAME_BGM) if @useMusic saveHallEntry - @xmovement = [] - @ymovement = [] + @movements = [] createBattlers pbFadeInAndShow(@sprites) { pbUpdate } end @@ -92,14 +92,15 @@ class HallOfFame_Scene end def slowFadeOut(duration) + col = Color.new(0, 0, 0, 0) timer_start = System.uptime loop do - alpha = lerp(255, 0, duration, timer_start, System.uptime) - pbSetSpritesToColor(@sprites, Color.new(0, 0, 0, alpha)) + col.alpha = lerp(0, 255, duration, timer_start, System.uptime) + @viewport.color = col Graphics.update Input.update pbUpdate - break if alpha == 0 + break if col.alpha == 255 end end @@ -132,120 +133,94 @@ class HallOfFame_Scene # Return the x/y point position in screen for battler index number # Don't use odd numbers! def xpointformula(battlernumber) - ret = 0 if SINGLE_ROW_OF_POKEMON - ret = ((60 * (battlernumber / 2)) + 48) * (xpositionformula(battlernumber) - 1) - ret += (Graphics.width / 2) - 56 - else - ret = 32 + (160 * xpositionformula(battlernumber)) + ret = ((60 * (battlernumber / 2)) + 48) * (xpositionformula(battlernumber) - 1) # -48, 48, -108, 108, -168, 168 + return ret + (Graphics.width / 2) # 208, 304, 148, 364, 88, 424 end - return ret + return 96 + (160 * xpositionformula(battlernumber)) # 256, 96, 456, 256, 456, 96 end def ypointformula(battlernumber) - ret = 0 - if SINGLE_ROW_OF_POKEMON - ret = 96 - (8 * (battlernumber / 2)) - else - ret = 32 + (128 * ypositionformula(battlernumber) / 2) - end - return ret + return 180 - (32 * (battlernumber / 2)) if SINGLE_ROW_OF_POKEMON # 180, 180, 148, 148, 116, 116 + return 96 + (64 * ypositionformula(battlernumber)) # 90, 90, 90, 160, 160, 160 end - # Returns 0, 1 or 2 as the x/y column value + # Returns 0, 1 or 2 as the x position value (left, middle, right column) def xpositionformula(battlernumber) - ret = 0 - if SINGLE_ROW_OF_POKEMON - ret = (battlernumber % 2) * 2 - else - ret = (battlernumber / 3).even? ? (19 - battlernumber) % 3 : (19 + battlernumber) % 3 - end - return ret + return (battlernumber % 2) * 2 if SINGLE_ROW_OF_POKEMON # 0, 2, 0, 2, 0, 2 + return (1 - battlernumber) % 3 if (battlernumber / 3).even? # First 3 mons: 1, 0, 2 + return (1 + battlernumber) % 3 # Second 3 mons: 1, 2, 0 end + # Returns 0, 1 or 2 as the y position value (top, middle, bottom row) def ypositionformula(battlernumber) - ret = 0 - if SINGLE_ROW_OF_POKEMON - ret = 1 - else - ret = ((battlernumber / 3) % 2) * 2 - end - return ret + return 1 if SINGLE_ROW_OF_POKEMON # 1, 1, 1, 1, 1, 1 + return ((battlernumber / 3) % 2) * 2 # 0, 0, 0, 2, 2, 2 end def moveSprite(i) spritename = (i > -1) ? "pokemon#{i}" : "trainer" - speed = (i > -1) ? ANIMATIONSPEED : 2 - if !ANIMATION # Skips animation - @sprites[spritename].x -= speed * @xmovement[i] - @xmovement[i] = 0 - @sprites[spritename].y -= speed * @ymovement[i] - @ymovement[i] = 0 - end - if @xmovement[i] != 0 - direction = (@xmovement[i] > 0) ? -1 : 1 - @sprites[spritename].x += speed * direction - @xmovement[i] += direction - end - if @ymovement[i] != 0 - direction = (@ymovement[i] > 0) ? -1 : 1 - @sprites[spritename].y += speed * direction - @ymovement[i] += direction + if !ANIMATION # Skips animation, place directly in end position + @sprites[spritename].x = @movements[i][1] + @sprites[spritename].y = @movements[i][3] + @movements[i][0] = @movements[i][1] + @movements[i][2] = @movements[i][3] + return end + @movements[i][4] = System.uptime if !@movements[i][4] + speed = (i > -1) ? APPEAR_SPEED : APPEAR_SPEED * 3 + @sprites[spritename].x = lerp(@movements[i][0], @movements[i][1], speed, @movements[i][4], System.uptime) + @sprites[spritename].y = lerp(@movements[i][2], @movements[i][3], speed, @movements[i][4], System.uptime) + @movements[i][0] = @movements[i][1] if @sprites[spritename].x == @movements[i][1] + @movements[i][2] = @movements[i][3] if @sprites[spritename].y == @movements[i][3] end def createBattlers(hide = true) # Movement in animation - 6.times do |i| - # Clear all 6 pokémon sprites and dispose the ones that exists every time + Settings::MAX_PARTY_SIZE.times do |i| + # Clear all pokémon sprites and dispose the ones that exists every time # that this method is call restartSpritePosition(@sprites, "pokemon#{i}") next if i >= @hallEntry.size - xpoint = xpointformula(i) - ypoint = ypointformula(i) - pok = @hallEntry[i] + end_x = xpointformula(i) + end_y = ypointformula(i) @sprites["pokemon#{i}"] = PokemonSprite.new(@viewport) - @sprites["pokemon#{i}"].setOffset(PictureOrigin::TOP_LEFT) - @sprites["pokemon#{i}"].setPokemonBitmap(pok) + @sprites["pokemon#{i}"].setPokemonBitmap(@hallEntry[i]) # This method doesn't put the exact coordinates - @sprites["pokemon#{i}"].x = xpoint - @sprites["pokemon#{i}"].y = ypoint - if @sprites["pokemon#{i}"].bitmap && !@sprites["pokemon#{i}"].disposed? - @sprites["pokemon#{i}"].x += (128 - @sprites["pokemon#{i}"].bitmap.width) / 2 - @sprites["pokemon#{i}"].y += (128 - @sprites["pokemon#{i}"].bitmap.height) / 2 - end - @sprites["pokemon#{i}"].z = 7 - i if SINGLE_ROW_OF_POKEMON + @sprites["pokemon#{i}"].x = end_x + @sprites["pokemon#{i}"].y = end_y + @sprites["pokemon#{i}"].z = Settings::MAX_PARTY_SIZE - i if SINGLE_ROW_OF_POKEMON next if !hide # Animation distance calculation - horizontal = 1 - xpositionformula(i) - vertical = 1 - ypositionformula(i) - xdistance = (horizontal == -1) ? -@sprites["pokemon#{i}"].bitmap.width : Graphics.width - ydistance = (vertical == -1) ? -@sprites["pokemon#{i}"].bitmap.height : Graphics.height - xdistance = ((xdistance - @sprites["pokemon#{i}"].x) / ANIMATIONSPEED).abs + 1 - ydistance = ((ydistance - @sprites["pokemon#{i}"].y) / ANIMATIONSPEED).abs + 1 - biggerdistance = (xdistance > ydistance) ? xdistance : ydistance - @xmovement[i] = biggerdistance - @xmovement[i] *= -1 if horizontal == -1 - @xmovement[i] = 0 if horizontal == 0 - @ymovement[i] = biggerdistance - @ymovement[i] *= -1 if vertical == -1 - @ymovement[i] = 0 if vertical == 0 - # Hide the battlers - @sprites["pokemon#{i}"].x += @xmovement[i] * ANIMATIONSPEED - @sprites["pokemon#{i}"].y += @ymovement[i] * ANIMATIONSPEED + x_direction = xpositionformula(i) - 1 + y_direction = ypositionformula(i) - 1 + distance = 0 + if y_direction == 0 + distance = (x_direction > 0) ? end_x : Graphics.width - end_x + distance += @sprites["pokemon#{i}"].bitmap.width / 2 + else + distance = (y_direction > 0) ? end_y : Graphics.height - end_y + distance += @sprites["pokemon#{i}"].bitmap.height / 2 + end + start_x = end_x - x_direction * distance + start_y = end_y - y_direction * distance + @sprites["pokemon#{i}"].x = start_x + @sprites["pokemon#{i}"].y = start_y + @movements[i] = [start_x, end_x, start_y, end_y] end end def createTrainerBattler @sprites["trainer"] = IconSprite.new(@viewport) - @sprites["trainer"].setBitmap(GameData::TrainerType.front_sprite_filename($player.trainer_type)) + @sprites["trainer"].setBitmap(GameData::TrainerType.player_front_sprite_filename($player.trainer_type)) if SINGLE_ROW_OF_POKEMON @sprites["trainer"].x = Graphics.width / 2 - @sprites["trainer"].y = 178 + @sprites["trainer"].y = 208 else @sprites["trainer"].x = Graphics.width - 96 @sprites["trainer"].y = 160 end + @movements.push([Graphics.width / 2, @sprites["trainer"].x, @sprites["trainer"].y, @sprites["trainer"].y]) @sprites["trainer"].z = 9 @sprites["trainer"].ox = @sprites["trainer"].bitmap.width / 2 @sprites["trainer"].oy = @sprites["trainer"].bitmap.height / 2 @@ -253,13 +228,8 @@ class HallOfFame_Scene @sprites["overlay"].bitmap.clear @sprites["hallbars"].visible = false end - @xmovement[@battlerIndex] = 0 - @ymovement[@battlerIndex] = 0 if ANIMATION && !SINGLE_ROW_OF_POKEMON # Trainer Animation - startpoint = Graphics.width / 2 - # 2 is the trainer speed - @xmovement[@battlerIndex] = (startpoint - @sprites["trainer"].x) / 2 - @sprites["trainer"].x = startpoint + @sprites["trainer"].x = @movements.last[0] else timer_start = System.uptime loop do @@ -376,7 +346,9 @@ class HallOfFame_Scene def pbUpdateAnimation if @battlerIndex <= @hallEntry.size - if @xmovement[@battlerIndex] != 0 || @ymovement[@battlerIndex] != 0 + if @movements[@battlerIndex] && + (@movements[@battlerIndex][0] != @movements[@battlerIndex][1] || + @movements[@battlerIndex][2] != @movements[@battlerIndex][3]) spriteIndex = (@battlerIndex < @hallEntry.size) ? @battlerIndex : -1 moveSprite(spriteIndex) else @@ -404,7 +376,7 @@ class HallOfFame_Scene Graphics.update Input.update pbUpdate - break if System.uptime - timer_start >= ENTRY_WAIT_TIME * 2 + break if System.uptime - timer_start >= WELCOME_WAIT_TIME end setPokemonSpritesOpacity(-1, OPACITY) if !SINGLE_ROW_OF_POKEMON createTrainerBattler diff --git a/Data/Scripts/016_UI/015_UI_Options.rb b/Data/Scripts/016_UI/015_UI_Options.rb index d036ab17d..34129f17c 100644 --- a/Data/Scripts/016_UI/015_UI_Options.rb +++ b/Data/Scripts/016_UI/015_UI_Options.rb @@ -17,7 +17,7 @@ class PokemonSystem attr_accessor :textinput def initialize - @textspeed = 1 # Text speed (0=slow, 1=normal, 2=fast) + @textspeed = 1 # Text speed (0=slow, 1=medium, 2=fast, 3=instant) @battlescene = 0 # Battle effects (animations) (0=on, 1=off) @battlestyle = 0 # Battle style (0=switch, 1=set) @sendtoboxes = 0 # Send to Boxes (0=manual, 1=automatic) @@ -422,7 +422,7 @@ MenuHandlers.add(:options_menu, :text_speed, { "name" => _INTL("Text Speed"), "order" => 30, "type" => EnumOption, - "parameters" => [_INTL("Slow"), _INTL("Normal"), _INTL("Fast")], + "parameters" => [_INTL("Slow"), _INTL("Mid"), _INTL("Fast"), _INTL("Inst")], "description" => _INTL("Choose the speed at which text appears."), "on_select" => proc { |scene| scene.sprites["textbox"].letterbyletter = true }, "get_proc" => proc { next $PokemonSystem.textspeed }, diff --git a/Data/Scripts/016_UI/017_UI_PokemonStorage.rb b/Data/Scripts/016_UI/017_UI_PokemonStorage.rb index 170a22293..ec2ce79aa 100644 --- a/Data/Scripts/016_UI/017_UI_PokemonStorage.rb +++ b/Data/Scripts/016_UI/017_UI_PokemonStorage.rb @@ -5,26 +5,20 @@ class PokemonBoxIcon < IconSprite def initialize(pokemon, viewport = nil) super(0, 0, viewport) @pokemon = pokemon - @release = SpriteInterpolator.new - @startRelease = false + @release_timer_start = nil refresh end def releasing? - return @release.tweening? + return !@release_timer_start.nil? end def release - self.ox = self.src_rect.width / 2 # 32 + self.ox = self.src_rect.width / 2 # 32 self.oy = self.src_rect.height / 2 # 32 - self.x += self.src_rect.width / 2 # 32 + self.x += self.src_rect.width / 2 # 32 self.y += self.src_rect.height / 2 # 32 - @release.tween(self, - [[SpriteInterpolator::ZOOM_X, 0], - [SpriteInterpolator::ZOOM_Y, 0], - [SpriteInterpolator::OPACITY, 0]], - 100) - @startRelease = true + @release_timer_start = System.uptime end def refresh @@ -35,9 +29,17 @@ class PokemonBoxIcon < IconSprite def update super - @release.update - self.color = Color.new(0, 0, 0, 0) - dispose if @startRelease && !releasing? + if releasing? + time_now = System.uptime + self.zoom_x = lerp(1.0, 0.0, 1.5, @release_timer_start, System.uptime) + self.zoom_y = self.zoom_x + self.opacity = lerp(255, 0, 1.5, @release_timer_start, System.uptime) + self.color = Color.new(0, 0, 0, 0) + if self.opacity == 0 + @release_timer_start = nil + dispose + end + end end end diff --git a/Data/Scripts/016_UI/023_UI_PurifyChamber.rb b/Data/Scripts/016_UI/023_UI_PurifyChamber.rb index bdb61a5fe..b360180e7 100644 --- a/Data/Scripts/016_UI/023_UI_PurifyChamber.rb +++ b/Data/Scripts/016_UI/023_UI_PurifyChamber.rb @@ -35,11 +35,11 @@ def pbDrawGauge(bitmap, rect, color, value, maxValue) end end -def calcPoint(x, y, distance, angle) # angle in degrees - angle -= (angle / 360.0).floor * 360 # normalize - angle = (angle / 360.0) * (2 * Math::PI) # convert to radians - angle = -angle % (2 * Math::PI) # normalize radians - point = [(Math.cos(angle) * distance), (Math.sin(angle) * distance)] +def calcPoint(x, y, distance, angle) # angle in degrees + angle -= (angle / 360.0).floor * 360 # normalize + angle = (angle / 360.0) * (2 * Math::PI) # convert to radians + angle = -angle % (2 * Math::PI) # normalize radians + point = [distance * Math.cos(angle), distance * Math.sin(angle)] point[0] += x point[1] += y return point @@ -670,6 +670,9 @@ end # #=============================================================================== class DirectFlowDiagram + # Distance travelled by a dot in 1 second. + DOT_SPEED = 80 + def initialize(viewport = nil) @points = [] @angles = [] @@ -681,21 +684,25 @@ class DirectFlowDiagram @distance = 96 end + def dispose + @points.each { |point| point.dispose } + end + # 0=none, 1=weak, 2=strong def setFlowStrength(strength) @strength = strength end def visible=(value) - @points.each do |point| - point.visible = value - end + @points.each { |point| point.visible = value } end - def dispose - @points.each do |point| - point.dispose - end + def color=(value) + @points.each { |point| point.color = value } + end + + def setAngle(angle1) + @angle = angle1 - ((angle1 / 360).floor * 360) end def ensurePoint(j) @@ -725,18 +732,9 @@ class DirectFlowDiagram end i += (@strength == 2) ? 16 : 32 end - @offset += (@strength == 2) ? 3 : 2 - @offset %= @distance - end - - def color=(value) - @points.each do |point| - point.color = value - end - end - - def setAngle(angle1) - @angle = angle1 - ((angle1 / 360).floor * 360) + offset_delta = System.uptime * DOT_SPEED + offset_delta *= 1.5 if @strength == 2 + @offset = offset_delta % @distance end end @@ -744,6 +742,9 @@ end # #=============================================================================== class FlowDiagram + # Distance travelled by a dot in 1 second. + DOT_SPEED = 80 + def initialize(viewport = nil) @points = [] @angles = [] @@ -755,21 +756,21 @@ class FlowDiagram @distance = 96 end - # 0=none, 1=weak, 2=strong - def setFlowStrength(strength) - @strength = strength + def dispose + @points.each { |point| point.dispose } end def visible=(value) - @points.each do |point| - point.visible = value - end + @points.each { |point| point.visible = value } end - def dispose - @points.each do |point| - point.dispose - end + def color=(value) + @points.each { |point| point.color = value } + end + + # 0=none, 1=weak, 2=strong + def setFlowStrength(strength) + @strength = strength end def ensurePoint(j) @@ -781,6 +782,15 @@ class FlowDiagram @points[j].visible = (@strength != 0) end + def setRange(angle1, angle2) + @startAngle = angle1 - ((angle1 / 360).floor * 360) + @endAngle = angle2 - ((angle2 / 360).floor * 360) + if @startAngle == @endAngle && angle1 != angle2 + @startAngle = 0 + @endAngle = 359.99 + end + end + def withinRange(angle, startAngle, endAngle) if startAngle > endAngle return (angle >= startAngle || angle <= endAngle) && @@ -808,23 +818,9 @@ class FlowDiagram end i += (@strength == 2) ? 10 : 20 end - @offset -= (@strength == 2) ? 3 : 2 - @offset %= (360 * 6) - end - - def color=(value) - @points.each do |point| - point.color = value - end - end - - def setRange(angle1, angle2) - @startAngle = angle1 - ((angle1 / 360).floor * 360) - @endAngle = angle2 - ((angle2 / 360).floor * 360) - if @startAngle == @endAngle && angle1 != angle2 - @startAngle = 0 - @endAngle = 359.99 - end + offset_delta = -System.uptime * DOT_SPEED + offset_delta *= 1.5 if @strength == 2 + @offset = offset_delta % (360 * 6) end end @@ -870,7 +866,7 @@ class PurifyChamberSetView < Sprite setcount.times do |i| @flows[i] = FlowDiagram.new(self.viewport) if !@flows[i] angle = 360 - (i * 360 / setcount) - angle += 90 # start at 12 not 3 o'clock + angle += 90 # start at 12 not 3 o'clock endAngle = angle - (360 / setcount) @flows[i].setRange(endAngle, angle) @flows[i].setFlowStrength(@chamber[@set].affinity(i)) @@ -913,7 +909,7 @@ class PurifyChamberSetView < Sprite if pos.nil? @cursor = 0 else - pos -= (pos / points).floor * points # modulus + pos -= (pos / points).floor * points # modulus pos *= 2 if @chamber.setCount(@set) == PurifyChamber::SETSIZE @cursor = pos + 1 end diff --git a/Data/Scripts/016_UI/025_UI_TextEntry.rb b/Data/Scripts/016_UI/025_UI_TextEntry.rb index 81afad451..687878a54 100644 --- a/Data/Scripts/016_UI/025_UI_TextEntry.rb +++ b/Data/Scripts/016_UI/025_UI_TextEntry.rb @@ -216,19 +216,19 @@ class PokemonEntryScene pbPlayDecisionSE break end - elsif index == -1 # Insert a space + elsif index == -1 # Insert a space if @sprites["entry"].insert(" ") pbPlayDecisionSE else pbPlayBuzzerSE end - elsif index == -2 # Change character set + elsif index == -2 # Change character set pbPlayDecisionSE @symtype += 1 @symtype = 0 if @symtype >= @@Characters.length @sprites["entry2"].setCharset(@@Characters[@symtype][0]) @sprites["entry2"].setOtherCharset(@@Characters[@symtype][1]) - else # Insert given character + else # Insert given character if @sprites["entry"].insert(@sprites["entry2"].character) pbPlayDecisionSE else diff --git a/Data/Scripts/017_Minigames/003_Minigame_SlotMachine.rb b/Data/Scripts/017_Minigames/003_Minigame_SlotMachine.rb index 888e6ffc6..e77640a9a 100644 --- a/Data/Scripts/017_Minigames/003_Minigame_SlotMachine.rb +++ b/Data/Scripts/017_Minigames/003_Minigame_SlotMachine.rb @@ -6,28 +6,23 @@ # - The number is either 0 (easy), 1 (default) or 2 (hard). #=============================================================================== class SlotMachineReel < BitmapSprite - attr_accessor :reel - attr_accessor :toppos - attr_accessor :spinning - attr_accessor :stopping - attr_accessor :slipping - - SCROLLSPEED = 16 # Must be a divisor of 48 - ICONSPOOL = [[0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7], # 0 - Easy - [0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 6, 7], # 1 - Medium (default) - [0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 6, 7]] # 2 - Hard + SCROLL_SPEED = 640 # Pixels moved per second + ICONS_SETS = [[3, 2, 7, 6, 3, 1, 5, 2, 3, 0, 6, 4, 7, 5, 1, 3, 2, 3, 6, 0, 4, 5], # Reel 1 + [0, 4, 1, 2, 7, 4, 6, 0, 1, 5, 4, 0, 1, 3, 4, 0, 1, 6, 7, 0, 1, 5], # Reel 2 + [6, 2, 1, 4, 3, 2, 1, 4, 7, 3, 2, 1, 4, 3, 7, 2, 4, 3, 1, 2, 4, 5]] # Reel 3 SLIPPING = [0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 3] - def initialize(x, y, difficulty = 1) + def initialize(x, y, reel_num, difficulty = 1) @viewport = Viewport.new(x, y, 64, 144) @viewport.z = 99999 super(64, 144, @viewport) - @reel = [] - ICONSPOOL[difficulty].length.times do |i| - @reel.push(ICONSPOOL[difficulty][i]) - end - @reel.shuffle! + @reel_num = reel_num + @difficulty = difficulty + @reel = ICONS_SETS[reel_num - 1].clone @toppos = 0 + @current_y_pos = -1 + @spin_speed = SCROLL_SPEED + @spin_speed /= 1.5 if difficulty == 0 @spinning = false @stopping = false @slipping = 0 @@ -39,11 +34,25 @@ class SlotMachineReel < BitmapSprite def startSpinning @spinning = true + @spin_timer_start = System.uptime + @initial_index = @index + 1 + @current_y_pos = -1 + end + + def spinning? + return @spinning end def stopSpinning(noslipping = false) @stopping = true - @slipping = SLIPPING[rand(SLIPPING.length)] + @slipping = SLIPPING.sample + if @difficulty == 0 # Easy + second_slipping = SLIPPING.sample + @slipping = [@slipping, second_slipping].min + elsif @difficulty == 2 # Hard + second_slipping = SLIPPING.sample + @slipping = [@slipping, second_slipping].max + end @slipping = 0 if noslipping end @@ -59,15 +68,28 @@ class SlotMachineReel < BitmapSprite def update self.bitmap.clear - if @toppos == 0 && @stopping && @slipping == 0 - @spinning = @stopping = false - end if @spinning - @toppos += SCROLLSPEED - if @toppos > 0 - @toppos -= 48 - @index = (@index + 1) % @reel.length - @slipping -= 1 if @slipping > 0 + new_y_pos = (System.uptime - @spin_timer_start) * @spin_speed + new_index = (new_y_pos / @images.height).to_i + old_index = (@current_y_pos / @images.height).to_i + @current_y_pos = new_y_pos + @toppos = new_y_pos + while @toppos > 0 + @toppos -= @images.height + end + if new_index != old_index + if @stopping + if @slipping == 0 + @spinning = false + @stopping = false + @toppos = 0 + else + @slipping = [@slipping - new_index + old_index, 0].max + end + end + if @spinning + @index = (new_index + @initial_index) % @reel.length + end end end 4.times do |i| @@ -130,11 +152,11 @@ class SlotMachineScene reel1 = @sprites["reel1"].showing reel2 = @sprites["reel2"].showing reel3 = @sprites["reel3"].showing - combinations = [[reel1[1], reel2[1], reel3[1]], # Centre row - [reel1[0], reel2[0], reel3[0]], # Top row - [reel1[2], reel2[2], reel3[2]], # Bottom row - [reel1[0], reel2[1], reel3[2]], # Diagonal top left -> bottom right - [reel1[2], reel2[1], reel3[0]]] # Diagonal bottom left -> top right + combinations = [[reel1[1], reel2[1], reel3[1]], # Centre row + [reel1[0], reel2[0], reel3[0]], # Top row + [reel1[2], reel2[2], reel3[2]], # Bottom row + [reel1[0], reel2[1], reel3[2]], # Diagonal top left -> bottom right + [reel1[2], reel2[1], reel3[0]]] # Diagonal bottom left -> top right combinations.length.times do |i| break if i >= 1 && @wager <= 1 # One coin = centre row only break if i >= 3 && @wager <= 2 # Two coins = three rows only @@ -206,18 +228,25 @@ class SlotMachineScene @sprites["light2"].visible = false @sprites["window1"].src_rect.set(0, 0, 152, 208) # Pay out + timer_start = System.uptime + last_paid_tick = -1 loop do break if @sprites["payout"].score <= 0 Graphics.update Input.update update - @sprites["payout"].score -= 1 - @sprites["credit"].score += 1 + this_tick = ((System.uptime - timer_start) * 20).to_i # Pay out 1 coin every 1/20 seconds + if this_tick != last_paid_tick + @sprites["payout"].score -= 1 + @sprites["credit"].score += 1 + this_tick = last_paid_tick + end if Input.trigger?(Input::USE) || @sprites["credit"].score == Settings::MAX_COINS @sprites["credit"].score += @sprites["payout"].score @sprites["payout"].score = 0 end end + # Wait timer_start = System.uptime loop do Graphics.update @@ -247,9 +276,9 @@ class SlotMachineScene @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport.z = 99999 addBackgroundPlane(@sprites, "bg", "Slot Machine/bg", @viewport) - @sprites["reel1"] = SlotMachineReel.new(64, 112, difficulty) - @sprites["reel2"] = SlotMachineReel.new(144, 112, difficulty) - @sprites["reel3"] = SlotMachineReel.new(224, 112, difficulty) + @sprites["reel1"] = SlotMachineReel.new(64, 112, 1, difficulty) + @sprites["reel2"] = SlotMachineReel.new(144, 112, 2, difficulty) + @sprites["reel3"] = SlotMachineReel.new(224, 112, 3, difficulty) (1..3).each do |i| @sprites["button#{i}"] = IconSprite.new(68 + (80 * (i - 1)), 260, @viewport) @sprites["button#{i}"].setBitmap("Graphics/UI/Slot Machine/button") @@ -304,18 +333,18 @@ class SlotMachineScene update if Input.trigger?(Input::USE) pbSEPlay("Slots stop") - if @sprites["reel1"].spinning + if @sprites["reel1"].spinning? @sprites["reel1"].stopSpinning(@replay) @sprites["button1"].visible = true - elsif @sprites["reel2"].spinning + elsif @sprites["reel2"].spinning? @sprites["reel2"].stopSpinning(@replay) @sprites["button2"].visible = true - elsif @sprites["reel3"].spinning + elsif @sprites["reel3"].spinning? @sprites["reel3"].stopSpinning(@replay) @sprites["button3"].visible = true end end - if !@sprites["reel3"].spinning + if !@sprites["reel3"].spinning? @gameEnd = true @gameRunning = false end diff --git a/Data/Scripts/017_Minigames/006_Minigame_Mining.rb b/Data/Scripts/017_Minigames/006_Minigame_Mining.rb index 073dce933..fb9b792e6 100644 --- a/Data/Scripts/017_Minigames/006_Minigame_Mining.rb +++ b/Data/Scripts/017_Minigames/006_Minigame_Mining.rb @@ -75,11 +75,10 @@ end # #=============================================================================== class MiningGameCursor < BitmapSprite - attr_accessor :mode attr_accessor :position - attr_accessor :hit - attr_accessor :counter + attr_accessor :mode + HIT_FRAME_DURATION = 0.05 # In seconds TOOL_POSITIONS = [[1, 0], [1, 1], [1, 1], [0, 0], [0, 0], [0, 2], [0, 2], [0, 0], [0, 0], [0, 2], [0, 2]] # Graphic, position @@ -90,51 +89,53 @@ class MiningGameCursor < BitmapSprite @position = position @mode = mode @hit = 0 # 0=regular, 1=hit item, 2=hit iron - @counter = 0 @cursorbitmap = AnimatedBitmap.new("Graphics/UI/Mining/cursor") @toolbitmap = AnimatedBitmap.new("Graphics/UI/Mining/tools") @hitsbitmap = AnimatedBitmap.new("Graphics/UI/Mining/hits") update end - def isAnimating? - return @counter > 0 + def animate(hit) + @hit = hit + @hit_timer_start = System.uptime end - def animate(hit) - @counter = 22 - @hit = hit + def isAnimating? + return !@hit_timer_start.nil? end def update self.bitmap.clear x = 32 * (@position % MiningGameScene::BOARD_WIDTH) y = 32 * (@position / MiningGameScene::BOARD_WIDTH) - if @counter > 0 - @counter -= 1 - toolx = x - tooly = y - i = 10 - (@counter / 2).floor - case TOOL_POSITIONS[i][1] - when 1 - toolx -= 8 - tooly += 8 - when 2 - toolx += 6 - end - self.bitmap.blt(toolx, tooly, @toolbitmap.bitmap, - Rect.new(96 * TOOL_POSITIONS[i][0], 96 * @mode, 96, 96)) - if i < 5 && i.even? - if @hit == 2 - self.bitmap.blt(x - 64, y, @hitsbitmap.bitmap, Rect.new(160 * 2, 0, 160, 160)) - else - self.bitmap.blt(x - 64, y, @hitsbitmap.bitmap, Rect.new(160 * @mode, 0, 160, 160)) + if @hit_timer_start + hit_frame = ((System.uptime - @hit_timer_start) / HIT_FRAME_DURATION).to_i + @hit_timer_start = nil if hit_frame >= TOOL_POSITIONS.length + if @hit_timer_start + toolx = x + tooly = y + case TOOL_POSITIONS[hit_frame][1] + when 1 + toolx -= 8 + tooly += 8 + when 2 + toolx += 6 + end + self.bitmap.blt(toolx, tooly, @toolbitmap.bitmap, + Rect.new(96 * TOOL_POSITIONS[hit_frame][0], 96 * @mode, 96, 96)) + if hit_frame < 5 && hit_frame.even? + if @hit == 2 + self.bitmap.blt(x - 64, y, @hitsbitmap.bitmap, Rect.new(160 * 2, 0, 160, 160)) + else + self.bitmap.blt(x - 64, y, @hitsbitmap.bitmap, Rect.new(160 * @mode, 0, 160, 160)) + end + end + if @hit == 1 && hit_frame < 3 + self.bitmap.blt(x - 64, y, @hitsbitmap.bitmap, Rect.new(160 * hit_frame, 160, 160, 160)) end end - if @hit == 1 && i < 3 - self.bitmap.blt(x - 64, y, @hitsbitmap.bitmap, Rect.new(160 * i, 160, 160, 160)) - end - else + end + if !@hit_timer_start self.bitmap.blt(x, y + 64, @cursorbitmap.bitmap, Rect.new(32 * @mode, 0, 32, 32)) end end diff --git a/Data/Scripts/020_Debug/001_Editor screens/003_EditorScreens_MapConnections.rb b/Data/Scripts/020_Debug/001_Editor screens/003_EditorScreens_MapConnections.rb index 61edbe939..57192bf04 100644 --- a/Data/Scripts/020_Debug/001_Editor screens/003_EditorScreens_MapConnections.rb +++ b/Data/Scripts/020_Debug/001_Editor screens/003_EditorScreens_MapConnections.rb @@ -491,6 +491,7 @@ class MapScreenScene end end end + # TODO: FPS. Scroll speed with arrow keys. Can probably leave this alone. if Input.press?(Input::UP) @mapsprites.each do |i| i[1].y += 4 if i diff --git a/Data/Scripts/020_Debug/002_Animation editor/001_AnimEditor_SceneElements.rb b/Data/Scripts/020_Debug/002_Animation editor/001_AnimEditor_SceneElements.rb index c40bd9e44..6e002f57a 100644 --- a/Data/Scripts/020_Debug/002_Animation editor/001_AnimEditor_SceneElements.rb +++ b/Data/Scripts/020_Debug/002_Animation editor/001_AnimEditor_SceneElements.rb @@ -77,7 +77,7 @@ module BattleAnimationEditor menuwindow.update hit = menuwindow.hittest menuwindow.index = hit if hit >= 0 - if Input.trigger?(Input::MOUSELEFT) || Input.trigger?(Input::MOUSERIGHT) # Left or right button + if Input.trigger?(Input::MOUSELEFT) || Input.trigger?(Input::MOUSERIGHT) # Left or right button menuwindow.dispose return hit end @@ -86,7 +86,7 @@ module BattleAnimationEditor menuwindow.dispose return hit end - if Input.trigger?(Input::BACK) # Escape + if Input.trigger?(Input::BACK) # Escape break end end @@ -198,7 +198,7 @@ module BattleAnimationEditor right.x += self.x right.y += self.y swatchrects = [] - repeattime = Input.time?(Input::MOUSELEFT) / 1000 + repeattime = Input.time?(Input::MOUSELEFT) NUMFRAMES.times do |i| swatchrects.push(Rect.new(arrowwidth + (i * 96) + self.x, self.y, 96, 96)) end @@ -211,7 +211,7 @@ module BattleAnimationEditor end # Left arrow if left.contains?(mousepos[0], mousepos[1]) - if repeattime > 750 + if repeattime > 0.75 @start -= 3 else @start -= 1 @@ -221,7 +221,7 @@ module BattleAnimationEditor end # Right arrow if right.contains?(mousepos[0], mousepos[1]) - if repeattime > 750 + if repeattime > 0.75 @start += 3 else @start += 1 @@ -903,7 +903,7 @@ module BattleAnimationEditor end updateInput # @testscreen.update - # self.bitmap=@testscreen.bitmap + # self.bitmap = @testscreen.bitmap if @currentframe < @animation.length PBAnimation::MAX_SPRITES.times do |i| next if !@dirty[i] diff --git a/Data/Scripts/020_Debug/002_Animation editor/002_AnimEditor_ControlsButtons.rb b/Data/Scripts/020_Debug/002_Animation editor/002_AnimEditor_ControlsButtons.rb index 6a705c3cb..234d0f2a2 100644 --- a/Data/Scripts/020_Debug/002_Animation editor/002_AnimEditor_ControlsButtons.rb +++ b/Data/Scripts/020_Debug/002_Animation editor/002_AnimEditor_ControlsButtons.rb @@ -237,12 +237,14 @@ module BattleAnimationEditor def text=(value) @text = value + @cursor_shown = true self.invalidate end def initialize(label, text) super(label) - @frame = 0 + @cursor_timer_start = System.uptime + @cursor_shown = true @label = label @text = text @cursor = text.scan(/./m).length @@ -254,7 +256,8 @@ module BattleAnimationEditor @text = "" chars.each { |char| @text += char } @cursor += 1 - @frame = 0 + @cursor_timer_start = System.uptime + @cursor_shown = true self.changed = true self.invalidate end @@ -265,21 +268,25 @@ module BattleAnimationEditor @text = "" chars.each { |char| @text += char } @cursor -= 1 - @frame = 0 + @cursor_timer_start = System.uptime + @cursor_shown = true self.changed = true self.invalidate end def update - @frame += 1 - @frame %= 20 + cursor_to_show = ((System.uptime - @cursor_timer_start) / 0.35).to_i % 2 == 0 self.changed = false - self.invalidate if (@frame % 10) == 0 + if cursor_to_show != @cursor_shown + @cursor_shown = cursor_to_show + self.invalidate + end # Moving cursor if Input.triggerex?(:LEFT) || Input.repeatex?(:LEFT) if @cursor > 0 @cursor -= 1 - @frame = 0 + @cursor_timer_start = System.uptime + @cursor_shown = true self.invalidate end return @@ -287,7 +294,8 @@ module BattleAnimationEditor if Input.triggerex?(:RIGHT) || Input.repeatex?(:RIGHT) if @cursor < self.text.scan(/./m).length @cursor += 1 - @frame = 0 + @cursor_timer_start = System.uptime + @cursor_shown = true self.invalidate end return @@ -344,13 +352,13 @@ module BattleAnimationEditor # Draw text shadowtext(bitmap, x, y, textwidth + 4, 32, c) # Draw cursor if necessary - if ((@frame / 10) & 1) == 0 && i == @cursor + if i == @cursor && @cursor_shown bitmap.fill_rect(x, y + 4, 2, 24, Color.new(120, 120, 120)) end # Add x to drawn text width x += textwidth end - if ((@frame / 10) & 1) == 0 && textscan.length == @cursor + if textscan.length == @cursor && @cursor_shown bitmap.fill_rect(x, y + 4, 2, 24, Color.new(120, 120, 120)) end # Draw outline @@ -419,12 +427,12 @@ module BattleAnimationEditor left = toAbsoluteRect(@leftarrow) right = toAbsoluteRect(@rightarrow) oldvalue = self.curvalue - repeattime = Input.time?(Input::MOUSELEFT) / 1000 + repeattime = Input.time?(Input::MOUSELEFT) # Left arrow if left.contains?(mousepos[0], mousepos[1]) - if repeattime > 3000 + if repeattime > 3.0 self.curvalue -= 10 - elsif repeattime > 1500 + elsif repeattime > 1.5 self.curvalue -= 5 else self.curvalue -= 1 @@ -435,9 +443,9 @@ module BattleAnimationEditor end # Right arrow if right.contains?(mousepos[0], mousepos[1]) - if repeattime > 3000 + if repeattime > 3.0 self.curvalue += 10 - elsif repeattime > 1500 + elsif repeattime > 1.5 self.curvalue += 5 else self.curvalue += 1 @@ -671,12 +679,12 @@ module BattleAnimationEditor left = toAbsoluteRect(@leftarrow) right = toAbsoluteRect(@rightarrow) oldvalue = self.curvalue - repeattime = Input.time?(Input::MOUSELEFT) / 1000 + repeattime = Input.time?(Input::MOUSELEFT) # Left arrow if left.contains?(mousepos[0], mousepos[1]) - if repeattime > 3000 + if repeattime > 3.0 self.curvalue -= 10 - elsif repeattime > 1500 + elsif repeattime > 1.5 self.curvalue -= 5 else self.curvalue -= 1 @@ -686,9 +694,9 @@ module BattleAnimationEditor end # Right arrow if right.contains?(mousepos[0], mousepos[1]) - if repeattime > 3000 + if repeattime > 3.0 self.curvalue += 10 - elsif repeattime > 1500 + elsif repeattime > 1.5 self.curvalue += 5 else self.curvalue += 1 diff --git a/Data/Scripts/020_Debug/002_Animation editor/003_AnimEditor_Interpolation.rb b/Data/Scripts/020_Debug/002_Animation editor/003_AnimEditor_Interpolation.rb index 4d5d5a9a9..54bebd98e 100644 --- a/Data/Scripts/020_Debug/002_Animation editor/003_AnimEditor_Interpolation.rb +++ b/Data/Scripts/020_Debug/002_Animation editor/003_AnimEditor_Interpolation.rb @@ -241,7 +241,7 @@ module BattleAnimationEditor Graphics.update Input.update sliderwin2.update - if sliderwin2.changed?(0) # Number of frames + if sliderwin2.changed?(0) # Number of frames if path path = path.smoothPointPath(sliderwin2.value(0), false) i = 0 @@ -341,7 +341,7 @@ module BattleAnimationEditor points.clear if showline path = curveToPointPath(curve, sliderwin2.value(0)) - # File.open("pointpath.txt","wb") { |f| f.write(path.inspect) } +# File.open("pointpath.txt", "wb") { |f| f.write(path.inspect) } path.each do |point| points.push(PointSprite.new(point[0], point[1], canvas.viewport)) end @@ -400,11 +400,11 @@ module BattleAnimationEditor path.each do |point| points.push(PointSprite.new(point[0], point[1], canvas.viewport)) end - # File.open("pointpath.txt","wb") { |f| f.write(path.inspect) } +# File.open("pointpath.txt", "wb") { |f| f.write(path.inspect) } sliderwin2.visible = true next elsif sliderwin2.changed?(okbutton) && path - # File.open("pointpath.txt","wb") { |f| f.write(path.inspect) } +# File.open("pointpath.txt", "wb") { |f| f.write(path.inspect) } neededsize = canvas.currentframe + sliderwin2.value(0) if neededsize > canvas.animation.length canvas.animation.resize(neededsize) diff --git a/Data/Scripts/020_Debug/002_Animation editor/005_AnimEditor_Functions.rb b/Data/Scripts/020_Debug/002_Animation editor/005_AnimEditor_Functions.rb index 5efad2258..bd864f8a5 100644 --- a/Data/Scripts/020_Debug/002_Animation editor/005_AnimEditor_Functions.rb +++ b/Data/Scripts/020_Debug/002_Animation editor/005_AnimEditor_Functions.rb @@ -157,15 +157,15 @@ module BattleAnimationEditor _INTL("Rename"), _INTL("Delete")], -1) case cmd2 - when 0 # Load Animation + when 0 # Load Animation canvas.loadAnimation(animations[cmdwin.index]) animwin.animbitmap = canvas.animbitmap animations.selected = cmdwin.index break - when 1 # Rename + when 1 # Rename pbAnimName(animations[cmdwin.index], cmdwin) cmdwin.refresh - when 2 # Delete + when 2 # Delete if pbConfirmMessage(_INTL("Are you sure you want to delete this animation?")) animations[cmdwin.index] = PBAnimation.new cmdwin.commands[cmdwin.index] = _INTL("{1} {2}", cmdwin.index, animations[cmdwin.index].name) @@ -409,13 +409,13 @@ module BattleAnimationEditor cmdwin.index != cmdEditBG && cmdwin.index != cmdNewFO && cmdwin.index != cmdEditFO - if framewindow.changed?(1) # Set Frame + if framewindow.changed?(1) # Set Frame canvas.animation.timing[cmdwin.index].frame = framewindow.value(0) - 1 cmdwin.commands[cmdwin.index] = canvas.animation.timing[cmdwin.index].to_s cmdwin.refresh next end - if framewindow.changed?(2) # Delete Timing + if framewindow.changed?(2) # Delete Timing canvas.animation.timing.delete_at(cmdwin.index) cmdwin.commands.delete_at(cmdwin.index) cmdNewSound -= 1 if cmdNewSound >= 0 @@ -429,35 +429,35 @@ module BattleAnimationEditor end if Input.trigger?(Input::USE) redrawcmds = false - if cmdwin.index == cmdNewSound # Add new sound + if cmdwin.index == cmdNewSound # Add new sound newaudio = PBAnimTiming.new(0) if pbSelectSE(canvas, newaudio) newaudio.frame = framewindow.value(0) - 1 canvas.animation.timing.push(newaudio) redrawcmds = true end - elsif cmdwin.index == cmdNewBG # Add new background graphic set + elsif cmdwin.index == cmdNewBG # Add new background graphic set newtiming = PBAnimTiming.new(1) if pbSelectBG(canvas, newtiming) newtiming.frame = framewindow.value(0) - 1 canvas.animation.timing.push(newtiming) redrawcmds = true end - elsif cmdwin.index == cmdEditBG # Add new background edit + elsif cmdwin.index == cmdEditBG # Add new background edit newtiming = PBAnimTiming.new(2) if pbEditBG(canvas, newtiming) newtiming.frame = framewindow.value(0) - 1 canvas.animation.timing.push(newtiming) redrawcmds = true end - elsif cmdwin.index == cmdNewFO # Add new foreground graphic set + elsif cmdwin.index == cmdNewFO # Add new foreground graphic set newtiming = PBAnimTiming.new(3) if pbSelectBG(canvas, newtiming) newtiming.frame = framewindow.value(0) - 1 canvas.animation.timing.push(newtiming) redrawcmds = true end - elsif cmdwin.index == cmdEditFO # Add new foreground edit + elsif cmdwin.index == cmdEditFO # Add new foreground edit newtiming = PBAnimTiming.new(4) if pbEditBG(canvas, newtiming) newtiming.frame = framewindow.value(0) - 1 @@ -596,7 +596,7 @@ module BattleAnimationEditor Input.update cmdwin.update maxsizewindow.update - if maxsizewindow.changed?(8) # OK + if maxsizewindow.changed?(8) # OK timing.name = File.basename(filename, ".*") timing.bgX = maxsizewindow.value(1) timing.bgY = maxsizewindow.value(2) @@ -647,7 +647,7 @@ module BattleAnimationEditor Graphics.update Input.update maxsizewindow.update - if maxsizewindow.changed?(8) # OK + if maxsizewindow.changed?(8) # OK if maxsizewindow.controls[1].checked || maxsizewindow.controls[2].checked || maxsizewindow.controls[3].checked || @@ -694,7 +694,7 @@ module BattleAnimationEditor endvalue = sliderwin2.value(1) - 1 dstvalue = sliderwin2.value(2) - 1 length = (endvalue - startvalue) + 1 - if length > 0 # Ensure correct overlap handling + if length > 0 # Ensure correct overlap handling if startvalue < dstvalue startvalue += length dstvalue += length @@ -1037,7 +1037,7 @@ module BattleAnimationEditor sliderwin.invalidate end next - elsif Input.trigger?(Input::MOUSERIGHT) # Right mouse button + elsif Input.trigger?(Input::MOUSERIGHT) # Right mouse button mousepos = Mouse.getMousePos mousepos = [0, 0] if !mousepos commands = [ @@ -1051,29 +1051,29 @@ module BattleAnimationEditor ] hit = pbTrackPopupMenu(commands) case hit - when 0 # Properties + when 0 # Properties if canvas.currentCel pbCellProperties(canvas) canvas.invalidateCel(canvas.currentcel) end - when 1 # Cut + when 1 # Cut if canvas.currentCel Clipboard.setData(canvas.currentCel, "PBAnimCel") canvas.deleteCel(canvas.currentcel) end - when 2 # Copy + when 2 # Copy Clipboard.setData(canvas.currentCel, "PBAnimCel") if canvas.currentCel - when 3 # Paste + when 3 # Paste canvas.pasteCel(mousepos[0], mousepos[1]) - when 4 # Delete + when 4 # Delete canvas.deleteCel(canvas.currentcel) - when 5 # Renumber + when 5 # Renumber if canvas.currentcel && canvas.currentcel >= 2 cel1 = canvas.currentcel cel2 = pbChooseNum(cel1) canvas.swapCels(cel1, cel2) if cel2 >= 2 && cel1 != cel2 end - when 6 # Extrapolate Path + when 6 # Extrapolate Path if canvas.currentCel pbDefinePath(canvas) sliderwin.invalidate @@ -1081,10 +1081,10 @@ module BattleAnimationEditor end next end - if sliderwin.changed?(0) # Current frame changed + if sliderwin.changed?(0) # Current frame changed canvas.currentframe = sliderwin.value(0) - 1 end - if sliderwin.changed?(1) # Change frame count + if sliderwin.changed?(1) # Change frame count pbChangeMaximum(canvas) if canvas.currentframe >= canvas.animation.length canvas.currentframe = canvas.animation.length - 1 @@ -1092,12 +1092,12 @@ module BattleAnimationEditor end sliderwin.refresh end - if sliderwin.changed?(2) # Set Animation Sheet + if sliderwin.changed?(2) # Set Animation Sheet pbSelectAnim(canvas, animwin) animwin.refresh sliderwin.refresh end - if sliderwin.changed?(3) # List of Animations + if sliderwin.changed?(3) # List of Animations pbAnimList(animation, canvas, animwin) sliderwin.controls[0].curvalue = canvas.currentframe + 1 bottomwindow.refresh @@ -1107,7 +1107,7 @@ module BattleAnimationEditor pbTimingList(canvas) if sidewin.changed?(0) if sidewin.changed?(1) positions = [_INTL("User"), _INTL("Target"), _INTL("User and target"), _INTL("Screen")] - indexes = [2, 1, 3, 4] # Keeping backwards compatibility + indexes = [2, 1, 3, 4] # Keeping backwards compatibility positions.length.times do |i| selected = "[ ]" selected = "[X]" if animation[animation.selected].position == indexes[i] diff --git a/Data/Scripts/020_Debug/003_Debug menus/002_Debug_MenuCommands.rb b/Data/Scripts/020_Debug/003_Debug menus/002_Debug_MenuCommands.rb index 0408fde93..4e7af0aee 100644 --- a/Data/Scripts/020_Debug/003_Debug menus/002_Debug_MenuCommands.rb +++ b/Data/Scripts/020_Debug/003_Debug menus/002_Debug_MenuCommands.rb @@ -1030,12 +1030,14 @@ MenuHandlers.add(:debug_menu, :toggle_snag_machine, { } }) -MenuHandlers.add(:debug_menu, :relic_stone, { - "name" => _INTL("Use Relic Stone"), +MenuHandlers.add(:debug_menu, :toggle_purify_chamber_access, { + "name" => _INTL("Toggle Purify Chamber Access"), "parent" => :shadow_pokemon_menu, - "description" => _INTL("Choose a Shadow Pokémon to show to the Relic Stone for purification."), + "description" => _INTL("Toggle access to the Purify Chamber via the PC."), "effect" => proc { - pbRelicStone + $player.seen_purify_chamber = !$player.seen_purify_chamber + pbMessage(_INTL("The Purify Chamber is accessible.")) if $player.seen_purify_chamber + pbMessage(_INTL("The Purify Chamber is not accessible.")) if !$player.seen_purify_chamber } }) @@ -1048,6 +1050,15 @@ MenuHandlers.add(:debug_menu, :purify_chamber, { } }) +MenuHandlers.add(:debug_menu, :relic_stone, { + "name" => _INTL("Use Relic Stone"), + "parent" => :shadow_pokemon_menu, + "description" => _INTL("Choose a Shadow Pokémon to show to the Relic Stone for purification."), + "effect" => proc { + pbRelicStone + } +}) + #=============================================================================== # PBS file editors #=============================================================================== diff --git a/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb b/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb index b22a5b10c..12d2feb2c 100644 --- a/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb +++ b/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb @@ -185,14 +185,14 @@ def pbDebugVariables(mode) end current_id = right_window.index + 1 case mode - when 0 # Switches + when 0 # Switches if Input.trigger?(Input::USE) pbPlayDecisionSE $game_switches[current_id] = !$game_switches[current_id] right_window.refresh $game_map.need_refresh = true end - when 1 # Variables + when 1 # Variables if Input.repeat?(Input::LEFT) pbDebugSetVariable(current_id, -1) right_window.refresh diff --git a/Data/Scripts/021_Compiler/001_Compiler.rb b/Data/Scripts/021_Compiler/001_Compiler.rb index cfaf9dd92..3d95dc789 100644 --- a/Data/Scripts/021_Compiler/001_Compiler.rb +++ b/Data/Scripts/021_Compiler/001_Compiler.rb @@ -1098,9 +1098,7 @@ module Compiler end end raise Reset.new if e.is_a?(Hangup) - loop do - Graphics.update - end + raise "Unknown exception when compiling." end end end diff --git a/Game.exe b/Game.exe index c32d7f423..6e13e4a68 100644 Binary files a/Game.exe and b/Game.exe differ