完成了状态覆盖插件 #1

main
Salted 2 years ago
parent 51c6047a61
commit 43a76d1c61
Signed by: SaltedFish
GPG Key ID: FCF3F47D9BD7AD42

@ -21,8 +21,9 @@
## 更新记录 ## 更新记录
- **2022/9/24****咸鱼**;添加了状态覆盖插件 #1
- **2022/9/17****咸鱼**;修改了 Galv_MessageBusts 支持了预先扫描文件来获取相关信息 - **2022/9/17****咸鱼**;修改了 Galv_MessageBusts 支持了预先扫描文件来获取相关信息
- **2022/9/17****咸鱼**;添加了普攻替换插件 - **2022/9/17****咸鱼**;添加了普攻替换插件 #
- **2022/9/7****面具**;数值整理,素材整理,添加怪物 - **2022/9/7****面具**;数值整理,素材整理,添加怪物
- **2022/8/30****不明枪兵**;更新海上的剧情 - **2022/8/30****不明枪兵**;更新海上的剧情
- **2022/8/25****不明枪兵**;更新海滩前的剧情 - **2022/8/25****不明枪兵**;更新海滩前的剧情

@ -12,7 +12,7 @@ var $plugins =
{"name":"SF_Scenes","status":true,"description":"scenes lib for salted fish plugins","parameters":{}}, {"name":"SF_Scenes","status":true,"description":"scenes lib for salted fish plugins","parameters":{}},
{"name":"--------------------","status":true,"description":"------------------------------------------------------------","parameters":{}}, {"name":"--------------------","status":true,"description":"------------------------------------------------------------","parameters":{}},
{"name":"SF_SkipLoadError","status":true,"description":"try to skip load errors","parameters":{}}, {"name":"SF_SkipLoadError","status":true,"description":"try to skip load errors","parameters":{}},
{"name":"SF_AutoUpdate","status":true,"description":"v1.0.0 - Automatically update the game.","parameters":{}}, {"name":"SF_AutoUpdate","status":false,"description":"v1.0.0 - Automatically update the game.","parameters":{}},
{"name":"SF_WindowScrollCommand","status":true,"description":"v1.0 Allows you to scroll text in selected commands.","parameters":{}}, {"name":"SF_WindowScrollCommand","status":true,"description":"v1.0 Allows you to scroll text in selected commands.","parameters":{}},
{"name":"SF_InputBindControl","status":true,"description":"v1.0 support add anf remove input event listener","parameters":{}}, {"name":"SF_InputBindControl","status":true,"description":"v1.0 support add anf remove input event listener","parameters":{}},
{"name":"SF_AutoRevive","status":true,"description":"v1.0.0 - Automatically revive dead party members.","parameters":{}}, {"name":"SF_AutoRevive","status":true,"description":"v1.0.0 - Automatically revive dead party members.","parameters":{}},

