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.

Event issues with graphic-Support 7

Hey all,

I'm trying to use an event that uses Support 7, unfortunately the top part has a priority setting. This is bad because the rune thing is supposed to be a teleporter set on the floor. How do I remove the priority from the graphic? Or is there another way to make sure my main character has a higher priority? As it is right now, it looks like the graphic is over the character when he steps onto the top part of it.

My explanation is a little confusing, here's a screenshot to show what I mean.

http://img515.imageshack.us/img515/1910 ... rorlw1.png[/IMG]
 
Ok. Here we are:

Code:
class Game_Map
  Player_On_Top_Regions = {}
  Player_On_Top_Regions.default = []
  attr_writer :player_on_top_regions
  alias_method :seph_playerontopregions_gmmap_setup, :setup
  def setup(map_id)
    seph_playerontopregions_gmmap_setup(map_id)
    @player_on_top_regions = Player_On_Top_Regions[map_id]
  end
  def player_on_top_regions
    regions = []
    @events.values.each do |event|
      event.player_on_top_regions.each {|r| regions << r}
    end
    regions.delete([])
    return regions
  end
end

class Game_Event
  attr_accessor :player_on_top_regions
  alias_method :seph_playerontopregions_gmevt_refresh, :refresh
  def refresh
    seph_playerontopregions_gmevt_refresh
    @player_on_top_regions = []
    return if @erased || @list.nil?
    for event_command in @list
      next unless [108, 408].include?(event_command.code)
      next unless event_command.parameters[0].upcase.include?('PLAYER ON TOP REGION')
      event_command.parameters[0].dup.gsub!(/\((.+?)\)/) do
        @player_on_top_regions << (eval "[#{$1}]")
      end
    end
  end
end

class Game_Player
  alias_method :seph_playerontopregions_gmplyr_update, :update
  def update
    seph_playerontopregions_gmplyr_update
    if @x != @last_playerontopregionsearch_x || 
       @y != @last_playerontopregionsearch_y
      @last_playerontopregionsearch_x = @x
      @last_playerontopregionsearch_y = @y
      update_player_on_top_regions
    end
  end
  def update_player_on_top_regions
    for region in $game_map.player_on_top_regions
      if VR.in_rect_range?(@x, @y, *region)
        unless @seph_playerontopregion_refresh
          @seph_playerontopregion_refresh = true
          @seph_playerontopregion_restore = @always_on_top
          @always_on_top = true
        end
        return
      end
    end
    if @seph_playerontopregion_refresh
      @always_on_top = @seph_playerontopregion_restore
      @seph_playerontopregion_refresh = false
    end
  end
end

Its in a bit of a crude format now, but it works.

It requires the MACL 2.1+ or this script.


To make it work, either customize your Player_On_Top_Regions for each map with your regions the player is on top. For instance:
Code:
# Game Map 1
Player_On_Top_Regions[1] = []
# Region from 5, 7 to 8, 9
Player_On_Top_Regions[1] << [5, 7, 3, 2]

Likewise, you can use event comments.
Code:
Comment: PLAYER ON TOP REGION (x, y, w, h)


I plan to make this a little faster, by caching the default game map constant setup, so I suggest setting up the constant as opposed to using comments.
 

poccil

Sponsor

Here is a better solution; it involves editing the screen_z function of the Game_Character 1 script section.

Code:
  def screen_z(height = 0)
    # If display flag on closest surface is ON
    if @always_on_top
      # 999, unconditional
      return 999
    end
    # Get screen coordinates from real coordinates and map display position
    z = (@real_y - $game_map.display_y + 3) / 4 + 32
    # If tile
    if @tile_id > 0
      # Add tile priority * 32
      return z + $game_map.priorities[@tile_id] * 32
    # If character
    else
[b]      # Subtract Z if height exceeds 32
      zsubtract=(((height+1)/32)*32)-1
      return z - [0,zsubtract].max[/b]
    end
  end
 
Or you could just set all the four boxes around the event for when the player touches, make the player on top of all (under "set mouve route", and then outside of that, make the player "on top of all"=off.
Thats a bit easier isn't it...?
 

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