Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[XP] Haki's Event Spawn Script

Haki

Member

Event Spawn ver. 1.2
by Haki

Introduction:

This script is used to force a number of events come out of a specific place. Only one event needs to be created and you can use this script to multiply it as many times as you want (okay, that's not true because RMXP has it's limit, but I guess you won't need so many events).


Script:

Please follow the instructions inside the script. If there's anything you don't get please download the demo.

Code:
#==============================================================
# Haki's Event Spawn Script ver. 1.2
#==============================================================
#
# How to use:
# -Create an event which will be your spawn point. First page of the event should be
#  the template for events to spawn. When you're done, create an empty page. The
#  third page is your spawn point's page. The fourth page should be empty. The first 
#  line in the third page should look like
#  this:
#
# Comment: spawn
#
# -Second line is used for number of events to spawn, and the third one indicates
#  the number of frames that need to pass in order for another event to appear. When
#
#  So, if you want ten events to appear with twenty frames interval, the event
#  would look like this:
#
#  Comment: spawn
#  Comment: 10
#  Comment: 20
#
# Compatibility
# -The script hasn't been tested with any other scripts.
#
# Bug report:
# -If you find any bugs, e-mail me at ivica.hakstok@du.t-com.hr
#
#==============================================================

class Game_Event < Game_Character
  attr_accessor :event
  attr_accessor :list
  attr_accessor :spawn
  attr_accessor :maxno
  attr_accessor :sp_rate
  attr_accessor :real_sp_rate


  alias haki_event_update update
  def page
    return @page
  end
  
  def update
    if self.spawn == true
      if self.sp_rate == 0
        if self.maxno > 0
          new_ev = self.event.dup
          new_ev.id = $game_map.events.size + 1
          $game_map.events[$game_map.events.size + 1] = Game_Event.new($game_map.map_id, new_ev)
          $game_map.events[$game_map.events.size].event.pages[2] = $game_map.events[$game_map.events.size].event.pages[0]
          key = [$game_map.map_id, new_ev.id + 1, new_ev.pages[2].condition.self_switch_ch]
          $game_self_switches[key] = true
          self.sp_rate = self.real_sp_rate
          $scene = Scene_Map.new
          self.maxno -=1
        end
      else
        self.sp_rate -=1
      end
    end
    haki_event_update
  end

end

class Game_Map
  alias haki_map_update update
  
  def update
    for ev in 1..$game_map.events.size
      if $game_map.events[ev].list != nil
        if $game_map.events[ev].list[0].parameters[0].to_s == "spawn"
          $game_map.events[ev].spawn = true
          $game_map.events[ev].maxno = $game_map.events[ev].list[1].parameters[0].to_i
          $game_map.events[ev].sp_rate = $game_map.events[ev].list[2].parameters[0].to_i
          $game_map.events[ev].real_sp_rate = $game_map.events[ev].list[2].parameters[0].to_i
          $game_map.events[ev].list[0].parameters[0] = ""
        end
      end
    end
    haki_map_update
  end
end

Download:
http://www.megaupload.com/?d=JUCVVQ9B


Other Notes:
If you use this script credit me(Haki). The script hasn't been tested with any other scripts so if you find any compatibility issues post them in this topic or e-mail me at ivica.hakstok@du.t-com.hr
 

y 65

Member

Could be fault on my part but when Bugs come out of the tree i gave them a battle event
I kill them i never made a After their dead event tho but once you kill them they stop moving but graphic still their :P
 
I had this problem with my Auto Populate Map script. I solved by creating a brand new RPG::Event (not Game_Event), with a new unused id, for each Game_Event i create.
 

Haki

Member

I fixed the problem. You can now use self switches to make events disappear. I uploaded the new demo and script.
 
Is there a way of erasing an event, because when ever I attempt to do so I get the following messege, and the program crashes:


Script 'Haki Event Spawn Script' line 68: NoMethodError occured.

undefined method `[]' for nil:NilClass
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top