#==============================================================================
# ** Modules.Event Spawner (2.2) Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â By SephirothSpawn
#------------------------------------------------------------------------------
# * Description :
#
# Â This script was designed to allow you to create events via scripts. It
# Â will create events immeditately, and can save created events perm. on the
# Â map after creation, or appear once. You can also clone events, performing
# Â modifications via Event Spawner module, or immeditely end the clone
# Â event process and move the new event to a position.
#------------------------------------------------------------------------------
# * Instructions :
#
# Â THIS SCRIPT IS COMPLEX!!! I TOOK HOURS OF COMMENTING, RUNNING THROUGH
# Â ALL EVENT CODES & PARAMETERS (600+ LINES), AND MAKING THIS SCRIPT EASIER
# Â TO USE. PLEASE READ THE CREATION & EVENT COMMAND CODES & PARAMETERS
# Â BEFORE ASKING FOR SUPPORT!
#
# Â If you are ever unsure of a event layout, insert this at the top of event
# Â commands
#
# Â Call Script :
#
# Â Â for event_command in $game_map.events[event_id].list
# Â Â Â p [event_command.code, event_command.parameters, event_command.indent]
# Â Â end
#
# Â Write down the code, parameters & indention, and use the add event command
# Â function to create event commands.
#
# Â To see instructions on creating events, refer to creation instrucitons.
# Â To see event command codes & parameters, refer to event command c & p.
#------------------------------------------------------------------------------
# * Making Events Without Huge Call Scripts :
#
# Â This script has a built-in sub-module that will create events with a
# Â simple 1-line call script, rather than creating a 15 line call script.
#
# Â To create a simple event spawn, search for the Presets module, directly
# Â below the Event_Spawner module heading.
#
# Â Create a method name, which should match the event you are creating. For
# Â example; if you were creating a event on your map that will show a simple
# Â text message, you can use a name such as
#
# Â def self.sample_event_text
#
# Â Make sure to put the self. in from of your method name, or it will not
# Â read the method and you will have an error.
#
# Â Basic Syntax For Method Naming
#
# Â Â def self.<event_name>
#
# Â Feel free to use method arguments as well (If you don't understand this,
# Â do not worry about it)
#
#
# Â Once your method is defined, you can now put what you would put in your
# Â call script here in the method name.
#
# Â Finish you method by adding a end and you are finished.
#
#
# Â Example Preset Event:
#
# Â Â def self.sample_event_a
# Â Â Â Event_Spawner.create_event(3, 5, 'Sample Event A')
# Â Â Â Event_Spawner.set_page_graphic({'c_name' => '002-Fighter02'})
# Â Â Â Event_Spawner.add_event_command(101, ['I am a spawned event'])
# Â Â Â Event_Spawner.end_event
# Â Â end
#
# Â ~ Creates an event at 3, 5 named Sample Event A
# Â ~ Sets 1st Page Graphic Character Name to 002-Fighter02
# Â ~ Creates Event Command : Show Message (Code 101)
# Â ~ Ends Event
#
# Â To call your event preset, use
#
# Â Event_Spawner.Presets.<method_name>
#
# Â (This Basically Serves as nothing more than call scripts in the script
# Â Â itself, rather than the events.)
#------------------------------------------------------------------------------
# * Event Creation Instructions :
#
#
# Â **** Basic Event Creation Procedure ****
#
# Â 1) Create Event
# Â 2) Set Page Graphics & Conditions
# Â 3) Set Page Conditions
# Â 4) Add New Page (If Needed)
# Â 5) Repeat Steps 2-4 as needed
# Â 6) End Event
#
#
# Â **** Syntax Instructions *****
#
# Â Creating Event
# Â Â - Event_Spawner.create_event(x = 0, y = 0, name = '')
#
# Â Adding Event Command
# Â Â - Event_Spawner.add_event_command(code, parameters = [], indent = 0)
#
# Â Setting Page Condition
# Â Â - Event_Spawner.set_page_condition({<parameters>})
# Â Â Â 'switch1' Â Â => switch_id
# Â Â Â 'switch2' Â Â => switch_id
# Â Â Â 'selfswitch' => 'A', 'B', 'C' or 'D'
# Â Â Â 'variable' Â => [variable_id, value]
#
# Â Setting Page Graphic
# Â Â - Event_Spawner.set_page_graphic(
# Â Â Â 'tileid' Â => id
# Â Â Â 'c_name' Â => 'character_filename'
# Â Â Â 'c_hue' Â => 0..360
# Â Â Â 'dir' Â Â => 2 : Down, 4 : Left, 6 : Right, 8 : Up
# Â Â Â 'pattern' => 0..3
# Â Â Â 'opacity' => 0..255
# Â Â Â 'blend' Â => 0 : Normal, 1 : Addition, 2 : Subtraction
#
# Â Setting Page Trigger
# Â Â - Event_Spawner.set_page_trigger(trigger)
# Â Â Â 0 : Action Button, 1 : Contact With Player, 2 - Contact With Event
# Â Â Â 3 : Autorun, Â Â Â 4 : Parallel Processing
#
# Â Set Page Move Settings
# Â Â - Event_Spawner.set_page_move_settings({<parameters>})
# Â Â Â 'type' Â => 0 : fixed, 1 : random, 2 : approach, 3 : custom).
# Â Â Â 'speed' => 1 : slowest ... 6 : fastest
#    'freq'  => 1 : lowest  ... 6 : highest
# Â Â Â 'route' => RPG::MoveRoute (See Generate Move Route)
#
# Â Generate Move Route
# Â Â - Event_Spawner.generate_move_route(list = [], repeat, skippable)
# Â Â Â See Method Heading For List Parameters
#------------------------------------------------------------------------------
# * Cloning Events
#
# Â Cloning events from current map
# Â Â - Event_Spawner.clone_event(target_id, new_x, new_y, new_name,
# Â Â Â Â end_event = false, save_event = false)
#
# Â Cloning events from different map
# Â Â - Event_Spawner.clone_event(map_id, target_id, new_x, new_y, new_name,
# Â Â Â Â end_event = false, save_event = false)
#------------------------------------------------------------------------------
# * Event Command Code & Parameters
#
# Â ~~ Show Text
#   - Code    : 101 (Lines After First Line : 401)
# Â Â - Parameters : ['Text Line']
#
# Â ~~ Show Choices
#   - Code    : 102
# Â Â - Parameters : Did not comment on yet
#
# Â ~~ When [**]
#   - Code    : 402
# Â Â - Parameters : Did not comment on yet
#
# Â ~~ When Cancel
#   - Code    : 403
# Â Â - Parameters : Did not comment on yet
#
# Â ~~ Input Number
#   - Code    : 103
# Â Â - Parameters : Did not comment on yet
# Â ~~ Change Text Options
#   - Code    : 104
# Â Â - Parameters : [ <message_position>, <message_frame> ]
#
# Â Â Â <message_position> - (0 : Up, 1 : Middle, 2 : Down)
# Â Â Â <message_frame> Â Â - (0 : Visible, 1 : Invisible)
#
# Â ~~ Button Input Processing
#   - Code    : 105
# Â Â - Parameters : [ variable_id ]
#
# Â ~~ Wait
#   - Code    : 106
# Â Â - Parameters : [ frames ]
#
# Â ~~ Comment :
#   - Code    : 108 (Lines After First Line - 408)
# Â Â - Parameters : [ 'Comment Text' ]
#
# Â ~~ Conditional Branch
#   - Code    : 111
# Â Â - Parameters : Did not comment on yet
#
# Â ~~ Else
#   - Code    : 411
# Â Â - Parameters : Did not comment on yet
#
# Â ~~ Loop
#   - Code    : 112
# Â Â - Parameters : Did not comment on yet
#
# Â ~~ Repeat Above
#   - Code    : 413
# Â Â - Parameters : Did not comment on yet
#
# Â ~~ Break Loop
#   - Code    : 113
# Â Â - Parameters : Did not comment on yet
#
# Â ~~ Exit Event Processing
#   - Code    : 115
# Â Â - Parameters : []
#
# Â ~~ Erase Event
#   - Code    : 116
# Â Â - Parameters : []
#
# Â ~~ Call Common Event
#   - Code    : 117
# Â Â - Parameters : [ common_event_id ]
#
# Â ~~ Label
#   - Code    : 118
# Â Â - Parameters : [ 'label_name' ]
#
# Â ~~ Jump to Label
#   - Code    : 119
# Â Â - Parameters : [ 'label_name' ]
#
# Â ~~ Control Switches
#   - Code    : 121
# Â Â - Parameters : [ start_variable, end_variable, <boolean> ]
#
# Â Â <boolean> - (0 : On, 1 : Off)
#
# Â ~~ Control Variables
#   - Code    : 122
# Â Â - Parameters : [ start_var_id, end_var_id, <opperation>, <opperand>, <p> ]
#
# Â Â <opperation> - (0: Set, 1: +, 2: -, 3: *, 4: /, 5: %)
# Â Â <opperand> - (0: Constant, 1: Variable, 2: Random Number, 3: Item,
# Â Â Â Â Â Â Â Â Â 4: Hero, 5: Monster, 6: Sprite, 7: Other)
# Â Â <p>
# Â Â Â When <opperand> is Constant (0)
# Â Â Â Â - n
# Â Â Â When <opperand> is Variable (1)
# Â Â Â Â - variable_id
# Â Â Â When <opperand> is Random Number (2)
# Â Â Â Â - lower, higher
# Â Â Â When <opperand> is Item (3)
# Â Â Â Â - item_id
# Â Â Â When <opperand> is Hero (4)
# Â Â Â Â - hero_id, <stat> (See <stat> Below)
# Â Â Â When <opperand> is Monster (5)
# Â Â Â Â - monster_id, <stat> (See <stat> Below)
# Â Â Â When <opperand> is Sprite (6)
# Â Â Â Â - <event_id>, <tile>
#
# Â Â Â Â <event_id> - (-1: Player, 0: This Event, 1-X: Event ID)
# Â Â Â Â <tile> - (0: X Tile, 1: Y Tile, 2: Face, 3: Screen X, 4: Screen Y,
# Â Â Â Â Â Â Â Â Â 5:Terrain)
# Â Â Â When <opperand> is Other (7)
# Â Â Â Â - (0: Map ID, 1: Party Size, 2: Money, 3: # of Steps,
# Â Â Â Â Â 4: Timer in Secs, 5: # of Saves)
#
# Â Â Â Â <stat> - (0: HP, 1: SP, 2: Max HP, 3: Max SP, 4: Str,
# Â Â Â Â Â Â Â Â Â 5: Dex, 6: Agi, 7: Int, 8: Atk, 9: PDef, 10: MDef, 11: Eva)
# Â ~~ Control Self Switch
#   - Code    : 123
# Â Â - Parameters : [ 'switch_letter', <boolean> ]
#
# Â Â <boolean> - (0 : On, 1 : Off)
#
# Â ~~ Control Timer
#   - Code    : 124
# Â Â - Parameters : [ <boolean>, seconds ]
#
# Â Â <boolean> - (0 : On, 1 : Off)
#
# Â ~~ Change Gold
#   - Code    : 125
# Â Â - Parameters : [ <operation>, <type>, <operand> ]
#
# Â Â <operation> - (0 : Increase, 1 : Decrease)
# Â Â <type> - (0: Constant 1: Variable)
# Â Â <operand> - number or variable_id
#
# Â ~~ Change Items
#   - Code    : 126
# Â Â - Parameters : [ item_id, <operation>, <type>, <operand> ]
#
# Â Â <operation> - (0 : Increase, 1 : Decrease)
# Â Â <type> - (0: Constant 1: Variable)
# Â Â <operand> - number or variable_id
#
# Â ~~ Change Weapons
#   - Code    : 127
# Â Â - Parameters :[ weapon_id, <operation>, <type>, <operand> ]
#
# Â Â <operation> - (0 : Increase, 1 : Decrease)
# Â Â <type> - (0: Constant 1: Variable)
# Â Â <operand> - number or variable_id
#
# Â ~~ Change Armor
#   - Code    : 128
# Â Â - Parameters :[ armor_id, <operation>, <type>, <operand> ]
#
# Â Â <operation> - (0 : Increase, 1 : Decrease)
# Â Â <type> - (0: Constant 1: Variable)
# Â Â <operand> - number or variable_id
#
# Â ~~ Change Party Member
#   - Code    : 129
# Â Â - Parameters : [ actor_id, <operation>, <reset> ]
#
# Â Â <operation> - (0 : Add, 1 : Remove)
# Â Â <reset> - (0 : Leave As Is, 1 : Reset Actor Information)
#
# Â ~~ Change Windowskin
#   - Code    : 131
# Â Â - Parameters : [ 'windowskin_name' ]
#
# Â ~~ Change Battle BGM
#   - Code    : 132
# Â Â - Parameters : [ 'battle_bgm' ]
#
# Â ~~ Change Battle End ME
#   - Code    : 133
# Â Â - Parameters : [ 'battle_me' ]
#
# Â ~~ Change Save Access
#   - Code    : 134
# Â Â - Parameters : [ <boolean> ]
#
# Â Â <boolean> - (0 : On, 1 : Off)
#
# Â ~~ Change Menu Access
#   - Code    : 135
# Â Â - Parameters : [ <boolean> ]
#
# Â Â <boolean> - (0 : On, 1 : Off)
#
# Â ~~ Change Encounter
#   - Code    : 136
# Â Â - Parameters : [ <boolean> ]
#
# Â Â <boolean> - (0 : On, 1 : Off)
#
# Â ~~ Transfer Player
#   - Code    : 201
# Â Â - Parameters : [ <type>, <map_id>, <x>, <y>, <direction> ]
#
# Â Â <type> - (0 : Constant, 1 : Game Variable)
# Â Â <map_id> - number or variable_id
# Â Â <x> - number or variable_id
# Â Â <x> - number or variable_id
# Â Â <direction> - (2 : Down, 4 : Left, 6 : Right, 8 : Up)
#
# Â ~~ Set Event Location
#   - Code    : 202
# Â Â - Parameters : [ <target_event>, <type>, <params>, <direction> ]
#
# Â Â <target_event> - (-1 : Player, 0 : Current Event, N : Event ID)
# Â Â <type> - (0 : Constant, 1 : Variables, 2 : Switch With Event)
# Â Â <params>
# Â Â When type is Constant (0) - target_x, target_y
# Â Â When type is Variables (1) - x_variable, y_variable
# Â Â When type is Switch Event (2) - event_id
# Â Â <direction> - (2 : Down, 4 : Left, 6 : Right, 8 : Up)
#
# Â ~~ Scroll Map
#   - Code    : 203
# Â Â - Parameters : [ <direction>, distance, speed ]
#
# Â Â <direction> - (2 : Down, 4 : Left, 6 : Right, 8 : Up)
#
# Â ~~ Change Map Settings
#   - Code    : 204
# Â Â - Parameters : [ <type>, <params> ]
#
# Â Â <type> - (0 : Panorama, 1 : Fog, 2 : Battleback)
# Â Â <params>
# Â Â When type is Panorama (0) - name, hue
# Â Â When type is Fog (1) - name, hue, opacity, blend_type, zoom, sx, sy
# Â Â When type is Battleback (2) - name
#
# Â ~~ Change Fog Color Tone
#   - Code    : 205
# Â Â - Parameters : [ tone, duration ]
#
# Â ~~ Change Fog Opacity
#   - Code    : 206
# Â Â - Parameters : [ opacity, duration ]
#
# Â ~~ Show Animation
#   - Code    : 207
# Â Â - Parameters : [ <target_event>, animation_id ]
#
# Â Â <target_event> - (-1 : Player, 0 : Current Event, N : Event ID)
#
# Â ~~ Change Transparent Flag
#   - Code    : 208
# Â Â - Parameters : [ <boolean> ]
#
# Â Â <boolean> - (0 : Transparent, 1 : Non-Transparent)
#
# Â ~~ Set Move Route
#   - Code    : 209
# Â Â - Parameters : [ <target_event>, RPG::MoveRoute ]
#
# Â Â <target_event> - (-1 : Player, 0 : Current Event, N : Event ID)
#
# Â ~~ Wait for Move's Completion
#   - Code    : 210
# Â Â - Parameters : []
#
# Â ~~ Prepare for Transition
#   - Code    : 221
# Â Â - Parameters : []
#
# Â ~~ Execute Transition
#   - Code    : 222
# Â Â - Parameters : [ transition_name ]
#
# Â ~~ Change Screen Color Tone
#   - Code    : 223
# Â Â - Parameters : [ tone, duration ]
#
# Â ~~ Screen Flash
#   - Code    : 224
# Â Â - Parameters : [ color, duration ]
#
# Â ~~ Screen Shake
#   - Code    : 225
# Â Â - Parameters : [ power, speed, duration ]
#
# Â ~~ Show Picture
#   - Code    : 231
# Â Â - Parameters : [ pic_id, name orgin, <type>, <x>, <y>,
# Â Â Â Â Â Â Â Â Â Â zoom_x, zoom_y, opacity, blend_type ]
#
# Â Â <type> - (0 : Constant, 1 : Variables)
# Â Â <x> - number or variable_id
# Â Â <y> - number or variable_id
#
# Â ~~ Move Picture
#   - Code    : 232
# Â Â - Parameters : [ pic_id, name orgin, <type>, <x>, <y>,
# Â Â Â Â Â Â Â Â Â Â zoom_x, zoom_y, opacity, blend_type ]
#
# Â Â <type> - (0 : Constant, 1 : Variables)
# Â Â <x> - number or variable_id
# Â Â <y> - number or variable_id
#
# Â ~~ Rotate Picture
#   - Code    : 233
# Â Â - Parameters : [ pic_id, angel ]
#
# Â ~~ Change Picture Color Tone
#   - Code    : 234
# Â Â - Parameters : [ pic_id, tone, duration ]
#
# Â ~~ Erase Picture
#   - Code    : 235
# Â Â - Parameters : [ pic_id ]
#
# Â ~~ Set Weather Effects
#   - Code    : 236
# Â Â - Parameters : [ <type>, power, duration ]
#
# Â Â <type> - (0 : None, 1 : Rain, 2: Storm; 3: Snow)
#
# Â ~~ Play BGM
#   - Code    : 241
# Â Â - Parameters : [ RPG::AudioFile ]
#
# Â ~~ Fade Out BGM
#   - Code    : 242
# Â Â - Parameters : [ time ]
#
# Â ~~ Play BGS
#   - Code    : 245
# Â Â - Parameters : [ RPG::AudioFile ]
#
# Â ~~ Fade Out BGS
#   - Code    : 246
# Â Â - Parameters : [ time ]
#
# Â ~~ Memorize BGM/BGS
#   - Code    : 247
# Â Â - Parameters : []
#
# Â ~~ Restore BGM/BGS
#   - Code    : 248
# Â Â - Parameters : []
#
# Â ~~ Play ME
#   - Code    : 249
# Â Â - Parameters : [ RPG::AudioFile ]
#
# Â ~~ Play SE
#   - Code    : 250
# Â Â - Parameters : [ RPG::AudioFile ]
#
# Â ~~ Stop SE
#   - Code    : 251
# Â Â - Parameters : []
#
# Â ~~ Battle Processing
#   - Code    : 301
# Â Â - Parameters : [ troop_id, can_escape_boolean, can_lose_boolean ]
#
# Â ~~ If Win
#   - Code    : 601
# Â Â - Parameters : []
#
# Â ~~ If Escape
#   - Code    : 602
# Â Â - Parameters : []
#
# Â ~~ If Lose
#   - Code    : 603
# Â Â - Parameters : []
#
# Â ~~ Shop Processing
#   - Code    : 302 (For Additional Shop Item Setup - 605)
# Â Â - Parameters : [ [ <item_type>, item_id] ]
#
# Â Â <item_type> - (0 : Item, 1 : Weapon, 2 : Armor)
#
# Â ~~ Name Input Processing
#   - Code    : 303
# Â Â - Parameters : [ actor_id, max_characters ]
#
# Â ~~ Change HP
#   - Code    : 311
# Â Â - Parameters : [ <actors>, <operation>, <type>, <operand> ]
#
# Â Â <actors> - (0 : All Party Actors, N : Actor ID)
# Â Â <operation> - (0 : Increase, 1 : Decrease)
# Â Â <type> - (0: Constant 1: Variable)
# Â Â <operand> - number or variable_id
#
# Â ~~ Change SP
#   - Code    : 312
# Â Â - Parameters : [ <actors>, <operation>, <type>, <operand> ]
#
# Â Â <actors> - (0 : All Party Actors, N : Actor ID)
# Â Â <operation> - (0 : Increase, 1 : Decrease)
# Â Â <type> - (0: Constant 1: Variable)
# Â Â <operand> - number or variable_id
#
# Â ~~ Change State
#   - Code    : 313
# Â Â - Parameters : [ <actors>, <operation>, state_id ]
#
# Â Â <actors> - (0 : All Party Actors, N : Actor ID)
# Â Â <operation> - (0 : Add State, 1 : Remove State)
#
# Â ~~ Recover All
#   - Code    : 314
# Â Â - Parameters :[ <actors> ]
#
# Â Â <actors> - (0 : All Party Actors, N : Actor ID)
#
# Â ~~ Change EXP
#   - Code    : 315
# Â Â - Parameters : [ <actors>, <operation>, <type>, <operand> ]
#
# Â Â <actors> - (0 : All Party Actors, N : Actor ID)
# Â Â <operation> - (0 : Increase, 1 : Decrease)
# Â Â <type> - (0: Constant 1: Variable)
# Â Â <operand> - number or variable_id
#
# Â ~~ Change Level
#   - Code    : 316
# Â Â - Parameters : [ <actors>, <operation>, <type>, <operand> ]
#
# Â Â <actors> - (0 : All Party Actors, N : Actor ID)
# Â Â <operation> - (0 : Increase, 1 : Decrease)
# Â Â <type> - (0: Constant 1: Variable)
# Â Â <operand> - number or variable_id
#
# Â ~~ Change Parameters
#   - Code    : 317
# Â Â - Parameters : [ <actors>, <parameter>, <operation>, <type>, <operand> ]
#
# Â Â <actors> - (0 : All Party Actors, N : Actor ID)
# Â Â <parameter> - (0 : MaxHP, 1 : MaxSP, 2 : Str, 3 : Dex, 4 : Agi, 4 : Int)
# Â Â <operation> - (0 : Increase, 1 : Decrease)
# Â Â <type> - (0: Constant 1: Variable)
# Â Â <operand> - number or variable_id
#
# Â ~~ Change Skills
#   - Code    : 318
# Â Â - Parameters : [ actor_id, <operation>, skill_id ]
#
# Â Â <operation> - (0 : Learn Skill, 1 : Forget Skill)
#
# Â ~~ Change Equipment
#   - Code    : 319
# Â Â - Parameters : [ actor_id, <equip_type>, equipment_id ]
#
# Â Â <equip_type> : (0 : Weapon, 1 : Shield, 2 : Head, 3 : Body, 4 : Acc)
#
# Â ~~ Change Actor Name
#   - Code    : 320
# Â Â - Parameters : [ actor_id, 'name' ]
#
# Â ~~ Change Actor Class
#   - Code    : 321
# Â Â - Parameters : [ actor_id, class_id ]
#
# Â ~~ Change Actor Graphic
#   - Code    : 322
# Â Â - Parameters : [ actor_id, character_name, character_hue,
# Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â battler_name, battler_hue ]
#
# Â ~~ Change Enemy HP
#   - Code    : 331
# Â Â - Parameters : [ <enemies>, <operation>, <type>, <operand> ]
#
# Â Â <enemies> - (0 : All Enemies, N : Enemy Index)
# Â Â <operation> - (0 : Increase, 1 : Decrease)
# Â Â <type> - (0: Constant 1: Variable)
# Â Â <operand> - number or variable_id
#
# Â ~~ Change Enemy SP
#   - Code    : 332
# Â Â - Parameters : [ <enemies>, <operation>, <type>, <operand> ]
#
# Â Â <enemies> - (0 : All Enemies, N : Enemy Index)
# Â Â <operation> - (0 : Increase, 1 : Decrease)
# Â Â <type> - (0: Constant 1: Variable)
# Â Â <operand> - number or variable_id
#
# Â ~~ Change Enemy State
#   - Code    : 333
# Â Â - Parameters : [ <enemies>, <operation>, state_id ]
#
# Â Â <enemies> - (0 : All Enemies, N : Enemy Index)
# Â Â <operation> - (0 : Add State, 1 : Remove State)
#
# Â ~~ Enemy Recover All
#   - Code    : 334
# Â Â - Parameters : [ <enemies> ]
#
# Â Â <enemies> - (0 : All Enemies, N : Enemy Index)
#
# Â ~~ Enemy Appearance
#   - Code    : 335
# Â Â - Parameters : [ <enemies> ]
#
# Â Â <enemies> - (0 : All Enemies, N : Enemy Index)
#
# Â ~~ Enemy Transform
#   - Code    : 336
# Â Â - Parameters : [ enemy_index, target_enemy_id ]
#
# Â ~~ Show Battle Animation
#   - Code    : 337
# Â Â - Parameters : [ <target_troop>, <battlers>, animation_id ]
#
# Â Â <target_troop> - (0 : Enemies, 1 : Actors)
# Â Â <battlers> - (0 : Entire Troop, N : Index)
#
# Â ~~ Deal Damage
#   - Code    : 338
# Â Â - Parameters : [ <target_troop>, <battlers>, <type>, <operand> ]
#
# Â Â <target_troop> - (0 : Enemies, 1 : Actors)
# Â Â <battlers> - (0 : Entire Troop, N : Index)
# Â Â <type> - (0: Constant 1: Variable)
# Â Â <operand> - number or variable_id]
#
# Â ~~ Force Action
#   - Code    : 339
# Â Â - Parameters : [ <target_group>, <battlers>, <kind>, <basic>,
# Â Â Â Â Â Â Â Â Â Â <target>, <forcing> ]
#
# Â Â <target_troop> - (0 : Enemies, 1 : Actors)
# Â Â <battlers> - (0 : Entire Troop, N : Index)
# Â Â <kind> - (0 : Attack/Guard, 1: Skill)
# Â Â <basic>
# Â Â Â When Kind is 0 - (0 : Attack, 1 : Guard)
# Â Â Â When Kind is 1 - skill_id
# Â Â <target> - (-2 : Last Target, -1 : Random Target, N : Target Index)
# Â Â <forcing> - (0 : Execute Instead Of Next Move, 1 : Force Now)
#
# Â ~~ Abort Battle
#   - Code    : 340
# Â Â - Parameters : []
#
# Â ~~ Call Menu Screen
#   - Code    : 351
# Â Â - Parameters : []
#
# Â ~~ Call Save Screen
#   - Code    : 352
# Â Â - Parameters : []
#
# Â ~~ Game Over
#   - Code    : 353
# Â Â - Parameters : []
#
# Â ~~ Return to Title Screen
#   - Code    : 354
# Â Â - Parameters : []
#
# Â ~~ Script
#   - Code    : 355 (Lines After First line - 655)
# Â Â - Parameters : [ 'script text' ]
#==============================================================================
Â
MACL::Loaded << 'Modules.Event Spawner'
Â
#==============================================================================
# ** Event_Spawner
#==============================================================================
Â
module Event_Spawner
 #--------------------------------------------------------------------------
 # * Event
 #--------------------------------------------------------------------------
 def self.event
  return @event
 end
 #--------------------------------------------------------------------------
 # * Create Event
 #--------------------------------------------------------------------------
 def self.create_event(x = 0, y = 0, name = '')
  # Creates New Event
  @event = RPG::Event.new(x, y)
  @event.name = name
  # Generates ID
  @event.id = $game_map.events.empty? ? 1 : $game_map.events.keys.max + 1
 end
 #--------------------------------------------------------------------------
 # * Add Event Command (See Script Heading for Event Command Details)
 #--------------------------------------------------------------------------
 def self.add_event_command(code, parameters = [], indent = 0)
  # Creates New Event Command
  event_command = RPG::EventCommand.new
  # Sets Code, Parameters & Indent
  event_command.code = code
  event_command.parameters = parameters
  event_command.indent = indent
  # Adds Event Command To Page List
  self.get_current_page.list.insert(-2, event_command)
 end
 #--------------------------------------------------------------------------
 # * Set Page Condition
 #
 #  'switch1'   => switch_id
 #  'switch2'   => switch_id
 #  'selfswitch' => 'A', 'B', 'C' or 'D'
 #  'variable'  => [variable_id, value]
 #--------------------------------------------------------------------------
 def self.set_page_condition(parameters = {})
  # Gets Last Page Condition Settings
  page_c = self.get_current_page.condition
  # If 'switch1' Found
  if parameters.has_key?('switch1')
   # Turns Switch 1 On & Sets ID
   page_c.switch1_valid = true
   page_c.switch1_id   = parameters['switch1']
  end
  # If 'switch2' Found
  if parameters.has_key?('switch2')
   # Turns Switch 2 On & Sets ID
   page_c.switch2_valid = true
   page_c.switch2_id   = parameters['switch1']
  end
  # If 'selfswitch' Found
  if parameters.has_key?('selfswitch')
   # Turns Self Switch ON & Sets Switch Variable
   page_c.self_switch_valid = true
   page_c.self_switch_ch   = parameters['selfswitch']
  end
  # If 'variable' Found
  if parameters.has_key?('variable')
   # Turns Variable On, Sets Variable ID & Sets Value
   page_c.variable_valid = true
   page_c.variable_id   = parameters['variable'][0]
   page_c.variable_value = parameters['variable'][1]
  end
 end
 #--------------------------------------------------------------------------
 # * Set Page Graphic
 #
 #  'tileid'  => id
 #  'c_name'  => 'character_filename'
 #  'c_hue'  => 0..360
 #  'dir'   => 2 : Down, 4 : Left, 6 : Right, 8 : Up
 #  'pattern' => 0..3
 #  'opacity' => 0..255
 #  'blend'  => 0 : Normal, 1 : Addition, 2 : Subtraction
 #--------------------------------------------------------------------------
 def self.set_page_graphic(parameters = {})
  # Gets Last Page Graphic Settings
  page_g = self.get_current_page.graphic
  # Tile ID
  if parameters.has_key?('tileid')
   page_g.tile_id = parameters['tileid']
  end
  # Character Name
  if parameters.has_key?('c_name')
   page_g.character_name = parameters['c_name']
  end
  # Character Hue
  if parameters.has_key?('c_hue')
   page_g.character_hue = parameters['c_hue']
  end
  # Direction
  if parameters.has_key?('dir')
   page_g.direction = parameters['dir']
  end
  # Pattern
  if parameters.has_key?('pattern')
   page_g.pattern = parameters['pattern']
  end
  # Opacity
  if parameters.has_key?('opacity')
   page_g.opacity = parameters['opacity']
  end
  # Blend Type
  if parameters.has_key?('blend')
   page_g.blend_type = parameters['blend']
  end
 end
 #--------------------------------------------------------------------------
 # * Set Page Trigger
 #
 #  0 - Action Button
 #  1 - Contact With Player
 #  2 - Contact With Event
 #  3 - Autorun
 #  4 - Parallel Processing
 #--------------------------------------------------------------------------
 def self.set_page_trigger(trigger = 0)
  # Sets Last Page Trigger
  self.get_current_page.trigger = trigger
 end
 #--------------------------------------------------------------------------
 # * Set Page Move Settings
 #
 #  'type'  => 0 : fixed, 1 : random, 2 : approach, 3 : custom).
 #  'speed' => 1 : slowest ... 6 : fastest
 #  'freq'  => 1 : lowest  ... 6 : highest
 #  'route' => RPG::MoveRoute (See Generate Move Route)
 #--------------------------------------------------------------------------
 def self.set_page_move_settings(parameters = {})
  # Gets Last Page
  page = self.get_current_page
  # Type
  if parameters.has_key?('type')
   page.move_type = parameters['type']
  end
  # Speed
  if parameters.has_key?('speed')
   page.move_speed = parameters['speed']
  end
  # Frequency
  if parameters.has_key?('freq')
   page.move_frequency = parameters['freq']
  end
  # Route
  if parameters.has_key?('route')
   if parameters['route'].is_a?(RPG::MoveRoute)
    page.move_route = parameters['route']
   end
  end
 end
 #--------------------------------------------------------------------------
 # * Set Page Options
 #
 #  'walk_anime'   => true or false
 #  'step_anime'   => true or false
 #  'direction_fix' => true or false
 #  'through'    => true or false
 #  'always_on_top' => true or false
 #--------------------------------------------------------------------------
 def self.set_page_options(parameters = {})
  # Gets Last Page
  page = self.get_current_page
  # Walk Animation
  if parameters.has_key?('walk_anime')
   page.walk_anime = parameters['walk_anime']
  end
  # Step Animation
  if parameters.has_key?('step_anime')
   page.step_anime = parameters['step_anime']
  end
  # Direction Fix
  if parameters.has_key?('direction_fix')
   page.direction_fix = parameters['direction_fix']
  end
  # Through
  if parameters.has_key?('through')
   page.through = parameters['through']
  end
  # Always On Top
  if parameters.has_key?('always_on_top')
   page.always_on_top = parameters['always_on_top']
  end
 end
 #--------------------------------------------------------------------------
 # * Add New Page
 #--------------------------------------------------------------------------
 def self.add_page
  @event.pages << RPG::Event::Page.new
 end
 #--------------------------------------------------------------------------
 # * Generate Move Route
 #
 #  list = [ <move_command>, ... ]
 #
 #  <move_command> : [code, parameters]
 #
 #  If no parameters required :
 #
 #  <move_command> : code
 #--------------------------------------------------------------------------
 def self.generate_move_route(list = [], repeat = true, skippable = false)
  # Creates New Move Route
  move_route = RPG::MoveRoute.new
  # Sets Repeat & Skipable
  move_route.repeat   = repeat
  move_route.skippable = skippable
  # Passes Through List
  for move_command in list
   if move_command.is_a?(Array)
    code, parameters = move_command[0], move_command[1]
   else
    code, parameters = move_command, []
   end
   # Crates New MoveCommand
   move_command = RPG::MoveCommand.new
   # Adds MoveCommand to List
   move_route << move_command
   # Sets MoveCommand Properties
   move_command.parameters = parameters
   move_command.code = code
  end
  # Add Blank Move Command
  move_route << RPG::MoveCommand.new
  # Return Move Route
  return move_route
 end
 #--------------------------------------------------------------------------
 # * End Event
 #--------------------------------------------------------------------------
 def self.end_event(save_event = false)
  # Stop If nil Event Created
  return if @event.nil?
  # Fix ID
  @event.id = $game_map.events.empty? ? 1 : $game_map.events.keys.max + 1
  # Add Event to Map & Spriteset Data
  $game_map.add_event(@event)
  # If Save Event Data
  if save_event
   # Creates Map Event Data (If none Present)
   unless @saved_events.has_key?((map_id = $game_map.map_id))
    @saved_events[map_id] = []
   end
   # Saves Event Data
   @saved_events[map_id] << @event.id
  end
  # Clear Event Data
  @event = nil
 end
 #--------------------------------------------------------------------------
 # * Clone Event
 #--------------------------------------------------------------------------
 def self.clone_event(target_id, new_x, new_y, new_name,
   end_event = false, save_event = false)
  # Stops If Event Not Found
  return unless $game_map.events.has_key?(target_id)
  # Gets Event Data
  @event = $game_map.events[target_id].event
  # Changes X, Y & name
  @event.x   = new_x
  @event.y   = new_y
  @event.name = new_name
  # Generates New ID
  @event.id = $game_map.events.empty? ? 1 : $game_map.events.keys.max + 1
  # If End Event
  if end_event
   # Ends Event Creation
   self.end_event(save_event)
  end
 end
 #--------------------------------------------------------------------------
 # * Clone Event (From different map)
 #--------------------------------------------------------------------------
 def self.clone_event2(map_id, target_id, new_x, new_y, new_name,
   end_event = false, save_event = false)
  # Loads map events
  events = load_data(sprintf("Data/Map%03d.rxdata", map_id)).events
  # Add saved events
  saved_events = self.saved_events(map_id)
  saved_events.each {|event_id, event| events[event_id] = event}
  # Return if events list doesn't contain target_id
  return unless events.has_key?(target_id)
  # Gets event
  @event = events[target_id]
  # Changes X, Y & name
  @event.x   = new_x
  @event.y   = new_y
  @event.name = new_name
  # Generates New ID
  @event.id = $game_map.events.empty? ? 1 : $game_map.events.keys.max + 1
  # If End Event
  if end_event
   # Ends Event Creation
   self.end_event(save_event)
  end
 end
 #--------------------------------------------------------------------------
 # * Saved Events { map_id => { event_id => name }, ... }
 #--------------------------------------------------------------------------
 @saved_events = {}
 #--------------------------------------------------------------------------
 # * Saved Events (Read)
 #--------------------------------------------------------------------------
 def self.saved_events(map_id = nil)
  # If Map ID not Defined
  if map_id.nil?
   # Return All Saved Event Data
   return @saved_events
  end
  # If Map Data Saved
  if @saved_events.has_key?(map_id)
   # Return Map Saved Event Data
   return @saved_events[map_id]
  end
  # Return Blank Array
  return []
 end
 #--------------------------------------------------------------------------
 # * Saved Events (Write)
 #--------------------------------------------------------------------------
 def self.saved_events=(saved_events)
  @saved_events = saved_events
 end
 #--------------------------------------------------------------------------
 # * Current Page
 #--------------------------------------------------------------------------
 def self.get_current_page
  return @event.pages.last
 end
