Event Collision Script

Hello! Good morning / Afternoon / Evening

I'm looking for a script that gives to an event the property of going through every tile, ignoring any collision except the player, so the event itself moves going through all but when the player collides with it, the event is triggered

I hope i explained well enough, thanks for reading.
bump
I coded this, if you do a script call:
$game_map.events[x].collide_with_player = true
With x the id of your event, then both the event and the player won't be able to cross each others, regardless of the event's passability rules.

Ruby:
#==============================================================================
# Ghost Event
#------------------------------------------------------------------------------
# Author: Timtrack (no need for credit)
# date: 21/03/2025
#==============================================================================
# Allows some events to cross everything except the player
# To do so, give an event the through everything attribute and
# set collide_with_player to true.
# script call in events:
# $game_map.events[i].collide_with_player = true
# You may remove the property by setting it to false
#
# Both the event and the player won't be able to cross each others
#==============================================================================
class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # override method: passable?
  #--------------------------------------------------------------------------
  def passable?(x, y, d)
    x2 = $game_map.round_x_with_direction(x, d)
    y2 = $game_map.round_y_with_direction(y, d)
    return false if !(@through || debug_through?) && $game_map.events.values.any? {|event| event.pos?(x2,y2) && event.collide_with_player}
    super(x,y,d)
  end
end


class Game_Event < Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor   :collide_with_player
  #--------------------------------------------------------------------------
  # override method: passable?
  #--------------------------------------------------------------------------
  def passable?(x, y, d)
    x2 = $game_map.round_x_with_direction(x, d)
    y2 = $game_map.round_y_with_direction(y, d)
    return false if (collide_with_player && $game_player.pos?(x2,y2))
    super(x,y,d)
  end
end
Hey bro, it works perfectly! Anyways, i would ask you if its possible to make it like a note tag for the event instead of a script call that would help me a lot

But thanks for the help!
You will have to be more precise, by notetag, do you mean an event comment? What behavior do you want:
-do you want the property to be linked to the event's page? That way when you change page then the event may or may not collide?
-do you want it to be linked to the event and this property will never change?
You will have to be more precise, by notetag, do you mean an event comment? What behavior do you want:
-do you want the property to be linked to the event's page? That way when you change page then the event may or may not collide?
-do you want it to be linked to the event and this property will never change?
Oh, sorry for that.

well i think it would better something to be linked to the event´s page to be able to change the collision.
Here is an updated version of the script, you cannot edit with script calls collide_with_player.
You just need to link to your event pages <collide_with_player> if you want it to collide with the player even when in through all mode.

If your event changes page, then the property is updated based on whether there is this comment.

Ruby:
#==============================================================================
# Ghost Event v2
#------------------------------------------------------------------------------
# Author: Timtrack
# date: 24/03/2025
#==============================================================================
# Allows some events to cross everything except the player
# To do so, put in the comment of the active event's page:
# <collide_with_player>
#
# Both the event and the player won't be able to cross each others
#==============================================================================
module GHOST_EVENT
  ACTIVE = "<collide_with_player>"
end #GHOST_EVENT

#==========================================================================
# Game_Map
#==========================================================================
class Game_Map
  #--------------------------------------------------------------------------
  # alias method: setup
  #--------------------------------------------------------------------------
  alias tge_gm_setup setup
  def setup(map_id)
    tge_gm_setup(map_id)
    @events.each_value {|event|  event.read_collide}
  end
end #Game_Map

#==========================================================================
# Game_Event
#==========================================================================
class Game_Event < Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :collide_with_player
  #--------------------------------------------------------------------------
  # override method: passable?
  #--------------------------------------------------------------------------
  def passable?(x, y, d)
    x2 = $game_map.round_x_with_direction(x, d)
    y2 = $game_map.round_y_with_direction(y, d)
    return false if (@collide_with_player && $game_player.pos?(x2,y2))
    super(x,y,d)
  end
  #--------------------------------------------------------------------------
  # alias method: refresh
  #--------------------------------------------------------------------------
  alias tge_ge_refresh refresh
  def refresh
    tge_ge_refresh
    read_collide
  end
  #--------------------------------------------------------------------------
  # new method: read_collide
  #--------------------------------------------------------------------------
  def read_collide
    @collide_with_player = @list.any? {|command| command.code == 108 and command.parameters[0].include?(GHOST_EVENT::ACTIVE)} if @list
  end
end #Game_Event


#==========================================================================
# Game_Player
#==========================================================================
class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # override method: passable?
  #--------------------------------------------------------------------------
  def passable?(x, y, d)
    x2 = $game_map.round_x_with_direction(x, d)
    y2 = $game_map.round_y_with_direction(y, d)
    return false if !(@through || debug_through?) && $game_map.events.values.any? {|event| event.pos?(x2,y2) && event.collide_with_player}
    super(x,y,d)
  end
end #Game_Player
It works perfect!! Thank you a lot man, you are a man saver or something like that, i don't speak english xD. But thank you again!

Original thread: https://forums.rpgmakerweb.com/threads/event-collision-script.176319/