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

[转载发布] James' Easier Distance Conditions

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

    连续签到: 2 天

    [LV.7]常住居民III

    5778

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 昨天 12:47 | 显示全部楼层 |阅读模式

            Distance Conditional 1.0



            Written By James Westbrook(assistance given by Galv)



    Introduction


            Normally to make a conditional that makes an event happen if you(or another event) are X spaces close to an event, you have to either make a bunch of variables and assign each of them to the correct value of the event and player. Or you could write 4 lines of code that does it without the need of variables. With my plugin it's as simple as entering in one line of code.


            This can be used in any way, even commercial. Credit not necessary since this is the probably the simplest plugin out there.


    Features


            This plugin has two basic functions:


            Allows you to make conditional statement that only happens if you are X away from the event.


            Or it allows you to make a conditional statement that only happens if an event is X away from another event.


            I would use screenshots here, but I cannot think of a way to show this, unless you were actively playing the demo yourself.


    How to Use


            To install 1.0 of this plugin, you simply take the "JMW_DistanceConditional.js" file and copy it over to your project folder, inside the "plugins" folder which resides in "js". In your project, open the plugin manager. Double click on an empty space to add a plugin. In the drop down under "name" select "JMW_DistanceConditional". Then change the status to "on". Click "OK. Then click "OK" a second time, or click "APPLY".


            To use the script, make a new event command. The command you are entering is under the first tab, "Conditonal Branch". Go to the fourth tab and enter either of the script commands below into the box. 


    JMW.checkDist(eventID, distance)


            This script command will be used when making things happen if the player is close enough to the event.


            You replace "eventID" with the ID of the event. "Distance" you replace with the number of how close you want to be to make the event happen. For example, if I put "JMW.checkDist(5,2)", if my character walked within 2 spaces near event 5, the specified actions in the conditional will go off!


    JMW.checkEventsDist(eventNumber1, eventNumber2, distance)


            This command is if you want something to happen if two events get close enough.


            You replace "eventNumber1" with the first event's ID, and "eventNumber2" with the second event's ID. "Distance" you replace with the distance you want to be between them.


            For example, If I put "JMW.checkEventsDist(1,16,8), and events 1 and 16 were as little as 8 spaces close to each other, the actions specified in the conditional will occur!


            Demo


    Demo 1.0


            Plugin Download:


    Plugin 1.0


            Script

                    Code:       
    1. //-----------------------------------------------------------------------------
    2. // James Westbrook's Distance Conditional
    3. // Version 1.0
    4. var Imported = Imported || {};
    5. Imported.JMW_DistanceConditional = true;
    6. var JMW = JMW || {};                // Main object
    7. JMW.DC = JMW.DC || {};  // Plugin object
    8. /*:
    9. * @plugindesc Version 1.0 Checks how close the event is to the player/ another event.
    10. *
    11. * @author James Westbrook 1.0
    12. *
    13. * @param
    14. * @desc
    15. * @default
    16. *
    17. * @help
    18. *Credits: James Westbrook for writing plugin, and Galv for
    19. *assisting James in writing his first plugin.
    20. *(find Galv at galvs-scripts.com)
    21. *Allowed for any use. Credit not necessary since this
    22. *is one of the easiest plugins to make.
    23. *
    24. * Normally when determining the distance between the player and an event(or an
    25. *event with another event), you need four lines of scripting that you will have
    26. *to insert into a conditional command. This plugin allows you to need only
    27. *one line!
    28. *
    29. *Uses for this plugin:
    30. *You can use this plugin to determine if the player is close enough to an
    31. *event to meet the distance requirement. You are able to modify this distance
    32. *number to suit your needs. You can also use it with two different events,
    33. *instead of with a player.
    34. *
    35. *Script Calls:
    36. *You can put either of the scripts in a conditional event.
    37. *
    38. *JMW.checkDist(eventID, X distance)
    39. *
    40. *JMW.checkEventsDist(eventNumber1, eventNumber2, distance)
    41. *
    42. *(read later in help for further instructions
    43. * on how to use these calls)
    44. *
    45. *The first is used when you want the condition to be if
    46. *the player is X close to the event. In "eventID"
    47. *you fill in what the event's ID is.
    48. *In "X distance" you fill in the distance you
    49. *want. For example if I put "JMW.checkDist(4, 5)"
    50. *, it would make the conditional would only
    51. *be met if the player was within 5 spaces
    52. *of event 4!
    53. *
    54. *The second script can be used to determine
    55. *if two events were within X range. For
    56. *example, if I put "JMW.checkEventsDist(7, 8, 5)"
    57. * if events 7 and 8 were within 5 spaces, the
    58. condition is met.
    59. *The exact place you will be using these SCRIPT
    60. *commands is found in the first tab when making
    61. * an event. Under "Flow Control", select
    62. *"Conditional Branch". Go to the fourth
    63. *tab. At the bottom is the script option.
    64. *Click onto the word "Script" and then
    65. fill in the box with your script call!
    66. *For a visual aid, refer to my Distance
    67. *Conditional Demo!
    68. *
    69. *
    70. */
    71.    
    72. (function() {
    73.    
    74. JMW.checkDist = function(eventNumber, playerDistance) {
    75. return $gameMap.event(eventNumber)._x > $gamePlayer._x - playerDistance && $gameMap.event(eventNumber)._x < $gamePlayer._x + playerDistance && $gameMap.event(eventNumber)._y > $gamePlayer._y - playerDistance && $gameMap.event(eventNumber)._y < $gamePlayer._y + playerDistance
    76. };
    77. JMW.checkEventsDist = function(eventFirst, eventSecond, distanceSecond) {
    78.     return $gameMap.event(eventFirst)._x > $gameMap.event(eventSecond)._x - distanceSecond && $gameMap.event(eventFirst)._x < $gameMap.event(eventSecond)._x + distanceSecond && $gameMap.event(eventFirst)._y > $gameMap.event(eventSecond)._y - distanceSecond && $gameMap.event(eventFirst)._y < $gameMap.event(eventSecond)._y + distanceSecond
    79. };
    80.    
    81.        
    82. })();
    复制代码




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

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-7-26 03:55 , Processed in 0.063416 second(s), 52 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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