- Joined
- Oct 8, 2015
- Messages
- 215
- Reaction score
- 83
- First Language
- English
- Primarily Uses
- RMMV
.
Last edited:
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Collision Sound
# Author: DiamondandPlatinum3
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Description:
#
# This script plays a collision sound when you try walking on to an
# non-passable space. This is not used if you have 'through' checked on your
# player on the other hand.
# Collision sound only works for the Player, it does not play for other
# events if they try to walk into something they shouldn't.
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#------------------------------------------------------------------------------
# Instructions:
#
# Editable Region, simply replace the Filename, VOlume & Pitch for the
# Collision_SE. You must also set a wait timer until it can be heard again.
# This is because the collision sound can play many many times if you keep
# attempting to walk into a wall, so this option sets the cooldown time until
# it can be heard again.
#
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
class Game_Player < Game_Character
#----------------------------------------
# Editable Region
#----------------------------------------
Collision_SE = [ "Bite", 80, 100 ] # The Collision Sound you wish to play, volume, pitch.
Collision_Wait_Timer = 60 # Wait Timer (in frames) until next collision sound.
Collision_Switch = 3 # On to play sounds
#----------------------------------------
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias dp3_collisionsound_gameplayer_update_sevt update
def update
dp3_collisionsound_gameplayer_update_sevt()
@collision_sound_timer = 0 unless @collision_sound_timer != nil
@collision_sound_timer -= 1 unless @collision_sound_timer == 0
end
#--------------------------------------------------------------------------
# * Determine if Passable
#--------------------------------------------------------------------------
alias dp3_collisionsound_gameplayer_passable_sevt passable?
def passable?( *args )
passable = dp3_collisionsound_gameplayer_passable_sevt( *args )
return passable unless $game_switches[Collision_Switch] == true
unless passable == true || @collision_sound_timer > 0
RPG::SE.new(*Collision_SE).play
@collision_sound_timer = Collision_Wait_Timer
end
return passable
end
end
alias romanticist_frame_update update
def update
romanticist_gameplayer_frame_update
alias romanticist_frame_update update
def update
romanticist_frame_update
I need to see more of your code.SWITCH = OFF
Jump Common Event
SWITCH = ON
or 
class Game_Player < Game_Character
alias romanticist_collisionbump_sfx passable?
def passable?(*args)
passable = romanticist_collisionbump_sfx(*args)
x2 = $game_map.round_x_with_direction(@x, @direction)
y2 = $game_map.round_y_with_direction(@y, @direction)
return passable if facing_jump_event?
return passable unless $game_switches[Collision_Switch]
unless passable || @collision_sound_timer > 0
RPG::SE.new(*Collision_SE).play
@collision_sound_timer = Collision_Wait_Timer
end
return passable
end
def facing_jump_event?
x2 = $game_map.round_x_with_direction(@x, @direction)
y2 = $game_map.round_y_with_direction(@y, @direction)
return false unless $game_map.event_id_xy(x2, y2) > 0
return $game_map.events[$game_map.event_id_xy(x2, y2)].jump_event?
end
end
class Game_Event < Game_Character
def name
@event.name
end
def jump_event?
name.include?("jump") # or whatever unique name you want to use
end
end
class Game_Player < Game_Character
Collision_SE = ["collision", 85, 50]
Collision_Wait_Timer = 20
Collision_Switch = 26
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias romanticist_frame_update update
def update
romanticist_frame_update
@collision_sound_timer = 0 unless @collision_sound_timer != nil
@collision_sound_timer -= 1 unless @collision_sound_timer == 0
end
#--------------------------------------------------------------------------
# * Determine if Passable
#--------------------------------------------------------------------------
alias romanticist_collisionbump_sfx passable?
def passable?(x, y, d)
passable = romanticist_collisionbump_sfx(x, y, d)
return passable if facing_jump_event?(d)
return passable unless $game_switches[Collision_Switch]
unless passable || @collision_sound_timer > 0
RPG::SE.new(*Collision_SE).play
@collision_sound_timer = Collision_Wait_Timer
end
return passable
end
def facing_jump_event?(direction)
x2 = $game_map.round_x_with_direction(@x, direction)
y2 = $game_map.round_y_with_direction(@y, direction)
return false unless $game_map.event_id_xy(x2, y2) > 0
return false unless $game_map.events[$game_map.event_id_xy(x2, y2)].jump_event?
return $game_map.events[$game_map.event_id_xy(x2, y2)].jump_directions.include?(direction)
end
end
class Game_Event < Game_Character
def name
@event.name
end
def jump_event?
name.include?("jump")
end
def jump_directions
res = []
name.scan(/jump\s*<(.+)>/i).each do |i|
i.each { |e| res << e.strip.split(",") }
end
res = res.flatten.map(&:to_i)
end
end
jump <4,6>