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

[转载发布] Revahar - Plugin JourNuit (day/night) RPGMMV

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

    连续签到: 2 天

    [LV.7]常住居民III

    7959

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 3 天前 | 显示全部楼层 |阅读模式
    Hello everyone !

    This is my very first plugin for RPG Maker MV.
    Any question ? Ask me !

    At the moment, I've only been learning JavaScript for 2 months, so if you see any errors, don't hesitate to tell me so that I can correct them.
    This plugin is a first draft. It is not finished but already functional as it is.

    Terms of use :
    - It can be used for commercial and non commercial games.
    - Just add my name in your game/project credits.
    - Please, link back to this post if you want to share it.
    (You can send me en message if you need help
    )

    /!\ Update 1.1 : Now you can set the tints !
    I don't update the demo. You just have to copy paste the code in the spoiler below or go to my github and download the last version of my plugin https://github.com/Revahar/RPG-Maker-MV-Plugin---Systeme-jour-nuit


    --------------------------------------------------------
    Plugin: Day/night system with screen tint management.
    --------------------------------------------------------

    This plugin uses 4 game variables that you can set in the plugin settings.
    These 4 variables will contain the start time of each phase of the day (morning, day, evening, night).
    You can therefore define the ID of the variable to use as well as its content (6, 8, 19, 21).
    In this way, the morning will start at 6 a.m., the day at 8 a.m., the evening at 7 p.m. and the night at 9 p.m.

    This plugin uses a counting system based on the number of frames (X frames = 1 seconds. 60 seconds = 1 minutes. Etc.)
    By default, this value is 5 but can be changed in plugin settings.

    The transition between each phase is done dynamically. By default, the hue transition is done in 600 frames (10 seconds).
    This value can be changed in the plugin settings.

    4 switches are used in this plugin, each switch corresponds to a phase.
    You can thus define the appearance of an event according to the active switch.
    By default, switches 1, 2, 3 and 4 are used but you can change the IDs in the settings.

    If you want the time to scroll but the hue change is no longer activated, then you can use the command
    DisableTint plugin in a parallel event.

    To enable or re-enable tints, use the plugin command EnableTint.
    /!\ Each Map where you want the day/night system to be active must contain an EnableTint.

    To have the tint update instantly when exiting a location where tint management was
    disabled, use the plugin command EnableTintOnExit.
    /!\ To put in the event of the exit door of the building just before or after the teleportation.

    To define the tint of dungeons/caves and other places without light (tint value editable on line 239)
    use the DungeonTint plugin command.
    /!\ To put in a parallel event.

    To enable or re-enable tints, use the plugin command EnableTint.
    /!\ Each Map where you want the day/night system to be active must contain an EnableTint.

    To have the tint update instantly when exiting a location where tint management was
    disabled, use the plugin command EnableTintOnExit.
    /!\ To put in the event of the exit door of the building just before or after the teleportation.

    To define the tint of dungeons/caves and other places without light (tint value editable on line 239)
    use the DungeonTint plugin command.
    /!\ To put in a parallel event.

    Spoiler: Français
    Bonjour à toutes et à tous !

    Voici mon tout premier plugin pour RPG Maker MV.
    Vous pouvez l'utiliser librement. Inscrivez moi juste dans vos crédits.
    À l'heure actuelle, ça ne fait que 2 mois que j'apprend le JavaScript donc si vous voyez des erreurs surtout n'hésitez pas à me le dire pour que je puisse corriger.
    Ce plugin est un premier jet. Il n'est pas terminé mais déjà fonctionnel en l'état.

    Plugin : Système jour/nuit avec gestion des teintes de l'écran.

    Ce plugin utilise 4 variables du jeu que vous pouvez définir dans les paramètres du plugin.
    Ces 4 variables vont contenir  l'heure du début de chaque phase de la journée (matin, journée, soir, nuit).
    Vous pouvez donc définir l'ID de la variable à utiliser ainsi que son contenu (6, 8, 19, 21).
    De cette manière, le matin commencera à 6h, la journée à 8h, le soir à 19h et la nuit à 21h.

    Ce plugin utilise un système de comptage basé sur le nombre de frames (X frames = 1 secondes. 60 secondes = 1 minutes. Etc.)
    Par défaut, cette valeur à est 5 mais peut être modifiée dans les paramètres du plugin.

    La transition entre chaque phase se fait de manière dynamique. Par défaut, la transition de teinte se fait en 600 frames (10 secondes).
    Cette valeur peut être modifiée dans les paramètres du plugin.

    4 switches sont utilisés dans ce plugin, chaque switch correspond à une phase.
    Vous pouvez ainsi définir l'apparition d'un évènement en fonction du switch actif.
    Par défaut, se sont les switch 1, 2, 3 et 4 qui sont utilisés mais vous pouvez modifier les IDs dans les paramètres.

    Si vous souhaitez que le temps défile mais que le changement de teinte ne soit plus activé, alors vous pouvez utiliser la commande
    de plugin DisableTint dans un évènement parallèle.

    Pour activer ou réactiver les teintes, utilisez la commande de plugin EnableTint.
    /!\ Chaque Map où vous souhaitez que le système jour/nuit soit actif doit contenir un EnableTint.

    Pour que la teinte se mette à jour instantanément lors de la sortie d'un lieu où la gestion des teintes était
    désactivée, utilisez la commande de plugin EnableTintOnExit.
    /!\ À mettre dans l'évènement de la porte de sortie du bâtiment juste avant ou après la téléportation.

    Pour définir la teinte des donjons/grottes et autres lieux sans lumière
    utilisez la commande de plugin DungeonTint.
    /!\ À mettre dans un évènement parallèle.
    Spoiler: Demo

    Demo_Day_Night

    MediaFire is a simple to use free service that lets you put all your photos, documents, music, and video in a single place so you can access them anywhere and share them everywhere.
                                            www.mediafire.com                               





    Spoiler: Code
                    JavaScript:       
    1. //=============================================================================
    2. // Revahar - Plugin DayNight RPGMMV
    3. //=============================================================================
    4. /*:
    5. * @plugindesc Day/Night System Plugin for RPG Maker MV.
    6. * Version 1.1
    7. * @author Revahar
    8. *
    9. * @param Variable Matin
    10. * @desc The variable containing the morning start time
    11. * @default 1
    12. *
    13. * @param Variable Journee
    14. * @desc The variable containing the time of the start of the day
    15. * @default 2
    16. *
    17. * @param Variable Soir
    18. * @desc The variable containing the evening start time
    19. * @default 3
    20. *
    21. * @param Variable Nuit
    22. * @desc The variable containing the time of the beginning of the night
    23. * @default 4
    24. *
    25. * @param Matin Heure
    26. * @desc The time at which the morning phase begins
    27. * @default 6
    28. *
    29. * @param Journee Heure
    30. * @desc The time at which the phase of the day begins
    31. * @default 8
    32. *
    33. * @param Soir Heure
    34. * @desc The time at which the evening phase begins
    35. * @default 19
    36. *
    37. * @param Nuit Heure
    38. * @desc The time at which the night phase begins
    39. * @default 21
    40. *
    41. * @param Frames par seconde
    42. * @desc The number of frames needed to make one second (60 frames = 1 second irl)
    43. * @default 5
    44. *
    45. * @param Transition Frames
    46. * @desc The number of frames for the transition between each tint
    47. * @default 600
    48. *
    49. * @param Frame On Exit
    50. * @desc The number of frames for the tint transition when exiting a location.
    51. * @default 0
    52. *
    53. * @param Switch Matin
    54. * @desc The switch corresponding to the morning period
    55. * @default 1
    56. *
    57. * @param Switch Journee
    58. * @desc The switch corresponding to the time of day
    59. * @default 2
    60. *
    61. * @param Switch Soir
    62. * @desc The switch corresponding to the evening period
    63. * @default 3
    64. *
    65. * @param Switch Nuit
    66. * @desc The switch corresponding to the period of the night
    67. * @default 4
    68. *
    69. * @param TeinteDongeon
    70. * @desc The desired tint for the interior of the dungeons (format: [R, G, B, Gray])
    71. * @default [-200, -200, -200, 0]
    72. *
    73. * @param TeinteMatin
    74. * @desc The desired tint for the morning (format: [R, G, B, Gray])
    75. * @default [-16, -84, -118, 120]
    76. *
    77. * @param TeinteJournee
    78. * @desc The desired tint for the day (format: [R, G, B, Gray])
    79. * @default [0, 0, 0, 0]
    80. *
    81. * @param TeinteSoir
    82. * @desc The desired tint for the evening (format: [R, G, B, Gray])
    83. * @default [-42, -134, -134, 100]
    84. *
    85. * @param TeinteNuit
    86. * @desc The desired tint for the night (format: [R, G, B, Gray])
    87. * @default [-200, -200, -100, 68]
    88. *
    89. * @param TeinteDefaut
    90. * @desc The desired tint by défaut (format: [R, G, B, Gray])
    91. * @default [0, 0, 0, 0]
    92. *
    93. * @help This plugin adds a day/night system to the game.
    94. * A day is divided into 4 phases.
    95. * The tint of the screen changes according to the time.
    96. * Hours, minutes and seconds can be found in game variables
    97. * (respectively 1, 2 and 3 by default).
    98. * Use it to display them or to set opening hours
    99. * for stores for example.
    100. *
    101. * To disable tints, use the following plugin command:
    102. * DisableTint
    103. *
    104. * To re-enable tints, use the following plugin command:
    105. * EnableTint
    106. * /!\ Each Map where you want the day/night system to be active must
    107. * contain an EnableTint.
    108. *
    109. * To have the hue update instantly when outputting a
    110. * where tint management was disabled, use the command:
    111. * EnableTintOnExit
    112. * /!\ To put in the event of the exit door of the building just before
    113. * teleportation.
    114. *
    115. * To set the tint in a dungeon
    116. * use the following plugin command: DungeonTint
    117. * /!\ To put in a parallel event.
    118. *
    119. * To manually add hours, use the plugin command:
    120. * AddHours x
    121. * Replace x with the number of hours to add.
    122. * For example, if it is 11 p.m. in game and you add 8h, it will be 7 a.m.
    123. *
    124. * By default, switches 1, 2, 3 and 4 are used to know the
    125. * current period (morning, day, evening, night). You can change them
    126. * depending on your switches in the settings.
    127. * This allows, via a single condition (If switch 4 = ON then...), to
    128. * allow a time-based event (for example, a store that
    129. * would only be open during the day, a dungeon accessible only at night, etc.).
    130. *
    131. * Tints automatically update based on game time
    132. * over a duration defined in frames in the "Frames par seconde" parameter.
    133. */
    134. (function() {
    135.     var parameters = PluginManager.parameters('Revahar - Plugin DayNight RPGMMV');
    136.     var varMatin = parseInt(parameters['Variable Matin']);
    137.     var varJournee = parseInt(parameters['Variable Journee']);
    138.     var varSoir = parseInt(parameters['Variable Soir']);
    139.     var varNuit = parseInt(parameters['Variable Nuit']);
    140.     var matinHeure = parseInt(parameters['Matin Heure']);
    141.     var journeeHeure = parseInt(parameters['Journee Heure']);
    142.     var soirHeure = parseInt(parameters['Soir Heure']);
    143.     var nuitHeure = parseInt(parameters['Nuit Heure']);
    144.     var switchMatin = parseInt(parameters['Switch Matin']);
    145.     var switchJournee = parseInt(parameters['Switch Journee']);
    146.     var switchSoir = parseInt(parameters['Switch Soir']);
    147.     var switchNuit = parseInt(parameters['Switch Nuit']);
    148.     var heureFrames = parseInt(parameters['Frames par seconde']);
    149.     var transitionFrames = parseInt(parameters['Transition Frames']);
    150.     var frameOnExit = parseInt(parameters['Frame On Exit']);
    151.     var tintEnabled = true;
    152.     var tintOnExit = false;
    153.     var dungeonTintValue = false;
    154.     var currentTint = null;
    155.     var targetTint = null;
    156.     var frameCount = 0;
    157.     // Turn off tints
    158.     function disableTint() {
    159.         tintEnabled = false;
    160.         updateTint();
    161.     }
    162.     // Reactivate tints
    163.     function enableTint() {
    164.         transitionFrames = parseInt(parameters['Transition Frames']);
    165.         tintEnabled = true;
    166.         updateTint();
    167.     }
    168.     // Reactivate colors when exiting buildings/dungeons
    169.     function enableTintOnExit() {
    170.         tintOnExit = true;
    171.         updateTint();
    172.     }
    173.     // Set tint for dungeons/caves
    174.     function dungeonTint() {
    175.         dungeonTintValue = true;
    176.         updateTint();
    177.     }
    178.     // Add hours
    179.     function addHours(hours) {
    180.         var currentTime = $gameVariables.value(1);
    181.         var newTime = currentTime + hours;
    182.         // Manage passing midnight
    183.         if (newTime >= 24) {
    184.             newTime -= 24;
    185.         } else if (newTime < 0) {
    186.             newTime += 24;
    187.         }
    188.         $gameVariables.setValue(1, newTime);
    189.         updateTint();
    190.     }
    191.     // Update tint
    192.     function updateTint() {
    193.         var currentTime = $gameVariables.value(1); // Variable containing the time
    194.         var periodeMatin = $gameSwitches.value(switchMatin); // Switch determining the morning period (OFF = not morning, ON = morning)
    195.         var periodeJournee = $gameSwitches.value(switchJournee); // Switch determining the day period (OFF = no day, ON = day)
    196.         var periodeSoir = $gameSwitches.value(switchSoir); // Switch determining the evening period (OFF = no evening, ON = evening)
    197.         var periodeNuit = $gameSwitches.value(switchNuit); // Switch determining the night period (OFF = no night, ON = night)
    198.         // Determine current phase based on time
    199.         var phase = 'matin';
    200.         if (currentTime >= matinHeure && currentTime < journeeHeure) {
    201.             phase = 'matin';
    202.             periodeMatin = true;
    203.             periodeJournee = false;
    204.             periodeSoir = false;
    205.             periodeNuit = false;
    206.         } else if (currentTime >= journeeHeure && currentTime < soirHeure) {
    207.             phase = 'journee';
    208.             periodeMatin = false;
    209.             periodeJournee = true;
    210.             periodeSoir = false;
    211.             periodeNuit = false;
    212.         } else if (currentTime >= soirHeure && currentTime < nuitHeure) {
    213.             phase = 'soir';
    214.             periodeMatin = false;
    215.             periodeJournee = false;
    216.             periodeSoir = true;
    217.             periodeNuit = false;
    218.         } else {
    219.             phase = 'nuit';
    220.             periodeMatin = false;
    221.             periodeJournee = false;
    222.             periodeSoir = false;
    223.             periodeNuit = true;
    224.         }
    225.         $gameSwitches.setValue(varMatin, periodeMatin);
    226.         $gameSwitches.setValue(varJournee, periodeJournee);
    227.         $gameSwitches.setValue(varSoir, periodeSoir);
    228.         $gameSwitches.setValue(varNuit, periodeNuit);
    229.         // Obtain the tint corresponding to the phase
    230.         var targetTint = getTintByPhase(phase);
    231.         // Change tint when exiting building/dungeon
    232.         if (tintOnExit) {
    233.             currentTint = targetTint;
    234.             transitionFrames = frameOnExit;
    235.             $gameScreen.startTint(currentTint, transitionFrames);
    236.             tintOnExit = false;
    237.             return;
    238.         }
    239.         // Set the tint of dungeons/caves/etc.
    240.         if (dungeonTintValue) {
    241.             currentTint = JSON.parse(parameters['TeinteDongeon']);
    242.             $gameScreen.startTint(currentTint, 0);
    243.             dungeonTintValue = false;
    244.             return;
    245.         }
    246.         // Disable tint if tintEnabled is false
    247.         if (!tintEnabled) {
    248.             currentTint = JSON.parse(parameters['TeinteDefaut']);
    249.             $gameScreen.startTint(currentTint, 0);
    250.             return;
    251.         }
    252.         // Gradually update the tint
    253.         if (currentTint === null) {
    254.             currentTint = targetTint;
    255.             $gameScreen.startTint(currentTint, transitionFrames);
    256.         } else if (!tintEquals(currentTint, targetTint)) {
    257.             currentTint = targetTint;
    258.             $gameScreen.startTint(currentTint, transitionFrames);
    259.         }
    260.     }
    261.     // Check if two shades are the same
    262.     function tintEquals(tint1, tint2) {
    263.         return (
    264.             tint1[0] === tint2[0] &&
    265.             tint1[1] === tint2[1] &&
    266.             tint1[2] === tint2[2] &&
    267.             tint1[3] === tint2[3]
    268.         );
    269.     }
    270.     // Get tint based on phase
    271.     function getTintByPhase(phase) {
    272.         switch (phase) {
    273.             case 'matin':
    274.                 return JSON.parse(parameters['TeinteMatin']);
    275.             case 'journee':
    276.                 return JSON.parse(parameters['TeinteJournee']);
    277.             case 'soir':
    278.                 return JSON.parse(parameters['TeinteSoir']);
    279.             case 'nuit':
    280.                 return JSON.parse(parameters['TeinteNuit']);
    281.             default:
    282.                 return JSON.parse(parameters['TeinteDefaut']);
    283.         }
    284.     }
    285.     // Update tint every frame
    286.     var _Scene_Map_update = Scene_Map.prototype.update;
    287.     Scene_Map.prototype.update = function() {
    288.         _Scene_Map_update.call(this);
    289.         frameCount++;
    290.         if (frameCount % heureFrames === 0) {
    291.             var currentTime = $gameVariables.value(1); // Variable containing hours
    292.             var currentMinutes = $gameVariables.value(2); // Variable containing the minutes
    293.             var currentSeconds = $gameVariables.value(3); // Variable containing the seconds
    294.             currentSeconds += 1;
    295.             // Manage overruns of seconds and minutes
    296.             if (currentSeconds >= 60) {
    297.                 currentSeconds = 0;
    298.                 currentMinutes ++;
    299.                 if (currentMinutes >= 60) {
    300.                     currentMinutes = 0;
    301.                     currentTime ++;
    302.                     if (currentTime >= 24) {
    303.                         currentTime = 0;
    304.                     }
    305.                 }
    306.             }
    307.             $gameVariables.setValue(1, currentTime);
    308.             $gameVariables.setValue(2, currentMinutes);
    309.             $gameVariables.setValue(3, currentSeconds);
    310.             updateTint();
    311.         }
    312.     };
    313.     // Plugin command Management
    314.     var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    315.     Game_Interpreter.prototype.pluginCommand = function(command, args) {
    316.         _Game_Interpreter_pluginCommand.call(this, command, args);
    317.         if (command === 'DisableTint') {
    318.             disableTint();
    319.         } else if (command === 'EnableTint') {
    320.             enableTint();
    321.         } else if (command === 'EnableTintOnExit') {
    322.             enableTintOnExit();
    323.         } else if (command === 'DungeonTint') {
    324.             dungeonTint();
    325.         } else if (command === 'AddHours') {
    326.             var hours = parseInt(args[0]);
    327.             addHours(hours);
    328.         }
    329.     };
    330. })();
    复制代码




    本贴来自国际rpgmaker官方论坛作者:Revahar处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/revahar-plugin-journuit-day-night-rpgmmv.158267/

    本帖子中包含更多资源

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

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

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-8-1 04:43 , Processed in 0.113685 second(s), 57 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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