设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 131|回复: 0

[转载发布] Event touch missing functionality - overlap and random movement

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    9071

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    58883
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    68848

    灌水之王

    发表于 2026-7-31 18:11:27 | 显示全部楼层 |阅读模式
    I ran into some trouble with eventing when I found out that Event Touch doesn't quite work as I expected in the default scripts. Specifically...

    - It doesn't trigger when an above, below, or through event moves into your space.

    - It doesn't trigger when a random movement event would randomly try to bump into you if it wasn't facing you in the first place.

    Since I couldn't find any scripts or advice to solve these issues, I wrote my own. Hope they're helpful.

    Event overlap movement fix

    Spoiler=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



    Random movement fix

    Spoiler=begin-------------------------------------------------------------------------------Random Movement Spin in PlaceVersion 1.0Created: Feb. 22, 2015Last update: Feb. 22, 2015Author: Garryl-------------------------------------------------------------------------------Description:This script causes random movement route events to visually turn when they tryto randomly move into an impassable space. It also causes Event Touch triggerevents to trigger when they turn around into the player as a result.-------------------------------------------------------------------------------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:With random move route, any time the RNG decides for the event to movein the direction of a space it can't move to, it won't turn. Mostly this is justa cosmetic thing. Some people (myself included) like seeing NPCs turn in placeto indicate the direction they're trying to move, instead of standing stockstill when they can't move in the direction they want.There is a practical aspect to this, however. Event Touch triggers only triggerif the event bumps into the player. Without the turning, the random-movementevent only bumps into the player if it's already facing that way before tryingand failing to move. If the event is facing away and RNG says to move into theplayer, it will not turn not trigger.-------------------------------------------------------------------------------References:- Game_Character.move_random-------------------------------------------------------------------------------Compatibility:The following default script functions are overwritten:- Game_Character.move_random-------------------------------------------------------------------------------=endclass Game_Character < Game_CharacterBase    #--------------------------------------------------------------------------  # * Move at Random  #--------------------------------------------------------------------------  def move_random    #move_straight(2 + rand(4) * 2, false)    move_straight(2 + rand(4) * 2)  endend



    Edit: Thanks, mods, for helping a newbie find the right place for this.


    本贴来自国际rpgmaker官方论坛作者:Garryl处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/event-touch-missing-functionality-overlap-and-random-movement.37205/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-17 21:10 , Processed in 0.134072 second(s), 54 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表