Panda_Artist

Humble RPG Fan
Veteran
Joined
Dec 22, 2018
Messages
338
Reaction score
17
First Language
Portuguese
Primarily Uses
RMVXA
Good Morning / Day / Afternoon / Evening everyone.

I have a request for a certain kind of snippet

So I would like the following:

1. The ability to make the battle screen shake during selected frames of animation

If this isn't too difficult I would really appreciate the help
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
692
Reaction score
448
First Language
English
Primarily Uses
RMVXA
Here you go:
Ruby:
=begin
#==============================================================================#
#   AMN Animation Shake
#   Version   1.02
#   Author:   AMoonlessNight
#   Date:     04 Jul 2020
#   Latest:   05 Jul 2020
#==============================================================================#
#   UPDATE LOG
#------------------------------------------------------------------------------#
# 04 Jul 2020 - created the script
# 05 Jul 2020 - fixed bug with frame ID, made compatible with TheoAllen's 
#               Multiple Animations script
#==============================================================================#
#   TERMS OF USE
#------------------------------------------------------------------------------#
# - Please credit AMoonlessNight or A-Moonless-Night
# - Free for non-commercial use; contact for commercial use
# - If you would like to edit/adjust this script, please make edits as a new
#   script (do not edit this script directly) and provide proper credit
# - I'd love to see your game if you end up using one of my scripts
#==============================================================================#

This script makes it so that you can set the screen to shake during certain
frames of an animation.

=end
module AMN_Animations
  SHAKE = {}
#==============================================================================
# ** EDITABLE REGION BELOW
#------------------------------------------------------------------------------
#  Change the values in the area below to suit your needs.
#==============================================================================

# SHAKE[ANIMATION_ID] = {
#   FRAME_ID => [POWER, SPEED, DURATION],
# }

  SHAKE[1] = {
  # FRAME_ID => [POWER, SPEED, DURATION],
    2 => [4, 4, 10],
  }
  
  SHAKE[68] = {
  # FRAME_ID => [POWER, SPEED, DURATION],
    3 => [8, 8, 10],
  }
  
  
#==============================================================================
# ** END OF EDITABLE REGION
#------------------------------------------------------------------------------
#  Please do not edit below this point unless you know what you are doing.
#==============================================================================

end

class RPG::Animation
  include AMN_Animations
  
  def init_animation_shake_timings
    @timings.each { |timing| timing.init_shake_timings }
    if SHAKE.key?(@id)
      SHAKE[@id].each do |frame_id, shake_array|
        timing = RPG::Animation::Timing.new
        timing.shake_power = [[shake_array[0], 9].min, 0].max
        timing.shake_speed = [[shake_array[1], 9].min, 0].max
        timing.shake_duration = shake_array[2]
        timing.frame = frame_id
        @timings << timing
        @timings.sort_by! { |timing| timing.frame }
      end
    end
  end

end

class RPG::Animation::Timing
  attr_accessor :shake_power, :shake_speed, :shake_duration

  def init_shake_timings
    @shake_power = 0
    @shake_speed = 0
    @shake_duration = 0
  end

end

module DataManager
  class << self; alias :amn_anishake_datamgr_loaddb :load_database; end

  def self.load_database
    amn_anishake_datamgr_loaddb
    init_animation_shake_timings
  end
  
  def self.init_animation_shake_timings
    $data_animations.each { |obj| obj.init_animation_shake_timings unless obj.nil? }
  end
  
end

class Sprite_Base < Sprite
  
  def animation_process_shake(timing)
    if timing.shake_power > 0 && timing.shake_speed > 0 && !@ani_duplicated
      screen = $game_party.in_battle ? $game_troop.screen : $game_map.screen
      screen.start_shake(timing.shake_power, timing.shake_speed, timing.shake_duration)
    end
  end
  
  alias amn_anishake_spritebase_aniproctiming animation_process_timing
  def animation_process_timing(timing)
    amn_anishake_spritebase_aniproctiming(timing)
    animation_process_shake(timing) unless $imported && $imported[:Theo_MultiAnime]
  end
  
end

if $imported && $imported[:Theo_MultiAnime]
  class Sprite_MultiAnime < Sprite_Base
    
    alias amn_anishake_spritemultanim_aniproctiming animation_process_timing
    def animation_process_timing(timing)
      animation_process_shake(timing)
      amn_anishake_spritemultanim_aniproctiming(timing)
    end
    
  end
end

EDIT: updated code
 
Last edited:

Panda_Artist

Humble RPG Fan
Veteran
Joined
Dec 22, 2018
Messages
338
Reaction score
17
First Language
Portuguese
Primarily Uses
RMVXA
animation shake.png

I am NOT properly doing something correctly or maybe I have a script that is making this incompatible

I'm using TheoAllen's multiple animations also, in conjunction with your other Z animation script... maybe there is an incompatibility

Unfortunately it doesn't seem to work, I code the animation id and the frames, but in game, the shake effect ALWAYS only happens when the animation starts... maybe it's one of the scripts i'm using....

EDIT:

Nope, it doesn't seem to work in a new clean project either, no matter which frame I code it in, the shake effect always starts in the first frame for some reason.

Is there anything here I am not doing right?
 
Last edited:

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,138
Reaction score
709
First Language
English
Primarily Uses
RMVXA
You have animations that have 118 frames? that's a long animation.
 

Panda_Artist

Humble RPG Fan
Veteran
Joined
Dec 22, 2018
Messages
338
Reaction score
17
First Language
Portuguese
Primarily Uses
RMVXA
Yeah some abilities I have have some big animations.

Unfortunately this snippet doesn't seem to work in a new clean project either, no matter which frame I code it in, the shake effect always starts in the first frame for some reason.

