-
Notifications
You must be signed in to change notification settings - Fork 2
/
RememberSkillByType.js
83 lines (73 loc) · 2.77 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
//=============================================================================
// RememberSkillByType.js
//=============================================================================
/*:
* @plugindesc Remembers last-used skill for each skill type.
* @author Toru Higuruma
*
* @help RememberSkillByType v1.0 (2017-04-27)
* Copyright (c) 2017 Toru Higuruma
* This plugin is provided under the MIT License.
* https://git.io/tmv
*
* Plugin commands:
* This plugin does not provide plugin commands.
*/
/*:ja
* @plugindesc 最後に使用したスキルをスキルタイプごとに記憶します。
* @author Toru Higuruma
*
* @help RememberSkillByType v1.0 (2017-04-27)
* Copyright (c) 2017 Toru Higuruma
* このプラグインは MIT License の下で提供されます。
* https://git.io/tmv
*
* プラグインコマンド:
* このプラグインにプラグインコマンドはありません。
*/
(function() {
var _Game_Actor_initMembers = Game_Actor.prototype.initMembers;
Game_Actor.prototype.initMembers = function() {
_Game_Actor_initMembers.call(this);
this._lastMenuSkillsByStype = [];
this._lastBattleSkillsByStype = [];
};
var _Game_Actor_setLastMenuSkill = Game_Actor.prototype.setLastMenuSkill;
Game_Actor.prototype.setLastMenuSkill = function(skill) {
_Game_Actor_setLastMenuSkill.call(this, skill);
var skills = this._lastMenuSkillsByStype;
if (skills[skill.stypeId]) {
skills[skill.stypeId].setObject(skill);
} else {
skills[skill.stypeId] = new Game_Item(skill);
}
};
var _Game_Actor_setLastBattleSkill = Game_Actor.prototype.setLastBattleSkill;
Game_Actor.prototype.setLastBattleSkill = function(skill) {
_Game_Actor_setLastBattleSkill.call(this, skill);
var skills = this._lastBattleSkillsByStype;
if (skills[skill.stypeId]) {
skills[skill.stypeId].setObject(skill);
} else {
skills[skill.stypeId] = new Game_Item(skill);
}
};
Game_Actor.prototype.getLastMenuSkillByStype = function(stypeId) {
var skill = this._lastMenuSkillsByStype[stypeId];
return skill ? skill.object() : null;
}
Game_Actor.prototype.getLastBattleSkillByStype = function(stypeId) {
var skill = this._lastBattleSkillsByStype[stypeId];
return skill ? skill.object() : null;
}
Window_SkillList.prototype.selectLast = function() {
var skill;
if ($gameParty.inBattle()) {
skill = this._actor.getLastBattleSkillByStype(this._stypeId);
} else {
skill = this._actor.getLastMenuSkillByStype(this._stypeId);
}
var index = this._data.indexOf(skill);
this.select(index >= 0 ? index : 0);
};
})();