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

[制作教程] Doing More With Script Calls (Proximity, Chase, and Puzzle Events) - MZ tutoria

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

    连续签到: 2 天

    [LV.7]常住居民III

    4620

    主题

    864

    回帖

    2万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 2026-7-7 08:00:10 | 显示全部楼层 |阅读模式
    INTRODUCTION

    This tutorial describes and models uses for a range of simple script calls within events, which can be used to great effect in lieu of plugins or bulky event process. Using script calls you can make chase events, proximity triggers and create a range of puzzles. You don't need to know JavaScript, but you should have familiarity with the basic functions of the engine and an understanding of switches and variables, parallel processing, etc.

    Spoiler: Disclaimers
    If you're still new to the engine/game development you should first look at this thread: RPG Maker MZ The Basics Tutorial Series and come back here later.

    I am not a coder, and you don't need to be to use script calls. I've improved my understanding of JS over time, but I'm still just a hobbyist developer, taking advantage of whatever tricks I can to make more interesting mechanics.
    Below are a number of simple script calls with explanation of what they do. You will find examples of Proximity Events, Chase Events, Puzzle Events and more using script calls for added/simpler functionality. I will add more as I implement them in MZ (although in general calls from MV work in MZ the same).  I've also put together a video demoing and explaining some of these examples, if you prefer watching to reading:

    Video Version:
    Spoiler: Youtube Tutorial Version
    Basic Notes:
    Spoiler: Some Basic JavaScript notation
                    Code:        
    === //Equals !== //Does not Equal > < //Greater and less than >= <= //Greater/equal and less/equal than a &&  b // a and b must be true a ||  b //a or b must be true

    Remember JavaScript is case sensitive. So $gamePlayer.x !== $gameplayer.x
    Also it is a good practice to add a wait in parallel events to prevent lag.
    POSITION RELATED CALLS

    Spoiler: Position Script Calls
                    Code:        
    $gamePlayer.x //Gives the Player's current X location value. $gamePlayer.y //Gives the Players current Y location value. $gameMap.regionId(x, y) //Gives the region ID of the x,y coordinates) $gameMap.regionId($gamePlayer.x, $gamePlayer.y) //Gives the region ID of the x, y coordinates, in this case the Player's. $gameMap.terrainTag($gamePlayer.x, $gamePlayer.y) //Gives the terrain tag of the x,y coordinates, in this case the Player's. $gameMap.event(n).x //Gives the x of event n $gameMap.event(n).y //Gives the y of event n $gameMap.event(this._eventId).x //Gives the x of the current event $gameMap.event(this._eventId).y//Gives the y of the current event


    Examples of Position Data Use:


    Proximity Event: Checking if the player is next to an event in a cross pattern.
    Spoiler: Proximity Event Example
    Set up event in Parallel with a conditional check and the following in the script box (on one line):
                    Code:        
    $gameMap.event(this._eventId).x - 1 === $gamePlayer.x && $gameMap.event(this._eventId).y === $gamePlayer.y  || $gameMap.event(this._eventId).x + 1 === $gamePlayer.x && $gameMap.event(this._eventId).y === $gamePlayer.y  || $gameMap.event(this._eventId).x === $gamePlayer.x && $gameMap.event(this._eventId).y + 1 === $gamePlayer.y  || $gameMap.event(this._eventId).x === $gamePlayer.x && $gameMap.event(this._eventId).y - 1 === $gamePlayer.y

    By modifying the x and y value checks as well as the && and || statements, you can change this to be a line, a square, two boxes from the player. Etc. Lots of possibilities with this.
    SWITCH AND VARIABLE RELATED CALLS

    Spoiler: Switch and Variable Script Calls
                    Code:        
    $gameSwitches.value(n) //check value of switch n (true or false) $gameVariables.value(n) === 1 //checks value of variable n === 1 (or any number) $gameSwitches.setValue(n, true) //Sets Switch n to true. $gameSwitches.setValue(n, false) //Sets Switch n to false. $gameVariables.setValue(n, 1) //Sets Variable n to 1 (or any number) $gameSelfSwitches.setValue([this._mapId, $gameMap.event(this._eventId), 'A'], true) //Sets Self Switch A on, for the current event on the current map. $gameSelfSwitches.setValue([n, e, 'A'], true) //Sets Self Switch A on for event e on map n. $gameSelfSwitches.value([this._mapId, $gameMap.event(this._eventId), 'A']) === true //checks if the self switch A is on for current event $gameSelfSwitches.value([n, e, 'A']) === true //Checks if self switch A is on for event e on map n.



    Examples of Switch control use:

    Puzzle Event: Push a boulder onto a space to trigger another event with parallel.
    Spoiler: Boulder Puzzle Event Example
    Two Events: First a simple boulder that moves on player touch (skip).  Second a parallel that checks in a conditional if that boulder event is at a certain x,y and if so flips a switch (making the witch appear in this case when switch is on.). You can also add an else to flip the switch off if the boulder is moved off the location.
                    Code:        
    $gameMap.event(3).x === 12 && $gameMap.event(3).y === 6 // use in conditional check.  $gameSwitches.setValue(1, true) // optional script call for switch/off(false), //In this case though, you could just use the built in switch flip just as easily.


    Chase Event: Check a player's current region and flipping a switch so an event chases.
    Spoiler: Chase Event Example
    Set up a parallel event checking RegionId of player in conditional, and flip self switch of an event to chase player when in certain regions. Flip off if outside of region (use in else condition). You could also use a regular switch flip instead of the self switch, as in n the puzzle event.
                    Code:        
    $gameMap.regionId($gamePlayer.x, $gamePlayer.y) === 3 // checks if Player is on Region 3 $gameSelfSwitches.setValue([this._mapId, 2, 'A'], true) //flips self switch A on event 2.  $gameSelfSwitches.setValue([this._mapId, 2, 'A'], false) //flips self switch A off event 2


    I'll be updating this with more examples as I go.

    Questions and suggestions are welcome. I'd especially love to see examples of what you make with script calls! Good luck!


    本贴来自国际rpgmaker官方论坛作者:Rubescen处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/doing-more-with-script-calls-proximity-chase-and-puzzle-events-mz-tutorial.126943/

    本帖子中包含更多资源

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

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

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-7-16 20:27 , Processed in 0.130373 second(s), 55 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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