-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathAkeaTeamSkill.js
468 lines (426 loc) · 21.2 KB
/
AkeaTeamSkill.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
/*:
//=============================================================================
// RPG Maker MZ - Akea Team Battle Skill
//=============================================================================
* @target MZ
* @plugindesc Akea Team Battle Skill
* @author Reisen (Mauricio Pastana)
* @url https://www.patreon.com/raizen884
* @orderAfter AkeaAnimatedBattleSystem
* @help Akea Team Battle Skill - this plugins is under zlib license
* For support and new plugins join our discord server! https://discord.gg/Kh9XXZ2
* Want to support new creations? be a patreon!
* To configure this plugin, just go to the parameters and create a new Team Skills Configuration
* When you create one you will first need to say what skill id it is on the Database.
* So you can create a kill like usually, then you set it up on the parameters.
* After that, you will set the group of members who can learn this skill, you can create
* as many groups as you want starting from 2. Each group can have as many actors as you want.
* So if you want a skill that uses 4 members of the party, you will need to create 4 groups.
*
* After creating the groups and putting each respective member on it, you will need to
* add the skills which affects the mp/tp usage of each actor.
* It needs to have the same length as the group of actors.
*
* Now you are ready to go! If you are using akea and want to make animations for
* each party member, do as it follows below.
* The actor in the first group will be the "anchor", so in the notetags he will be
* the one that dictates each other member
*
* The actions are <akeaTeam>action:Name of the action...
* <akeaTeam>
* action: Name of the action without the akea prefix Ex: for akeaCameraOnUser it becomes only
* action:CameraOnUser
* teamId: This is the position of the team on the group configured in the parameters,
* if the actor is on the second group of the parameters:
* teamId: 2
* Do note for the first group, you can use just the normal actions as usual.
* then you close it with
* </akeaTeam>
*
*
* <akeaTeam>action:Actions teamId:2 id: 8</akeaTeam>
* this will make the second member of the group do the Actions of id 8
*
* <akeaTeam>action:AniSelf teamId:2 id: 80</akeaTeam>
* this will play the animation of id 80 on the second member of the group in the parameters
*
* The same will follow using any other action for example.
* <akeaTeam>action:Hit teamId:3 damage: 230</akeaTeam>
* This will create a hit using the 3rd member of the group attributes for 230% damage.
* <akeaTeam>action:HitWeapon teamId:4 damage: 130</akeaTeam>
* This will create a hit using the 4th member of the group attributes for 130% damage.
* And showing the weapon animation
*
* You can use basically any action, if an action has not been mapped for team skills just
* contact me!
*
*
* @param Team Skills Configuration
* @type struct<TeamSkills>[]
* @text After Images Base Configuration
* @param learnSkill
* @type boolean
* @default true
* @text Automatic Skill Learn
* @desc If on you can learn skills automatically if all conditions are met.
*/
/*~struct~TeamSkills:
* @param skill
* @type skill
* @default 174
* @text Skill Id
* @desc Skill id of the team skill on the database
* @param members
* @type actor[][]
* @default [[2], [8]]
* @text Members Group
* @desc Group of members, you can add more than 1 actor in each group, you can add as many groups as you want.
* @param baseSkills
* @type skill[]
* @default [20, 21]
* @text Base Skills
* @desc Base skills for the groups above, these skills are used as bases for mp/tp cost, and skill learning.
*/
// NÃO MEXE AQUI POR FAVOR :(!
// No touching this part!
var Akea = Akea || {};
Akea.BattleTeamSkill = Akea.BattleTeamSkill || {};
Akea.BattleTeamSkill.VERSION = [1, 0, 3];
//if (!Akea.BattleSystem) throw new Error("AkeaBattleAfterImage plugin needs the AkeaAnimatedBattleSystem base.");
//if (Akea.BattleSystem.VERSION < [1, 1, 1]) throw new Error("This plugin only works with versions 1.1.1 or higher of the Akea Animated Battle System ");
//////////////////////////////////////////////////////////////////////////////////////////////////
// Akea Battler After Image
//////////////////////////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
(() => {
const pluginName = "AkeaTeamSkill";
Akea.params = PluginManager.parameters(pluginName);
Akea.BattleTeamSkill.TeamSkillGlobaConfigs = JSON.parse(Akea.params['Team Skills Configuration']);
Akea.BattleTeamSkill.TeamSkillJSON = [];
Akea.BattleTeamSkill.TeamSkill = [];
Akea.BattleTeamSkill.LearSkills = Akea.params['learnSkill'] == "true" ? true : false;
for (const teamSkill of Akea.BattleTeamSkill.TeamSkillGlobaConfigs) { Akea.BattleTeamSkill.TeamSkillJSON.push(JSON.parse(teamSkill)) };
for (const teamSkill of Akea.BattleTeamSkill.TeamSkillJSON) {
Akea.BattleTeamSkill.TeamSkill.push({
skill: parseInt(teamSkill.skill), members: JSON.parse(teamSkill.members).map(JSON.parse).map(a => a.map(parseInt)), baseSkill: JSON.parse(teamSkill.baseSkills).map(a => parseInt(a))
})
};
BattleManager.getAkeaTeamSkill = function () {
return this._akeaTeamSkills;
}
const _akeaTeamSkill_BattleManager_initMembers = BattleManager.initMembers;
BattleManager.initMembers = function () {
_akeaTeamSkill_BattleManager_initMembers.call(this, ...arguments);
this._akeaTeamSkills = new Game_AkeaTeamSkills();
}
const _akeaTeamSkill_BattleManager_endAction = BattleManager.endAction;
BattleManager.endAction = function () {
if (BattleManager.getAkeaTeamSkill().hasMember(this._subject)) {
for (const member of BattleManager.getAkeaTeamSkill().getTeam(this._subject)) {
this.endBattlerActions(member);
}
};
_akeaTeamSkill_BattleManager_endAction.call(this, ...arguments);
};
const _akeaTeamSkill_BattleManager_endTurn = BattleManager.endTurn;
BattleManager.endTurn = function () {
_akeaTeamSkill_BattleManager_endTurn.call(this, ...arguments);
this._akeaTeamSkills.clearTeams();
};
const _akeaTeamSkill_BattleManager_gainRewards = BattleManager.gainRewards;
BattleManager.gainRewards = function () {
_akeaTeamSkill_BattleManager_gainRewards.call(this, ...arguments);
if (Akea.BattleTeamSkill.LearSkills)
this.checkAkeaSkillChange();
};
BattleManager.canUseTeamSkill = function (skill, castingMember) {
let membersCasting = [];
const battleMembers = castingMember.isActor() ? $gameParty.battleMembers() : $gameTroop.members();
for (var n = 0; n < Akea.BattleTeamSkill.TeamSkill.filter(ts => ts.skill == skill.id)[0].members.length; n++) {
membersCasting[n] = BattleManager.akeaChooseCastingMembers(battleMembers, n, skill.id, this._phase != "input");
if (membersCasting[n].includes(castingMember)) {
membersCasting[n] = [castingMember];
}
let newItem = Akea.BattleTeamSkill.TeamSkill.filter(ts => ts.skill == skill.id)[0].baseSkill[n]
membersCasting[n] = membersCasting[n].filter(member => _akeaTeamSkill_Game_BattlerBase_meetsSkillConditions.call(member, $dataSkills[newItem]));
if (BattleManager.isTpb() && !membersCasting[n].some(member => member.isTpbCharged()))
return false;
if (membersCasting[n].length == 0) { return false };
}
return true;
};
BattleManager.akeaChooseCastingMembers = function (allMembers, groupNumber, skillId, checkTeam) {
let members = [];
const teamMembers = Akea.BattleTeamSkill.TeamSkill.filter(ts => ts.skill == skillId)[0].members
for (const member of allMembers) {
if (teamMembers[groupNumber].includes(member.actorId()) && member.hasSkill(skillId) && (checkTeam || !BattleManager.getAkeaTeamSkill().hasMember(member))) {
members.push(member);
}
}
return members;
};
BattleManager.finishActorInput = function () {
if (this._currentActor && this._currentActor.currentAction().isSkill() &&
Akea.BattleTeamSkill.TeamSkill.some(ts => ts.skill == this._currentActor.currentAction().item().id)) {
BattleManager.useTeamSkill(this._currentActor.currentAction().item(), BattleManager.actor());
if (BattleManager.isTpb()) {
this._currentActor = BattleManager.getAkeaTeamSkill().getTeam(this._currentActor)[0]
for (var n = 1; n < BattleManager.getAkeaTeamSkill().getTeam(this._currentActor).length; n++) {
BattleManager.endBattlerActions(BattleManager.getAkeaTeamSkill().getTeam(this._currentActor)[n])
}
}
}
if (this._currentActor) {
if (this.isTpb()) {
this._currentActor.startTpbCasting();
}
this._currentActor.setActionState("waiting");
}
};
BattleManager.changeCurrentActor = function (forward) {
const members = $gameParty.battleMembers();
let actor = this._currentActor;
for (; ;) {
const currentIndex = members.indexOf(actor);
actor = members[currentIndex + (forward ? 1 : -1)];
if (!actor || actor.canInput()) {
break;
}
}
this._currentActor = actor ? actor : null;
BattleManager.getAkeaTeamSkill().removeTeam(this._currentActor);
this.startActorInput();
};
BattleManager.useTeamSkill = function (skill, castingMember) {
let membersCasting = [];
const battleMembers = castingMember.isActor() ? $gameParty.battleMembers() : $gameTroop.members();
for (let n = 0; n < Akea.BattleTeamSkill.TeamSkill.filter(ts => ts.skill == skill.id)[0].members.length; n++) {
membersCasting[n] = this.akeaChooseCastingMembers(battleMembers, n, skill.id);
if (membersCasting[n].includes(castingMember)) {
membersCasting[n] = [castingMember];
}
let newItem = Akea.BattleTeamSkill.TeamSkill.filter(ts => ts.skill == skill.id)[0].baseSkill[n]
membersCasting[n] = membersCasting[n].filter(member => _akeaTeamSkill_Game_BattlerBase_meetsSkillConditions.call(member, $dataSkills[newItem]));
if (membersCasting[n].length == 0) { return false };
membersCasting[n] = membersCasting[n][0];
}
membersCasting = membersCasting.flat().sort(function compare(a, b) {
if ($gameParty.battleMembers().indexOf(a) > $gameParty.battleMembers().indexOf(b)) return 1;
if ($gameParty.battleMembers().indexOf(b) > $gameParty.battleMembers().indexOf(a)) return -1;
return 0;
})
for (let n = 0; n < membersCasting.length; n++) {
membersCasting[n].setAkeaTeamSkillIndex(n);
if (n == 0) {
membersCasting[n].setAction(0, castingMember.action(0));
}
else {
let newItem = Akea.BattleTeamSkill.TeamSkill.filter(ts => ts.skill == skill.id)[0].baseSkill[n]
_akeaTeamSkill_Game_Battler_useItem.call(membersCasting[n], $dataSkills[newItem]);
membersCasting[n].makeActions();
}
}
BattleManager.getAkeaTeamSkill().addNewTeam(membersCasting);
};
const _akeaTeamSkill_Game_BattlerBase_meetsSkillConditions = Game_BattlerBase.prototype.meetsSkillConditions;
Game_BattlerBase.prototype.meetsSkillConditions = function (skill) {
if (Akea.BattleTeamSkill.TeamSkill.some(ts => ts.skill == skill.id)) {// Create condition to check if it is a team Skill
return BattleManager.canUseTeamSkill(skill, this);
}
return _akeaTeamSkill_Game_BattlerBase_meetsSkillConditions.call(this, ...arguments);
};
const _akeaTeamSkill_Game_BattlerBase_canInput = Game_BattlerBase.prototype.canInput;
Game_BattlerBase.prototype.canInput = function () {
return this.akeaFirstTeamBattleSkill() && _akeaTeamSkill_Game_BattlerBase_canInput.call(this, ...arguments);
};
Game_BattlerBase.prototype.akeaFirstTeamBattleSkill = function () {
return this.getAkeaTeamSkill() <= 0;
}
Game_BattlerBase.prototype.setAkeaTeamSkillIndex = function (index) {
this._akeaTeamSkillIndex = index;
}
Game_BattlerBase.prototype.getAkeaTeamSkill = function () {
return this._akeaTeamSkillIndex;
}
const _akeaTeamSkill_Game_BattlerBase_initialize = Game_BattlerBase.prototype.initialize;
Game_BattlerBase.prototype.initialize = function () {
_akeaTeamSkill_Game_BattlerBase_initialize.call(this, ...arguments);
this._akeaTeamSkillIndex = -1;
};
Game_Battler.prototype.setAction = function (index, action) {
this._actions[index] = action;
};
const _akeaTeamSkill_Game_BattlerBase_canUse = Game_BattlerBase.prototype.canUse;
Game_BattlerBase.prototype.canUse = function (item) {
if (!item) { return false; }
let canUse = true;
if (BattleManager.getAkeaTeamSkill().hasMember(this)) {
if (BattleManager.isTpb() && BattleManager.getAkeaTeamSkill().hasMember(this)) { return true };
for (const member of BattleManager.getAkeaTeamSkill().getTeam(this)) {
canUse = canUse && _akeaTeamSkill_Game_BattlerBase_canUse.call(member, item);
}
} else {
canUse = _akeaTeamSkill_Game_BattlerBase_canUse.call(this, ...arguments);
}
return canUse;
};
//-----------------------------------------------------------------------------
// Game_AkeaTeamSkills
//
// The game object class for managing the after images.
//-----------------------------------------------------------------------------
function Game_AkeaTeamSkills() {
this.initialize(...arguments);
}
Game_AkeaTeamSkills.prototype.initialize = function () {
this._teamUps = [];
};
Game_AkeaTeamSkills.prototype.clearTeams = function () {
for (const team of this._teamUps) {
for (const member of team) {
member.setAkeaTeamSkillIndex(-1);
}
}
this._teamUps = [];
};
Game_AkeaTeamSkills.prototype.addNewTeam = function (members) {
this._teamUps.push(members);
};
Game_AkeaTeamSkills.prototype.hasMember = function (member) {
for (const team of this._teamUps) {
if (team.includes(member)) {
return true;
}
}
return false;
};
Game_AkeaTeamSkills.prototype.getTeam = function (member) {
for (const team of this._teamUps) {
if (team.includes(member)) {
return team;
}
}
return false;
};
Game_AkeaTeamSkills.prototype.removeTeam = function (removingMember) {
for (const team of this._teamUps) {
if (team.includes(removingMember)) {
for (const member of team) {
member.setAkeaTeamSkillIndex(-1);
}
this._teamUps.remove(team);
}
}
};
const _akeaTeamSkill_Window_BattleLog_startAction = Window_BattleLog.prototype.startAction;
Window_BattleLog.prototype.startAction = function (subject, action, targets) {
if (BattleManager.getAkeaTeamSkill().hasMember(subject)) {
this.processTeamSkill(subject, action, targets);
if (BattleManager.isTpb())
BattleManager.getAkeaTeamSkill().clearTeams();
} else {
_akeaTeamSkill_Window_BattleLog_startAction.call(this, ...arguments);
}
};
Window_BattleLog.prototype.processTeamSkill = function (subject, action, targets) {
const item = action.item();
const team = BattleManager.getAkeaTeamSkill().getTeam(subject);
//for (const member of team) { this.push("performActionStart", member, action) };
this.push("waitForMovement");
for (const member of team) { this.push("performAction", member, action) };
for (const member of team) { this.push("showAnimation", member, targets.clone(), item.animationId) };
for (const member of team) { this.displayAction(member, item) };
}
Game_Action.prototype.isValid = function () {
return (this._forcing && this.item()) || this.subject().canUse(this.item());
};
const _akeaTeamSkill_Game_Battler_useItem = Game_Battler.prototype.useItem;
Game_Battler.prototype.useItem = function (item) {
if (BattleManager.getAkeaTeamSkill().hasMember(this)) {
for (const member of BattleManager.getAkeaTeamSkill().getTeam(this)) {
let newItem = Akea.BattleTeamSkill.TeamSkill.filter(ts => ts.skill == item.id)[0].baseSkill[member.getAkeaTeamSkill()]
_akeaTeamSkill_Game_Battler_useItem.call(member, $dataSkills[newItem]);
}
} else {
_akeaTeamSkill_Game_Battler_useItem.call(this, ...arguments);
}
};
const _akeaTeamSkill_Game_Battler_callAkeaActions = Game_Battler.prototype.callAkeaActions;
Game_Battler.prototype.callAkeaActions = function (actionName, parameters, action, targets) {
_akeaTeamSkill_Game_Battler_callAkeaActions.call(this, ...arguments);
let regex = /(\w+):\s*([^\s]*)/gm;
let obj = {};
let param;
let id;
do {
param = regex.exec(parameters);
if (param) {
if (RegExp.$1 == "id" || RegExp.$1 == "damage") {
id = parseInt(RegExp.$2);
} else {
obj[RegExp.$1] = RegExp.$2;
}
}
} while (param);
if (!obj.teamId) { obj.teamId = 1 };
if (actionName == "Team") {
const subject = BattleManager.getAkeaTeamSkill().getTeam(this)[obj.teamId - 1]
subject.initialTargets = this.initialTargets;
this._akeaAnimatedBSActions.addCustomAddon(id, targets, "Team".concat(obj["action"]), subject, action, obj);
}
};
const _akeaTeamSkill_Sprite_Battler_manageAkeaActions = Sprite_Battler.prototype.manageAkeaActions
Sprite_Battler.prototype.manageAkeaActions = function (action) {
_akeaTeamSkill_Sprite_Battler_manageAkeaActions.call(this, ...arguments);
switch (action.getActionType()) {
case "TeamActions":
const params = action.getObject();
moveAction = action.getAction();
action.getSubject()._akeaAnimatedBSActions.addAkeaSkillActions(action.getId(), action.getTargets(), action.getActionType().replace("Team", ""), moveAction);
break;
case "TeamHitWeapon":
case "TeamHit":
action.getSubject()._akeaAnimatedBSActions.addAkeaHit(action.getId(), action.getTargets(), action.getActionType().replace("Team", ""), action.getSubject(), action.getAction());
break;
case "TeamHitAll":
action.getSubject()._akeaAnimatedBSActions.addAkeaHit(action.getId(), action.getTargets(), action.getActionType().replace("Team", ""), action.getSubject(), action.getAction());
break;
case "TeamAniSelf":
action.getSubject()._akeaAnimatedBSActions.addAkeaAnimation(action.getId(), [action.getSubject()], action.getActionType().replace("Team", ""), action.getAction());
break;
case "TeamAfterImage":
action.getSubject()._akeaAnimatedBSActions.addCustomAddon(action.getId(), action.getTargets(), action.getActionType().replace("Team", ""), action.getSubject(), action.getAction(), action.getObject());
break;
case "TeamStopAfterImage":
action.getSubject()._akeaAnimatedBSActions.addCustomAddon(action.getId(), action.getTargets(), action.getActionType().replace("Team", ""), action.getSubject(), action.getAction(), action.getObject());
break;
case "TeamCameraOnUser":
case "TeamCameraOnTarget":
case "TeamCameraAbsolute":
case "TeamCameraZoom":
case "TeamCameraOffset":
case "TeamCameraMode":
case "TeamCameraReset":
action.getSubject()._akeaAnimatedBSActions.addCustomAddon(action.getObject(), action.getTargets(), action.getActionType().replace("Team", ""), action.getSubject(), action.getAction(), action.getObject());
break;
}
}
BattleManager.checkAkeaSkillChange = function () {
for (const teamSkill of Akea.BattleTeamSkill.TeamSkill) {
let canLearn = true;
for (const members of teamSkill.members) {
if (!$gameParty.members().some(actor => members.includes(actor.actorId()))) { canLearn = false };
}
if (canLearn) {
for (const members of teamSkill.members) {
for (const member of members) {
for (const actor of $gameParty.members().filter(actor => actor.actorId() == member)) {
actor.learnSkill(teamSkill.skill)
}
}
}
}
}
};
BattleManager._akeaTeamSkills = new Game_AkeaTeamSkills();
})();