完成了状态覆盖插件 #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****咸鱼**;添加了普攻替换插件
- **2022/9/17****咸鱼**;添加了普攻替换插件 #
- **2022/9/7****面具**;数值整理,素材整理,添加怪物
- **2022/8/30****不明枪兵**;更新海上的剧情
- **2022/8/25****不明枪兵**;更新海滩前的剧情

@ -12,7 +12,7 @@ var $plugins =
{"name":"SF_Scenes","status":true,"description":"scenes lib for salted fish plugins","parameters":{}},
{"name":"--------------------","status":true,"description":"------------------------------------------------------------","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_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":{}},

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

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