Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # * [ACE] Falcao's ABS + Kal's EventSpawn Patch
- #===============================================================================
- # * Made by: Sixth (www.rpgmakervxace.net, www.forums.rpgmakerweb.com)
- # * Version: 1.5
- # * Updated: 07/09/2016
- # * Requires: Falcao's Pearl ABS Liquid v3
- # Kal's EventSpawn
- #-------------------------------------------------------------------------------
- # * < Change Log >
- #-------------------------------------------------------------------------------
- # * Version 1.0 (15/01/2015)
- # - Initial release.
- # * Version 1.1 (28/07/2016)
- # - Added compatibility with my Summon System for Falcao's ABS script.
- # This is a private script, so if you are not me or the owner of the script,
- # you don't have to worry about this one!
- # * Version 1.2 (01/08/2016)
- # - Fixed events from the spawn map remaining on the current map after
- # spawning an event. The spawned event, of course, will remain on the map
- # like it should be.
- # * Version 1.3 (06/08/2016)
- # - Added compatibility with Khas' Ultra Lightning System.
- # Now you can summon events with lights.
- # * Version 1.4 (06/09/2016)
- # - Added a new option which lets you restrict the spawn location based on
- # region and terrain IDs.
- # - Fixed the co-ordinate getter method. It will no longer try to spawn
- # events outside the map's boundaries.
- # - Fixed a typo in the script. This fixed an issue with my Summon System
- # script (which is a private script, so don't worry about this one).
- # * Version 1.5 (07/09/2016)
- # - Fixed a typo from the previous update which caused a game crash. >.>
- #-------------------------------------------------------------------------------
- # * < Description >
- #-------------------------------------------------------------------------------
- # * This compatibility patch will let you summon enemy events.
- # * The summoner event itself can be an enemy now too. It will stop spawning
- # events when killed and it won't be able to spawn if it's using a tool.
- # * Added a self-switch condition for spawning. You can now make spawner events
- # which only spawn when the assigned self-switch is turned ON.
- # Extra useful for Falcao's ABS users!
- # * Added an animation display for the spawned events. It doesn't look good
- # when events just pop out of nowhere. The animation makes it much better.
- #-------------------------------------------------------------------------------
- # * < Event Comments >
- #-------------------------------------------------------------------------------
- # * To display an animation on the spawned events when they appear, you can use
- # the following comment:
- #
- # <spawn-anim ID> | Example: <spawn-anim 120>, <spawn-anim 68>
- #
- # Replace 'ID' with the ID of the animation you want to play on the spawned
- # events. This animation will be played on every single spawned event at the
- # moment they appear.
- #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # * To add a self-switch condition for the spawner event, you can use the
- # following comment:
- #
- # <spawn-sswitch ID> | Example: <spawn-sswitch B>, <spawn-sswitch D>
- #
- # Replace the 'ID' with the self-switch you want to check for.
- # This means it can be: A, B, C, or D.
- # The spawner event will only spawn when the assigned self-switch for it is
- # turned ON. If it is turned OFF, it will not spawn any events.
- # Needless to say, this is pretty much a mandatory function for Falcao's ABS,
- # since it automatically turns ON a self-switch when the player is near and it
- # automatically turns it OFF when the player is not in the event's range.
- # The self-switch operations (turning them ON or OFF) are only automated if
- # you made the spawner event an enemy and assigned the automatic sensor
- # self-switch from Falcao's ABS for the spawner!
- # If it is NOT an enemy, you must control the self-switch manually to make
- # the spawner start/finish spawning!
- #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # * To add a region or terrain position restriction for spawned events, use
- # these event comments:
- #
- # <spawn-region ID>
- # <spawn-terrain ID>
- #
- # Replace the ID with a region or terrain ID.
- #
- # Spawned events will only be spawned on those regions/terrains if you use
- # these comments!
- #
- # Note that this only works if you have set the spawn position to be random!
- # Also, it will only check for tiles within the range of the spawning
- # position! If it can't find a matching region/terrain tile, the spawned event
- # will appear on the spawner event instead!
- #-------------------------------------------------------------------------------
- # * < Important Notes >
- #-------------------------------------------------------------------------------
- # * Yeah, a whole section for them, they are that important!
- # * Do NOT try to spawn a spawner event ever!
- # Do NOT put ANY spawner events on the Spawn Map!
- # Doing any of the above will result in a lengthy freeze followed by a crash!
- # Kal forgot to mentioned this in his script, but I think it is a pretty
- # important information which should be noted somewhere.
- # * Do NOT try to spawn a real enemy (from the ABS) using the name based
- # comment! That won't work, since an enemy's event in Falcao's ABS must be
- # named <enemy: id>, and the symbols < and > will mess up the comment used
- # in Kal's script. Instead use the <spawn-id ID> to spawn the event based on
- # it's ID. The description in Kal's script is not updated, so you can't really
- # find any useful info on this feature.
- # To spawn an event using it's ID, you can use 2 kind of comments:
- # 1. <spawn-id ID> - This will spawn the event with the assigned ID from the
- # current map. Ex: <spawn-id 22>, <spawn-id 8>
- # 2. <spawn-id IDX> - This will spawn an event from the Spawn Map instead.
- # Ex: <spawn-id 14X>, <spawn-id 3X>
- # So, use these comment tags instead of the <spawn-name name> comment when you
- # want to spawn real enemies!
- #-------------------------------------------------------------------------------
- # * < Installation >
- #-------------------------------------------------------------------------------
- # * Place this script below Falcao's ABS and Kal's EventSpawner but above Main!
- #-------------------------------------------------------------------------------
- # * < Compatibility Info >
- #-------------------------------------------------------------------------------
- # * No known incompatibilities.
- #-------------------------------------------------------------------------------
- # * < Known Issues >
- #-------------------------------------------------------------------------------
- # * No known issues.
- #-------------------------------------------------------------------------------
- # * < Terms of Use >
- #-------------------------------------------------------------------------------
- # * Free to use for whatever purposes you want.
- # * Credit me (Sixth) in your game, pretty please! :P
- # * Posting modified versions of this script is allowed as long as you notice me
- # about it with a link to it!
- #===============================================================================
- $imported = {} if $imported.nil?
- $imported["SixthKalESpawnABSPatch"] = true
- #===============================================================================
- # No settings! Editing anything below may lead to... you know it, right?
- #===============================================================================
- module Kal::EventSpawn::Factory
- module_function
- class << self; alias add_new_stuffs7789 make_options_hash; end
- def make_options_hash(spawn_string)
- opts = add_new_stuffs7789(spawn_string)
- sswitch = spawn_string[/<spawn-sswitch\s+(\w+)>/i, 1]
- anim = spawn_string[/<spawn-anim\s+(\d+)>/i, 1]
- reg = spawn_string[/<spawn-region\s+(\d+)>/i, 1]
- terr = spawn_string[/<spawn-terrain\s+(\d+)>/i, 1]
- opts[:anim] = anim.to_i if anim
- opts[:sswitch] = sswitch if sswitch
- opts[:region] = reg.to_i if reg
- opts[:terrain] = terr.to_i if terr
- return opts
- end
- end
- class Kal::EventSpawn::Spawner
- attr_accessor :spawned_events, :spawn_count, :player_flag, :saved_lights
- def set_player_flag(key)
- @player_flag = key
- end
- def get_possible_coords(start_x, start_y, distance)
- coords = []
- left_most = [start_x - distance,0].max
- right_most = [start_x + distance,$game_map.width].min
- up_most = [start_y - distance,0].max
- down_most = [start_y + distance,$game_map.height].min
- (left_most..right_most).each do |x|
- (up_most..down_most).each do |y|
- next if @options[:region] && $game_map.region_id(x,y) != @options[:region]
- next if @options[:terrain] && $game_map.terrain_tag(x,y) != @options[:terrain]
- coords << [x, y] unless x == start_x && y == start_y
- end
- end
- coords
- end
- def spawn
- run_common_event
- set_spawn_pos
- if name = @options[:event_name]
- event = event_from_name(name)
- elsif id = @options[:event_id]
- event = event_from_id(id)
- end
- cloned_event = clone_event(event)
- cloned_event.life_es_kal = @options[:life]
- cloned_event.moveto(@x, @y)
- cloned_event.set_spawner_object(self) if $imported["SixthABSSummonSystem"]
- $game_map.events[cloned_event.id] = cloned_event
- spriteset = SceneManager.scene.instance_eval { @spriteset }
- spriteset.instance_eval do
- @character_sprites << Sprite_Character.new(@viewport1, cloned_event)
- end
- # Initializing the ABS enemy variables manually here!
- $game_map.events[cloned_event.id].init_manual_abs_stuffs
- if $imported["SixthABSSummonSystem"]
- @spawned_events = [] if @spawned_events.nil?
- @spawned_events << $game_map.events[cloned_event.id]
- end
- $game_map.events[cloned_event.id].animation_id = @options[:anim] if @options[:anim]
- # ABS enemy init end!
- @spawn_count += 1
- @should_spawn = false
- end
- alias abs_patch5543 update
- def update
- return if @options[:sswitch] && !$game_self_switches[[$game_map.map_id,@game_event.id,@options[:sswitch]]]
- return if @game_event.collapsing?
- if !@game_event.battler.nil?
- return unless @game_event.tool_can_use?
- end
- abs_patch5543
- end
- def load_spawn_map_events
- id = SPAWN_MAP_ID
- if id.is_a?(Numeric) && id > 0
- begin
- map = load_data(sprintf("Data/Map%03d.rvdata2", id))
- if $khas_graphics && $khas_graphics[:ultra_lighting]
- @saved_lights = {}
- map.events.each do |key,ev|
- ev.pages.each do |page|
- page.list.each do |cmd|
- next unless [108, 408].include?(cmd.code)
- comment = cmd.parameters[0]
- if comment =~ /\[light (.*)\]/i
- @saved_lights[key] = $1
- comment.sub!($1,"")
- end
- end
- end
- end
- end
- rescue Errno::ENOENT => e
- raise LoadError, "ERROR: Could not find a map with ID #{id}\n" +
- "(SPAWN_EVENT_ID = #{id})"
- end
- evs = map.events.values.map { |event| Game_Event.new(id, event) }
- if $khas_graphics && $khas_graphics[:ultra_lighting]
- evs.each do |ev|
- if @saved_lights[ev.event.id]
- ev.saved_light = @saved_lights[ev.event.id]
- end
- end
- end
- return evs
- end
- end
- def kill_lights
- @spawn_map_events.each {|ev| ev.drop_light if ev.light }
- end
- end
- class Game_Event < Game_Character
- attr_accessor :saved_light
- alias fix_spawn_maps8827 initialize
- def initialize(map_id, event)
- fix_spawn_maps8827(map_id, event)
- fix_spawn_map_issue
- end
- def fix_spawn_map_issue
- if @map_id != $game_map.map_id
- $game_map.events_withtags.delete(self) if $game_map.events_withtags.include?(self)
- $game_map.event_enemies.delete(self) if $game_map.event_enemies.include?(self)
- $game_map.enemies.delete(@enemy) if $game_map.enemies.include?(@enemy)
- if $imported["SixthABSSummonSystem"]
- $game_map.battler_data.delete(self) if $game_map.battler_data.include?(self)
- end
- if $khas_graphics && $khas_graphics[:ultra_lighting]
- drop_light if @light
- end
- end
- end
- alias fix_spawn_map8272 set_ids_es_kal
- def set_ids_es_kal(id)
- fix_spawn_map8272(id)
- @map_id = $game_map.map_id
- end
- def init_manual_abs_stuffs
- @awareness = false
- @inrangeev = nil
- @being_targeted = false
- @agroto_f = nil
- @draw_drop = false
- @dropped_items = []
- @epassive = false
- @touch_damage = 0
- @start_delay = 0
- @touch_atkdelay = 0
- @killed = false
- @knockdown_enable = false
- @deadposee = false
- @respawn_anim = 0
- create_token_arrays
- register_enemy(@event)
- @enemy.recover_all if @enemy
- end
- end
- #==============================================================================
- # !!END OF SCRIPT - OHH, NOES!!
- #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement