设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 237|回复: 0
打印 上一主题 下一主题

[交流讨论] 【VA移植MV】Theo - 经过指定时间后自动消失的状态

[复制链接]

Lv5.捕梦者

梦石
0
星屑
29116
在线时间
5658 小时
注册时间
2016-3-8
帖子
1723
跳转到指定楼层
1
发表于 2026-5-17 07:58:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 alexncf125 于 2026-5-17 08:05 编辑

JAVASCRIPT 代码复制
  1. //=============================================================================
  2. // Theo_RealTimeStates.js
  3. //=============================================================================
  4.  
  5. var Imported = Imported || {};
  6. Imported.Theo_RealTimeStates = true;
  7.  
  8. var Theo = Theo || {};
  9. Theo.RTS = Theo.RTS || {};
  10. Theo.RTS.version = 1.01;
  11.  
  12. //=============================================================================
  13. /*:
  14.  * @plugindesc v1.01 经过指定时间后自动消失的状态
  15.  * @author TheoAllen(原作者写的乃是va用的rb版本, 现转译成mv用的js版, 在mz上应该也能用)
  16.  *
  17.  * @param Message Pause
  18.  * @desc 是否在出现对话框时暂停状态的计时。
  19.  * @default true
  20.  *
  21.  * @param Pause Switch ID
  22.  * @desc 暂停状态计时的开关。
  23.  * @default 0
  24.  *
  25.  * @help
  26.  * ============================================================================
  27.  * 介绍
  28.  * ============================================================================
  29.  *
  30.  * 本脚本可以设定基于时间的状态,例如在地图上10秒后中毒状态自动消失。
  31.  *
  32.  * ============================================================================
  33.  * 使用方法
  34.  * ============================================================================
  35.  *
  36.  * 状态备注
  37.  * <Expired Time: n>
  38.  *
  39.  * n替换为数字,代表持续时间(秒)
  40.  * 比如要持续一分钟, 就填写<Expired Time: 60>
  41.  *
  42.  * ============================================================================
  43.  * 使用条款
  44.  * ============================================================================
  45.  *
  46.  * 署名脚本作者, TheoAllen.
  47.  * 你可以自由编辑此脚本,只要你不声明你是脚本的原作者.
  48.  *
  49.  * ============================================================================
  50.  * 更新日志
  51.  * ============================================================================
  52.  *
  53.  * Version 1.01:
  54.  * - Can now be applied to enemies!
  55.  *
  56.  * Version 1.00:
  57.  * - Finished plugin!
  58.  */
  59. //=============================================================================
  60.  
  61. //=============================================================================
  62. // Parameter Variables
  63. //=============================================================================
  64.  
  65. Theo.SetupParameters = function () {
  66.     Theo.Parameters = PluginManager.parameters('Theo_RealTimeStates');
  67.     Theo.Param = Theo.Param || {};
  68.     Theo.Param.RTSMsgPause = Boolean(Theo.Parameters['Message Pause'] === "true" ? true : false);
  69.     Theo.Param.RTSPauseSID = Number(Theo.Parameters['Pause Switch ID'] || 0);
  70. };
  71. Theo.SetupParameters();
  72.  
  73. //=============================================================================
  74. // DataManager
  75. //=============================================================================
  76.  
  77. Theo.RTS.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
  78. DataManager.isDatabaseLoaded = function () {
  79.     if (!Theo.RTS.DataManager_isDatabaseLoaded.call(this)) return false;
  80.     if (!Theo._loaded_RealTimeStates) {
  81.         this.processRTSNotetags1($dataStates);
  82.         Theo._loaded_RealTimeStates = true;
  83.     }
  84.     return true;
  85. };
  86.  
  87. DataManager.processRTSNotetags1 = function (group) {
  88.     var note1 = /<(?:EXPIRED TIME):[ ]*(\d+)>/i;
  89.     for (var n = 1; n < group.length; n++) {
  90.         var obj = group[n];
  91.         var notedata = obj.note.split(/[\r\n]+/);
  92.         obj.stateRealTime = 0;
  93.         for (var i = 0; i < notedata.length; i++) {
  94.             var line = notedata[i];
  95.             if (line.match(note1)) {
  96.                 obj.stateRealTime = parseInt(RegExp.$1) * 60;
  97.             }
  98.         }
  99.     }
  100. };
  101.  
  102. //=============================================================================
  103. // Game_System
  104. //=============================================================================
  105.  
  106. Theo.RTS.Game_System_initialize = Game_System.prototype.initialize;
  107. Game_System.prototype.initialize = function () {
  108.     Theo.RTS.Game_System_initialize.call(this);
  109.     this.initStateRealTime();
  110. };
  111.  
  112. Game_System.prototype.initStateRealTime = function () {
  113.     this._stateRealTime = 0;
  114. };
  115.  
  116. Game_System.prototype.updateStateRealTime = function () {
  117.     this._stateRealTime++;
  118. };
  119.  
  120. Game_System.prototype.stateRealTime = function () {
  121.     return this._stateRealTime;
  122. };
  123.  
  124. //=============================================================================
  125. // Game_Battler
  126. //=============================================================================
  127.  
  128. Theo.RTS.Game_Battler_initialize = Game_Battler.prototype.initialize;
  129. Game_Battler.prototype.initialize = function (actorId) {
  130.     Theo.RTS.Game_Battler_initialize.call(this, actorId);
  131.     this.initRealTimeStates();
  132. };
  133.  
  134. Game_Battler.prototype.initRealTimeStates = function () {
  135.     this._rtStates = {};
  136. };
  137.  
  138. Theo.RTS.Game_Battler_resetStateCounts = Game_Battler.prototype.resetStateCounts;
  139. Game_Battler.prototype.resetStateCounts = function (stateId) {
  140.     Theo.RTS.Game_Battler_resetStateCounts.call(this, stateId);
  141.     var time = $dataStates[stateId].stateRealTime;
  142.     if (time <= 0) return;
  143.     this._rtStates[stateId] = $gameSystem.stateRealTime() + time;
  144. };
  145.  
  146. Game_Battler.prototype.checkRealTimeStates = function () {
  147.     for (var i = 0; i < this._states.length; i++) {
  148.         var stateId = this._states[i];
  149.         if ($dataStates[stateId].stateRealTime <= 0) continue;
  150.         if (this.isRealTimeStateTimeUp(stateId)) {
  151.             this.removeState(stateId);
  152.             if ($gameParty.inBattle()) {
  153.                 BattleManager.refreshStatus();
  154.             }
  155.         }
  156.     }
  157. };
  158.  
  159. Game_Battler.prototype.isRealTimeStateTimeUp = function (stateId) {
  160.     if (!!this._rtStates[stateId]) {
  161.         return $gameSystem.stateRealTime() >= this._rtStates[stateId];
  162.     } else {
  163.         return false;
  164.     }
  165. };
  166.  
  167. //=============================================================================
  168. // Scene_Base
  169. //=============================================================================
  170.  
  171. Theo.RTS.Scene_Base_update = Scene_Base.prototype.update;
  172. Scene_Base.prototype.update = function () {
  173.     Theo.RTS.Scene_Base_update.call(this);
  174.     if (this instanceof Scene_Map || this instanceof Scene_Battle) {
  175.         if ($gameSwitches.value(Theo.Param.RTSPauseSID)) return;
  176.         if (!this.isMessagePause()) {
  177.             this.updateStateRealTime();
  178.             this.checkRealTimeStates();
  179.         }
  180.     }
  181. };
  182.  
  183. Scene_Base.prototype.updateStateRealTime = function () {
  184.     $gameSystem.updateStateRealTime();
  185. };
  186.  
  187. Scene_Base.prototype.checkRealTimeStates = function () {
  188.     for (var i = 0; i < $gameParty.members().length; i++) {
  189.         $gameParty.members()[i].checkRealTimeStates();
  190.     }
  191.     if ($gameParty.inBattle()) {
  192.         for (var i = 0; i < $gameTroop.members().length; i++) {
  193.             $gameTroop.members()[i].checkRealTimeStates();
  194.         }
  195.     }
  196. };
  197.  
  198. Scene_Base.prototype.isMessagePause = function () {
  199.     var isSceneChangeOk = this.isActive() && !$gameMessage.isBusy();
  200.     return Theo.Param.RTSMsgPause && !isSceneChangeOk;
  201. };
  202.  
  203. //=============================================================================
  204. // End of File
  205. //=============================================================================
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2026-6-4 13:11

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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