Trap events with 2 trigger types

Made this script on a request here.

[IMG]http://s28.postimg.org/oug2yqegd/Two_Trigger.png[/IMG]

Feature:

Allow events to be triggered when the player is On & Beside it.

Though it's a bit tricky to use, this allows developers to build traps that can be disarmed without having the player to trigger the traps first.

How to Use:

[1] Place the script below Material and above Main.

[2] Put <trap> tag in the event's name you wish to set up with 2 trigger.

      [IMG]http://s27.postimg.org/6kfml5sxb/traptag.png[/IMG]

[3] Set the event to trigger by "Player Touch" and Priority to "Below Characters"

      [IMG]http://s14.postimg.org/tll0dzvjl/triggersetup.png[/IMG]

[4] In the event's page, set up a conditional branch using this in the script box.

$game_map.events[@event_id].x == $game_player.x && $game_map.events[@event_id].y == $game_player.y[5] This will allow you to set up 2 trigger conditions.

       When the player walks on to the trap: trigger damage

       When the player is beside the trap and pushed a button to trigger it: trigger disarm.

Compatibility:

This script is using alias method, so it's unlikely it will cause any conflicts.

Terms of Use:

Free for use in both commercial and non-commercial.

Script:

Spoiler
Code:
#==============================================================================# ■ Meow Face 2 trigger type Traps#------------------------------------------------------------------------------# Allow the trap to be triggered On AND Beside the event#==============================================================================# How to Use:# [1] Plug & Play, Put this script below Material and above Main# [2] Put <trap> in the event's name you wish to have 2 trigger type#==============================================================================class Game_Event < Game_Character  attr_reader   :meowname  alias meow_name initialize  def initialize(map_id, event)    meow_name(map_id, event)    @meowname = event.name  endendclass Game_Player < Game_Character  alias meow_map start_map_event  def start_map_event(x, y, triggers, normal)      $game_map.events_xy(x, y).each do |event|        if event.trigger_in?(triggers)          return event.start if $game_map.events[event.id].meowname.include?('<trap>') && event.normal_priority? != normal        end      end    meow_map(x, y, triggers, normal)  endend
Due to the V3 to V4 migration, some of the script pasted in the top post are messed up.


Please use this Alternative version instead:

Code:
#==============================================================================
# ■ Meow Face 2 trigger type Traps
#------------------------------------------------------------------------------
# Allow the trap to be triggered On AND Beside the event
#==============================================================================
# How to Use:
# [1] Plug & Play, Put this script below Material and above Main
# [2] Put <trap> in the event's name you wish to have 2 trigger type
#==============================================================================
class Game_Event < Game_Character
  attr_accessor   :meow
  alias meow_name initialize
  def initialize(map_id, event)
    meow_name(map_id, event)
    @meow = event.name
  end
end
class Game_Player < Game_Character
  alias meow_map start_map_event
  def start_map_event(x, y, triggers, normal)
      $game_map.events_xy(x, y).each do |event|
        if event.trigger_in?(triggers)
          return event.start if $game_map.events[event.id].meow.include?('<trap>') && event.normal_priority? != normal
        end
      end
    meow_map(x, y, triggers, normal)
  end
end

Original thread: https://forums.rpgmakerweb.com/threads/trap-events-with-2-trigger-types.45193/