• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Question] [SOLVED] How to put more priority/ '.z' to the player?

WolfPP

Spriter/ Pixel Artist
  • 1,309
    Posts
    6
    Years
    I would like to know how to put the player to have more priority than Dependents and other Events when the player AND the event (Dependent or not) are facing down (direction==2):
    [PokeCommunity.com] [SOLVED] How to put more priority/ '.z' to the player?


    Thank you!
     
    Last edited:
    The z-index is determined by sprite height, which is what you're seeing with the following Pokémon. This can be found in Game_Character.

    Look for the line return z + ((height>32) ? 31 : 0) and add this above it:

    Code:
    if self == $game_player
      return z + 32
    end

    This will ensure the player always appears in front of larger sprites at the same MapY, no matter the size.

    Edit: You can add && self.direction == 2 to the if rule, if you did want to make it directional, but it looks best always in front.
     
    I just need to double check from HGSS about the priority but it is done.
    Code:
      def screen_z(height = 0)
        return 999 if @always_on_top
        z = (@real_y - self.map.display_y + 3) / 4 + 32
        if @tile_id>0
          return z + self.map.priorities[@tile_id] * 32
        end
        if self==$game_player
          return z + 32 if @direction==2
        end
        # Add z if height exceeds 32
        return z + ((height>32) ? 31 : 0)
      end

    [PokeCommunity.com] [SOLVED] How to put more priority/ '.z' to the player?


    [PokeCommunity.com] [SOLVED] How to put more priority/ '.z' to the player?


    Thanks!
     
    Back
    Top