forked from Trivel/RMMV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMrTS_ConjureWeapons.js
119 lines (110 loc) · 3.86 KB
/
MrTS_ConjureWeapons.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//=============================================================================
// MrTS_ConjureWeapons.js
//=============================================================================
/*:
* @plugindesc Skills can conjure weapons.
* @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.1
* --------------------------------------------------------------------------------
*
* --------------------------------------------------------------------------------
* Skill Tags
* --------------------------------------------------------------------------------
* To make skill conjure a weapon use the following tag:
* <ConjureWeapon: [WEAPON_ID], [DURATION]>
* [WEAPON_ID] - ID of the weapon you're conjuring.
* [DURATION] - How many turns will weapon last. If 0 - lasts whole battle.
*
* --------------------------------------------------------------------------------
* Version History
* --------------------------------------------------------------------------------
* 1.1 - Bug fix.
* 1.0 - Release
*/
(function() {
var _GameActor_initMembers = Game_Actor.prototype.initMembers;
Game_Actor.prototype.initMembers = function() {
_GameActor_initMembers.call(this);
this._originalWeapon = 0;
this._conjureWeaponTimer = 0;
this._conjuredWeapon = false;
};
Game_Actor.prototype.conjureWeapon = function(item, timer) {
if (this._equips[0]._itemId != item.id)
{
if (this._originalWeapon === 0)
this._originalWeapon = this._equips[0]._itemId;
this._conjureWeaponTimer = timer;
this._conjuredWeapon = true;
this._equips[0].setObject(item);
}
else
{
this._conjureWeaponTimer = timer;
}
};
_Game_Action_apply = Game_Action.prototype.apply;
Game_Action.prototype.apply = function(target) {
_Game_Action_apply.call(this, target);
var result = target.result();
if (result.isHit() && this.item().meta.ConjureWeapon)
{
var data = this.item().meta.ConjureWeapon.split(",");
var weapon = $dataWeapons[Number(data[0])];
var time = Number(data[1]);
target.conjureWeapon(weapon, time === 0 ? -1 : time+1);
}
};
Game_Actor.prototype.releaseUnequippableItems = function(forcing) {
for (;;) {
var slots = this.equipSlots();
var equips = this.equips();
var changed = false;
for (var i = 0; i < equips.length; i++) {
var item = equips[i];
if (item && (!this.canEquip(item) || item.etypeId !== slots[i]) &&
(!this._conjuredWeapon && i != 0)) {
if (!forcing) {
this.tradeItemWithParty(null, item);
}
this._equips[i].setObject(null);
changed = true;
}
}
if (!changed) {
break;
}
}
};
var _GameActor_onBattleEnd = Game_Actor.prototype.onBattleEnd;
Game_Actor.prototype.onBattleEnd = function() {
_GameActor_onBattleEnd.call(this);
if (this._originalWeapon > 0)
{
this.forceChangeEquip(0, $dataWeapons[this._originalWeapon]);
this._originalWeapon = 0;
this._conjuredWeapon = false;
}
};
var _GameActor_onTurnEnd = Game_Actor.prototype.onTurnEnd;
Game_Actor.prototype.onTurnEnd = function() {
_GameActor_onTurnEnd.call(this);
if (this._conjureWeaponTimer > 0)
this._conjureWeaponTimer--;
if (this._conjuredWeapon && this._conjureWeaponTimer <= 0)
{
this.forceChangeEquip(0, $dataWeapons[this._originalWeapon]);
this._originalWeapon = 0;
this._conjuredWeapon = false;
}
};
})();