Is there anything here I am not doing right?
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
692
Reaction score
448
First Language
English
Primarily Uses
RMVXA
Updated the original. Forgot to add something in about the frame ID, so this version should work now, and should work with Theo's script (although I haven't tested extensively).
 

Panda_Artist

Humble RPG Fan
Veteran
Joined
Dec 22, 2018
Messages
338
Reaction score
17
First Language
Portuguese
Primarily Uses
RMVXA
After testing it:

YES. So far so good and it works perfectly so far.

I will let you know if I encounter any errors, but amazing job and thank you very much for this!!
 

Sanzational

Villager
Member
Joined
Oct 25, 2020
Messages
6
Reaction score
0
First Language
Spanish
Primarily Uses
RMVXA
ive been trying to use your script but for some reason it dosent seem to work even on a clean project
Here you go:
Ruby:
=begin
#==============================================================================#
#   AMN Animation Shake
#   Version   1.02
#   Author:   AMoonlessNight
#   Date:     04 Jul 2020
#   Latest:   05 Jul 2020
#==============================================================================#
#   UPDATE LOG
#------------------------------------------------------------------------------#
# 04 Jul 2020 - created the script
# 05 Jul 2020 - fixed bug with frame ID, made compatible with TheoAllen's
#               Multiple Animations script
#==============================================================================#
#   TERMS OF USE
#------------------------------------------------------------------------------#
# - Please credit AMoonlessNight or A-Moonless-Night
# - Free for non-commercial use; contact for commercial use
# - If you would like to edit/adjust this script, please make edits as a new
#   script (do not edit this script directly) and provide proper credit
# - I'd love to see your game if you end up using one of my scripts
#==============================================================================#

This script makes it so that you can set the screen to shake during certain
frames of an animation.

=end
module AMN_Animations
  SHAKE = {}
#==============================================================================
# ** EDITABLE REGION BELOW
#------------------------------------------------------------------------------
#  Change the values in the area below to suit your needs.
#==============================================================================

# SHAKE[ANIMATION_ID] = {
#   FRAME_ID => [POWER, SPEED, DURATION],
# }

  SHAKE[1] = {
  # FRAME_ID => [POWER, SPEED, DURATION],
    2 => [4, 4, 10],
  }
 
  SHAKE[68] = {
  # FRAME_ID => [POWER, SPEED, DURATION],
    3 => [8, 8, 10],
  }
 
 
#==============================================================================
# ** END OF EDITABLE REGION
#------------------------------------------------------------------------------
#  Please do not edit below this point unless you know what you are doing.
#==============================================================================

end

class RPG::Animation
  include AMN_Animations
 
  def init_animation_shake_timings
    @timings.each { |timing| timing.init_shake_timings }
    if SHAKE.key?(@id)
      SHAKE[@id].each do |frame_id, shake_array|
        timing = RPG::Animation::Timing.new
        timing.shake_power = [[shake_array[0], 9].min, 0].max
        timing.shake_speed = [[shake_array[1], 9].min, 0].max
        timing.shake_duration = shake_array[2]
        timing.frame = frame_id
        @timings << timing
        @timings.sort_by! { |timing| timing.frame }
      end
    end
  end

end

class RPG::Animation::Timing
  attr_accessor :shake_power, :shake_speed, :shake_duration

  def init_shake_timings
    @shake_power = 0
    @shake_speed = 0
    @shake_duration = 0
  end

end

module DataManager
  class << self; alias :amn_anishake_datamgr_loaddb :load_database; end

  def self.load_database
    amn_anishake_datamgr_loaddb
    init_animation_shake_timings
  end
 
  def self.init_animation_shake_timings
    $data_animations.each { |obj| obj.init_animation_shake_timings unless obj.nil? }
  end
 
end

class Sprite_Base < Sprite
 
  def animation_process_shake(timing)
    if timing.shake_power > 0 && timing.shake_speed > 0 && !@ani_duplicated
      screen = $game_party.in_battle ? $game_troop.screen : $game_map.screen
      screen.start_shake(timing.shake_power, timing.shake_speed, timing.shake_duration)
    end
  end
 
  alias amn_anishake_spritebase_aniproctiming animation_process_timing
  def animation_process_timing(timing)
    amn_anishake_spritebase_aniproctiming(timing)
    animation_process_shake(timing) unless $imported && $imported[:Theo_MultiAnime]
  end
 
end

if $imported && $imported[:Theo_MultiAnime]
  class Sprite_MultiAnime < Sprite_Base
   
    alias amn_anishake_spritemultanim_aniproctiming animation_process_timing
    def animation_process_timing(timing)
      animation_process_shake(timing)
      amn_anishake_spritemultanim_aniproctiming(timing)
    end
   
  end
end

EDIT: updated code
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
692
Reaction score
448
First Language
English
Primarily Uses
RMVXA
@Sanzational Sorry, I just saw this now. Works fine for me in a clean project. How are you setting up your animations?
 

Panda_Artist

Humble RPG Fan
Veteran
Joined
Dec 22, 2018
Messages
338
Reaction score
17
First Language
Portuguese
Primarily Uses
RMVXA
works fine for me as well! Maybe you are doing something wrong with how you're setting it up?
 

Latest Threads

Latest Posts

Latest Profile Posts

I always end up having issues with things i'd never expect.

Capture.PNG

Those friggin mountains man xD
Time for my daily walk/jog ''Literally starts raining while I open the door''
I just discovered there's a giant jellyfish in the Ace RTP. My day is made.
I'm pretty sure I submitted a username change like 4 months ago.
...
No offense but uh, still waiting for my name to be updated :/

Forum statistics

Threads
112,398
Messages
1,068,050
Members
146,050
Latest member
ozfolo
Top