Aleworks Push Events (APE)
Created by Aleworks (vgvgf)
Version: 1.02
Last Updated: 22-02-2008(day/month/year)
Introduction
This script allow the game player to push events. It has functions for changing the pushing sound, push distance, push directions, and more.
Download links
Demostration
APE(v1.00).rar
Script
* Please give me credit if you use my script.
* Help me to continue developing this script
Send the errors that you find and your ideas to vgvgvgf@gmail.com or post here
Created by Aleworks (vgvgf)
Version: 1.02
Last Updated: 22-02-2008(day/month/year)
Introduction
This script allow the game player to push events. It has functions for changing the pushing sound, push distance, push directions, and more.
Download links
Demostration
APE(v1.00).rar
Script
Code:
=begin =======================================================================
â–“ Aleworks Push Events (APE)
==============================================================================
Created by Aleworks
Version: 1.02
Last Update: 22/02/2008 (dd/mm/yyyy)
==============================================================================
*** Instructions ***
For setup an event for being pushable, you need to add a comment with one or
more of the commands in the comment commands list. The PUSH SPEED #,
PUSH DISTANCE #, PUSH SOUND # and PUSH TRIGGER commands, need that the
PUSHABLE command be added.
==============================================================================
*** Comment Commands List ***
PUSHABLE
If the player move in the direction of the event, it will move in the same
direction the player moves, if the event can't move in that direction, it
will try to move in other directions.
PUSHABLE IN DIRECTION
If the player move in the direction of the event, it will move in the same
direction the player moves.
PUSHABLE #
PUSHABLE IN DIRECTION #
Change the # with the posible directions that the event can be pushed.
PUSH SPEED #
Change the # with the speed that the event will move when pushed.
PUSH DISTANCE #
Change the # with the tiles that the event will be pushed.
PUSH SOUND #
Change the # with the file name of the sound effect that will be played when
the event is pushed.
PUSH TRIGGER
The event will be pushed, only if the button C is pressed.
TRASPASABLE
Make that the player can pass through the event.
==============================================================================
*** APE RGSS Classes edits ***
*** Game_Character ***
alias: update; alias name: aleworks_pushevents_gamecharacter_update
replace: passable?(x, y, d)
replace: screen_z
*** Game_Event ***
alias: refresh; alias name: aleworks_pushevents_gameevent_refresh
*** Game_Player ***
replace: update
==============================================================================
=end
#=============================================================================
# â–’ Game_Character
#=============================================================================
class Game_Character
attr_accessor :move_speed
alias aleworks_pushevents_gamecharacter_update update
#===========================================================================
# â–‘ update
#===========================================================================
def update
if moving? == false and self.is_a?(Game_Event)
if @left_push == 0
@pushing = false
@pushing_direction = 0
else
case @pushing_direction
when 2
move_down
Audio.se_play("Audio/SE/" + @push_sound) if @push_sound != nil
when 4
move_left
Audio.se_play("Audio/SE/" + @push_sound) if @push_sound != nil
when 6
move_right
Audio.se_play("Audio/SE/" + @push_sound) if @push_sound != nil
when 8
move_up
Audio.se_play("Audio/SE/" + @push_sound) if @push_sound != nil
end
@left_push -= 1
end
end
if @old_speed != nil and @pushing == false
@move_speed = @old_speed if @move_speed == @push_speed
@old_speed = nil
end
aleworks_pushevents_gamecharacter_update
end
#===========================================================================
# â–‘ passable?
#===========================================================================
def passable?(x, y, d)
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
return false unless $game_map.valid?(new_x, new_y)
return true if @through
return false unless $game_map.passable?(x, y, d, self)
return false unless $game_map.passable?(new_x, new_y, 10 - d)
for event in $game_map.events.values
if event.x == new_x and event.y == new_y
next if self == $game_player and event.traspasable
unless event.through
return false if event.character_name != ""
end
end
end
if $game_player.x == new_x and $game_player.y == new_y
unless $game_player.through
return false if @character_name != ""
end
end
return true
end
#===========================================================================
# â–‘ screen_z
#===========================================================================
def screen_z(height = 0)
return 999 if @always_on_top
z = (@real_y - $game_map.display_y + 3) / 4 + 32
if @tile_id > 0
return z + $game_map.priorities[@tile_id] * 32
else
if self.is_a?(Game_Event)
if @traspasable == true
return z + ((height > 32) ? 31 : 0) + 16
else
return z + ((height > 32) ? 31 : 0)
end
else
return z + ((height > 32) ? 31 : 0)
end
end
end
end
#=============================================================================
# â–’ Game_Event
#=============================================================================
class Game_Event
attr_reader :pushable
attr_reader :push_speed
attr_reader :push_distance
attr_reader :traspasable
attr_reader :push_in_diretion
attr_reader :push_direction
attr_reader :push_sound
attr_reader :push_trigger
attr_accessor :pushing
attr_accessor :old_speed
attr_accessor :left_push
attr_accessor :pushing_direction
alias aleworks_pushevents_gameevent_refresh refresh
#===========================================================================
# â–‘ refresh
#===========================================================================
def refresh
@pushable = false
@push_speed = nil
@push_distance = 1
@pushing = false
@old_speed = nil
@left_push = 0
@push_direction = []
@pushing_direction = 0
@traspasable = false
@push_in_diretion = false
@push_sound = nil
@push_trigger = false
aleworks_pushevents_gameevent_refresh
return if @page.nil? or @page.list.nil?
for i in @page.list
if i.code == 108 or i.code == 408
if i.parameters[0].upcase[/PUSHABLE/] != nil
@pushable = true
@push_in_diretion = true if i.parameters[0].upcase[/IN DIRECTION/] != nil
@push_direction.push(2) if i.parameters[0][/2/] != nil
@push_direction.push(4) if i.parameters[0][/4/] != nil
@push_direction.push(6) if i.parameters[0][/6/] != nil
@push_direction.push(8) if i.parameters[0][/8/] != nil
end
if i.parameters[0].upcase[/PUSH SPEED/] != nil
@push_speed = i.parameters[0].split[2].to_i
end
if i.parameters[0].upcase[/PUSH DISTANCE/] != nil
@push_distance = i.parameters[0].split[2].to_i
end
if i.parameters[0].upcase[/PUSH SOUND/] != nil
@push_sound = i.parameters[0].split[2]
end
if i.parameters[0].upcase[/PUSH TRIGGER/] != nil
@push_trigger = true
end
if i.parameters[0].upcase[/TRASPASABLE/] != nil
@traspasable = true
end
end
end
end
end
#=============================================================================
# â–’ Game_Player
#=============================================================================
class Game_Player
#===========================================================================
# â–‘ update
#===========================================================================
def update
last_moving = moving?
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
case Input.dir4
when 2
dir = 2
alt_dir = [4,6,8]
push_x = 0
push_y = 1
when 4
dir = 4
alt_dir = [2,6,8]
push_x = -1
push_y = 0
when 6
dir = 6
alt_dir = [2,4,8]
push_x = 1
push_y = 0
when 8
dir = 8
alt_dir = [2,4,6]
push_x = 0
push_y = -1
else
dir = 0
push_x = 0
push_y = 0
end
if passable?(@x, @y, dir) and dir != 0
case dir
when 2
move_down
when 4
move_left
when 6
move_right
when 8
move_up
end
elsif dir != 0
case dir
when 2
turn_down
check_event_trigger_touch(@x, @y+1)
when 4
turn_left
check_event_trigger_touch(@x-1, @y)
when 6
turn_right
check_event_trigger_touch(@x+1, @y)
when 8
turn_up
check_event_trigger_touch(@x, @y-1)
end
if $game_map.passable?(@x, @y, dir)
for event in $game_map.events.values
if event.x == @x + push_x and event.y == @y + push_y
next if event.through == true
next if event.pushable == false
next if event.moving? == true
next if event.push_trigger == true
next if event.push_direction.size >= 1 and
!event.push_direction.include?(dir)
if event.passable?(event.x, event.y, dir)
event.pushing = true
else
if !event.push_in_diretion
if event.passable?(event.x, event.y, alt_dir[0])
dir = alt_dir[0]
event.pushing = true
elsif event.passable?(event.x, event.y, alt_dir[1])
dir = alt_dir[1]
event.pushing = true
elsif event.passable?(event.x, event.y, alt_dir[2])
dir = alt_dir[2]
event.pushing = true
end
end
end
if event.pushing == true
case dir
when 2
event.move_down
when 4
event.move_left
when 6
event.move_right
when 8
event.move_up
end
if event.push_speed != nil
event.old_speed = event.move_speed
event.move_speed = event.push_speed
end
if event.push_distance > 1
event.left_push = event.push_distance
event.pushing_direction = dir
end
if event.push_sound != nil
Audio.se_play("Audio/SE/" + event.push_sound)
end
end
end
end
end
end
end
last_real_x = @real_x
last_real_y = @real_y
super
if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
$game_map.scroll_down(@real_y - last_real_y)
end
if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
$game_map.scroll_left(last_real_x - @real_x)
end
if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
$game_map.scroll_right(@real_x - last_real_x)
end
if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
$game_map.scroll_up(last_real_y - @real_y)
end
unless moving?
if last_moving
result = check_event_trigger_here([1,2])
if result == false
unless $DEBUG and Input.press?(Input::CTRL)
if @encounter_count > 0
@encounter_count -= 1
end
end
end
end
if Input.trigger?(Input::C)
check_event_trigger_here([0])
check_event_trigger_there([0,1,2])
case @direction
when 2
dir = 2
alt_dir = [4,6,8]
push_x = 0
push_y = 1
when 4
dir = 4
alt_dir = [2,6,8]
push_x = -1
push_y = 0
when 6
dir = 6
alt_dir = [2,4,8]
push_x = 1
push_y = 0
when 8
dir = 8
alt_dir = [2,4,6]
push_x = 0
push_y = -1
else
dir = 0
push_x = 0
push_y = 0
end
for event in $game_map.events.values
if event.x == @x + push_x and event.y == @y + push_y
next if event.through == true
next if event.pushable == false
next if event.push_trigger == false
next if event.moving? == true
next if event.push_direction.size >= 1 and
!event.push_direction.include?(dir)
if event.passable?(event.x, event.y, dir)
event.pushing = true
else
if !event.push_in_diretion
if event.passable?(event.x, event.y, alt_dir[0])
dir = alt_dir[0]
event.pushing = true
elsif event.passable?(event.x, event.y, alt_dir[1])
dir = alt_dir[1]
event.pushing = true
elsif event.passable?(event.x, event.y, alt_dir[2])
dir = alt_dir[2]
event.pushing = true
end
end
end
if event.pushing == true
case dir
when 2
event.move_down
when 4
event.move_left
when 6
event.move_right
when 8
event.move_up
end
if event.push_speed != nil
event.old_speed = event.move_speed
event.move_speed = event.push_speed
end
if event.push_distance > 1
event.left_push = event.push_distance
event.pushing_direction = dir
end
if event.push_sound != nil
Audio.se_play("Audio/SE/" + event.push_sound)
end
end
end
end
end
end
end
end
* Please give me credit if you use my script.
* Help me to continue developing this script
Send the errors that you find and your ideas to vgvgvgf@gmail.com or post here