#==============================================================================
#
# ▼ Yanfly Engine Ace - Spawn Event v1.00
# -- Last Updated: 2012.02.08
# -- Level: Normal, Hard
# -- Requires: n/a
#
#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.02.08 - Started Script and Finished.
# Edited for RPG Maker XP by Wrinkle
# Credit to Modern Algebra for fixing the graphic refresh bug
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# For those who would like to spawn pre-made events from the current map or
# even other maps, this script allows you to do so. With the option of spawning
# the events at specific locations or a random spot marked by a certain region,
# you can have events spawn using simple script calls. The events remain until
# a map change.
#
# -----------------------------------------------------------------------------
# Script Calls - These commands are used with script calls.
# -----------------------------------------------------------------------------
# spawn_event_location(x, y, event_id)
# spawn_event_location(x, y, event_id, map_id)
# This causes a new event to be created at location x,y on the current map with
# the data from the corresponding event and map ID.
# The map_id is where the event will be called from according to event_id.
# If no map_id is included it will call the event from your current map.
#
#==============================================================================
#==============================================================================
# ■ Game_Map
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# new method: spawn_event
#--------------------------------------------------------------------------
def spawn_event(dx, dy, event_id, map_id)
map_id = @map_id if map_id == 0
map = load_data(sprintf("Data/Map%03d.rxdata", map_id))
event = generated_event(map, event_id)
return if event.nil?
key_id = @events.keys.max + 1
@events[key_id] = Game_Event.new(@map_id, event)
@events[key_id].moveto(dx, dy)
$scene.spriteset.wrinkle_refresh_event(@events[key_id])
end
#--------------------------------------------------------------------------
# new method: generated_event
#--------------------------------------------------------------------------
def generated_event(map, event_id)
for key in map.events
event = key[1]
next if event.nil?
return event if event.id == event_id
end
return nil
end
end # Game_Map
#==============================================================================
# ■ Game_Interpreter
#==============================================================================
class Interpreter
#--------------------------------------------------------------------------
# new method: spawn_event_location
#--------------------------------------------------------------------------
def spawn_event_location(dx, dy, event_id, map_id = 0)
$game_map.spawn_event(dx, dy, event_id, map_id)
end
end # Game_Interpreter
#==============================================================================
# ■ Scene_Map
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :spriteset
end # Scene_Map
class Spriteset_Map
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Refresh Event
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def wrinkle_refresh_event(event)
# Refresh new region event
index = @character_sprites.size - 1
@character_sprites.insert(index, Sprite_Character.new(@viewport1, event))
end
end
#==============================================================================
#
# ▼ End of File
#
#==============================================================================