@ -13,37 +13,37 @@ SF_Plugins.SF_SkillUpdate.version = 1.0;
//============================================================================= //=============================================================================
/*: /*:
* @plugindesc v1.0 Allows you to auto update skills. * @plugindesc v1.0 Allows you to auto update skills.
* @author SaltedFish * @author SaltedFish
* *
* @help * @help
* ============================================================================ * ============================================================================
* Introduction * Introduction
* ============================================================================ * ============================================================================
* *
* When learning a high-priority skill with the same ID, the skill will be * When learning a high-priority skill with the same ID, the skill will be
* automatically forgotten * automatically forgotten
* 当学习一个同ID的高优先级技能时低优先级技能将自动遗忘 * 当学习一个同ID的高优先级技能时低优先级技能将自动遗忘
* *
* ============================================================================ * ============================================================================
* Skill Notes * Skill Notes
* ============================================================================ * ============================================================================
* *
* You can set the skill to auto update by adding the following to the skill's * You can set the skill to auto update by adding the following to the skill's
* notebox: * note:
* <SF_SkillUpdate: ID, priority> * <SF_SkillUpdate: ID, priority>
* *
* ID: The skill ID * ID: The skill ID
* priority: The skill priority. High-priority skills override low-priority * priority: The skill priority. High-priority skills override low-priority
* skills * skills
* *
* 在技能的注释中添加以下代码可以设置技能自动更新 * 在技能的注释中添加以下代码可以设置技能自动更新
* <SF_SkillUpdate: ID, priority> * <SF_SkillUpdate: ID, priority>
* *
* ID: 技能ID * ID: 技能ID
* priority: 技能优先级高优先级的技能会覆盖低优先级的技能 * priority: 技能优先级高优先级的技能会覆盖低优先级的技能
* *
*/ */
//============================================================================= //=============================================================================
//============================================================================= //=============================================================================
@ -55,25 +55,25 @@ DataManager.isDatabaseLoaded = function () {
if (!SF_Plugins.SF_SkillUpdate.DataManager_isDatabaseLoaded.call(this)) return false; if (!SF_Plugins.SF_SkillUpdate.DataManager_isDatabaseLoaded.call(this)) return false;
if (!this.SF_SkillUpdate_isDatabaseLoaded($dataSkills)) return false; if (!this.SF_SkillUpdate_isDatabaseLoaded($dataSkills)) return false;
return true; return true;
} };
DataManager.SF_SkillUpdate_isDatabaseLoaded = function (group) { DataManager.SF_SkillUpdate_isDatabaseLoaded = function (group) {
var note = /<SF_SkillUpdate:\s*?(\d+),\s*?(\d+)>/i; var note = /<SF_SkillUpdate:\s*?(\d+),\s*?(\d+)>/i;
for (var i = 1; i < group.length; i++) { for (var i = 1; i < group.length; i++) {
var obj = group[i]; var obj = group[i];
var notedata = obj.note.split(/[\r\n]+/); var noteData = obj.note.split(/[\r\n]+/);
obj.SF_Skill_ID = 0; obj.SF_Skill_ID = 0;
obj.SF_Skill_priority = 0; obj.SF_Skill_priority = 0;
for (var j = 0; j < notedata.length; j++) { for (var j = 0; j < noteData.length; j++) {
var line = notedata[j]; var line = noteData[j];
if (line.match(note)) { if (line.match(note)) {
obj.SF_Skill_ID = parseInt(RegExp.$1); obj.SF_Skill_ID = RegExp.$1;
obj.SF_Skill_priority = parseInt(RegExp.$2); obj.SF_Skill_priority = parseInt(RegExp.$2);
} }
} }
} }
return true; return true;
} };
//============================================================================= //=============================================================================
// Game_Actor // Game_Actor
@ -91,4 +91,4 @@ Game_Actor.prototype.learnSkill = function (skillId) {
this.forgetSkill(needForgetSkills[i].id); this.forgetSkill(needForgetSkills[i].id);
} }
} }
} };

