[RMVX ACE] WORKING ON A INTENTIONAL "DIZZY EFFECT" SCRIPT.

Posts

Pages: 1
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
Mirak
Stand back. Artist at work. I paint with enthusiasm if not with talent.
9300
Oh man that would be an amazing script. Good luck!
Eh i can't really script right now so i need anyone to guess if i have one detail right or to change.
Marrend
Guardian of the Description Thread
21781
I gave this a shot, but, I'm not sure if I have an answer yet, per say.

I know if I leave this as-is, I get a "Stack level too deep" error. I don't think you necessarily need to alias Game_System.save_bgm, or Game_BattlerBase.state?, but, I could be proven wrong!

Game_Interpreter.update is definitely wacky. The statement "if @dizzystate == true" will always return false, since the class-variable "@dizzystate" is never defined. It would never look at Game_BattlerBase as a reference. What I think you can do is something more like...

class Game_Party < Game_Unit
  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

...this, and check against $game_party.dizzystate instead. At least, I think only one member in the party needs to have the state for the effect to apply?


So, back to Game_Interpreter, this time, the update method. When the effect applies initially, the value of @dizzy_pitch_timer is "nil". I think that means the line "@dizzy_pitch_timer = 0 unless @dizzy_pitch_timer != nil" would occur? Then, when it tries to evaluate "@dizzy_pitch_timer -= 1 unless @dizzy_pitch_timer == 0", it does nothing? Unless you mean to do something like...

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

...that?
author=Marrend
I gave this a shot, but, I'm not sure if I have an answer yet, per say.

I know if I leave this as-is, I get a "Stack level too deep" error. I don't think you necessarily need to alias Game_System.save_bgm, or Game_BattlerBase.state?, but, I could be proven wrong!

Game_Interpreter.update is definitely wacky. The statement "if @dizzystate == true" will always return false, since the class-variable "@dizzystate" is never defined. It would never look at Game_BattlerBase as a reference. What I think you can do is something more like...

class Game_Party < Game_Unit
  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


...this, and check against $game_party.dizzystate instead. At least, I think only one member in the party needs to have the state for the effect to apply?


So, back to Game_Interpreter, this time, the update method. When the effect applies initially, the value of @dizzy_pitch_timer is "nil". I think that means the line "@dizzy_pitch_timer = 0 unless @dizzy_pitch_timer != nil" would occur? Then, when it tries to evaluate "@dizzy_pitch_timer -= 1 unless @dizzy_pitch_timer == 0", it does nothing? Unless you mean to do something like...

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


...that?


This got rid of that Stack level error, but since i am a newbie at RGSS3, i don't see which variable/boolean has its return in the dizzystate method.

can something like this
if $game_party.dizzystate = true

# timer, pitching and stuff
end

work?
Marrend
Guardian of the Description Thread
21781
author=JohnLeagsdurg
This got rid of that Stack level error, but since i am a newbie at RGSS3, i don't see which variable/boolean has its return in the dizzystate method.


I'm not sure what you mean by this. The dizzystate method of Game_Party that I wrote in the last post should return "true" if any member in the party has a state with an ID whose value is equal to that of the global constant variable of "Dizzy_State" (26 in your code). It should otherwise return false.

author=JohnLeagsdurg
can something like this
if $game_party.dizzystate = true

# timer, pitching and stuff
end

work?


I think you have the right idea, but, the operator would be "==". Using the "=" operator would attempt to assign the value of "true" to the function of "$game_party.dizzystate", and might throw an error onto itself.
author=Marrend
author=JohnLeagsdurg
This got rid of that Stack level error, but since i am a newbie at RGSS3, i don't see which variable/boolean has its return in the dizzystate method.
I'm not sure what you mean by this. The dizzystate method of Game_Party that I wrote in the last post should return "true" if any member in the party has a state with an ID whose value is equal to that of the global constant variable of "Dizzy_State" (26 in your code). It should otherwise return false.

author=JohnLeagsdurg
can something like this
if $game_party.dizzystate = true

# timer, pitching and stuff
end

work?


I think you have the right idea, but, the operator would be "==". Using the "=" operator would attempt to assign the value of "true" to the function of "$game_party.dizzystate", and might throw an error onto itself.


Thanks.
I never knew that there are differences between = and == in Ruby. Because i'm actually oriented to GameMaker Language's syntax.
With == it actually worked as it prints the sentence to the console. Atleast it seems i got that one right, now the real deal is how to make the current BGM pitch down and up like Yoshi's Island Dizzy effect, which pratically it's what my script is based off.

Now here's the other one:

class Game_System
#--------------------------------------------------------------------------
# * Save BGM
#--------------------------------------------------------------------------
alias sc00p_DizzinessState_savebgm save_bgm
def save_bgm
@saved_bgm = RPG::BGM.last
end
end

As you can see, in my Game_System class, i borrowed a piece of script which saves the BGM, and i need how i could manage to modify the current BGM playing with its pitch being updated by the "updating pitch" variable. I know how to change BGM settings by existing variables, but i just need a command that just modifies the BGM.
Marrend
Guardian of the Description Thread
21781
I've made several attempts at this with various tweaks to the rate at which the pitch changes. Either the sound comes out choppy (and the game is laggy), or the game is not laggy, but the pitch seems constant. The mess of code I'm looking at right now...

Dizzy_State = 26
Dizzy_Pitch_Timer = 300 #15

class Game_Map
  def update(main = false)
    refresh if @need_refresh
    update_interpreter if main
    update_scroll
    update_events
    update_vehicles
    update_parallax
    update_bgm
    @screen.update
  end
  
  def update_bgm
    bgm = @map.bgm
    pos = bgm.pos
    if $game_party.dizzystate == true
      i = 0
      while i < 100
        if @dizzy_timer == nil
          @dizzy_timer = Dizzy_Pitch_Timer
        end
        @dizzy_timer -= 1
        if @dizzy_timer == 0
          bgm.pitch = i + 50
          bgm.play(pos)
          @dizzy_timer = nil
        end
        i += 20
      end
      while i > 0
        if @dizzy_timer == nil
          @dizzy_timer = Dizzy_Pitch_Timer
        end
        @dizzy_timer -= 1
        if @dizzy_timer == 0
          bgm.pitch = i + 50
          bgm.play(pos)
          @dizzy_timer = nil
        end
        i -= 20
      end
    else
      bgm.pitch = 100
      bgm.play(pos)
    end
  end
end

class Game_Party < Game_Unit
  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

...is a non-choppy/non-laggy instance with a lower pitch than normal. Though, if the increase/decrease of pitch is larger, my guess is that there can be a non-choppy/non-laggy instance with a higher pitch?


I hope this is of some use.
Whooooops, this actually came out horrible than i wanted to do so. What i've seen is that for every command that changes any parameters of music, the game takes very few frames to pause for changing music, and basically for changing the pitch and position has the game literally go slow because it's literally changing the music all the time, in every frame.

Now that i've seen that this seem unfair, i fear that there is actually no good way to make pitch-changing music, i'll keep my own code commented out just for future references, unless somebody cares to help me. But i may believe that this might not be done for good.

Well, this was just my idea after all.
Pages: 1