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.

different passability for events and player

hello,

is it possible to create a script which will make some events unpassable for the player but passable for some events (that do not have 'through' checked)?  I'd like to make water that arrows can fly over, while the hero can't.

thanks in advance!
 
The arrows need to be able to hit walls and houses and things.  i have a common event that will make the arrow disappear if it stops for a moment, so if it hits a house (or whatever) it will disappear.

i had this system working perfectly in rm2k because you could have events that the player could not pass, but events on the 'above hero' setting could pass.  i used the passability of the map to create walls the would stop both the hero and arrow, while i used invisible wall events to create places (like the edge of water) that i wanted the arrow to pass without the hero being able to.

if i could set the arrows on 'through' and then have some tiles that they could not pass even though they are on through, that would work just fine too.
 
Well, I'm not sure if this is what you asked for... but at least I tried, eh?

Code:
#==============================================================================
# ** Game_Character 
#------------------------------------------------------------------------------
#  This class deals with characters. It's used as a superclass for the
#  Game_Player and Game_Event classes.
#==============================================================================
class Game_Character
  
  # Terrain that events can walk on, but not player
  TERRAIN = 4
  
  # Alias method
  alias :broken_through_gamecharacter_passable? :passable?
  
  #--------------------------------------------------------------------------
  # * Determine if Passable
  #     x : x-coordinate
  #     y : y-coordinate
  #     d : direction (0,2,4,6,8)
  #         * 0 = Determines if all directions are impassable (for jumping)
  #--------------------------------------------------------------------------
  def passable?(x, y, d)
    # Get new coordinates
    new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
    # If next tile's terrain tag equals set terrain and character is not the player
    if $game_map.terrain_tag(new_x, new_y) == TERRAIN and self != $game_player
      return true
    end
    # If current tile's terrain tag equals set terrain and character is not the player
    if $game_map.terrain_tag(x, y) == TERRAIN and self != $game_player
      return true
    end
    # Calls the original passable? method
    broken_through_gamecharacter_passable?(x, y, d)
  end
end

Basically, what is does is checks to see what the next tile's terrain tag is and if the person trying to move their is not the player. If they're not the player and the terrain matches, then the event will move.

To use it, just put it in a script somewhere above main.
 
Dunno if that script would work, but I did something similar one time, where I set the terrain tag of buildings and things to a certain number, and then in the map checked if the projectile's terrain id matched that one, and if it did it disappeared. Of course, if that script is easier than go for it. :thumb:
 

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