@ -1,5 +1,5 @@
//============================================================================= //=============================================================================
// Saletd Fish Plugins - Sprites // Salted Fish Plugins - Sprites
// SF_Sprites.js // SF_Sprites.js
//============================================================================= //=============================================================================
"use strict"; "use strict";
@ -9,17 +9,17 @@ Imported.SF_Sprites = true;
var SF_Plugins = SF_Plugins || {}; var SF_Plugins = SF_Plugins || {};
//============================================================================= //=============================================================================
/*: /*:
* @plugindesc sprite base for salted fish plugins * @plugindesc sprite base for salted fish plugins
* @author Salted Fish * @author Salted Fish
* *
* @help * @help
* ============================================================================ * ============================================================================
* Requirements * Requirements
* ============================================================================ * ============================================================================
* *
* This plugin requires the following plugins: * This plugin requires the following plugins:
* SF_Core * SF_Core
*/ */
//============================================================================= //=============================================================================
(function () { (function () {
@ -28,7 +28,6 @@ var SF_Plugins = SF_Plugins || {};
SF_Sprites.version = 1.0; SF_Sprites.version = 1.0;
//============================================================================= //=============================================================================
// Sprite_SFBase // Sprite_SFBase
//============================================================================= //=============================================================================
@ -46,23 +45,23 @@ var SF_Plugins = SF_Plugins || {};
Sprite_SFBase.prototype.initialize = function () { Sprite_SFBase.prototype.initialize = function () {
Sprite.prototype.initialize.apply(this, arguments); Sprite.prototype.initialize.apply(this, arguments);
this._active = true; this._active = true;
} };
Sprite_SFBase.prototype.activate = function () { Sprite_SFBase.prototype.activate = function () {
this._active = true; this._active = true;
} };
Sprite_SFBase.prototype.deactivate = function () { Sprite_SFBase.prototype.deactivate = function () {
this._active = false; this._active = false;
} };
Sprite_SFBase.prototype.isActive = function () { Sprite_SFBase.prototype.isActive = function () {
return this._active; return this._active;
} };
Sprite_SFBase.prototype.canUpdate = function () { Sprite_SFBase.prototype.canUpdate = function () {
return this.isActive() && this.visible && this.worldVisible; return this.isActive() && this.visible && this.worldVisible;
} };
//============================================================================= //=============================================================================
// Sprite_ButtonBase // Sprite_ButtonBase
@ -80,51 +79,51 @@ var SF_Plugins = SF_Plugins || {};
Sprite_ButtonBase.prototype.initialize = function () { Sprite_ButtonBase.prototype.initialize = function () {
Sprite_SFBase.prototype.initialize.apply(this, arguments); Sprite_SFBase.prototype.initialize.apply(this, arguments);
this._state = 'pointer-out';// pointer-over pointer-out pointer-down this._state = "pointer-out"; // pointer-over pointer-out pointer-down
} };
Sprite_ButtonBase.prototype.onPointerOver = function () { Sprite_ButtonBase.prototype.onPointerOver = function () {
// override // override
} };
Sprite_ButtonBase.prototype.onPointerMove = function () { Sprite_ButtonBase.prototype.onPointerMove = function () {
// override // override
} };
Sprite_ButtonBase.prototype.onPointerEnter = function () { Sprite_ButtonBase.prototype.onPointerEnter = function () {
// override // override
} };
Sprite_ButtonBase.prototype.onPointerLeave = function () { Sprite_ButtonBase.prototype.onPointerLeave = function () {
// override // override
} };
Sprite_ButtonBase.prototype.onPointerDown = function () { Sprite_ButtonBase.prototype.onPointerDown = function () {
// override // override
} };
Sprite_ButtonBase.prototype.onPointerUp = function () { Sprite_ButtonBase.prototype.onPointerUp = function () {
// override // override
} };
Sprite_ButtonBase.prototype.onClick = function () { Sprite_ButtonBase.prototype.onClick = function () {
// override // override
} };
Sprite_ButtonBase.prototype.releasePointer = function () { Sprite_ButtonBase.prototype.releasePointer = function () {
Sprite_SFBase.prototype.releasePointer.call(this); Sprite_SFBase.prototype.releasePointer.call(this);
this.setState('pointer-out'); this.setState("pointer-out");
} };
Sprite_ButtonBase.prototype.update = function () { Sprite_ButtonBase.prototype.update = function () {
if (this.canUpdate()) { if (this.canUpdate()) {
Sprite_SFBase.prototype.update.call(this); Sprite_SFBase.prototype.update.call(this);
if (this._state !== 'pointer-out') { if (this._state !== "pointer-out") {
this.onPointerOver(); this.onPointerOver();
} }
this.updatePointerEvent(); this.updatePointerEvent();
} }
} };
Sprite_ButtonBase.prototype.updatePointerEvent = function () { Sprite_ButtonBase.prototype.updatePointerEvent = function () {
var pointer = this.getPointer(); var pointer = this.getPointer();
@ -133,65 +132,65 @@ var SF_Plugins = SF_Plugins || {};
var inFrame = this.containsPoint(new Point(pointer.x, pointer.y)); var inFrame = this.containsPoint(new Point(pointer.x, pointer.y));
if (inFrame) { if (inFrame) {
pointer.setUser(this); pointer.setUser(this);
if (this._state === 'pointer-out') { if (this._state === "pointer-out") {
this.setState('pointer-over'); this.setState("pointer-over");
} }
for (var i = 0; i < events.length; i++) { for (var i = 0; i < events.length; i++) {
var event = events[i]; var event = events[i];
if (event === 'pointer-down') { if (event === "pointer-down") {
this.setState('pointer-down'); this.setState("pointer-down");
} else if (event === 'pointer-up') { } else if (event === "pointer-up") {
this.setState('pointer-over'); this.setState("pointer-over");
} else if (event === 'pointer-move') { } else if (event === "pointer-move") {
this.onPointerMove(); this.onPointerMove();
} else if (event === 'pointer-cancel') { } else if (event === "pointer-cancel") {
this.setState('pointer-out'); this.setState("pointer-out");
} }
} }
} else { } else {
pointer.removeUser(this); pointer.removeUser(this);
this.setState('pointer-out'); this.setState("pointer-out");
} }
} else if (this._state !== 'pointer-out') { } else if (this._state !== "pointer-out") {
this.setState('pointer-out'); this.setState("pointer-out");
} }
} };
Sprite_ButtonBase.prototype.setState = function (state) { Sprite_ButtonBase.prototype.setState = function (state) {
if (this._state !== state) { if (this._state !== state) {
if (state === 'pointer-out') { if (state === "pointer-out") {
if (this._state === 'pointer-down') { if (this._state === "pointer-down") {
this._state = 'pointer-over'; this._state = "pointer-over";
this.onPointerUp(); this.onPointerUp();
} }
if (this._state === 'pointer-over') { if (this._state === "pointer-over") {
this._state = 'pointer-out'; this._state = "pointer-out";
this.onPointerLeave(); this.onPointerLeave();
} }
} else if (state === 'pointer-down') { } else if (state === "pointer-down") {
if (this._state === 'pointer-out') { if (this._state === "pointer-out") {
this._state = 'pointer-over'; this._state = "pointer-over";
this.onPointerEnter(); this.onPointerEnter();
} }
if (this._state === 'pointer-over') { if (this._state === "pointer-over") {
this._state = 'pointer-down'; this._state = "pointer-down";
this.onPointerDown(); this.onPointerDown();
} }
} else if (state === 'pointer-over') { } else if (state === "pointer-over") {
if (this._state === 'pointer-out') { if (this._state === "pointer-out") {
this._state = 'pointer-over'; this._state = "pointer-over";
this.onPointerEnter(); this.onPointerEnter();
} }
if (this._state === 'pointer-down') { if (this._state === "pointer-down") {
this._state = 'pointer-over'; this._state = "pointer-over";
this.onPointerUp(); this.onPointerUp();
this.onClick(); this.onClick();
} }
} else { } else {
SF_Plugins.SF_Core.Utils.error('Sprite_ButtonBase.setState: unknown state: ' + state); SF_Plugins.SF_Core.Utils.error("Sprite_ButtonBase.setState: unknown state: " + state);
} }
} }
} };
//============================================================================= //=============================================================================
// Sprite_SFButton // Sprite_SFButton
@ -212,35 +211,35 @@ var SF_Plugins = SF_Plugins || {};
this._coldBitmap = null; this._coldBitmap = null;
this._hotBitmap = null; this._hotBitmap = null;
this._clickHandler = null; this._clickHandler = null;
} };
Sprite_SFButton.prototype.setColdBitmap = function (bitmap) { Sprite_SFButton.prototype.setColdBitmap = function (bitmap) {
this._coldBitmap = bitmap; this._coldBitmap = bitmap;
} };
Sprite_SFButton.prototype.setHotBitmap = function (bitmap) { Sprite_SFButton.prototype.setHotBitmap = function (bitmap) {
this._hotBitmap = bitmap; this._hotBitmap = bitmap;
} };
Sprite_SFButton.prototype.setClickHandler = function (handler) { Sprite_SFButton.prototype.setClickHandler = function (handler) {
this._clickHandler = handler; this._clickHandler = handler;
} };
Sprite_SFButton.prototype.onClick = function () { Sprite_SFButton.prototype.onClick = function () {
if (this._clickHandler) { if (this._clickHandler) {
this._clickHandler(); this._clickHandler();
} }
} };
Sprite_SFButton.prototype.refresh = function () { Sprite_SFButton.prototype.refresh = function () {
this.bitmap = this._coldBitmap; this.bitmap = this._coldBitmap;
} };
Sprite_SFButton.prototype.onPointerEnter = function () { Sprite_SFButton.prototype.onPointerEnter = function () {
this.bitmap = this._hotBitmap; this.bitmap = this._hotBitmap;
} };
Sprite_SFButton.prototype.onPointerLeave = function () { Sprite_SFButton.prototype.onPointerLeave = function () {
this.bitmap = this._coldBitmap; this.bitmap = this._coldBitmap;
} };
})(); })();

