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

[制作教程] Guide on how to prevent a player from blocking npc paths

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

    连续签到: 2 天

    [LV.7]常住居民III

    4456

    主题

    864

    回帖

    2万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 3 天前 | 显示全部楼层 |阅读模式
    This tutorial is made to help get rid of the problem of players being able to block paths of npcs (which causes npcs to just stand there).

    Note: This guide assumes you have some experience with VX Ace

    For this tutorial you will need two script snippets and one script.

    Put these scripts in the same order as the links are in the script section.

    Step 1:

    Create a npc that will be moving around a map of some kind. It is a good idea to keep track of the event id for this method (it's event id is the events default name).  For this tutorial I made it so I have to talk to him to get him to move on the first event page.

    Here is Bill's (my npc) first page:





    Step 2:

    Let's have the npc Bill follow a path after self switch A gets turned on. So lets have the second page have a custom move route using Theo's script.





    For this to work we will use find_path(x,y) in the move route dialog window. the x and y coordinates are where you want the npc to move too.

    Should look something like this:





    step 3:

    At the spot where you want the npc's trail to come to an end, put a region there (I used region 1).  Then put a second region around the region at the end point (I used region 2).  These two regions will indicate if the player is on top of the ending point of the npc and if the npc is close to getting to the location.

    What my map looked like:





    Step 4:

    Now we are going to need another event to control when the player is blocking the end point of the npc. (in parallel process mode) It can be left blank in terms of image

    We are going to need three functions from the first script to make this work:


    • get_region_event_is_in(id) - id is the event id of the event (Bill) that the npc is currently in
    • get_region_player_is_in - what region the player is in
    • get_event_position_relative_to_player(id) - is the event (Bill) to the right, left, above, or behind the player. id will be Bill's event id in this case.
    get_region_event_is_in(id) is going to check if the event is in region 2 (or the region you picked for the region surrounding the ending point). get_region_player_is_in is going to check if the player is in region 1. get_event_position_relative_to_player(id) is going to be used to see what direction to move the player if he is in the ending sport (to allow the npc to move there).

    To do this, in the new event's page make a condition branch that checks if Bill (event id 1) is in region 2 (ex: get_region_event_is_in(1) == 2 ). Make sure to use script option on page 4 of the conditional branch pop-up window to get this check to work.  Within this condition branch another condition branch should be added that checks what region the player is in (ex: get_region_player_is_in == 1).  

    In this condition branch, add four more conditional branches that check if the event is to the left, right, above, or below the player (ex: get_event_position_relative_to_player(1) == "right"). Note that right needs to be in-between "" marks. within each of these branches make the player move in the opposite direction of the check for the branch (ex: if you check to see if the event is to the right of the player, then move the player to the left).

    This will cause the player to move out of the way of the npc when he gets close to his destination.

    (optional) Step 5:

    Make it so the second event stops checking if the player is in the way when the destination is reached.

    like this (this switch will make the event go to the next page):





    Demo:

    Here is a link to the demo of the tutorial that I tested.

    Link: https://www.dropbox.com/s/c8kjy2e8awskndu/NPC%20tutorial%201.zip?dl=0

    Hope this tutorial helps you out (it is my first tutorial).   


    Thank you for your time.  



    本贴来自国际rpgmaker官方论坛作者:AwesomeCool处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/guide-on-how-to-prevent-a-player-from-blocking-npc-paths.39329/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-7-14 15:48 , Processed in 0.063338 second(s), 52 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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