じ☆ve冰风 发表于 2026-8-1 13:21:08

Trap events with 2 trigger types

Made this script on a request here.

http://s28.postimg.org/oug2yqegd/Two_Trigger.png

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:

Place the script below Material and above Main.

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

      http://s27.postimg.org/6kfml5sxb/traptag.png

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

      http://s14.postimg.org/tll0dzvjl/triggersetup.png

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 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:# Plug & Play, Put this script below Material and above Main# 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.meowname.include?('<trap>') && event.normal_priority? != normal        end      end    meow_map(x, y, triggers, normal)  endend








本贴来自国际rpgmaker官方论坛作者:MeowFace处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/trap-events-with-2-trigger-types.45193/
页: [1]
查看完整版本: Trap events with 2 trigger types