-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathMrTS_UseWeaponsArmorInBattle.js
96 lines (84 loc) · 3.32 KB
/
MrTS_UseWeaponsArmorInBattle.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
86
87
88
89
90
91
92
93
94
95
96
//=============================================================================
// MrTS_UseWeaponsArmorInBattle.js
//=============================================================================
/*:
* @plugindesc Allows to use Weapons and Armor to invoke skills in battle.
* @author Mr. Trivel
*
* @help
* --------------------------------------------------------------------------------
* Terms of Use
* --------------------------------------------------------------------------------
* Don't remove the header or claim that you wrote this plugin.
* Credit Mr. Trivel if using this plugin in your project.
* Free for commercial and non-commercial projects.
* --------------------------------------------------------------------------------
* Version 1.0
* --------------------------------------------------------------------------------
*
* --------------------------------------------------------------------------------
* Weapon/Armor tags
* --------------------------------------------------------------------------------
* Use the following tag for weapon or armor note fields:
* <BattleSkill: [ID], [CONSUMES]>
* Weapon or Armor will be treated as skill of [ID].
* [CONSUMES] - 0 - no, 1 - yes. Does it consume the item on use.
* --------------------------------------------------------------------------------
* Version History
* --------------------------------------------------------------------------------
* 1.0 - Release
*/
(function() {
var parameters = PluginManager.parameters('MrTS_UseWeaponsArmorInBattle');
var _SceneBattle_onItemOk = Scene_Battle.prototype.onItemOk;
Scene_Battle.prototype.onItemOk = function() {
var item = this._itemWindow.item();
if (item.meta.BattleSkill)
{
var action = BattleManager.inputtingAction();
var meta = item.meta.BattleSkill.split(',');
action.setSkill(Number(meta[0]));
action.setFree();
action.setConsume(Number(meta[1]) === 1 ? item : null);
$gameParty.setLastItem(item);
this.onSelectAction();
}
else
{
_SceneBattle_onItemOk.call(this);
}
};
var _WindowBattleItem_includes = Window_BattleItem.prototype.includes;
Window_BattleItem.prototype.includes = function(item) {
return _WindowBattleItem_includes.call(this, item) || (item && item.meta.BattleSkill);
};
var _WindowBattleItem_isEnabled = Window_BattleItem.prototype.isEnabled;
Window_BattleItem.prototype.isEnabled = function(item) {
return _WindowBattleItem_isEnabled(item) || (item && item.meta.BattleSkill);
};
Game_Action.prototype.setFree = function() {
this._freeSkill = true;
};
Game_Action.prototype.setConsume = function(item) {
this._consumeItem = item;
};
Game_Action.prototype.isFree = function() {
return this._freeSkill;
};
Game_Action.prototype.isConsumed = function() {
return this._consumeItem;
};
var _GameAction_clear = Game_Action.prototype.clear;
Game_Action.prototype.clear = function() {
_GameAction_clear.call(this);
this._freeSkill = false;
this._consumeItem = null;
};
var _Game_BattlerBase_paySkillCost = Game_BattlerBase.prototype.paySkillCost;
Game_BattlerBase.prototype.paySkillCost = function(skill) {
if (!this.currentAction().isFree())
_Game_BattlerBase_paySkillCost.call(this, skill);
if (this.currentAction().isConsumed())
$gameParty.loseItem(this.currentAction().isConsumed(), 1);
};
})();