Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[Resolved] Screen shake on Critical hit.

Status
Not open for further replies.
Can someone please tell me, what do I need to add and where, to make it so that the screen would shake when an actor or an enemy makes a critical hit in battle?

Thanks a bunch.
 
Code:
#============================================================================
# ** Module: HitShake (Configure the setting here)
#============================================================================
module HitShake
  Power    = 5
  Speed    = 10
  Duration = 10
end
#============================================================================
# ** Critical Hit : Screenshake
#============================================================================
class Scene_Battle
  alias kurisu_hitshake_update_phase4_step4 update_phase4_step4
  def update_phase4_step4
    kurisu_hitshake_update_phase4_step4
    for target in @target_battlers
      target.animation_id = @animation2_id
      target.animation_hit = (target.damage != "Miss")
      if target.critical
        $game_screen.start_shake(HitShake::Power, HitShake::Speed, HitShake::Duration)
      end
    end
  end
end

Coded this up quickly.
Thanks to Trickster and Raz for their help.
 
Thanks alot! Finally someone replied :)

Although, I get an error, it is incompilant (or compactible, dunno what's the difference :p) with RTAB.
Sorry for not telling this before, but I didn't really think it will affect it. Also, I was afraid no one is going to help me, since alot of people hate RTAB for some reason... :-\
Could you please make it compactible with the RTAB?

But thanks again! I really appreciate it.
 
Well erm, I don't know how to use RTAB, the coding is right a mess.
But I recommend Trickster's RTAB. It work the exact the same as the RTAB you're using. (The code I coded quickly will work) And its highly compable with most scripts.

But. If you insist on using RTAB, Perhap DerVVulfman will help you to convert it to the RTAB Coding, As he knows the system well.

Sorry I couldn't help, you didn't waste my time. :) I learned a valuable lesson in my 'Scripting Learning Progress'.

EDIT:
DerVVulfman has converted the code, here it is, credits to him. :)

Code:
#============================================================================
# ** Critical Hit : Screenshake
#----------------------------------------------------------------------------
# by Cool_Rix (05-12-2007)
#============================================================================

#============================================================================
# ** Module: HitShake (Configure the setting here)
#============================================================================
module HitShake
  Power    = 5
  Speed    = 10
  Duration = 10
end

#==============================================================================
# ** Scene_Battle 
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 4 : animation for target)
  #-------------------------------------------------------------------------- 
  alias kurisu_hitshake_update_phase4_step4 update_phase4_step4
  def update_phase4_step4(battler = @active_battler)
    # Perform RTAB check
    @rtab = !@target_battlers
    # Perform original call
    @rtab ? kurisu_hitshake_update_phase4_step4(battler) : kurisu_hitshake_update_phase4_step4
    # If non-RTAB, screen shakes during animation... not during damage pop-up
    unless @rtab
      # Cycle through the targets
      for target in  @target_battlers
        # If the target suffers a critical hit
        if target.critical
          # Perform the shake
          $game_screen.start_shake(HitShake::Power, HitShake::Speed, HitShake::Duration)
        end        
      end
    end
  end  
  #--------------------------------------------------------------------------
  # * Frame Update (main phase step 5 : damage display)
  #--------------------------------------------------------------------------  
  alias kurisu_hitshake_update_phase4_step5 update_phase4_step5
  def update_phase4_step5(battler = @active_battler)
    # Perform RTAB check
    @rtab = !@target_battlers
    # Perform original call
    @rtab ? kurisu_hitshake_update_phase4_step5(battler) : kurisu_hitshake_update_phase4_step5
    # If RTAB, screen shakes during animation & damage pop-up
    if @rtab
      # Cycle through the targets
      for target in battler.target
        # If the target suffers a critical hit
        if target.critical[battler]
          # Perform the shake
          $game_screen.start_shake(HitShake::Power, HitShake::Speed, HitShake::Duration)
        end        
      end
    end
  end
end
 
Do I need to say anything? Just look at the coding difference.

They really need to put DerV's name on the RTAB. He has done probably more work for the RTAB then the RTAB. 'Tis a shame to see his talents... just so focused on something so pain-in-the-assy. Just redo the rtab the same, just fix all those non-needed method rewrites, variable names, etc. There really was no reason to do that other than destry compatability.

Anyways, let us know if what the two of them together gave you works.

Good work Kuri$u and DerV (What do we have to do to get you to join our side?).
 
Status
Not open for further replies.

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top