If you don't mind using scripts, my Advanced Event Commands script can do that.
You can use it in a conditional branch:
I'm still working on it, adding some more features etc, but you can have it now. Place it in a new page above main.
[rgss]#----------------------------------------------------#
# Advanced event commands #
# #
# made by: Silver Wind #
# v1.0 #
#----------------------------------------------------#
# Instructions: #
# -Use one of the following lines inside a #
# Conditional Branch (in the script box). #
# #
# event_is_at?(x,y) #
# taken_tile?(x,y) #
# #
# -To create a new event, put this code in a #
# script box. It can be used for bullets, etc. #
# #
# spawn_event(sprite, name, through, x, y) * #
# move_route_copy(from,to) ** #
# #
# - To check if 2 events touch, use: #
# event_touch?(event1,event2) #
# #
# * The last 4 are optional. #
# for example: #
# my_sprite = "001-Fighter01.png" #
# spawn_new_event(my_sprite) #
# spawn_new_event(my_sprite, "Some Name") #
# spawn_new_event(my_sprite, "Some Name" , true) #
# ** Set the move route of your event. #
# from & to can be the event name or the id. #
#----------------------------------------------------#
class Game_Event < Game_Character
attr_reader :erased
end
class Interpreter
attr_reader :event_id
def get_event
return $game_map.events[@event_id]
end
<span style="color:#000080; font-style:italic;">=begin
<span style="color:#000080; font-style:italic;"> def event_x
<span style="color:#000080; font-style:italic;"> return (get_event).x
<span style="color:#000080; font-style:italic;"> end
<span style="color:#000080; font-style:italic;">
<span style="color:#000080; font-style:italic;"> def event_y
<span style="color:#000080; font-style:italic;"> return (get_event).y
<span style="color:#000080; font-style:italic;"> end
<span style="color:#000080; font-style:italic;">
<span style="color:#000080; font-style:italic;"> def event_is_at?(x,y)
<span style="color:#000080; font-style:italic;"> if ((event_x)==x) and ((event_y)==y)
<span style="color:#000080; font-style:italic;"> p 'true'
<span style="color:#000080; font-style:italic;"> return true
<span style="color:#000080; font-style:italic;"> end
<span style="color:#000080; font-style:italic;"> p 'false'
<span style="color:#000080; font-style:italic;"> return false
<span style="color:#000080; font-style:italic;"> end
<span style="color:#000080; font-style:italic;">=end
end
class Game_System
#attr_reader :map_interpreter
def active_event_id
return @map_interpreter.event_id
end
end
class Game_Temp
attr_accessor :new_events
end
class Game_Character
attr_reader :move_route
end
class Game_Event
def name
return @event.name
end
def get_speed
return @move_speed
end
def set_speed(s)
@move_speed = s
update
end
end
class Spriteset_Map
def add_sprite(event_id)
if event_id.is_a?(Array)
event_id.each {|id| add_sprite(id) }
return
end
id = event_id
sprite = Sprite_Character.new(@viewport1, $game_map.events[id])
@character_sprites.push(sprite)
end
alias new_event_update update
def update
event_ids = $game_temp.new_events
unless event_ids.nil?
add_sprite(event_ids)
$game_temp.new_events = nil
end
new_event_update
end
end
class Scene_Map
attr_accessor :spriteset
end
class Game_Map
def occupied_tile?(x,y)
return false if @map.events.keys.size ==0
for i in @map.events.keys
e = @events
if (e.x == x) and (e.y==y)
return true
end
end
return false
end
def new_event(sprite, name, through=false, x=0,y=0)
ids = @map.events.keys
event_id = (ids.size==0) ? 1 : ((ids.max) +1)
newx = x
newy = y
# if the tile is taken, select an empty nearby tile.
while (occupied_tile?(newx,newy))
# advance non equally, to get tiles like: (1,15)
(rand(1) ==0) ? newx += 1 : newy += 1
end
new_event = RPG::Event.new(newx,newy)
new_event.name = name.nil? ? "EV00" + event_id.to_s : name
# set the graphic of the event
new_event.pages[0].graphic.character_name = sprite
new_event.pages[0].through = through
l = @map.events.keys.length
@map.events.keys[l]=event_id
@map.events[event_id]=new_event
game_event = Game_Event.new(@map_id, new_event)
@events[event_id] = game_event
# This flag is used in Spriteset_Map to add the new sprite.
if $game_temp.new_events.nil?
$game_temp.new_events = [event_id]
else
$game_temp.new_events.push(event_id)
end
end
def get_event_by_name(name)
for i in @map.events.keys
ev = @events
return ev if ev.name == name
end
#p "Error: No such event #{name}"
return nil
end
# from, to : event name or id
def copy_move_route(from, to)
if from.is_a?(String)
from = get_event_by_name(from)
from = from.id
end
if to.is_a?(String)
event = get_event_by_name(to)
else
event = @events[to]
end
move = @events[from].move_route
event.force_move_route(move)
speed = @events[from].get_speed
event.set_speed(speed)
end
#def _at?(x,y) #event_is_at?(x,y)
#return @map_interpreter.event_is_at?(x,y)
#end
def event_touch?(event1, event2)
<span style="color:#000080; font-style:italic;">=begin
<span style="color:#000080; font-style:italic;"> if event1.is_a?(String)
<span style="color:#000080; font-style:italic;"> e1 = get_event_by_name(event1)
<span style="color:#000080; font-style:italic;"> else
<span style="color:#000080; font-style:italic;"> e1 = @events[event1]
<span style="color:#000080; font-style:italic;"> end
<span style="color:#000080; font-style:italic;">=end
if event2.is_a?(String)
e2 = get_event_by_name(event2)
else
e2 = @events[event2]
end
return false if e2.erased
x = e2.x
y = e2.y
# is the event below/above/beside event2
right = event_is_at?(event1,x+1,y)
left = event_is_at?(event1, x-1,y)
below = event_is_at?(event1, x,y+1)
above = event_is_at?(event1, x,y-1)
result = ( right or left or below or above )
return result
end
# new
<span style="color:#000080; font-style:italic;">=begin
<span style="color:#000080; font-style:italic;"> def event_x
<span style="color:#000080; font-style:italic;"> return nil unless $scene.is_a?(Scene_Map)
<span style="color:#000080; font-style:italic;"> id = $game_system.active_event_id
<span style="color:#000080; font-style:italic;"> return @events[id].x
<span style="color:#000080; font-style:italic;"> end
<span style="color:#000080; font-style:italic;">
<span style="color:#000080; font-style:italic;"> def event_y
<span style="color:#000080; font-style:italic;"> return nil unless $scene.is_a?(Scene_Map)
<span style="color:#000080; font-style:italic;"> id = $game_system.active_event_id
<span style="color:#000080; font-style:italic;"> return @events[id].y
<span style="color:#000080; font-style:italic;"> end
<span style="color:#000080; font-style:italic;">
<span style="color:#000080; font-style:italic;"> def _at?(x,y) # was event_is_at?(x,y)
<span style="color:#000080; font-style:italic;"> return false unless $scene.is_a?(Scene_Map)
<span style="color:#000080; font-style:italic;"> if ((event_x)==x) and ((event_y)==y)
<span style="color:#000080; font-style:italic;"> p 'true'
<span style="color:#000080; font-style:italic;"> return true
<span style="color:#000080; font-style:italic;"> end
<span style="color:#000080; font-style:italic;"> p 'false'
<span style="color:#000080; font-style:italic;"> return false
<span style="color:#000080; font-style:italic;"> end
<span style="color:#000080; font-style:italic;">=end
def event_is_at?(event, x, y)
if event.is_a?(String)
e = get_event_by_name(event)
else
e = @events[event]
end
return false if e.erased
return (e.x==x and e.y==y)
end
#new
def erase_event(event)
if event.is_a?(String)
e = get_event_by_name(event)
else
e = @events[event]
end
e.erase
end
end
# ------------------------------------------------------------------ #
def event_is_at?(event, x, y)
return $game_map.event_is_at?(event,x,y)
end
def taken_tile?(x,y)
return $game_map.occupied_tile?(x,y)
end
def spawn_event(sprite, name, through ,x ,y)
$game_map.new_event(sprite, name, through ,x ,y)
end
def move_route_copy(from,to)
$game_map.copy_move_route(from,to)
end
def erase_event(event)
$game_map.erase_event(event)
end
# ----------------------------------------------------- #
# Check if event 1 touches event2. #
# event 1,2 : event name or id #
# ----------------------------------------------------- #
def event_touch?(event1,event2)
$game_map.event_touch?(event1,event2)
end
# ------------------------------------------------------------------ #
[/rgss]