Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: calvinchun832 on July 05, 2014, 09:24:38 pm

Title: [XP] Needed help with a small edited Kain Nobel Footstep script
Post by: calvinchun832 on July 05, 2014, 09:24:38 pm
I figured that i really need help with this script that i have made edit on.
I'm trying to fix it for a couple of days now but have found no success.
Spoiler: ShowHide
#===============================================================================
# ** Player & Event Step Sound Effects
#-------------------------------------------------------------------------------
# Written by      : Kain Nobel
# Version          : 1.0
# Last Updated   : 7/20/2008
# Date Created   : 6/20/2008
#===============================================================================
################################################################################
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
# ~**                         CUSTOMIZABLE CONSTANTS - BEGIN                                  **~ #
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
################################################################################
module StepSFX
 #-----------------------------------------------------------------------------
 # * Is this script active and enabled?
 #-----------------------------------------------------------------------------
 Enabled       = true
 #-----------------------------------------------------------------------------
 # * Horizontal Limit before event is out of range.
 #-----------------------------------------------------------------------------
 Arg_Dist_X   = 6
 #-----------------------------------------------------------------------------
 # * Vertical Limit before event is out of range.
 #-----------------------------------------------------------------------------
 Arg_Dist_Y   = 4
 #-----------------------------------------------------------------------------
 # * The master volume of the step sound effects.
 #-----------------------------------------------------------------------------
 Volume         = 50
 #-----------------------------------------------------------------------------
 # * The modifier for the step sound effect volume (for events vs player dist)
 #-----------------------------------------------------------------------------
 Adjust         = 2.5
 #-----------------------------------------------------------------------------
 # * Step sounds based on terrain tag ID
 #-----------------------------------------------------------------------------
 Tag = {
    # Default tag for no terrain
    0 => "Steps-00-Default",
    # Special Terrains such as grass, water, etc...
    1 => "Wood Step",
    2 => "Steps-02-Cement",
    3 => "Steps-03-Dirt",
    4 => "Steps-07-Snow",
    5 => "Wood Step",
    6 => "Steps-06-Metal",
    7 => "step in water"
 }
   TagLicker = {
    # Default tag for no terrain
    0 => "Steps-00-Default",
    # Special Terrains such as grass, water, etc...
    1 => "Wood Step",
    2 => "Steps-02-Cement",
    3 => "Steps-03-Dirt",
    4 => "Steps-07-Snow",
    5 => "Wood Step",
    6 => "Steps-06-Metal",
    7 => "step in water"
 }
end
################################################################################
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
# ~**                           CUSTOMIZABLE CONSTANTS - END                                    **~ #
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#
################################################################################
#===============================================================================
# ** Game_Character
#-------------------------------------------------------------------------------
#    This class has been enhanced to use step sounds with player/events based on
# terrain tags.
#===============================================================================
class Game_Character
 #-----------------------------------------------------------------------------
 # * Alias Listing
 #-----------------------------------------------------------------------------
 alias_method   :kn_step_sounds_game_character_update,       :update
 #-----------------------------------------------------------------------------
 # * Update Method (Aliased)
 #-----------------------------------------------------------------------------
 def update
    if StepSFX::Enabled && self.moving? && arg_frames
       if arg_screen_x && arg_screen_y
          if within_x && within_y
             play_step_sounds
          end
       end
    end
    kn_step_sounds_game_character_update
  end
 #-----------------------------------------------------------------------------
 # * Play Step Sounds
 #-----------------------------------------------------------------------------
 def play_step_sounds
    if event.name.include?("[Licker]")
    sound_effect = "Audio/SE/"+StepSFX::TagLicker[self.terrain_tag]
    elsif
    sound_effect = "Audio/SE/"+StepSFX::Tag[self.terrain_tag]
    end
    if StepSFX::Tag.has_key?(self.terrain_tag)
       begin
          Audio.se_play(sound_effect, walk_volume, 75)
       rescue
       end
    end
 end
 #-----------------------------------------------------------------------------
 # * Frame Count Argument
 #-----------------------------------------------------------------------------
 def arg_frames
    unless @move_speed.nil?
       return ((Graphics.frame_count + 2 * self.id) % (18 - @move_speed)).zero?
    end
 end
 #-----------------------------------------------------------------------------
 # * Screen X Argument
 #-----------------------------------------------------------------------------
 def arg_screen_x
    return (self.screen_x > 0 && self.screen_x < 640)
 end
 #-----------------------------------------------------------------------------
 # * Screen Y Argument
 #-----------------------------------------------------------------------------
 def arg_screen_y
    return (self.screen_y > 0 && self.screen_y < 480)
 end
 #-----------------------------------------------------------------------------
 # * Distance X Argument
 #-----------------------------------------------------------------------------
 def arg_distance_x
    return ((self.x + $game_player.x) / 2)
 end
 #-----------------------------------------------------------------------------
 # * Distance Y Argument
 #-----------------------------------------------------------------------------
 def arg_distance_y
    return ((self.y + $game_player.y) / 2)
 end
 #-----------------------------------------------------------------------------
 # * Within Distance X
 #-----------------------------------------------------------------------------
 def within_x
    return arg_distance_x < (StepSFX::Arg_Dist_X * 32)
 end
 #-----------------------------------------------------------------------------
 # * Within Distance Y
 #-----------------------------------------------------------------------------
 def within_y
    return arg_distance_y < (StepSFX::Arg_Dist_Y * 32)
 end
 #-----------------------------------------------------------------------------
 # * Define Walk Volume
 #-----------------------------------------------------------------------------
 def walk_volume
    return StepSFX::Volume+(StepSFX::Adjust*(arg_distance_x+arg_distance_y)/2)
 end
end

#===============================================================================
# ** Game_Player
#-------------------------------------------------------------------------------
#    Game_Player's walk volume doesn't have to be measured against anything, so
# this class's volume is constantly a certain value * 2. This overrides the
# 'walk_volume' method in Game_Character.
#===============================================================================
class Game_Player < Game_Character
 #-----------------------------------------------------------------------------
 # * Define Walk Volume
 #-----------------------------------------------------------------------------
 def walk_volume
    return StepSFX::Volume * 2
 end
end

The error raised is this :(http://3.bp.blogspot.com/-eHQrhFY2pyQ/U7il8nwp3rI/AAAAAAAAAZU/JkZ5BRIA04c/s1600/lol.png)
I knew that the error causer was 'if event.name.include?("[Licker]")' on line 96. Basically, what i want to do is, that if an event on the map has either 'Licker' as the event's name or as a comment in the page list, sounds on the 'TagLicker' (in the modules StepFX) will be the event footstep sound play when the event moves. So, i hope i can get help regarding about this. Thanks everyone~!

(P.S : I really hope my english is not tangled xD)
Title: Re: [XP] Needed help with a small edited Kain Nobel Footstep script
Post by: KK20 on July 05, 2014, 11:14:40 pm
If the character graphic file is named [Licker], then do this

if @character_name == "[Licker]"

You were, as I like to call it, experimenting with various variable names hoping that the program would make sense of it. Unfortunately, coding doesn't work like that.
Title: [SOLVED] Needed help with a small edited Kain Nobel Footstep script
Post by: calvinchun832 on July 06, 2014, 03:43:02 am
Woah! KK20! That was.. fast lol.
It worked so thank you  :^_^': and yeah, you are right about that.
Coding did not work that way. I will now begin learning rgss scripting
in a much more proper way. So, double thanks to you for making me
realise that xD