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.

Game_Event Edits

ok so im working on modifying my Chest data script to run off comments in events instead of my old format. i have the data processing part down. but i have no idea how to make it so when the player talks to an event the chest window will open. so to clarify im asking some one to show me what i have to do to make it so when a event is selected that has my comment in it i can open a window, i think from there i can figure everything else out.

here is what i have done in my script in case you need it for what ever reason, i didn't include my window because im still rewriting it to work better.
[rgss]#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
#  This class deals with events. It handles functions including event page
#  switching via condition determinants, and running parallel process events.
#  It's used within the Game_Map class.
#==============================================================================
 
class Game_Event
  alias_method :game_event_initialize,                            :initialize
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor  :chestdata         # chestdata
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     map_id : map ID
  #     event  : event (RPG::Event)
  #--------------------------------------------------------------------------
  def initialize(map_id, event)
    game_event_initialize(map_id, event)
    @items,@weaps,@armor = check_comments
    @chestdata = []
    @chest_counter = 0
    @has_items = false
    if @chestdata.size > 0
      @has_items = true
    end  
  end
  #--------------------------------------------------------------------------
  # * Determine if event has items
  #--------------------------------------------------------------------------
  def has_items?
    return @has_items
  end  
  #--------------------------------------------------------------------------
  # * Combine chest data for display
  #--------------------------------------------------------------------------
  def all_data
    # Erase old combined chest data because data may have been edited since
    # last data creation.
    @has_items = false
    @chest_counter = 0
    for i in 0...chestdata.size
      @chestdata.delete(i)
    end  
    # Make new combinied chest data
    for i in 0...@items.size
      @chestdata[@chest_counter] = @items.to_i
      @chest_counter += 1
    end  
    for i in 0...@weaps.size
      @chestdata[@chest_counter] = @items.to_i
      @chest_counter += 1
    end  
    for i in 0...@armor.size
      @chestdata[@chest_counter] = @items.to_i
      @chest_counter += 1
    end
    # Set has_items to true if there are any items
    if @chestdata.size > 0
      @has_items = true
    end
  end  
  #--------------------------------------------------------------------------
  # * Check for chest comments
  #--------------------------------------------------------------------------
  def check_comments
    @items = []
    @weaps = []
    @armor = []
    @cut = 2
    @count = 0
    for ec in @list
      # Skip if not comment or not comment next line
      next unless [108, 408].include?(ec.code)
      # Read Event Comment & Turn Downcase
      comment = ec.parameters[0].downcase
      # If Comment Include Parameters
      if comment.include?('item|')
        # Remove starting info
        @data = comment.split("|")
        # Grab Items data
        @data = @data[1].split("[")[1].split("]")[0]
        # Loop through each item. good to know it counts how many loop based on
        # the number of commas. was a pain for me get the right number to loop
        # untill i remembered the count method.
        for i in 0...(@data.count(","))+1
          @items = @data.split(",")[0]
          @data = @data.slice!(@cut...@data.length)
          @count += 1
          # account for double digits.
          if @count == 9
            @cut = 3
          end  
        end  
      end
      # end items start weapons, reset @cut and @count
      @cut = 2
      @count = 0
      if comment.include?('wep|')
        # Remove starting info
        @data = comment.split("|")
        # Grab Weapons data
        @data = @data[1].split("[")[1].split("]")[0]
        # Loop through each weapon. good to know it counts how many loop based
        # on the number of commas. was a pain for me get the right number to
        # loop untill i remembered the count method.
        for i in 0...(@data.count(","))+1
          @weaps = @data.split(",")[0]
          @data = @data.slice!(@cut...@data.length)
          @count += 1
          # account for double digits.
          if @count == 9
            @cut = 3
          end  
        end  
      end
      # end weapons start armor, reset @cut and @count
      @cut = 2
      @count = 0
      if comment.include?('armor|')
        # Remove starting info
        @data = comment.split("|")
        # Grab Armor data
        @data = @data[1].split("[")[1].split("]")[0]
        # Loop through each armor. good to know it counts how many loop based
        # on the number of commas. was a pain for me get the right number to
        # loop untill i remembered the count method.
        for i in 0...(@data.count(","))+1
          @armor = @data.split(",")[0]
          @data = @data.slice!(@cut...@data.length)
          @count += 1
          # account for double digits.
          if @count == 9
            @cut = 3
          end  
        end  
      end
    end
    return @items,@weaps,@armor
  end
end
 
[/rgss]
 
I'd go about initializing a window within Scene_Map, starting non-active, non-visible. Then, add a definition to your update method that activates it when a certain something is triggered... I'd personally set a $game_temp variable to the chest's contents, and display/activate your window if the variable isn't empty (along with taking the same measures to avoid movement, yada yada, just like the message window does). That variable can be set in the "interact with events"-method (that I know exists, however don't remember what it's called) that should be within Interpreter class, therefore allowing you pretty easy access to comments (which I remember to be read much more simply than what you did there... but I'd have to take a look).
Vacate the window with the $game_temp's variable's contents, and empty it. Finally, when you press B (or whatever your conditions for exiting out of the thing might be), the window goes back to non-visible, non-active to be triggered next time around.

You can see that this doesn't require any additional methods (at least not in a open_chest_window(chest_contents) fashion), meaning updates will be very natural to create without having to mess with too many additional clutter.
 
this method?
[rgss] #--------------------------------------------------------------------------
  # * Starting Event Setup
  #--------------------------------------------------------------------------
  def setup_starting_event
    # Refresh map if necessary
    if $game_map.need_refresh
      $game_map.refresh
    end
    # If common event call is reserved
    if $game_temp.common_event_id > 0
      # Set up event
      setup($data_common_events[$game_temp.common_event_id].list, 0)
      # Release reservation
      $game_temp.common_event_id = 0
      return
    end
    # Loop (map events)
    for event in $game_map.events.values
      # If running event is found
      if event.starting
        # If not auto run
        if event.trigger < 3
          # Clear starting flag
          event.clear_starting
          # Lock
          event.lock
        end
        # Set up event
        setup(event.list, event.id)
        return
      end
    end
    # Loop (common events)
    for common_event in $data_common_events.compact
      # If trigger is auto run, and condition switch is ON
      if common_event.trigger == 1 and
         $game_switches[common_event.switch_id] == true
        # Set up event
        setup(common_event.list, 0)
        return
      end
    end
  end
[/rgss]
 
No, I don't think that's what I'm talking about... but then again it's been far too long that I've worked with it...

I see event.starting in there though... might wanna give that a try.
 

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