-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRememberSkillByType.js
85 lines (76 loc) · 2.9 KB
/
RememberSkillByType.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//=============================================================================
// RememberSkillByType.js
//=============================================================================
/*:
* @target MZ
* @plugindesc Remembers last-used skill for each skill type.
* @author Toru Higuruma
* @url https://github.com/neofuji/RPGMZ-Plugins
*
* @help RememberSkillByType v1.0 (2020-08-20)
* Copyright (c) 2020 Toru Higuruma
* This plugin is provided under the MIT License.
*
* It does not provide plugin commands.
*/
/*:ja
* @target MZ
* @plugindesc 最後に使用したスキルをスキルタイプごとに記憶します。
* @author Toru Higuruma
* @url https://github.com/neofuji/RPGMZ-Plugins
*
* @help RememberSkillByType v1.0 (2020-08-20)
* Copyright (c) 2020 Toru Higuruma
* このプラグインは MIT License の下で提供されます。
*
* プラグインコマンドはありません。
*/
(() => {
const _Game_Actor_initMembers = Game_Actor.prototype.initMembers;
Game_Actor.prototype.initMembers = function() {
_Game_Actor_initMembers.apply(this, arguments);
this._lastMenuSkillsByStype = [];
this._lastBattleSkillsByStype = [];
};
const _Game_Actor_setLastMenuSkill = Game_Actor.prototype.setLastMenuSkill;
Game_Actor.prototype.setLastMenuSkill = function(skill) {
_Game_Actor_setLastMenuSkill.apply(this, arguments);
const skills = this._lastMenuSkillsByStype;
if (skills[skill.stypeId]) {
skills[skill.stypeId].setObject(skill);
} else {
skills[skill.stypeId] = new Game_Item(skill);
}
};
const _Game_Actor_setLastBattleSkill =
Game_Actor.prototype.setLastBattleSkill;
Game_Actor.prototype.setLastBattleSkill = function(skill) {
_Game_Actor_setLastBattleSkill.apply(this, arguments);
const skills = this._lastBattleSkillsByStype;
if (skills[skill.stypeId]) {
skills[skill.stypeId].setObject(skill);
} else {
skills[skill.stypeId] = new Game_Item(skill);
}
};
Game_Actor.prototype.getLastSkillByStype = function(stypeId) {
if ($gameParty.inBattle()) {
return this.getLastBattleSkillByStype(stypeId);
} else {
return this.getLastMenuSkillByStype(stypeId);
}
};
Game_Actor.prototype.getLastMenuSkillByStype = function(stypeId) {
const skill = this._lastMenuSkillsByStype[stypeId];
return skill ? skill.object() : null;
};
Game_Actor.prototype.getLastBattleSkillByStype = function(stypeId) {
const skill = this._lastBattleSkillsByStype[stypeId];
return skill ? skill.object() : null;
};
Window_SkillList.prototype.selectLast = function() {
const skill = this._actor.getLastSkillByStype(this._stypeId);
const index = this._data.indexOf(skill);
this.forceSelect(index >= 0 ? index : 0);
};
})();