Main Menu
  • Welcome to The RPG Maker Resource Kit.

[RMVX Request]Script Modification (worale's call event script)

Started by Solar Eclipse, March 26, 2011, 11:18:20 PM

0 Members and 1 Guest are viewing this topic.

Solar Eclipse

Hey! I really like this script and it is extremely useful! In my project, I wanted to have common events be able to affect Guard events in any map. Unfortunately, the only way for me to do that is to make sure that my guards are always a certain event i.d., and that is a real pain, plus it makes it hard to make a map look nice and work right when you have to make guards at an exact certain point in mapping. (that was a long sentence) Anyway, I was thinking that it would be possible for a script to call an event based on its name.

It should be possible, because I have seen many scripts that make events do certain things based on their names, and hopefully it wouldn't take too much of the scripter's time. Here is the script, and anything else whoever helps me needs will be available on demand.

http://rmrk.net/index.php/topic,26623.0.html

Thanks in advance!

Solar Eclipse


Solar Eclipse


Kyo Panda

Still needing it? (7 days off)

Paste this script above Main and below Woratana's script:



#==============================================================================
# Game_Map
#------------------------------------------------------------------------------
# This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # Public instance variables
  #--------------------------------------------------------------------------
  attr_reader :map
end
 
#==============================================================================
# Game_Interpreter
#------------------------------------------------------------------------------
# An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # Method alias of call event
  #--------------------------------------------------------------------------
  alias cebn_callev callev
  #--------------------------------------------------------------------------
  # Call event
  #     event_attr : Attribute of the called event
  #     page       : Event page to be called
  #     map_id     : Map ID where the event is
  #--------------------------------------------------------------------------
  def callev(event_attr, page, map_id = $game_map.map_id)
    if event_attr.is_a?(Integer)
      cebn_callev(event_attr, page, map_id = $game_map.map_id)
    else
      return if event_attr.nil?
      return if event_attr.empty?
      if map_id != $game_map.map_id
        map = load_data(sprintf("Data/Map%03d.rvdata", map_id))
      else
        map = $game_map.map
      end
      for i in map.events.values
        next if i.name != event_attr
        event_id = i.id
      end
      return if event_id.nil?
      if page == 0
        event = map.events[event_id].pages[0]
      else
        event = map.events[event_id].pages[page - 1]
      end
      @child_interpreter = Game_Interpreter.new(@depth + 1)
      @child_interpreter.setup(event.list, @event_id)
    end
  end
end


Change the Event ID for the Event Name in call method:

callev("Event Name", page, map_id)

or

callev("Event Name", page)

For the actual map.

The Call Event by ID function of the original script still working.

Sorry for the bad English...

See you.
I'm Brazilian, so don't bother me about my English