-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathMrTS_DamageEfficiency.js
163 lines (150 loc) · 5.15 KB
/
MrTS_DamageEfficiency.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
//=============================================================================
// MrTS_DamageEfficiency.js
//=============================================================================
/*:
* @plugindesc Adds notetags that allow battlers to deal more damage with skills depending on their efficiency.
* @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
* --------------------------------------------------------------------------------
*
* --------------------------------------------------------------------------------
* Trait Object Note Tags (Actor, Class, Enemy, State, Armor, Weapon)
* --------------------------------------------------------------------------------
* <WeaponEfficiency: [WEAPON_TYPE_ID], [PERCENT]>
* <ElementEfficiency: [ELEMENT_ID], [PERCENT]>
* <SkillTypeEfficiency: [SKILL_TYPE_ID], [PERCENT]>
* <OverallEfficiency: [PERCENT]>
* [PERCENT]: 0.01 - 1%, 0.5 - 50%, -0.25 - -25%
*
* Weapon Efficiency - battlers deal more damage while wielding that weapon type.
* Element Efficiency - battlers deal more damage with skills of that element.
* Skill Type Efficiency - battlers deal more damage with skills of that type.
* Overall Efficiency - battlers just deal more damage
*
* Examples:
* <WeaponEfficiency: 2, 0.5>
* <ElementEfficiency: 2, 1.0>
* <SkillTypeEfficiency: 1, -0.5>
* <OverallEfficiency: 2.0>
* --------------------------------------------------------------------------------
*
* --------------------------------------------------------------------------------
* Skill/Item Note Tags
* --------------------------------------------------------------------------------
* By default all skills are affected by efficiency. For some skill/item to ignore
* effiency bonus use the following note tags:
* <IgnoreWeaponBonus: [WEAPON_TYPE_ID], [WEAPON_TYPE_ID], ..., [WEAPON_TYPE_ID]>
* <IgnoreElementBonus>
* <IgnoreSkillTypeBonus>
* <IgnoreOverallBonus>
* <IgnoreAllBonuses>
*
* Examples:
* <IgnoreWeaponBonus: 1, 2, 3, 4, 5>
* --------------------------------------------------------------------------------
*
* --------------------------------------------------------------------------------
* Version History
* --------------------------------------------------------------------------------
* 1.0 - Release
*/
(function() {
Game_BattlerBase.prototype.getWeaponEfficiency = function(id) {
var to = this.traitObjects();
var eff = 0.0;
for (var i = 0; i < to.length; i++) {
if (to[i].meta.WeaponEfficiency) {
var val = to[i].meta.WeaponEfficiency.split(',');
if (Number(val[0]) === id) {
eff += Number(val[1]);
}
}
}
return eff;
};
Game_BattlerBase.prototype.getElementEfficiency = function(id) {
var to = this.traitObjects();
var eff = 0.0;
for (var i = 0; i < to.length; i++) {
if (to[i].meta.ElementEfficiency) {
var val = to[i].meta.ElementEfficiency.split(',');
if (Number(val[0]) === id) {
eff += Number(val[1]);
}
}
}
return eff;
};
Game_BattlerBase.prototype.getSkillTypeEfficiency = function(id) {
var to = this.traitObjects();
var eff = 0.0;
for (var i = 0; i < to.length; i++) {
if (to[i].meta.SkillTypeEfficiency) {
var val = to[i].meta.SkillTypeEfficiency.split(',');
if (Number(val[0]) === id) {
eff += Number(val[1]);
}
}
}
return eff;
};
Game_BattlerBase.prototype.getOverallEfficiency = function() {
var to = this.traitObjects();
var eff = 0.0;
for (var i = 0; i < to.length; i++) {
if (to[i].meta.OverallEfficiency) {
eff += Number(to[i].meta.OverallEfficiency);
}
}
return eff;
};
var _Game_Action_applyVariance = Game_Action.prototype.applyVariance;
Game_Action.prototype.applyVariance = function(damage, variance) {
var value = damage;
var item = this.item();
var a = this.subject();
if (!item.meta.IgnoreAllBonuses)
{
var ignoreWeaponBonus = false;
if (item.meta.IgnoreWeaponBonus && a.isActor()) {
var arr = item.meta.IgnoreWeaponBonus.split(',');
for (var i = 0; i < arr.length; i++) {
if (a.weapons()[0] && a.weapons()[0].wtypeId === Number(arr[i])) {
ignoreWeaponBonus = true;
break;
}
}
}
if (!ignoreWeaponBonus && a.isActor() && a.weapons()[0]) {
var wb = 1 + a.getWeaponEfficiency(a.weapons()[0].wtypeId);
if (wb < 0) wb = 0;
value *= wb;
}
if (!item.meta.IgnoreElementBonus) {
var eb = 1 + a.getElementEfficiency(item.damage.elementId);
if (eb < 0) eb = 0;
value *= eb;
}
if (!item.meta.IgnoreSkillTypeBonus && item.stypeId) {
var stb = 1 + a.getSkillTypeEfficiency(item.stypeId);
if (stb < 0) stb = 0;
value *= stb;
}
if (!item.meta.IgnoreOverallBonus) {
var ob = 1 + a.getOverallEfficiency();
if (ob < 0) ob = 0;
value *= ob;
}
}
return _Game_Action_applyVariance.call(this, value, variance);
};
})();