@ -0,0 +1,140 @@
//=============================================================================
// Salted Fish Plugins - State Override
// SF_StateOverride.js
//=============================================================================
"use strict";
var Imported = Imported || {};
Imported.SF_StateOverride = True;
var SF_Plugins = SF_Plugins || {};
//=============================================================================
/*:
* @plugindesc 状态覆盖插件
* @author Salted Fish
*
* @help
* ============================================================================
* 介绍
* ============================================================================
* 同类状态同时存在时保留高级状态解除低级状态避免属性过量叠加
* 如果存在高级状态则不会添加低级状态
*
* 使用 状态ID 作为状态的类别标识
*
* ============================================================================
* 使用
* ============================================================================
* <SF_StatesOverride: 状态ID, 状态级别>
* 状态级别只能是非负整数
*
* ============================================================================
* 举例
* ============================================================================
* 定义三个状态
* 1.1 力量增强I物理攻击*120%
* 1.2 力量增强II物理攻击*130%
* 1.3 力量增强III物理攻击*140%
*
* 插件效果是状态1.1 力量增强I存在时若获得状态1.2力量增强II
* 直接解除状态1.1力量增强I
*
* 同理状态1.1力量增强I存在时若获得状态1.3力量增强III
* 直接解除状态1.1力量增强I
*
* 状态1.2力量增强II存在时若获得状态1.3力量增强III
* 直接解除状态1.2力量增强II
*
* 状态1.3存在时无法获得状态 1.1 和状态 1.2
*
* ============================================================================
* 已知问题
* ============================================================================
* - 与状态叠加插件不兼容不能两个状态既属于需要覆盖的又属于需要叠加的
* 如果出现这种情况取决于在插件列表中的顺序行为暂时不可预测
*
*/
//=============================================================================
SF_Plugins.SF_StateOverride = SF_Plugins.SF_StateOverride || {};
SF_Plugins.SF_StateOverride.version = 1.0;
//=============================================================================
// DataManager
//=============================================================================
SF_Plugins.SF_StateOverride.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
DataManager.isDatabaseLoaded = function () {
if (!SF_Plugins.SF_SkillUpdate.DataManager_isDatabaseLoaded.call(this)) return false;
if (!this.SF_StateOverride_isDatabaseLoaded($dataStates)) return false;
return true;
};
DataManager.SF_StateOverride_isDatabaseLoaded = function (group) {
var note = /<SF_StatesOverride:\s*?(\d+),\s*?(\d+)>/i;
for (var i = 1; i < group.length; i++) {
var obj = group[i];
var noteData = obj.note.split(/[\r\n]+/);
for (var j = 0; j < noteData.length; j++) {
var line = noteData[j];
if (line.match(note)) {
obj.SF_StateOverride_ID = RegExp.$1;
obj.SF_StateOverride_Priority = RegExp.$2;
}
}
}
return true;
};
//=============================================================================
// Game_Battler
//=============================================================================
SF_Plugins.SF_StateOverride.GameBattler_addState = Game_Battler.prototype.addState;
Game_Battler.prototype.addState = function (stateId) {
var needAddState = $dataStates[stateId];
var existStates = this.states();
var isAddable = true;
if (needAddState.SF_StateOverride_ID !== undefined) {
needRemoveState = existStates.filter(function (state) {
if (state.SF_StateOverride_ID === needAddState.SF_StateOverride_ID) {
if (state.SF_StateOverride_Priority < needAddState.SF_StateOverride_Priority) {
return true;
}
if (state.SF_StateOverride_Priority > needAddState.SF_StateOverride_Priority) {
isAddable = false;
}
}
return false;
});
// 存在优先级更高的状态,不添加。
if (!isAddable) {
return;
}
needRemoveState.forEach(function (state) {
this.removeState(state.id);
}, this);
}
SF_Plugins.SF_StateOverride.GameBattler_addState.call(this, stateId);
};
SF_Plugins.SF_StateOverride.GameBattler_isStateAddable = Game_Battler.prototype.isStateAddable;
Game_Battler.prototype.isStateAddable = function (stateId) {
if (!SF_Plugins.SF_StateOverride.GameBattler_isStateAddable.call(this, stateId)) {
return false;
}
// 判断是否存在优先级更高的状态
var needAddState = $dataStates[stateId];
var isAddable = true;
if (needAddState.SF_StateOverride_ID != undefined) {
this.states().forEach(function (state) {
if (
state.SF_StateOverride_ID === needAddState.SF_StateOverride_ID &&
state.SF_StateOverride_Priority > needAddState.SF_StateOverride_Priority
) {
isAddable = false;
}
});
}
return isAddable;
};
Loading…
Cancel
Save