From c78e32db099214d14b5aa7e7fd9973d8ecc321b0 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Thu, 18 Jan 2024 23:47:33 +0000 Subject: [PATCH] Fixed Database animations' position not moving the animation for exclamations --- Data/Scripts/001_Technical/006_RPG_Sprite.rb | 4 +-- .../004_Game classes/006_Game_Character.rb | 14 +++++++-- .../005_Sprites/003_Sprite_Character.rb | 4 +-- .../005_Sprites/008_Sprite_AnimationSprite.rb | 8 +++-- .../012_Overworld/005_Overworld_Fishing.rb | 4 ++- .../006_Overworld_BerryPlants.rb | 6 ++-- Data/Scripts/019_Utilities/001_Utilities.rb | 30 ++++++++----------- 7 files changed, 41 insertions(+), 29 deletions(-) diff --git a/Data/Scripts/001_Technical/006_RPG_Sprite.rb b/Data/Scripts/001_Technical/006_RPG_Sprite.rb index 7a960d094..eb5052304 100644 --- a/Data/Scripts/001_Technical/006_RPG_Sprite.rb +++ b/Data/Scripts/001_Technical/006_RPG_Sprite.rb @@ -49,9 +49,9 @@ module RPG array.push(anim) end - def animation(animation, hit, height = 3) + def animation(animation, hit, height = 3, no_tone = false) anim = SpriteAnimation.new(self) - anim.animation(animation, hit, height) + anim.animation(animation, hit, height, no_tone) pushAnimation(@animations, anim) end diff --git a/Data/Scripts/004_Game classes/006_Game_Character.rb b/Data/Scripts/004_Game classes/006_Game_Character.rb index 475f43a37..a358b8422 100644 --- a/Data/Scripts/004_Game classes/006_Game_Character.rb +++ b/Data/Scripts/004_Game classes/006_Game_Character.rb @@ -22,7 +22,9 @@ class Game_Character attr_accessor :lock_pattern attr_reader :move_route_forcing attr_accessor :through - attr_accessor :animation_id + attr_reader :animation_id + attr_accessor :animation_height + attr_accessor :animation_regular_tone attr_accessor :transparent attr_reader :move_speed attr_reader :jump_speed @@ -54,7 +56,7 @@ class Game_Character @lock_pattern = false @move_route_forcing = false @through = false - @animation_id = 0 + animation_id = 0 @transparent = false @original_direction = 2 @original_pattern = 0 @@ -86,6 +88,14 @@ class Game_Character @prelock_direction = 0 end + def animation_id=(value) + @animation_id = value + if value == 0 + @animation_height = 3 + @animation_regular_tone = false + end + end + def x_offset; return @x_offset || 0; end def y_offset; return @y_offset || 0; end diff --git a/Data/Scripts/005_Sprites/003_Sprite_Character.rb b/Data/Scripts/005_Sprites/003_Sprite_Character.rb index d28a9e6f1..9b0bbbe93 100644 --- a/Data/Scripts/005_Sprites/003_Sprite_Character.rb +++ b/Data/Scripts/005_Sprites/003_Sprite_Character.rb @@ -176,9 +176,9 @@ class Sprite_Character < RPG::Sprite self.z = @character.screen_z(@ch) self.opacity = @character.opacity self.blend_type = @character.blend_type - if @character.animation_id != 0 + if @character.animation_id && @character.animation_id != 0 animation = $data_animations[@character.animation_id] - animation(animation, true) + animation(animation, true, @character.animation_height || 3, @character.animation_regular_tone || false) @character.animation_id = 0 end @reflection&.update diff --git a/Data/Scripts/005_Sprites/008_Sprite_AnimationSprite.rb b/Data/Scripts/005_Sprites/008_Sprite_AnimationSprite.rb index 05eadab84..9f28b268c 100644 --- a/Data/Scripts/005_Sprites/008_Sprite_AnimationSprite.rb +++ b/Data/Scripts/005_Sprites/008_Sprite_AnimationSprite.rb @@ -28,12 +28,13 @@ class SpriteAnimation dispose_loop_animation end - def animation(animation, hit, height = 3) + def animation(animation, hit, height = 3, no_tone = false) dispose_animation @_animation = animation return if @_animation.nil? @_animation_hit = hit @_animation_height = height + @_animation_no_tone = no_tone @_animation_duration = @_animation.frame_max @_animation_index = -1 fr = 20 @@ -207,7 +208,7 @@ class SpriteAnimation sprite.zoom_y = cell_data[i, 3] / 100.0 sprite.angle = cell_data[i, 4] sprite.mirror = (cell_data[i, 5] == 1) - sprite.tone = self.tone + sprite.tone = self.tone if !@_animation_no_tone sprite.opacity = cell_data[i, 6] * self.opacity / 255.0 sprite.blend_type = cell_data[i, 7] end @@ -301,6 +302,9 @@ class Spriteset_Map _animationSprite_initialize(map) end + # Used to display animations that remain in the same location on the map. + # Typically for grass rustling and dust clouds, and other animations that + # aren't relative to an event. def addUserAnimation(animID, x, y, tinting = false, height = 3) sprite = AnimationContainerSprite.new(animID, self.map, x, y, @@viewport1, tinting, height) addUserSprite(sprite) diff --git a/Data/Scripts/012_Overworld/005_Overworld_Fishing.rb b/Data/Scripts/012_Overworld/005_Overworld_Fishing.rb index 8af02127c..c71a75206 100644 --- a/Data/Scripts/012_Overworld/005_Overworld_Fishing.rb +++ b/Data/Scripts/012_Overworld/005_Overworld_Fishing.rb @@ -46,7 +46,9 @@ def pbFishing(hasEncounter, rodType = 1) break end if hasEncounter && rand(100) < biteChance - $scene.spriteset.addUserAnimation(Settings::EXCLAMATION_ANIMATION_ID, $game_player.x, $game_player.y, true, 3) + $game_player.animation_id = Settings::EXCLAMATION_ANIMATION_ID + $game_player.animation_height = 3 + $game_player.animation_regular_tone = true duration = rand(5..10) / 10.0 # 0.5-1 seconds if !pbWaitForInput(msgWindow, message + "\n" + _INTL("Oh! A bite!"), duration) pbFishingEnd { pbMessageDisplay(msgWindow, _INTL("The Pokémon got away...")) } diff --git a/Data/Scripts/012_Overworld/006_Overworld_BerryPlants.rb b/Data/Scripts/012_Overworld/006_Overworld_BerryPlants.rb index d8fb14227..929642e11 100644 --- a/Data/Scripts/012_Overworld/006_Overworld_BerryPlants.rb +++ b/Data/Scripts/012_Overworld/006_Overworld_BerryPlants.rb @@ -268,9 +268,9 @@ class BerryPlantSprite end if berry_plant.new_mechanics && @old_stage != berry_plant.growth_stage && @old_stage > 0 && berry_plant.growth_stage <= GameData::BerryPlant::NUMBER_OF_GROWTH_STAGES + 1 - spriteset = $scene.spriteset(@map.map_id) - spriteset&.addUserAnimation(Settings::PLANT_SPARKLE_ANIMATION_ID, - @event.x, @event.y, false, 1) + @event.animation_id = Settings::PLANT_SPARKLE_ANIMATION_ID + @event.animation_height = 1 + @event.animation_regular_tone = true end end @old_stage = berry_plant.growth_stage diff --git a/Data/Scripts/019_Utilities/001_Utilities.rb b/Data/Scripts/019_Utilities/001_Utilities.rb index 39df7ce43..f79153ed8 100644 --- a/Data/Scripts/019_Utilities/001_Utilities.rb +++ b/Data/Scripts/019_Utilities/001_Utilities.rb @@ -191,25 +191,21 @@ def pbTimeEventValid(variableNumber) return ret end -def pbExclaim(event, id = Settings::EXCLAMATION_ANIMATION_ID, tinting = false) - if event.is_a?(Array) - sprite = nil - done = [] - event.each do |i| - next if done.include?(i.id) - spriteset = $scene.spriteset(i.map_id) - sprite ||= spriteset&.addUserAnimation(id, i.x, i.y, tinting, 2) - done.push(i.id) - end - else - spriteset = $scene.spriteset(event.map_id) - sprite = spriteset&.addUserAnimation(id, event.x, event.y, tinting, 2) +def pbExclaim(events, anim = Settings::EXCLAMATION_ANIMATION_ID, tinting = false) + events = [events] if !events.is_a?(Array) + events.each do |ev| + ev.animation_id = anim + ev.animation_height = 3 + ev.animation_regular_tone = !tinting end - until sprite.disposed? - Graphics.update - Input.update - pbUpdateSceneMap + anim_data = $data_animations[anim] + frame_count = anim_data.frame_max + frame_rate = 20 + if anim_data.name[/\[\s*(\d+?)\s*\]\s*$/] + frame_rate = $~[1].to_i end + pbWait(frame_count / frame_rate.to_f) + events.each { |i| i.animation_id = 0 } end def pbNoticePlayer(event, always_show_exclaim = false)