查看: 839|回复: 2

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

[复制链接]
梦石
0
星屑
982
在线时间
528 小时
注册时间
2011-1-16
回帖
32
发表于 2025-8-3 02:22:00 | 显示全部楼层 |阅读模式

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

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

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

用状态叠层系统+deepseek网页,勉强整出来的新功能
不知道各位大佬是否可以改进?
[pre lang="ruby"]/*:
@target MZ
@plugindesc v1.1.0 - 状态叠层系统
@author TheoAllen
@url https://github.com/theoallen/RMMZ/tree/master/Plugins
@help
♦ 关于:
允许同一个状态多次叠加,并可在达到特定层数时触发额外效果

♦ 使用方法:
1. 基础叠层功能:
   在状态的备注栏中添加标签 <stack: n>
   n = 最大叠加层数

2. 层数触发效果:
   在状态的备注栏中添加标签 <stack_effect: x, stateId>
   x = 每叠多少层触发一次
   stateId = 要触发的状态ID

   示例:<stack_effect: 5, 10>
        表示每叠5层时,自动添加10号状态
        在5层、10层、15层等倍数层数时都会触发

♦ 使用条款:
- https://github.com/theoallen/RMMZ/blob/master/README.md
*/

// v1.1.0 - 新增层数触发效果功能

var Theo = Theo || {}
Theo.StackingStates = function(){
    const $ = Theo.StackingStates
    $._version = '1.1.0'

    // 移除重复项
    if(!Array.prototype.uniq){
        Array.prototype.uniq = function() {
            const copy = this.concat();
            const len = copy.length
            for(var i=0; i<len; ++i) {
                for(var j=i+1; j<len; ++j) {
                    if(copy === copy[j])
                        copy.splice(j--, 1);
                }
            }
            return copy;
        };
    }

    // 解析层数触发效果
    $.parseStackEffect = function(stateId) {
        const state = $dataStates[stateId];
        if (!state || !state.meta) return [];
        
        const effects = [];
        for (const key in state.meta) {
            if (key.toLowerCase() === 'stack_effect') {
                const value = state.meta[key].trim();
                const match = value.match(/(\d+)\s*,\s*(\d+)/);
                if (match) {
                    const step = parseInt(match[1]);
                    const effectStateId = parseInt(match[2]);
                    if (!isNaN(step) && !isNaN(effectStateId)) {
                        effects.push({ step, stateId: effectStateId });
                    }
                }
            }
        }
        return effects;
    };

    // 覆盖原方法
    Game_Battler.prototype.addState = function(stateId) {
        if (this.isStateAddable(stateId)) {
            const wasAffected = this.isStateAffected(stateId);
            
            if (!wasAffected || !this.isMaxStack(stateId)) {
                this.addNewState(stateId);
                const currentStack = this.stateStack(stateId);
               
                // 检查并触发层数效果
                const effects = $.parseStackEffect(stateId);
                for (const effect of effects) {
                    if (currentStack % effect.step === 0) {
                        this.addState(effect.stateId);
                    }
                }
               
                this.refresh();
            }
            this.resetStateCounts(stateId);
            this._result.pushAddedState(stateId);
        }
    };

    Game_Battler.prototype.isMaxStack = function(stateId){
        const data = $dataStates[stateId]
        const max = data.meta.stack ? Number(data.meta.stack) : 1
        return max === this.stateStack(stateId)
    }

    Game_Battler.prototype.stateStack = function(stateId){
        return this._states.filter(id => id === stateId).length
    }

    // 覆盖原方法
    Game_Battler.prototype.updateStateTurns = function() {
        const updated = []
        for (const stateId of this._states) {
            if (this._stateTurns[stateId] > 0 && !updated.includes(stateId)) {
                this._stateTurns[stateId]--;
                updated.push(stateId)
            }
        }
    };
}
Theo.StackingStates()[/pre]
梦石
0
星屑
3538
在线时间
918 小时
注册时间
2018-5-18
回帖
474
发表于 2025-8-4 10:30:36 | 显示全部楼层
MZ为啥是RUBY代码
这个人很馋,什么都没有留下。。。
回复

使用道具 举报

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

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部