-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathAkeaAnimatedBattleSystem.js
1683 lines (1542 loc) · 59.8 KB
/
AkeaAnimatedBattleSystem.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
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//=============================================================================
// RPG Maker MZ AkeaAnimatedBattleSystem.js
//=============================================================================
/*:
* @target MZ
* @plugindesc Akea Animated Battle System 2
* @author Reisen (Mauricio Pastana)
* @url https://www.patreon.com/raizen884
* @help If you want to support me further more, become a patreon!
* You can chat, get support, report bugs on our discord Server: https://discord.gg/wsPeqeA
* You can get some beautiful battler with Vibrato! http://p3x774.web.fc2.com/
* This plugin is under zlib license.
* You can get always the most updated version here: https://github.com/comuns-rpgmaker/Akea/blob/master/AkeaAnimatedBattleSystem.js
* For further help, check out the documentation : https://comuns-rpgmaker.github.io/Akea/
* Welcome to the ultimate action battle system experience!
* For battle add-on developers head to NOTES FOR ADD-ON DEVS, in this code to
* know how to optimize your add for this system!
*
* You have in hands a very powerful battle system, to get a look at how the battle is
* configured, I would grab a demo first:
*
* With the demo there are some big configurations to do if you want to customize,
* you can also keep it simple if you wish to use more default-ish sv battlers.
*
* Each parameter has a text to help you now what it is configuring, but the main core of
* this battle system are the:
* Poses - Poses are the stance the battlers take when they meet certain conditions,
* poses can be an battler attacking, dodging, jumping, and anything else you
* think of.
* MZ has 18 default poses, which are:
* walk:
* wait:
* chant:
* guard:
* damage:
* evade:
* thrust:
* swing:
* missile:
* skill:
* spell:
* item:
* escape:
* victory:
* dying:
* abnormal
* sleep:
* dead:
* All those are already configured in this battle system by default, if you create a new
* pose that has the same name of this one it will be overwritten ONLY for the characters
* you choose the pose. Ah do remember, each battler(Actors or Enemies), after you configure the
* pose, you need to append them to that battler, that gives TOTAL freedom to have multiple
* poses for different battlers.
*
* The second part of this System is the actions, Actions are the movement the battler takes,
* Actions can be any movement like going toward character, jumping high, running, walking forward.
* Anything you want. Combine them with poses and you have a lot of freedom to create your
* dream battle for your game!
* You can add the following tags to your notes on skills or items of the database:
*
* <akeaActions>id: num</akeaActions> : Number of the action,
* Ex: <akeaAction>id: 2</akeaActions> to get the second action on the parameters
*
* <akeaActionEnemy>id: num</akeaActionEnemy> : exactly the same as above, but the action will be dealt
* to the target and not the user.
*
* <akeaAniTarget>id: number</akeaAniTarget> : Play a, database animation on the target Ex:
* <akeaAniTarget>id: 55</akeaAniTarget> : Plays animation id 55 on the Target
*
* <akeaAniSelf>id: number</akeaAniSelf> : Same as above, but on the user Ex:
* <akeaAniSelf>id: 55</akeaAniSelf> : Plays animation id 55 on the User
*
* <akeaScript>id: number</akeaScript> : Calls the expression configured on the Script Call parameters:
* <akeaScript>id: 33</akeaScript> : Calls the expression 33 on the parameters
*
* <akeaSkill>id: number</akeaSkill> : Appends skill to the current skill, just be careful to not make loops:
* <akeaSkill>id: 27</akeaSkill> : Calls the skill 27, all animations will be added to the current one
*
* <akeaHit>damage: number</akeaHit> : Calls a damage to the target, this damage is in percent according
* to the same formula in that skill on the database
* <akeaHit>id: 50</akeaHit> : Calls a hit for aproximately 50% damage of the skill formula
*
* <akeaHitWeapon>damage: damage</akeaHitWeapon> : Same as above, but with weapon animation
* to the same formula in that skill on the database
* <akeaHitWeapon 30> : Calls a hit for aproximately 30% damage of the skill formula
*
* <akeaHitAll>damage: damage</akeaHitAll> : Same as above, but with all targets
* <akeaHitAll>damage: 50</akeaHitAll> : Calls a hit for aproximately 50% damage of the skill formula
*
* <akeaWait>time: time</akeaWait> : Waits a certain time before the next action, in frames, usually 60 = 1 second
* <akeaWait>time: 60</akeaWait> : Waits 60 frames (1 second)
*
* <akeaRandomize></akeaRandomize> : Randomizes the target, choose random target on the skill and this
* will change targets in the middle of the Action!
*
*
*
* That is the basics, if you have any more question, head toward our discord server for
* further support.
* Do remeber this system was made optimized to accept most add-ons, so do not hesitate to
* try an add-on with it!
*
* @param Frame Configuration
* @type struct<PosesFrames>[]
* @text Spritesheet Configuration
* @desc Configure Poses Spritesheet here if want to add different type of spritesheets.
*
* @param Actor Configuration
* @type struct<ActorPoses>[]
* @text Actor Spritesheet Configuration
* @desc Configure Actor Spritesheet here, if an actor is not configured here, default spritesheet will be used.
* @param Actor Poses
* @type struct<EmbedPoseActor>[]
* @text Actor Poses Configuration
* @desc You can add any number of poses to an actor ID
* @param Enemy Configuration
* @type struct<EnemyPoses>[]
* @text Enemy Spritesheet Configuration
* @desc Configure Enemy Spritesheet here, if an enemy is not configured here, he will not use spritesheets.
* @param Enemy Poses
* @type struct<EmbedPoseEnemy>[]
* @text Enemy Poses Configuration
* @desc You can add any number of poses to an enemy ID
* @param Poses
* @type struct<Poses>[]
* @text All poses configuration
* @desc Configure any extra pose here, if you use the same name as an existing pose, it will use this one instead
* @param Actions
* @type struct<Actions>[]
* @text All action configuration
* @desc Configure all actions here, actions are the movement from the battlers
* @param Script
* @type struct<Script>[]
* @text Script Calls
* @desc Configure if any script call to be used during actions
* @param entryActors
* @type struct<EntryPose>
* @text Entry Actors
* @desc Action of actors entering the battle
* @param entryEnemies
* @type struct<EntryPose>
* @text Entry Enemies
* @desc Action id of enemies entering the battle
* @param returnAction
* @type number
* @text Step Back Action
* @desc Action number to return battlers
* @param idleAction
* @type number
* @text Standing Action
* @desc Action number that battlers will have when on starting point
* @param stepForward
* @type number
* @text Step Forward Action
* @desc Action number to make battlers step forward
* @param retreat
* @type number
* @text Retreat Action
* @desc Action number to make battlers retreat
* @param damage
* @type number
* @text Damage Action
* @desc Action number to make battlers take damage
* @param evade
* @type number
* @text Evade Action
* @desc Action number to make battlers evade hits
* @param shortNoteNotation
* @type boolean
* @text Short Note Notation
* @desc Set true to use short note notation on skills and weapon notes
*/
/*~struct~EntryPose:
* @param action
* @type number
* @default 1
* @desc Id of the action to be used for entering the battlefield
* @param offsetX
* @type number
* @default 400
* @min -10000
* @desc Offset in X from the starting point
* @param offsetY
* @type number
* @default -50
* @min -10000
* @desc Offset in Y from the starting point
* @param homeX
* @type text
* @default 600 + index * 32
* @desc formula of the battlers X final spot when on the battle (only actors)
* @param homeY
* @type text
* @default 280 + index * 48
* @desc formula of the battlers Y final spot when on the battle (only actors)
*/
/*~struct~EmbedPoseActor:
* @param id
* @type actor
* @default 1
* @desc Id of the Actor/Enemy to add the poses
* @param poses
* @type number[]
* @desc Poses that will be loaded for this character, they are configures on "Poses"
*/
/*~struct~EmbedPoseEnemy:
* @param id
* @type enemy
* @default 1
* @desc Id of the Actor/Enemy to add the poses
* @param poses
* @type number[]
* @desc Poses that will be loaded for this character, they are configures on "Poses"
*/
/*~struct~Poses:
* @param info
* @type string
* @default info
* @desc This area is free to use to help organization
* @param name
* @type string
* @default stand
* @desc Name of the Pose, you can duplicate name poses for different indexes
* @param InOut
* @type boolean
* @default false
* @desc If false, frames will rotate like usual 1-2-3-1-2, if true 1-2-3-4-3-2-1-2
* @param loop
* @type boolean
* @default true
* @desc If true, animation will loop
* @param frequency
* @type number
* @default 12
* @desc the frequency the frame animates, 12 is default, the lower the faster.
* @param poseIndex
* @type number
* @default 1
* @desc index of the pose in the spritesheet
*/
/*~struct~ActorPoses:
* @param id
* @type actor
* @default 1
* @desc Id of actor or enemy on the database
* @param baseSpritesheet
* @type number
* @default 1
* @desc Spritesheet to be used, configure the spritesheets on Frame Configuration, 0 for default spritesheet poses.
*/
/*~struct~EnemyPoses:
* @param id
* @type enemy
* @default 1
* @desc Id of actor or enemy on the database
* @param baseSpritesheet
* @type number
* @default 1
* @desc Spritesheet to be used, configure the spritesheets on Frame Configuration, 0 for default spritesheet poses.
* @param svBattler
* @type file
* @dir img/sv_enemies/
* @desc Image of the enemy SV Battler
*/
/*~struct~PosesFrames:
* @param FrameNum
* @type number
* @default 4
* @desc Numbers of maximum frames, you can configure the frames individually also
* @param SpritesheetHeight
* @type number
* @default 6
* @desc Spritesheet height, the number of poses from up to down (default has 6)
* @param SpritesheetWidth
* @type number
* @default 9
* @desc Spritesheet width, the number of poses from left to right (default has 9)
*/
/*~struct~Actions:
* @param info
* @type string
* @default info
* @desc This area is free to use to help organization
* @param pose
* @type text
* @default waiting
* @desc Name of the pose you want this action to make, look at help for default poses
* @param time
* @type number
* @default 10
* @desc Time in frames to execute this action
* @param movementType
* @type select
* @option absolute
* @option fromHome
* @option target
* @option noMove
* @desc The type of movement, absolute considers where the character is, fromHome where is his "base", target goes to target.
* @param offsetX
* @type number
* @default 10
* @max 10000
* @min -10000
* @desc how much in X character will move, depends on the movement Type selected
* @param offsetY
* @type number
* @default 10
* @max 10000
* @min -10000
* @desc how much in Y character will move, depends on the movement Type selected
* @param jumpHeight
* @type number
* @default 0
* @desc Height of the jump, 0 for no jump.
* @param levitate
* @type boolean
* @default false
* @desc If true, shadow will stay in its place.
* @param mirror
* @type boolean
* @default false
* @desc mirror action?
*/
/*~struct~Script:
* @param scriptCall
* @type note
* @default alert("This is a Script Call")
* @desc Put the script call here.
*/
/*
|| NOTES FOR ADD-ON DEVS!!!!
||
|| Most add-ons should work fine for this system, but if you do wish to
|| further improve your add-on experience with the plugin, you will do as it follows.
\\
\\ callAkeaActions : translates the commands in the notes from the skill/item through a regex
\\ <akeaNameAction yourparameters>
\\ or for Regular expressions Group 1 <akeaNameAction yourparameters>
\\ Group 2 NameAction Group 3 yourparameters
\\ pretty simple right? RegExp.$3 will hold your parameters and RegExp.$2 your action name.
\\ Below is after the action has been translated, when it will occur on the action.
\\ It is a FIFO, so you can know the order of the actions here.
\\ The Game_Akea_Actions and Game_Akea_Action hold the actions that will be passed to the
\\ Sprite, you can if you wish to add new functions to better improve compatibility.
\\ When creating your add-on, correctly alias callAkeaActions and manageAkeaActions
\\ Example Below of a picture add-on.
let _specificName_Game_Battler_callAkeaActions = Game_Battler.prototype.callAkeaActions
Game_Battler.prototype.callAkeaActions = function (actionName, parameters, action, targets) {
_specificName_Game_Battler_callAkeaActions.call(this, ...arguments);
if (RegExp.$2 == "Picture") { //Which would be called <akeaPicture id>
this._akeaAnimatedBSActions.addCustomAddon(YourId, targets, actionName, this, action, parameters);
OR A new one creating based on the Game_Akea_Action structure
this._akeaAnimatedBSActions.addPicture(YourId, targets, actionName, this, action);
}
}
let _specificName_Sprite_Battler_manageAkeaActions = Sprite_Battler.prototype.manageAkeaActions
Sprite_Battler.prototype.manageAkeaActions = function (action) {
_specificName_Sprite_Battler_manageAkeaActions.call(this, ...arguments);
if (action.getActionType() == "Picture") { //Which would be called <akeaPicture id>
this.callMyFunction(action.getId(), action.getObject()); // If you used the addCustomAddon the parameters will be stored on getObject
}
}
You can retrieve the targes of the action
action.getTargets()
The battler doing the action
action.getSubject()
or the action itself
action.getAction()
or all the parameters passed if you used addCustomAddon
action.getObject()
Pretty simple right? Any questions, you know where to find me :)
*/
// NÃO MEXE AQUI POR FAVOR :(!
// No touching this part!
var Akea = Akea || {};
Akea.BattleSystem = Akea.BattleSystem || {};
Akea.BattleSystem.VERSION = [1, 1, 11];
Akea.BattleSystem.GlobalSettings = Akea.BattleSystem.GlobalSettings || {};
Akea.BattleSystem.GlobalSettings['shortNoteNotation'] = PluginManager.parameters('AkeaAnimatedBattleSystem')['shortNoteNotation'] === 'true';
function checkDefaultParam(parameters, actionName){
if (parameters.indexOf(':') === -1) {
switch (actionName) {
case "Randomize":
return '';
case "Actions":
case "ActionEnemy":
case "AniTarget":
case "AniSelf":
case "Script":
case "Skill":
return `id: ${parameters}`;
case "HitWeapon":
case "Hit":
case "HitAll":
return `damage: ${parameters}`;
case "Wait":
return `time: ${parameters}`;
}
} else {
return parameters;
}
}
"use strict";
Game_Battler.prototype.callAkeaActions = function (actionName, parameters, action, targets) {
let parsedParams = {};
let checkedParameters = checkDefaultParam(parameters, actionName);
let regex = /(\w+):\s*([^\s]*)/gm;
let id;
let param;
do {
param = regex.exec(checkedParameters);
if (param) {
switch (RegExp.$1) {
case "id":
case "damage":
case "time":
parsedParams[RegExp.$1] = parseInt(RegExp.$2);
break;
default:
parsedParams[RegExp.$1] = RegExp.$2;
break;
}
}
} while (param);
for (let key in parsedParams){
id = parsedParams[key];
break;
}
switch (actionName) {
case "Randomize":
this._akeaAnimatedBSActions.addAkeaHit(id, targets, actionName, this, action);
break;
case "Actions":
this._akeaAnimatedBSActions.addAkeaSkillActions(id, targets, actionName, action);
break;
case "ActionEnemy":
this._akeaAnimatedBSActions.addAkeaSkillActionsEnemy(id, targets, actionName, this, action);
break;
case "AniTarget":
this._akeaAnimatedBSActions.addAkeaAnimation(id, targets, actionName, action);
break;
case "AniSelf":
this._akeaAnimatedBSActions.addAkeaAnimation(id, [this], actionName, action);
break;
case "Script":
this._akeaAnimatedBSActions.addAkeaScript(id, targets, actionName, this, action);
break;
case "Skill":
action = JsonEx.parse(JsonEx.stringify(this.initialAction));
action.setSkill(id);
let newTargets = action.makeTargets();
this.translateSkillActions(action, newTargets, $dataSkills[id].note, true);
break;
case "HitWeapon":
case "Hit":
this._akeaAnimatedBSActions.addAkeaHit(id, targets, actionName, this, action);
break;
case "HitAll":
this._akeaAnimatedBSActions.addAkeaHit(id, targets, actionName, this, action);
break;
case "Wait":
this._akeaAnimatedBSActions.addAkeaHit(id, targets, actionName, this, action);
break;
}
};
Sprite_Battler.prototype.manageAkeaActions = function (action) {
this._movementDuration = this._akeaMaxDuration = 1;
let subject;
let moveAction;
let targets;
let scriptCall;
let originalLength;
if (action.getTargets() && (!action.getTargets()[0] || action.getTargets()[0].hp == 0)) {
if (action.getTargets()[0] && $dataSkills[action.getAction().item().id].scope != 0) {
action.getTargets()[0].clearAkeaAnimatedBSActions();
}
if (action.getTargets().length > 0 && action.getTargets()[0].hp == 0 && $dataSkills[action.getAction().item().id].scope == 1) {
action.getTargets()[0].clearAkeaAnimatedBSActions();
BattleManager.akeaEmptyWindow();
return;
}
this._battler.getAkeaAnimatedBSActions().newTarget();
BattleManager.akeaEmptyWindow();
}
if (action.getTargets().length == 0 && $dataSkills[action.getAction().item().id].scope != 0) {
targets = action.getTargets();
this._battler.clearAkeaAnimatedBSActions();
return;
}
switch (action.getActionType()) {
case "Randomize":
this._battler.getAkeaAnimatedBSActions().isSingleTarget = true;
this._battler.getAkeaAnimatedBSActions().newTarget();
break;
case "Actions":
this.akeaActionTranslate(action);
break;
case "ActionEnemy":
moveAction = action.getAction();
action.getTargets()[0]._akeaAnimatedBSActions.addAkeaSkillActions(action.getId(), action.getEnemy(), "Actions", moveAction);
break;
case "AniTarget":
$gameTemp.requestAnimation(action.getTargets(), action.getId());
break;
case "AniSelf":
$gameTemp.requestAnimation([this._battler], action.getId());
break;
case "Script":
subject = action.getSubject();
targets = action.getTargets();
scriptCall = action.getScript();
eval(scriptCall);
break;
case "HitWeapon":
this._battler.performAttack();
case "Hit":
subject = action.getSubject();
targets = action.getTargets();
moveAction = action.getAction();
moveAction.applyAkeaHit(targets[0], action.getId())
originalLength = BattleManager.getWindowMethodsLength();
BattleManager._logWindow.push("popupDamage", (targets[0]));
BattleManager._logWindow.displayActionResults(subject, targets[0])
BattleManager.startActionAkea(subject, moveAction, targets);
BattleManager.akeaEmptyWindow(originalLength);
BattleManager._logWindow.displayChangedStates(targets[0]);
this._battler.getAkeaAnimatedBSActions().originalTarget(this._battler.initialTargets);
break;
case "HitAll":
subject = action.getSubject();
targets = action.getTargets();
moveAction = action.getAction();
originalLength = BattleManager.getWindowMethodsLength();
for (let t of targets) {
moveAction.applyAkeaHit(t, action.getId())
BattleManager._logWindow.push("popupDamage", (t));
BattleManager._logWindow.displayActionResults(subject, t)
}
BattleManager.startActionAkea(subject, moveAction, targets);
BattleManager.akeaEmptyWindow(originalLength);
for (let t of targets) { BattleManager._logWindow.displayChangedStates(t) };
this._battler.getAkeaAnimatedBSActions().originalTarget(this._battler.initialTargets);
break;
case "FinishAction":
this._movementDuration = this._akeaMaxDuration = 30;
this._jumpHeight = 0;
subject = action.getSubject();
targets = action.getTargets();
moveAction = action.getAction();
this._battler = subject;
if (this._battler.getAkeaAnimatedBSActions().isSingleTarget) {
BattleManager.startActionLast(subject, moveAction, [targets[0]]);
}
BattleManager.startActionLast(subject, moveAction, targets);
break
case "Wait":
this._jumpHeight = 0;
this._movementDuration = this._akeaMaxDuration = action.getId();
break
}
}
//-----------------------------------------------------------------------------
// Game_Akea_Actions
//
// This class manages Akea Battle Actions
function Game_Akea_Actions() {
this.initialize(...arguments);
}
Game_Akea_Actions.prototype = Object.create(Object.prototype);
Game_Akea_Actions.prototype.constructor = Game_Akea_Actions;
Game_Akea_Actions.prototype.initialize = function () {
this._actions = [];
this.action = "";
this.isSingleTarget = false;
const paramActions = PluginManager.parameters('AkeaAnimatedBattleSystem');
this._akeaSkillList = JSON.parse(paramActions['Actions']);
this._akeaScriptList = JSON.parse(paramActions['Script']);
};
Game_Akea_Actions.prototype.newTarget = function () {
let newtarget = this.action.makeTargets();
for (const action of this._actions) { action.setTargets(newtarget) }
}
Game_Akea_Actions.prototype.originalTarget = function (targets) {
for (const action of this._actions) { action.setTargets(targets) }
}
Game_Akea_Actions.prototype.idToAction = function (id, targets, moveAction) {
let actionObj = JSON.parse(this._akeaSkillList[id - 1]);
let action = new Game_Akea_Action();
let mirror = actionObj.mirror == "true" ? true : false;
action.setMovementType(actionObj.movementType);
action.setPose(actionObj.pose);
action.setDuration(parseInt(actionObj.time));
action.setOffsetX(parseInt(actionObj.offsetX));
action.setOffsetY(parseInt(actionObj.offsetY));
action.setJumpHeight(parseInt(actionObj.jumpHeight));
action.setTargets(targets);
action.setMirror(mirror);
action.setAction(moveAction);
this.action = moveAction;
this._actions.push(action);
}
Game_Akea_Actions.prototype.addAkeaSkillActions = function (id, targets, type, moveAction) {
let actionObj = JSON.parse(this._akeaSkillList[id - 1]);
let action = new Game_Akea_Action();
let mirror = actionObj.mirror == "true" ? true : false;
action.setActionType(type);
action.setMovementType(actionObj.movementType);
action.setPose(actionObj.pose);
action.setDuration(parseInt(actionObj.time));
action.setOffsetX(parseInt(actionObj.offsetX));
action.setOffsetY(parseInt(actionObj.offsetY));
action.setJumpHeight(parseInt(actionObj.jumpHeight));
action.setTargets(targets);
action.setMirror(mirror);
action.setAction(moveAction);
action.setLevitation(actionObj.levitate == "true" ? true : false);
this.action = moveAction;
this._actions.push(action);
}
Game_Akea_Actions.prototype.addAkeaSkillActionsEnemy = function (id, targets, type, subject, moveAction) {
let actionObj = JSON.parse(this._akeaSkillList[id - 1]);
let action = new Game_Akea_Action();
action.setId(id);
action.setActionType(type);
action.setMovementType(actionObj.movementType);
action.setPose(actionObj.pose);
action.setDuration(parseInt(actionObj.time));
action.setOffsetX(parseInt(actionObj.offsetX));
action.setOffsetY(parseInt(actionObj.offsetY));
action.setJumpHeight(parseInt(actionObj.jumpHeight));
action.setTargets(targets);
action.setEnemy(subject);
action.setAction(moveAction);
this.action = moveAction;
this._actions.push(action);
}
Game_Akea_Actions.prototype.addCustomAddon = function (id, targets, type, subject, moveAction, object) {
this.addAkeaHit(id, targets, type, subject, moveAction, object);
}
Game_Akea_Actions.prototype.addAkeaHit = function (id, targets, type, subject, moveAction, object) {
let action = new Game_Akea_Action();
action.setActionType(type);
action.setId(id);
action.setTargets(targets);
action.setSubject(subject);
action.setAction(moveAction);
action.setObject(object);
this.action = moveAction;
this._actions.push(action);
}
Game_Akea_Actions.prototype.addAkeaAnimation = function (id, targets, type, moveAction) {
let action = new Game_Akea_Action();
action.setActionType(type);
action.setId(id);
action.setTargets(targets);
action.setAction(moveAction);
this.action = moveAction;
this._actions.push(action);
}
Game_Akea_Actions.prototype.addAkeaScript = function (id, targets, type, subject, moveAction) {
let actionObj = JSON.parse(this._akeaScriptList[id - 1]);
let action = new Game_Akea_Action();
action.setActionType(type);
action.setScript(actionObj.scriptCall);
action.setTargets(targets);
action.setSubject(subject);
action.setAction(moveAction);
this.action = moveAction;
this._actions.push(action);
}
Game_Akea_Actions.prototype.addAkeaNewSkill = function (id, targets, type, moveAction) {
let actionObj = JSON.parse(this._akeaSkillList[id - 1]);
let action = new Game_Akea_Action();
action.setActionType(type);
action.setScript(actionObj.scriptCall);
action.setTargets(targets);
action.setAction(moveAction);
this.action = moveAction;
this._actions.push(action);
}
Game_Akea_Actions.prototype.hasActions = function () {
return this._actions.length > 0;
};
Game_Akea_Actions.prototype.canContinue = function () {
return this._actions.length == 0;
};
Game_Akea_Actions.prototype.count = function () {
return this._actions.length;
};
Game_Akea_Actions.prototype.unloadAction = function () {
return this._actions.shift();
};
//-----------------------------------------------------------------------------
// Game_Akea_Action
//
// This class manages Akea an individual Battle Action
function Game_Akea_Action() {
this.initialize(...arguments);
}
Game_Akea_Action.prototype = Object.create(Object.prototype);
Game_Akea_Action.prototype.constructor = Game_Akea_Action;
Game_Akea_Action.prototype.initialize = function () {
this._pose = "";
this._movementType = "";
this._actionType = "";
this._offsetX = 0;
this._offsetY = 0;
this._jumpHeight = 0;
this._actionId = 0;
this._duration = 0;
this._targets = false;
this._enemy = "";
this._id = 0;
this._mirror = false;
this._object;
};
Game_Akea_Action.prototype.setObject = function (object) {
this._object = object;
}
Game_Akea_Action.prototype.setPose = function (pose) {
this._pose = pose;
}
Game_Akea_Action.prototype.setMovementType = function (movementType) {
this._movementType = movementType;
}
Game_Akea_Action.prototype.setActionType = function (actionType) {
this._actionType = actionType;
}
Game_Akea_Action.prototype.setOffsetX = function (offsetX) {
this._offsetX = offsetX;
}
Game_Akea_Action.prototype.setOffsetY = function (offsetY) {
this._offsetY = offsetY;
}
Game_Akea_Action.prototype.setJumpHeight = function (jumpHeight) {
this._jumpHeight = jumpHeight;
}
Game_Akea_Action.prototype.setActionId = function (actionId) {
this._actionId = actionId;
}
Game_Akea_Action.prototype.setDuration = function (duration) {
this._duration = duration;
}
Game_Akea_Action.prototype.setTargets = function (targets) {
this._targets = targets;
}
Game_Akea_Action.prototype.setScript = function (text) {
this._script = text;
}
Game_Akea_Action.prototype.setEnemy = function (enemy) {
this._enemy = enemy;
}
Game_Akea_Action.prototype.setId = function (id) {
this._id = id;
}
Game_Akea_Action.prototype.setSubject = function (subject) {
this._subject = subject;
}
Game_Akea_Action.prototype.setAction = function (action) {
this._action = action;
}
Game_Akea_Action.prototype.setMirror = function (mirror) {
this._mirror = mirror;
}
Game_Akea_Action.prototype.setLevitation = function (levitate) {
this._levitate = levitate;
}
Game_Akea_Action.prototype.getLevitation = function () {
return this._levitate;
}
Game_Akea_Action.prototype.getMirror = function () {
return this._mirror;
}
Game_Akea_Action.prototype.getAction = function () {
return this._action;
}
Game_Akea_Action.prototype.getSubject = function () {
return this._subject;
}
Game_Akea_Action.prototype.getId = function () {
return this._id;
}
Game_Akea_Action.prototype.getEnemy = function () {
return this._enemy;
}
Game_Akea_Action.prototype.getScript = function () {
return this._script;
}
Game_Akea_Action.prototype.getTargets = function () {
return this._targets;
}
Game_Akea_Action.prototype.getActionType = function () {
return this._actionType;
}
Game_Akea_Action.prototype.getPose = function () {
return this._pose;
}
Game_Akea_Action.prototype.getMovementType = function () {
return this._movementType;
}
Game_Akea_Action.prototype.getOffsetX = function () {
return this._offsetX;
}
Game_Akea_Action.prototype.getOffsetY = function () {
return this._offsetY;
}
Game_Akea_Action.prototype.getJumpHeight = function () {
return this._jumpHeight;
}
Game_Akea_Action.prototype.getActionId = function () {
return this._actionId;
}
Game_Akea_Action.prototype.getDuration = function () {
return this._duration;
}
Game_Akea_Action.prototype.getObject = function () {
return this._object;
}
Sprite_Battler.prototype.startMotion = function (motionType) {
const newMotion = this.akeaMotions[motionType];
if (!newMotion) {
//alert(`${motionType} is not correctly configured!`);
return;
}
if (this._motion !== newMotion) {
this._akeaAnimatedBSFrameSpeed = newMotion.speed;
this._akeaInOutFrame = newMotion.inOut;
this._akeaPatternMotion = 1;
this._motion = newMotion;
this._motionCount = 0;
this._pattern = 0;
}
};
Sprite_Battler.prototype.refreshMotion = function () {
if (this._battler.motionType() == "damage") {
this.takeDamage();
return;
} else if (this._battler.motionType() == "evade") {
this.evadeHit();
return;
}
if (this._movementDuration > 0) {
return
}
this.startMove(this._offsetX, this._offsetY, 0);
const actor = this._battler.isEnemy() ? this._enemy : this._actor;
if (actor) {
const stateMotion = actor.stateMotionIndex();
if (actor.isInputting() || actor.isActing()) {
this.startMotion("walk");
} else if (stateMotion === 3) {
this.startMotion("dead");
} else if (stateMotion === 2) {
this.startMotion("sleep");
} else if (actor.isChanting()) {
this.startMotion("chant");
} else if (actor.isGuard() || actor.isGuardWaiting()) {
this.startMotion("guard");
} else if (stateMotion === 1) {
this.startMotion("abnormal");
} else if (actor.isDying()) {
this.startMotion("dying");
} else if (actor.isUndecided()) {
this.startMotion("walk");
} else {
this.startMotion("wait");
}
}
};
Sprite_Battler.prototype.updateMove = function () {
if (this._movementDuration > 0) {
this._currentJumpAcceleration = (this._movementDuration * 2 - this._akeaMaxDuration) * this._jumpHeight / 10;
this._currentJumpHeight += Math.floor(this._currentJumpAcceleration);
const d = this._movementDuration;
this._offsetX = (this._offsetX * (d - 1) + this._targetOffsetX) / d;
this._offsetY = (this._offsetY * (d - 1) + this._targetOffsetY) / d;
this._movementDuration--;
}
if (this._movementDuration === 0) {
this._currentJumpHeight = 0;
}
if (this._movementDuration <= 0 && this._battler.getAkeaAnimatedBSActions().hasActions()) {
this.unloadMovementAkea();
} else if (this._battler.getAkeaAnimatedBSActions().canContinue()) {
this.onMoveEnd();
this._battler._akeaRetreating = false
}
};
Sprite_Battler.prototype.createDamageSprite = function () {
const last = this._damages[this._damages.length - 1];
const sprite = new Sprite_Damage();
if (last) {
sprite.x = last.x + 8;
sprite.y = last.y - 16;
} else {
sprite.x = this.x + this.damageOffsetX();
sprite.y = this.y + this.damageOffsetY();
}
sprite.setup(this._battler);
this._damages.push(sprite);
this.parent.addChild(sprite);
sprite._zIndex = 10000;
};
Sprite_Battler.prototype.updateMotionCount = function () {
if (this._motion && ++this._motionCount >= this.akeaMotionspeed()) {
if (this._motion.loop) {
this._pattern = this.updateAkeaPattern();
} else if (this._pattern + 1 < this.akeaMaxFrame) {
this._pattern++;
} else {
this.refreshMotion();
}
this._motionCount = 0;
};
};
Sprite_Battler.prototype.updateAkeaFrame = function () {
const bitmap = this._mainSprite.bitmap;
if (bitmap) {
const motionIndex = this._motion ? this._motion.index : 0;
const pattern = this._pattern < this.akeaMaxFrame ? this._pattern : 1;
const cw = bitmap.width / this.akeaAnimatedBSMaxWidth;
const ch = bitmap.height / this.akeaAnimatedBSMaxHeight;
const cx = Math.floor(motionIndex / this.akeaAnimatedBSMaxHeight) * 3 + pattern;
const cy = motionIndex % this.akeaAnimatedBSMaxHeight;
this._mainSprite.setFrame(cx * cw, cy * ch, cw, ch);
this.setFrame(0, 0, cw, ch);
this.scale.x = this._akeaMirror ? -1 : 1;
if (this._akeaMirroredMoves) { this.scale.x *= -1 };
}
return; // Below is old Frame
}
Sprite_Battler.prototype.getJumpHeight = function () {
return this._currentJumpHeight;
}
Sprite_Battler.prototype.akeaActionTranslate = function (action) {
this._battler.requestMotion(action.getPose());
let offsetX = this._akeaMirroredMoves ? -action.getOffsetX() : action.getOffsetX();
let offsetY = this._akeaMirroredMoves ? -action.getOffsetY() : action.getOffsetY();
if (action.getMovementType() == "absolute") {
this.startMove(this._offsetX + offsetX, this._offsetY + offsetY, action.getDuration(), action.getJumpHeight(), action.getLevitation());
this._zIndex = this._offsetY + offsetY + this._homeY;
} else if (action.getMovementType() == "target") {
this.startMove(action.getTargets()[0].screenX() - this._homeX + offsetX, action.getTargets()[0].screenY() - this._homeY + offsetY, action.getDuration(), action.getJumpHeight(), action.getLevitation());
this._zIndex = action.getTargets()[0].screenY() + offsetY;
} else if (action.getMovementType() == "fromHome") {
this.startMove(offsetX, offsetY, action.getDuration(), action.getJumpHeight(), action.getLevitation());
this._zIndex = offsetY + this._homeY;
} else if (action.getMovementType() == "noMove") {
this.startMove(this._offsetX, this._offsetY, action.getDuration(), action.getJumpHeight(), action.getLevitation());
this._zIndex = this._offsetY + this._homeY;
}
this._akeaMirror = action.getMirror();
}
Sprite_Battler.prototype.unloadMovementAkea = function () {
let action = this._battler.getAkeaAnimatedBSActions().unloadAction();