The RPG Maker Resource Kit

RMRK RPG Maker Creation => XP => Topic started by: JackHGardner on June 18, 2011, 09:50:45 PM

Title: [RMXP] Events: Move through other events/player but NOT tiles?
Post by: JackHGardner on June 18, 2011, 09:50:45 PM
Hello there. I'm using XP to create a puzzle game and am having an issue with events.

I have events that move around the map. The player (and other events) should be able to pass through these and vise-versa. Simple right? Check the "Through" event option. PROBLEM! Now the event passes through tiles as well, ignoring the layout of the map. I don't want this... is there a way around this? To get that "through" without the event ignoring tile passability?

Thanks!
Title: Re: Events: Move through other events/player but NOT tiles?
Post by: pacdiggity on June 19, 2011, 12:49:43 AM
Uncheck through and make the priority of the event 'below character'. The character should now be able to walk over them, and they won't be able to walk through unpassable tiles.
Title: Re: Events: Move through other events/player but NOT tiles?
Post by: JackHGardner on June 19, 2011, 02:38:55 AM
There is no option for that, like in 2003. The only options are :

-Move Animation
-Stop Animation
-Direction Fix
-Through
-Always on Top (this doesn't work, only ensures the event will display above any tile)

I think the only solution is a small tweak to the script, but I don't know what to do.
Title: Re: Events: Move through other events/player but NOT tiles?
Post by: ForeverZero on June 19, 2011, 05:02:22 AM
This should work. Just configure the switch. When it is ON, character sprites will not collide with each other, and you don't need to worry about "through" or anything.

class Game_Character
 
 
  PASSABLE_SWITCH_ID = 20
  # Characters will not collide with each other as long as the game switch with
  # this ID is ON.

  alias zer0_make_character_passable passable?
  def passable?(x, y, d)
    if $game_switches[PASSABLE_SWITCH_ID]
      # Get new coordinates
      new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
      new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
      # If coordinates are outside of map
      return false unless $game_map.valid?(new_x, new_y)
      # If through is ON
      return true if @through
      # If unable to leave first move tile in designated direction
      return false unless $game_map.passable?(x, y, d, self)
      # If unable to enter move tile in designated direction
      return false unless $game_map.passable?(new_x, new_y, 10 - d)
      # passable
      return true
    else
      return zer0_make_character_passable(x, y, d)
    end
  end
end

Title: Re: Events: Move through other events/player but NOT tiles?
Post by: JackHGardner on June 20, 2011, 04:36:09 AM
Hey, I popped that in the Game_Character class and it does the trick.

Thanks a lot for doing that. Much appreciated!  :lol:

The only problem is I still want to have solid events at the same time.
Is it possible to use this code in place of the normal "through" code option instead of relying on a switch?

I suppose the best solution for me would be to make it so events pass one another (but not tiles) if BOTH of them are set to [Through]...
Example: If event moving to x/y "through" = true AND the event already at x/y "through" = true THEN passibility RETURN true.

I tried another thing. I set the event I wanted to be solid to a tile (with no passability) instead of a character and that worked. The only
issue then was while events couldn't pass it, it could pass through other events still.