Battle - Shake Screen when playing frames of animation

Panda_Artist

Humble RPG Fan
Veteran
Joined
Dec 22, 2018
Messages
195
Reaction score
15
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
662
Reaction score
429
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
195
Reaction score
15
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
2,506
Reaction score
534
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
195
Reaction score
15
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
662
Reaction score
429
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
195
Reaction score
15
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!!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

12 done, 4-5 started. Now that the weekend is over, things will sloooowwwww down again proabably.
when you're completely done with someone's crap lol...
Ami
--- Survival For RPGist Part 3 ---

F.Healer: Here it is,I made the Simple Sandwich
Survivalist
: it's so Delicious!
Chef: Here you Go! My Gourmet Steak.
Survivalist: It's Super Delicious,Too!
F.Mage: I Made it for you!
F.Healer: Uhh...Charcoal?
F.Mage No,It's a Toast!
Chef: Did you Let it in 10 Minutes?
F.Mage: Maybe?
I had a birthday party earlier today. No-one showed up. ;_;

Forum statistics

Threads
103,032
Messages
996,801
Members
134,508
Latest member
juegostudios
Top