end
Â
#==============================================================================
# ** Game_Map
#==============================================================================
Â
class Game_Map
 #--------------------------------------------------------------------------
 # * Alias Listings
 #--------------------------------------------------------------------------
 alias_method :seph_eventspawner_gmap_init,  :initialize
 alias_method :seph_eventspawner_gmap_setup, :setup
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize
  # Original Initialization
  seph_eventspawner_gmap_init
  # Create Saved Events
  @saved_events = {}
 end
 #--------------------------------------------------------------------------
 # * Setup
 #--------------------------------------------------------------------------
 def setup(map_id)
  # Gets Saved Events
  saved_events = Event_Spawner.saved_events(@map_id)
  # If Not Empty
  unless saved_events.empty?
   # Create List (If none exist)
   @saved_events[@map_id] = {} unless @saved_events.has_key?(@map_id)
   # Saves spawned events
   saved_events.each do |event_id|
    @saved_events[@map_id][event_id] = @events[event_id]
   end
  end
  # Original Map Setup
  seph_eventspawner_gmap_setup(map_id)
  # If Map Has Saved Events
  if @saved_events.has_key?(@map_id)
   # Add saved events to events list
   @saved_events[@map_id].each do |event_id, event|
    @events[event_id] = event
   end
  end
 end
end
Â
#==============================================================================
# ** Scene_Save
#==============================================================================
Â
class Scene_Save
 #--------------------------------------------------------------------------
 # * Alias Listings
 #--------------------------------------------------------------------------
 alias_method :seph_eventspawner_scnsave_wsd, :write_save_data
 #--------------------------------------------------------------------------
 # * Write Save Data
 #--------------------------------------------------------------------------
 def write_save_data(file)
  # Original Write Data
  seph_eventspawner_scnsave_wsd(file)
  # Saves Saved Event Data
  Marshal.dump(Event_Spawner.saved_events, file)
 end
end
Â
#==============================================================================
# ** Scene_Load
#==============================================================================
Â
class Scene_Load
 #--------------------------------------------------------------------------
 # * Alias Listings
 #--------------------------------------------------------------------------
 alias_method :seph_eventspawner_scnload_rsd, :read_save_data
 #--------------------------------------------------------------------------
 # * Read Save Data
 #--------------------------------------------------------------------------
 def read_save_data(file)
  # Original Write Data
  seph_eventspawner_scnload_rsd(file)
  # Load Saved Event Data
  Event_Spawner.saved_events = Marshal.load(file)
 end
end