forked from aaixy/rm-mvmz-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAXY_Skill.js
186 lines (178 loc) · 5.22 KB
/
AXY_Skill.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
//=============================================================================
// A XueYu Plugins - Skill
// AXY_Skill.js
// Version: 1.01
// License: MIT
//=============================================================================
/*:
* @plugindesc v1.01 Set param about skill.
* @author A XueYu Plugins
*
* @help
* Introduction
* This plugin allows to set param about skill.
* Github: https://github.com/aaixy/rmmv-plugins
*
* Usage:
* Write
* <axy_skill_repeat:10>
* <axy_skill_mode:a> //one by one, totals = repeats*targets
* <axy_skill_mode:b> //one by one, totals = repeats
* <axy_skill_mode:c> //round by round, totals = repeats*targets
* <axy_skill_mode:d> //round by round, totals = repeats
* to skill meta note box;
*
* changelog
* 1.01 2019.12.25
* add: abcd four repeat mode;
* 1.00 2019.11.28
* first release.
*
* //=============================================================================
* End of Help File
* //=============================================================================
*
*
*/
// Imported
var Imported = Imported || {};
Imported.AXY_Skill = true;
// Parameter Variables
var AXY = AXY || {};
AXY.Skill = AXY.Skill || {};
AXY.Skill.Parameters = PluginManager.parameters('AXY_Skill');
AXY.Skill.Param = AXY.Skill.Param || {};
AXY.Skill.Alias = AXY.Skill.Alias || {};
AXY.Skill.Variables = AXY.Skill.Variables || {};
//=============================================================================
// Utils
//=============================================================================
// Create a utility function to parse complex parameters.
//=============================================================================
Utils.recursiveParse = function (param) {
try {
if (typeof JSON.parse(param) == 'object') {
return JSON.parse(
param,
function (key, value) {
try {
return this.recursiveParse(value);
} catch (e) {
return value;
}
}.bind(this)
);
} else {
return JSON.parse(
param,
function (key, value) {
return value;
}.bind(this)
);
}
} catch (e) {
return param;
}
};
//=============================================================================
// Parameters
//=============================================================================
// Read and parse parameters into a locally scoped Parameters object.
//=============================================================================
Object.keys(AXY.Skill.Parameters).forEach(function (key) {
return (AXY.Skill.Param[key] = Utils.recursiveParse(
AXY.Skill.Parameters[key]
));
});
// Main
(function () {
Game_Action.prototype.numRepeats = function () {
//console.log(this.item());
var repeats = this.item().meta.axy_skill_repeat || this.item().repeats;
if (this.isAttack()) {
repeats += this.subject().attackTimesAdd();
}
return Math.floor(repeats);
};
Game_Action.prototype.repeatTargets = function (targets) {
var repeatedTargets = [];
var repeats = this.numRepeats();
//console.log(this.item().meta.axy_skill_mode);
var _tmp = this.item().meta.axy_skill_mode;
switch (_tmp == undefined ? '' : _tmp.toLowerCase()) {
case 'a': //one by one, totals = repeats*targets
for (var j = 0; j < repeats; j++) {
for (var i = 0; i < targets.length; i++) {
var target = targets[i];
if (target) {
repeatedTargets.push(target);
//console.log('a');
}
}
}
break;
case 'b': //one by one, totals = repeats
for (var j = 0; j < repeats;) {
for (var i = 0; i < targets.length; i++) {
var target = targets[i];
if (target) {
repeatedTargets.push(target);
j++;
//console.log('b');
}
}
}
break;
case 'c': //round by round, totals = repeats*targets
for (var j = 0; j < repeats; j++) {
targets = [];
if (!this._forcing && this.subject().isConfused()) {
targets = [this.confusionTarget()];
} else if (this.isForOpponent()) {
targets = this.targetsForOpponents();
} else if (this.isForFriend()) {
targets = this.targetsForFriends();
}
for (var i = 0; i < targets.length; i++) {
var target = targets[i];
if (target) {
repeatedTargets.push(target);
//console.log('c');
}
}
}
break;
case 'd': //round by round, totals = repeats
for (var j = 0; j < repeats;) {
targets = [];
if (!this._forcing && this.subject().isConfused()) {
targets = [this.confusionTarget()];
} else if (this.isForOpponent()) {
targets = this.targetsForOpponents();
} else if (this.isForFriend()) {
targets = this.targetsForFriends();
}
for (var i = 0; i < targets.length; i++) {
var target = targets[i];
if (target) {
repeatedTargets.push(target);
j++;
//console.log('d');
}
}
}
break;
default:
for (var i = 0; i < targets.length; i++) {
var target = targets[i];
if (target) {
for (var j = 0; j < repeats; j++) {
repeatedTargets.push(target);
}
}
}
break;
}
return repeatedTargets;
};
})();