luistop12Jue Dic 06, 2012 4:44 pm
SUPER MODERADOR
Les traigo Este script que les permite agarrar y lanzar cualquier objeto que tenga esto es su nombre
< ThrowX > debe ir sin los espacios
la X al final representa la distancia es decir que si quieres que el objeto caiga tres cuadros mas allá ponlo así
< Throw3 >
y necesitarás charas como esta
fuente:ateliergss2
link
< ThrowX > debe ir sin los espacios
la X al final representa la distancia es decir que si quieres que el objeto caiga tres cuadros mas allá ponlo así
< Throw3 >
y necesitarás charas como esta
fuente:ateliergss2
link
- Código:
#==============================================================================
# By Moghunter
# http://www.atelier-rgss.com/
#==============================================================================
# Sistema de carregar e arremessar eventos, útil para criar puzzles.
#==============================================================================
# Para definir quais os eventos serão arremessáveis basta nomear o evento
# da seguinte forma.
#
# <ThrowX>
#
# X é a distância que o evento pode ser arremessado.
#
# Exemplo
#
# Event01<Throw4>
#
#==============================================================================
# Sprite do personagem carregando o Objeto (Opcional)
#==============================================================================
# É preciso ter uma imagem do personagem em posição de carreagar objeto e
# nomear a imagem da sequinte forma.
#
# Character_Name + _Pickup
#
# Exemplo
#
# Actor1_Pickup.png
#==============================================================================
# HISTÓRICO
# 1.1 - Corrigido o bug relacionado ao Teleport.
# 1.2 - Adicionado a opção de ativar e desativar o sistema por Switch.
# 1.3 - Definição do som pelo script no lugar da animação do banco de dados.
#==============================================================================
module MOG_PICK_THROW
#Altura do sprite do objeto carregado.
SPRITE_POSITION = 18
#Definição do Som quando o objeto é arremessado.
THROW_SE = "Jump2"
#Definição do Som quando o objeto é carregado.
PICK_UP_SE = "Jump1"
#ID do balão quando o objeto é arremessado.
THROW_BALLOON_ID = 5
#ID do balão quando o objeto é carregado.
PICK_UP_BALLOON_ID = 6
#ID da Switch que desativa o sistema de carregar.
DISABLE_SWITCH_ID = 20
end
#==============================================================================
# ■ Game_Temp
#==============================================================================
class Game_Temp
attr_accessor :pickup_lock
attr_accessor :pickup_lock_time
attr_accessor :character_pre_name
attr_accessor :can_throw
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
alias mog_pick_initialize initialize
def initialize
@pickup_lock = false
@pickup_lock_time = 0
@character_pre_name = ""
@can_throw = true
mog_pick_initialize
end
end
#==============================================================================
# ■ Game_Event
#==============================================================================
class Game_Event < Game_Character
attr_accessor :throw_active
attr_accessor :throw
attr_accessor :x
attr_accessor :y
attr_accessor :move_speed
attr_accessor :pre_move_speed
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
alias mog_pickup_initialize initialize
def initialize(map_id, event)
@throw_active = false
if event.name =~ /<Throw(\d+)>/i
@throw = $1.to_i
else
@throw = 0
end
mog_pickup_initialize(map_id, event)
end
end
#==============================================================================
# ■ Game_Character
#==============================================================================
class Game_Character
attr_accessor :pre_move_speed
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_throw_initialize initialize
def initialize
mog_throw_initialize
@pre_move_speed = @move_speed
end
#--------------------------------------------------------------------------
# ● Throw Action
#--------------------------------------------------------------------------
def throw_action(range)
jump_range = range
@x = $game_player.x
@y = $game_player.y
range.times do
unless jumping?
case $game_player.direction
when 6
jump(jump_range,0) if throw_range?(jump_range,0,jump_range)
when 4
jump(-jump_range,0) if throw_range?(-jump_range,0,jump_range)
when 2
jump(0,jump_range) if throw_range?(0,jump_range,jump_range)
when 8
jump(0,-jump_range) if throw_range?(0,-jump_range,jump_range)
end
jump(0,0) if jump_range == 1
if @x == $game_player.x and @y == $game_player.y and jump_range == 1
$game_temp.can_throw = false
end
jump_range -= 1
end
end
end
#--------------------------------------------------------------------------
# ● Throw Range?
#--------------------------------------------------------------------------
def throw_range?(x, y,range )
x = $game_player.x
y = $game_player.y
case $game_player.direction
when 2
y += range
when 6
x += range
when 4
x -= range
when 8
y -= range
end
return false if collide_with_characters?(x, y)
return false unless map_passable?(x, y)
return true
end
end
#==============================================================================
# ■ Game_Player
#==============================================================================
class Game_Player < Game_Character
include MOG_PICK_THROW
#--------------------------------------------------------------------------
# ● Img Pickup Exist?
#--------------------------------------------------------------------------
def img_pickup_exist?
Cache.character(@character_name + "_Pickup") rescue return false
end
#--------------------------------------------------------------------------
# ● Check Action Event
#--------------------------------------------------------------------------
alias mog_pickup_check_action_event check_action_event
def check_action_event
throw_event
check_event_pickup([0,1,2])
mog_pickup_check_action_event
end
#--------------------------------------------------------------------------
# ● Reserve Transfer
#--------------------------------------------------------------------------
alias mog_pickup_reserve_transfer reserve_transfer
def reserve_transfer(map_id, x, y, direction)
if $game_temp.pickup_lock == true
for event in $game_map.events.values
if event.throw_active == true
event.throw_active = false
case @direction
when 2
event.jump(0,-1)
when 4
event.jump(1,0)
when 6
event.jump(-1,0)
when 8
event.jump(0,1)
end
end
end
$game_temp.pickup_lock = false
$game_temp.pickup_lock_time = 0
@character_name = $game_temp.character_pre_name
end
mog_pickup_reserve_transfer(map_id, x, y, direction)
end
#--------------------------------------------------------------------------
# ● Move By Input
#--------------------------------------------------------------------------
alias mog_pickup_move_by_input move_by_input
def move_by_input
return if $game_temp.pickup_lock_time > 0
mog_pickup_move_by_input
end
#--------------------------------------------------------------------------
# ● Throw Event
#--------------------------------------------------------------------------
def throw_event
return if $game_temp.pickup_lock == false
return if $game_temp.pickup_lock_time > 0
return if $game_map.interpreter.running?
for event in $game_map.events.values
if event.throw_active == true and not jumping?
$game_temp.can_throw = true
event.throw_action(event.throw)
$game_temp.pickup_lock_time = 120
return if $game_temp.can_throw == false
event.throw_active = false
$game_temp.pickup_lock = false
event.move_speed = event.pre_move_speed
Audio.se_play("Audio/SE/" + THROW_SE, 100, 100)
$game_player.balloon_id = THROW_BALLOON_ID
@character_name = $game_temp.character_pre_name
end
end
end
#--------------------------------------------------------------------------
# ● Check Event Pickup
#--------------------------------------------------------------------------
def check_event_pickup(triggers)
return if $game_temp.pickup_lock == true
return if $game_temp.pickup_lock_time > 0
return if $game_map.interpreter.running?
return if $game_switches[DISABLE_SWITCH_ID] == true
front_x = $game_map.x_with_direction(@x, @direction)
front_y = $game_map.y_with_direction(@y, @direction)
for event in $game_map.events_xy(front_x, front_y)
if event.throw > 0 and not jumping?
$game_temp.pickup_lock_time = 120
event.throw_active = true
$game_temp.pickup_lock = true
event.jump(0,0)
event.x = @x
event.y = @y
event.pre_move_speed = event.move_speed
event.move_speed = 5
$game_player.balloon_id = PICK_UP_BALLOON_ID
Audio.se_play("Audio/SE/" + PICK_UP_SE, 100, 100)
$game_temp.character_pre_name = @character_name
if img_pickup_exist?
@character_name = @character_name + "_Pickup"
end
end
end
end
end
#==============================================================================
# ■ Sprite_Character
#==============================================================================
class Sprite_Character < Sprite_Base
include MOG_PICK_THROW
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
alias mog_pickup_update update
def update
mog_pickup_update
update_pickup_position
end
#--------------------------------------------------------------------------
# ● Update Pickup Position
#--------------------------------------------------------------------------
def update_pickup_position
$game_temp.pickup_lock_time -= 1 if $game_temp.pickup_lock_time > 0
if @character.is_a?(Game_Event)
if @character.throw_active == true and not @character.jumping?
@character.x = $game_player.x
@character.y = $game_player.y
self.x = $game_player.screen_x
self.y = $game_player.screen_y - SPRITE_POSITION
self.z = $game_player.screen_z + 1
end
end
end
end
#==============================================================================
# ■ Scene_Map
#==============================================================================
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# ● Call Menu
#--------------------------------------------------------------------------
alias mog_pickup_call_menu call_menu
def call_menu
$game_temp.next_scene = nil if $game_temp.pickup_lock == true
return if $game_temp.pickup_lock == true
mog_pickup_call_menu
end
#--------------------------------------------------------------------------
# ● Call Save
#--------------------------------------------------------------------------
alias mog_pickup_call_save call_save
def call_save
$game_temp.next_scene = nil if $game_temp.pickup_lock == true
return if $game_temp.pickup_lock == true
mog_pickup_call_save
end
end
$mog_rgssvx_pickup_throw = true