JohnLeagsdurg

Working on a intentional "dizzy effect" script.

3 posts in this topic

So this is the first time i'm ever attempting to get into coding on RGSS3 by just starting on DiamondAndPlatinum3's video tutorials. I haven't bothered checking out the Ruby documentation so since i have a really scarse internet on vacation i just wanted to post here for help. I've reached up to Tutorial 20 since the creation of this post. 
I'm working on a script that would emit a LSD-like effect when you have been afflicted by an assigned state, but i'm having severe problems on finding the classes and methods needed to build up the script. 
The script would work what i am intending, in which there would be a method that would check for a specific state ID needed for the dizzy effect, and then when said state is owned by one of your actors, the effect would be enabled and would change your current BGM's pitch by pitching it down and up (zig zag), which each pitch value is changed by a timer variable and a variable that chooses if to pitch up or pitch down. 
This is the current revision of my script, and i would let anyone judge me if there's atleast a detail i've found. This is the first time and i thought of this idea myself, even if actually i did copy some of vx ace's default script parts. 
 

  Dizzy_State = 26
  Dizzy_Pitch_Timer = 15

class Game_System
  #--------------------------------------------------------------------------
  # * Save BGM
  #--------------------------------------------------------------------------
  alias sc00p_DizzinessState_savebgm     save_bgm
  def save_bgm
    @saved_bgm = RPG::BGM.last
  end
end
  
class Game_BattlerBase
  #--------------------------------------------------------------------------
  # * Check State
  #--------------------------------------------------------------------------
  alias sc00p_DizzinessState_checkstate     state?
  def state?(state_id)
    @dizzystate = sc00p_DizzinessState_checkstate(Dizzy_State)
  end
end

class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias sc00p_DizzinessState_initialization     initialize
  def initialize(depth = 0)
    sc00p_DizzinessState_initialization()
    @dizzyPitch = 100
    p("Dizziness initialized")
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias sc00p_DizzinessState_update     update
  def update
    sc00p_DizzinessState_update()
    @dizzy_pitch_timer  = 0 unless @dizzy_pitch_timer != nil
    @dizzy_pitch_timer -= 1 unless @dizzy_pitch_timer == 0
    if @dizzystate == true
      save_bgm()
    end
  end
end

 

Share this post


Link to post
Share on other sites

Now I don't have the engine on this machine so I can't check the proper syntax but maybe I can point you in the right direction.

 

Your party members is contained in a global array. Define the following method in the class that generates the desired effects.

 

class Game_Interpreter

  # the 'dizzy?' method will return true if any party member has the dizzy state.

  def dizzy?

    $game_party.each { |member| return true if member.state?(Dizzy_state) }

    return false

  end

end

 

You can now delete everything you did in the 'Game_Battlerbase' class

 

in the update method exchange the statment

'if @dizzystate == true

   save_bgm()

end'

 

with the line:

'save_bgm() if dizzy?'

 

As a rule of thumb, you should try to write concise non invasive code. Hope it helps ;)

 

PS: Your constants should be included in the class that calls them, otherwise they won't be found by the RGSS handler.

Share this post


Link to post
Share on other sites
19 hours ago, Cookie Ninja said:

Now I don't have the engine on this machine so I can't check the proper syntax but maybe I can point you in the right direction.

 

Your party members is contained in a global array. Define the following method in the class that generates the desired effects.

 

class Game_Interpreter

  # the 'dizzy?' method will return true if any party member has the dizzy state.

  def dizzy?

    $game_party.each { |member| return true if member.state?(Dizzy_state) }

    return false

  end

end

 

You can now delete everything you did in the 'Game_Battlerbase' class

 

in the update method exchange the statment

'if @dizzystate == true

   save_bgm()

end'

 

with the line:

'save_bgm() if dizzy?'

 

As a rule of thumb, you should try to write concise non invasive code. Hope it helps ;)

 

PS: Your constants should be included in the class that calls them, otherwise they won't be found by the RGSS handler.

Thanks for your help, but i've recently updated my code thanks to help from rpgmaker.net.


This is my 2nd revision code:

#==============================================================================
#                                sc00pj0hn's
#                            < DIZZINESS STATE >
#                                Version 1.0
#==============================================================================
# Description:
# This is another script made when i was still watching DiamondAndPlatinum3's
# RGSS3 tutorial videos. This script will make the game sound "dizzy" akin to
# the infamous LSD effects with the current music playing in distorted pitch
# and (later) the screen being distorted as well, all of these happen if you
# have been affected by a state that will make the game session go on "dizzy
# mode".
#
# Thanks to:
# * Marrend from rpgmaker.net for giving me the correct code for the script
# pieces.
#==============================================================================
# Instructions:
# This script is plug-and-play. You can only assign the state you want to use
# for the dizzy effect, then you can change the amount of frames to use to
# elevate the music pitch and the depth for making the music sound deeper and
# pitchy.
#==============================================================================

# (EDITING ZONE START ---------------------------------------------------------
  Dizzy_State = 26       # Which state you want it to assign as "Dizzy"?
  Dizzy_Pitch_Timer = 15 # How much 
  Dizzy_Pitch_Depth = 8
# (EDITING ZONE END -----------------------------------------------------------

class Game_System
  #--------------------------------------------------------------------------
  # * Save BGM
  #--------------------------------------------------------------------------
  alias sc00p_DizzinessState_savebgm     save_bgm
  def save_bgm
    @saved_bgm = RPG::BGM.last
  end
end
  
class Game_Party < Game_Unit
  #--------------------------------------------------------------------------
  # * Determine if has Dizzy State
  #--------------------------------------------------------------------------
  def dizzystate
    i = 0
    while i < members.size
      if members[i].state?(Dizzy_State) == true
        return true
      end
      i += 1
    end
    return false
  end
end

class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias sc00p_DizzinessState_initialization     initialize
  def initialize(depth = 0)
    sc00p_DizzinessState_initialization()
    @dizzyPitch = 100
    p("Dizziness initialized")
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias sc00p_DizzinessState_update     update
  def update
    sc00p_DizzinessState_update()
    if @dizzy_pitch_timer == nil
      @dizzy_pitch_timer = Dizzy_Pitch_Timer
    end
    @dizzy_pitch_timer -= 1
    if @dizzy_pitch_timer == 0
      @dizzy_pitch_timer = nil
    end
    
    if $game_party.dizzystate = true
      p("I AM INFECTED!!!")
    end
  end
end

It has Game_BattlerBase changed to Game_Party, which is returning the method when any of your game party has the state provided from the variable.

Since that, i tried to do a condition in Frame Update checking if $game_party.dizzystate is true, but it's wrong and i can't find out how to get the variable returned from my Game_Party's dizzystate method.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.