=begin-------------------------------------------------------------------------------Improved Event TouchVersion 1.0Created: Feb. 22, 2015Last update: Feb. 22, 2015Author: Garryl-------------------------------------------------------------------------------Description:This script allows Event Touch trigger events to run when they move into theplayer's space. The default RTP scripts only trigger when the event's movementis blocked by the player, thus preventing events with either below or abovecharacters priority or with through movement enabled from triggering from theirown movement.-------------------------------------------------------------------------------Installation:Copy into a new script slot in the Materials section.-------------------------------------------------------------------------------Usage Instructions:N/A. No special action is required. This script only enhances existingfunctionality in existing situations.-------------------------------------------------------------------------------Extended Description:The purpose of this script is to make Event Touch events trigger when theevent moves underneath the player. Normally, Event Touch only triggers whenthe event "bumps into" the player (ie: has its movement stopped by the playeror the impassability of the space the player is in). It does NOT trigger whenthe event is allowed to move into the player's space (such as when the event has THROUGH checked or when priority is above or below characters).Side note: Random move route doesn't try to bump into the player if it's notalready facing that direction. Any time the RNG decides for the event to movein the direction of a space it can't move to, it won't turn. It will, however,do the aforementioned bumping into the player, but only if it's already facingthat direction. If the event is facing away and RNG says to move into theplayer, it will neither turn nor trigger.Solution: Game_Player has code for checking when the player moves into eventswith Player Touch and Event Touch triggers. It's a simple enough matter toco-opt the same concepts for events. This script causes moving events to checkeach update if they have finished moving, and if they have, to then check ifthey are overlapping the player and thus should run if they have an Event Touchtrigger.-------------------------------------------------------------------------------References:- Game_Event.update- Game_Player.update- Game_Player.update_nonmoving-------------------------------------------------------------------------------Compatibility:The following default script functions are overwritten:- Game_Event.updateThe following functions are added to default script classes:- Game_Event.check_event_trigger_touch_overlap- Game_Event.update_nonmoving-------------------------------------------------------------------------------=endclass Game_Event < Game_Character #-------------------------------------------------------------------------- # * Determine if Touch Event is Triggered # * Checks against player's x and y coordinates. # * Similar to check_event_trigger_touch, except ignores priority and # uses this event's x/y coordinates by default. # * If no event is running in the main thread, and this event has # an Event Touch type trigger, and it's in the same space as the player, # and it's not in the middle of a jump (ie: jumping over the player), # starts the event. #-------------------------------------------------------------------------- def check_event_trigger_touch_overlap(x = @x, y = @y) return if $game_map.interpreter.running? if @trigger == 2 && $game_player.pos?(x, y) start if !jumping? end end #-------------------------------------------------------------------------- # * Processing When Not Moving # last_moving : Was it moving previously? # * Similar to update_nonmoving in Game_Player, except stripped way down for # only the things relevant to events. Specifically, triggering # Event Touch upon ending movement. #-------------------------------------------------------------------------- def update_nonmoving(last_moving) return if $game_map.interpreter.running? if last_moving check_event_trigger_touch_overlap end end #-------------------------------------------------------------------------- # * Frame Update # * Modified function. # * Checks if the event has finished movement in this latest update and # does things (like triggering event touch for overlap) if it has. #-------------------------------------------------------------------------- def update # Added block last_moving = moving? # End added block super # Added block update_nonmoving(last_moving) unless moving? # End added block check_event_trigger_auto # Note: Only has its own interpreter if parallel process. # Just adding this comment so I don't get confused # if I have to look over this again. return unless @interpreter @interpreter.setup(@list, @event.id) unless @interpreter.running? @interpreter.update endend