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

Project1

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

[有事请教] 一个状态叠层系统

[复制链接]

Lv2.观梦者

梦石
0
星屑
743
在线时间
511 小时
注册时间
2011-1-16
帖子
61
跳转到指定楼层
1
发表于 2025-8-3 02:22:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 yuanlongyu 于 2025-8-3 02:25 编辑

用状态叠层系统+deepseek网页,勉强整出来的新功能
不知道各位大佬是否可以改进?
RUBY 代码复制
  1. /*:
  2. @target MZ
  3. @plugindesc v1.1.0 - 状态叠层系统
  4. @author TheoAllen
  5. @url [url]https://github.com/theoallen/RMMZ/tree/master/Plugins[/url]
  6. @help
  7. ♦ 关于:
  8. 允许同一个状态多次叠加,并可在达到特定层数时触发额外效果
  9.  
  10. ♦ 使用方法:
  11. 1. 基础叠层功能:
  12.    在状态的备注栏中添加标签 <stack: n>
  13.    n = 最大叠加层数
  14.  
  15. 2. 层数触发效果:
  16.    在状态的备注栏中添加标签 <stack_effect: x, stateId>
  17.    x = 每叠多少层触发一次
  18.    stateId = 要触发的状态ID
  19.  
  20.    示例:<stack_effect: 5, 10>
  21.         表示每叠5层时,自动添加10号状态
  22.         在5层、10层、15层等倍数层数时都会触发
  23.  
  24. ♦ 使用条款:
  25. - [url]https://github.com/theoallen/RMMZ/blob/master/README.md[/url]
  26. */
  27.  
  28. // v1.1.0 - 新增层数触发效果功能
  29.  
  30. var Theo = Theo || {}
  31. Theo.StackingStates = function(){
  32.     const $ = Theo.StackingStates
  33.     $._version = '1.1.0'
  34.  
  35.     // 移除重复项
  36.     if(!Array.prototype.uniq){
  37.         Array.prototype.uniq = function() {
  38.             const copy = this.concat();
  39.             const len = copy.length
  40.             for(var i=0; i<len; ++i) {
  41.                 for(var j=i+1; j<len; ++j) {
  42.                     if(copy[i] === copy[j])
  43.                         copy.splice(j--, 1);
  44.                 }
  45.             }
  46.             return copy;
  47.         };
  48.     }
  49.  
  50.     // 解析层数触发效果
  51.     $.parseStackEffect = function(stateId) {
  52.         const state = $dataStates[stateId];
  53.         if (!state || !state.meta) return [];
  54.  
  55.         const effects = [];
  56.         for (const key in state.meta) {
  57.             if (key.toLowerCase() === 'stack_effect') {
  58.                 const value = state.meta[key].trim();
  59.                 const match = value.match(/(\d+)\s*,\s*(\d+)/);
  60.                 if (match) {
  61.                     const step = parseInt(match[1]);
  62.                     const effectStateId = parseInt(match[2]);
  63.                     if (!isNaN(step) && !isNaN(effectStateId)) {
  64.                         effects.push({ step, stateId: effectStateId });
  65.                     }
  66.                 }
  67.             }
  68.         }
  69.         return effects;
  70.     };
  71.  
  72.     // 覆盖原方法
  73.     Game_Battler.prototype.addState = function(stateId) {
  74.         if (this.isStateAddable(stateId)) {
  75.             const wasAffected = this.isStateAffected(stateId);
  76.  
  77.             if (!wasAffected || !this.isMaxStack(stateId)) {
  78.                 this.addNewState(stateId);
  79.                 const currentStack = this.stateStack(stateId);
  80.  
  81.                 // 检查并触发层数效果
  82.                 const effects = $.parseStackEffect(stateId);
  83.                 for (const effect of effects) {
  84.                     if (currentStack % effect.step === 0) {
  85.                         this.addState(effect.stateId);
  86.                     }
  87.                 }
  88.  
  89.                 this.refresh();
  90.             }
  91.             this.resetStateCounts(stateId);
  92.             this._result.pushAddedState(stateId);
  93.         }
  94.     };
  95.  
  96.     Game_Battler.prototype.isMaxStack = function(stateId){
  97.         const data = $dataStates[stateId]
  98.         const max = data.meta.stack ? Number(data.meta.stack) : 1
  99.         return max === this.stateStack(stateId)
  100.     }
  101.  
  102.     Game_Battler.prototype.stateStack = function(stateId){
  103.         return this._states.filter(id => id === stateId).length
  104.     }
  105.  
  106.     // 覆盖原方法
  107.     Game_Battler.prototype.updateStateTurns = function() {
  108.         const updated = []
  109.         for (const stateId of this._states) {
  110.             if (this._stateTurns[stateId] > 0 && !updated.includes(stateId)) {
  111.                 this._stateTurns[stateId]--;
  112.                 updated.push(stateId)
  113.             }
  114.         }
  115.     };
  116. }
  117. Theo.StackingStates()

Lv3.寻梦者

梦石
0
星屑
3276
在线时间
775 小时
注册时间
2018-5-18
帖子
437
2
发表于 2025-8-4 10:30:36 | 只看该作者
MZ为啥是RUBY代码
这个人很馋,什么都没有留下。。。
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
7309
在线时间
1383 小时
注册时间
2018-9-29
帖子
546
3
发表于 2025-8-4 12:34:23 | 只看该作者
使用疊加到特定層數並添加新狀態的做法算是一種很硬湊的方式
這插件在各方面都很殘缺
1. 顯示方面 (你必須讓使用者知道你疊到幾層)
2.我疊到5層時有 追加 20% 的BUFF
  如果我喪失那5層狀態時,你並沒有適當的機制取消那20%的BUFF
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2025-8-23 16:52

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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