-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathLeTBS.js
9711 lines (8735 loc) · 334 KB
/
LeTBS.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
/*
#=============================================================================
# Lecode's Tactical Battle System
# LeTBS.js
# By Lecode
# Version 0.7d
#-----------------------------------------------------------------------------
# TERMS OF USE
#-----------------------------------------------------------------------------
# https://github.com/LecodeMV/leTBS/blob/master/LICENSE.txt
#-----------------------------------------------------------------------------
# Version History
#-----------------------------------------------------------------------------
# - 0.0 : Beta started.
# - 0.1 : Battles start and end correctly.
# Troop events are correctly triggered in battle. (mostly)
# Added an end window which appears when pressing ESC on the command window.
# That window allows you to escape and change options.
# Added the tags and parameters for one time move only and one time offense only.
# Fixed some errors in the demo.
# - 0.2 : The Item command is functional.
# Added custom move scopes and options.
# Downgraded the turn order visual for now to fix some bugs.
# Added a new option for turn order: "fair repartition".
# Status window is updated when a target is selected.
# There's now a help window. Status window is shifted if needed.
# - 0.3 : The mouse is supported.
# Prototype of the projectiles system.
# Prototype of the AI.
# Fixed a bug and improved the Turn Order Visual Version A.
# 85% of the tile effects and marks system.
# Fixed a bug with the line of sight.
# - 0.4 : Now there is ony one unique tag.
# Support custom sprites. (Yay !)
# AI improved.
# Added AI patterns. They can be used in AI commands.
# Now each entity has his own sequence system. This allows simultaneous sequences.
# Added some sequence commands.
# Now a sequence is played for the following events:
# battle start, turn start, victory, death, damaged, healed, buffed, weakened.
# - 0.5 : Projectile system completed
# Tile, Mark & Aura effects completed
# Added knockback damage
# Fixed and added some sequence commands
# Fixed some bugs
# Created DamagePopupEX
# - 0.6 : Added these sequence commands: 'call_for_every_cell', 'call_for_every_entity', 'reach_target'
# Added these sequence commands: 'save_cells', 'save_entities'
# Added these tag instructions: 'sprite_name' and 'sprite_config'
# Added a region ID to setup non-walkable tile but free for the line of sight (water)
# Improved AI
# Reduced lag generated by AI process
# Created Win Conditions ADD-ON
# New feature: TBS Events and Neutral entities
# Map events are now supported - battlers can interact with them.
# Support directional scope
# Added a new scope type: path
# Added an option to instantiate all enemies at the same time
# Start messages can be disabled
# Added some plugin command for in-battle eventing
# Added some event tag for in-battle eventing
# Fixed a bug where the system freezes on positioning phase
# Fixed the "param is not defined" error when an enemy starts its turn
# Fixed a bug where custom scopes ignore line of sight
# Fixed parallax scrolling when the cursor move
# Fixed a bug where move points could be negative
# Fixed a bug where knockback distance could be negative
# Fixed a bug where the game crashes when AI try to resume a move action
# The entities layer has now a correct Z coordinate
# Fixed a bug where entities overlap themselves
# Fixed a bug where the scope and marks layers weren't visible
# When the active entity die, the scope layer is correctly cleared
# Dead enemies don't try to play their turn anymore
# Dead actors can't be placed at the start of battles
# Battlers are correctly revived
# The turn order visual is correctly updated when en entity is revived
# The wait parameter for tile effects is correctly applied
# The parameter 'false' in the sequence commands 'push' and 'pull' to avoid
# knockback damage now works as intended
# Fixed 2 bugs related to the mark and tile effect add-on and improved it (1.1)
# Selected cells with TouchInput on large map are correctly handled
# - 0.61 : Optimized cells locating
# Added a trigger type for battle end
# - 0.7 : Reworked the battle HUD
# Improved the positioning phase, you can also specify fixed actor cells
# The positioning phase is now correctly resumed
# The mouse is now correctly supported during the positioning phase
# Defeat is now based on actors in battle and not the whole party (bugfix)
# Added a minimal parameter to scopes
# Scopes and AoEs parameters are now evaluated
# Added smooth map scrolling system in battle
# Added a parameter to hide AI's scopes
# Counter attacks and magic reflection are now supported
# Added a summon system (add-on)
# The system now automatically use RPT ressources (add-on)
# Added these sequence commands: switch_cells, use_skill
# Added a fast sequence system as well as arguments for sequences
# Added a HUD that appear on an entity when the mouse is over it (add-on)
# Added some tag instructions to change sprite scale, tone and hue
# Added a tag "has_no_corpse" to hide an entity's corpse
# Added states and equipment animations in battle
# Added a map tactical and auto battle system
# The tag sprite_name is correctly taken into account into these components: Turn Order, Window Status
# The selected AoE now blinks
# Greatly improved targets and cells selection in sequences
# The AI Core is completed: all behavior are supported
# The AI correctly use its skills and doesn't stick with just one
# The AI correctly calculate the closest/farhest path to a given cell (no more stuck by obstacles)
# The AI uses smartly AoE skills to hit, heal or boost multiple targets
# The AI can use move skills to escape or reach targets
# The AI doesn't escape anymore if it's already too far from actors (prevents endless battles)
# The AI is able to focus its action on a specified target
# Added a parameter to define how much AI should try to escape (prevents endless battles)
# The AI now handles confusion states
# Added a parameter to delay AI calculation rate, in order to prevent freezes
# Added a configuration tag for AI
# Fixed a bug where collapse effects are triggered multiple times
# Projectiles and entities are now summoned for each cell in the AoE
# The turn order is now correctly determined
# Command, Skill and Item windows are now correctly positioned
# Skills can now directly alter move points with the instruction "change_move_points: +x /-x"
# Move points popup is now added - Though a little bugged
# Fixed a bug where triggering tiles and mark effects change the next
# action damage
# - 0.7a : Fixed a bug where the "Free_LOS" command in event comments would not work
# Fixed a bug where the last summon data are used instead of a new data
# Sprites of summoned entities are destroyed
# - 0.7b : The automatic call of the battle start is now correctly processed
# Fixed actors cannot be swaped
# The command, skill and item windows can't be off the screen
# - 0.7c : Fixed a bug where deleted events could make the game crash
# The battle window layer isn't affected by the screen filters anymore
# Victory branches are now correctly supported
# The command window stay closed at the battle end
# - 0.7d : "Cannot move" states are handled
# The battlers layer is now correctly below the upper map layer
# Added a tag to make the AI play an actor
# Added sequence overloading
# Entities can now stay on a corpse if it's opacity is 0
# Added the sequence command "sprite_prop"
#=============================================================================
*/
var Imported = Imported || {};
Imported["LeTBS"] = true;
var Lecode = Lecode || {};
Lecode.S_TBS = {};
/*:
* @plugindesc A tactical battle system with awesome features
* @author Lecode
* @version 0.7d
*
* @param Actor Color Cell
* @desc Color of actor cells.
* @default #0FC50B
*
* @param Enemy Color Cell
* @desc Color of enemy cells.
* @default #C50B1B
*
* @param Cell Opacity Color
* @desc Opacity of the positioning cells.
* @default 175
*
* @param Placed Animation
* @desc Animation ID when a battler is placed.
* @default 124
*
* @param Instantiate All
* @desc Instantiate all enemies at the same time.
* @default true
*
* @param Display Start Messages
* @desc Show start messages ?
* @default false
*
* @param -- Misc --
* @desc ...
* @default
*
* @param Exploration Input
* @desc Input to trigger exploration.
* @default shift
*
* @param Opacity Input
* @desc Input to change windows' opacity.
* @default control
*
* @param Min Input Opacity
* @desc Minimum opacity of windows.
* @default 0
*
* @param Opacity Steps
* @desc Value of opacity to reduce when inputed.
* @default 10
*
* @param Battle Start Sprite Delay
* @desc Duration of the battle start sprite.
* @default 50
*
* @param Turn Order Fair Repartition ?
* @desc Allow a fair repartition of the turn order ?
* @default true
*
* @param Destination Duration
* @desc Duration of the destination sprite (when a cell is selected).
* @default 60
*
* @param -- Scopes --
* @desc ...
* @default
*
* @param Scope Cell Width
* @desc Width of cells.
* @default 46
*
* @param Scope Cell Height
* @desc Height of cells.
* @default 46
*
* @param Obstacle Region Id
* @desc Region ID for obstacles.
* @default 250
*
* @param Free Obstacle Region Id
* @desc Region ID for non-blocking los obstacles.
* @default 249
*
* @param -- Move Action --
* @desc ...
* @default
*
* @param Default Move Scope
* @desc Default move scope data.
* @default circle(_mp_)
*
* @param Default Move Points
* @desc Default amount of move points.
* @default 3
*
* @param Move Scope Color
* @desc Color of the move scope.
* @default #0A5C85
*
* @param Move Scope Opacity
* @desc Opacity of the move scope.
* @default 175
*
* @param Invalid Move Scope Opacity
* @desc Opacity of the move scope when cells are invalid.
* @default 60
*
* @param Selected Move Scope Opacity
* @desc Opacity of the move scope when cells are selected.
* @default 255
*
* @param Selected Move Scope Color
* @desc Color of the selected move scope.
* @default #81F7F3
*
* @param Enable Directional Facing
* @desc Battlers will be allowed to change their direction.
* @default true
*
* @param -- Attack Action --
* @desc ...
* @default
*
* @param Default Attack Animation
* @desc Default attack animation.
* @default 1
*
* @param Default Attack Sequence
* @desc Default attack sequence.
* @default atk
*
* @param Default Attack Scope
* @desc Default attack scope data.
* @default circle(1)
*
* @param Default Attack Ao E
* @desc Default attack aoe data.
* @default circle(0)
*
* @param Attack Scope Color
* @desc Color of the attack scope.
* @default #E20F2B
*
* @param Attack Scope Opacity
* @desc Opacity of the attack scope.
* @default 175
*
* @param Invalid Attack Scope Opacity
* @desc Opacity of the attack scope when cells are invalid.
* @default 60
*
* @param Selected Attack Scope Color
* @desc Color of the attack scope.
* @default #FB3B54
*
* @param Selected Attack Scope Opacity
* @desc Opacity of the attack scope when cells are selected.
* @default 255
*
* @param -- Skill Action --
* @desc ...
* @default
*
* @param Default Skill Sequence
* @desc Default skill sequence.
* @default skill
*
* @param Default Skill Scope
* @desc Default skill scope data.
* @default circle(3)
*
* @param Default Skill Ao E
* @desc Default skill aoe data.
* @default circle(0)
*
* @param Skill Scope Color
* @desc Color of the skill scope.
* @default #E20F2B
*
* @param Skill Scope Opacity
* @desc Opacity of the skill scope.
* @default 175
*
* @param Invalid Skill Scope Opacity
* @desc Opacity of the skill scope when cells are invalid.
* @default 60
*
* @param Selected Skill Scope Color
* @desc Color of the selected skill scope.
* @default #FB3B54
*
* @param Selected Skill Scope Opacity
* @desc Opacity of the skill scope when cells are selected.
* @default 255
*
* @param -- Item Action --
* @desc ...
* @default
*
* @param Default Item Sequence
* @desc Default item sequence.
* @default item
*
* @param Default Item Scope
* @desc Default item scope data.
* @default circle(3)
*
* @param Default Item Ao E
* @desc Default item aoe data.
* @default circle(0)
*
* @param Item Scope Color
* @desc Color of the item scope.
* @default #DF01D7
*
* @param Item Scope Opacity
* @desc Opacity of the item scope.
* @default 175
*
* @param Invalid Item Scope Opacity
* @desc Opacity of the item scope when cells are invalid.
* @default 60
*
* @param Selected Item Scope Color
* @desc Color of selected the item scope.
* @default #F969F4
*
* @param Selected Item Scope Opacity
* @desc Opacity of the item scope when cells are selected.
* @default 255
*
* @param -- Directional Damage --
* @desc ...
* @default
*
* @param Back Directional Damage Effects
* @desc Damage % when a battler is hit on the back.
* @default 15
*
* @param Side Directional Damage Effects
* @desc Damage % when a battler is hit on the sides.
* @default 0
*
* @param Face Directional Damage Effects
* @desc Damage % when a battler is hit on the face.
* @default -10
*
* @param -- Collision Damage --
* @desc ...
* @default
*
* @param Default Collision Formula
* @desc Formula to evaluate collision damage.
* @default b.mhp * 0.05 * (distance-covered)
*
* @param Collission Damage Chain Rate
* @desc Collision damage chain rate.
* @default 0.3
*
* @param -- Motions --
* @desc ...
* @default
*
* @param Battlers Move Speed
* @desc Default move speed.
* @default 4
*
* @param Battlers Frame Delay
* @desc Default delay value between sprites frames.
* @default 10
*
* @param -- AI --
* @desc ...
* @default
*
* @param Default Ai Pattern
* @desc Default AI pattern.
* @default melee_fighter
*
* @param Ai Wait Time
* @desc AI wait time.
* @default 5
*
* @param Show Scopes
* @desc ...
* @default false
*
* @param Escape Cooldown
* @desc ...
* @default 2
*
* @param Support Cooldown
* @desc ...
* @default 1
*
* @param Ai Process Delay
* @desc ...
* @default 5
*
* @param -- Actions Restrictions --
* @desc ...
* @default
*
* @param One Time Move
* @desc Enable the one time move feature. (See doc)
* @default false
*
* @param One Time Offense
* @desc Enable the one time offense feature. (See doc)
* @default true
*
* @param Auto Pass
* @desc Enable the auto pass feature. (See doc)
* @default true
*
* @param -- Battle End --
* @desc ...
* @default
*
* @param Escape Sound
* @desc Sound when the party try to escape.
* @default Buzzer2
*
* @param End Of Battle Wait
* @desc Wait amount before the end of the battle.
* @default 60
*
* @param Collapse Animation
* @desc Default collapse animation.
* @default 136
*
*
* @help
* See the documentation
*/
//#=============================================================================
/*-------------------------------------------------------------------------
* Get Parameters
-------------------------------------------------------------------------*/
var parameters = PluginManager.parameters('LeTBS');
Lecode.S_TBS.actorColorCell = String(parameters["Actor Color Cell"] || "#0FC50B"); // (): Color of actor cells.
Lecode.S_TBS.enemyColorCell = String(parameters["Enemy Color Cell"] || "#C50B1B"); // (): Color of enemy cells.
Lecode.S_TBS.positioningCellOpacity = Number(parameters["Cell Opacity Color"] || 175); // (Cell Opacity Color): Opacity of the positioning cells.
Lecode.S_TBS.placedBattlerAnim = Number(parameters["Placed Animation"] || 124); // (Placed Animation): Animation ID when a battler is placed.
Lecode.S_TBS.instantiateAll = String(parameters["Instantiate All"] || 'true') === 'true'; // (): Instantiate all enemies at the same time.
Lecode.S_TBS.displayStartMessages = String(parameters["Display Start Messages"] || 'false') === 'true'; // (): Show start messages ?
// Divider: -- Misc --
Lecode.S_TBS.explorationInput = String(parameters["Exploration Input"] || "shift"); // (): Input to trigger exploration.
Lecode.S_TBS.opacityInput = String(parameters["Opacity Input"] || "control"); // (): Input to change windows' opacity.
Lecode.S_TBS.minInputOpacity = Number(parameters["Min Input Opacity"] || 0); // (): Minimum opacity of windows.
Lecode.S_TBS.inputOpacityDecreaseSteps = Number(parameters["Opacity Steps"] || 10); // (Opacity Steps): Value of opacity to reduce when inputed.
Lecode.S_TBS.battleStartSpriteDelay = Number(parameters["Battle Start Sprite Delay"] || 50); // (): Duration of the battle start sprite.
Lecode.S_TBS.turnOrderFairRepartition = String(parameters["Turn Order Fair Repartition ?"] || 'true') === 'true'; // (Turn Order Fair Repartition ?): Allow a fair repartition of the turn order ?
Lecode.S_TBS.destinationDuration = Number(parameters["Destination Duration"] || 60); // (): Duration of the destination sprite (when a cell is selected).
// Divider: -- Scopes --
Lecode.S_TBS.scopeCellWidth = Number(parameters["Scope Cell Width"] || 46); // (): Width of cells.
Lecode.S_TBS.scopeCellHeight = Number(parameters["Scope Cell Height"] || 46); // (): Height of cells.
Lecode.S_TBS.obstacleRegionId = Number(parameters["Obstacle Region Id"] || 250); // (): Region ID for obstacles.
Lecode.S_TBS.freeObstacleRegionId = Number(parameters["Free Obstacle Region Id"] || 249); // (): Region ID for non-blocking los obstacles.
// Divider: -- Move Action --
Lecode.S_TBS.defaultMoveScope = String(parameters["Default Move Scope"] || "circle(_mp_)"); // (): Default move scope data.
Lecode.S_TBS.defaultMovePoints = Number(parameters["Default Move Points"] || 3); // (): Default amount of move points.
Lecode.S_TBS.moveColorCell = String(parameters["Move Scope Color"] || "#0A5C85"); // (Move Scope Color): Color of the move scope.
Lecode.S_TBS.moveCellOpacity = Number(parameters["Move Scope Opacity"] || 175); // (Move Scope Opacity): Opacity of the move scope.
Lecode.S_TBS.moveInvalidCellOpacity = Number(parameters["Invalid Move Scope Opacity"] || 60); // (Invalid Move Scope Opacity): Opacity of the move scope when cells are invalid.
Lecode.S_TBS.moveSelectedCellOpacity = Number(parameters["Selected Move Scope Opacity"] || 255); // (Selected Move Scope Opacity): Opacity of the move scope when cells are selected.
Lecode.S_TBS.selectedMoveColorCell = String(parameters["Selected Move Scope Color"] || "#81F7F3"); // (Selected Move Scope Color): Color of the selected move scope.
Lecode.S_TBS.enableDirectionalFacing = String(parameters["Enable Directional Facing"] || 'true') === 'true'; // (): Battlers will be allowed to change their direction.
// Divider: -- Attack Action --
Lecode.S_TBS.defaultAttackAnimation = Number(parameters["Default Attack Animation"] || 1); // (): Default attack animation.
Lecode.S_TBS.defaultAttackSequence = String(parameters["Default Attack Sequence"] || "atk"); // (): Default attack sequence.
Lecode.S_TBS.defaultAttackScope = String(parameters["Default Attack Scope"] || "circle(1)"); // (): Default attack scope data.
Lecode.S_TBS.defaultAttackAoE = String(parameters["Default Attack Ao E"] || "circle(0)"); // (): Default attack aoe data.
Lecode.S_TBS.attackColorCell = String(parameters["Attack Scope Color"] || "#E20F2B"); // (Attack Scope Color): Color of the attack scope.
Lecode.S_TBS.attackCellOpacity = Number(parameters["Attack Scope Opacity"] || 175); // (Attack Scope Opacity): Opacity of the attack scope.
Lecode.S_TBS.attackInvalidCellOpacity = Number(parameters["Invalid Attack Scope Opacity"] || 60); // (Invalid Attack Scope Opacity): Opacity of the attack scope when cells are invalid.
Lecode.S_TBS.selectedAttackColorCell = String(parameters["Selected Attack Scope Color"] || "#FB3B54"); // (Selected Attack Scope Color): Color of the attack scope.
Lecode.S_TBS.attackSelectedCellOpacity = Number(parameters["Selected Attack Scope Opacity"] || 255); // (Selected Attack Scope Opacity): Opacity of the attack scope when cells are selected.
// Divider: -- Skill Action --
Lecode.S_TBS.defaultSkillSequence = String(parameters["Default Skill Sequence"] || "skill"); // (): Default skill sequence.
Lecode.S_TBS.defaultSkillScope = String(parameters["Default Skill Scope"] || "circle(3)"); // (): Default skill scope data.
Lecode.S_TBS.defaultSkillAoE = String(parameters["Default Skill Ao E"] || "circle(0)"); // (): Default skill aoe data.
Lecode.S_TBS.skillColorCell = String(parameters["Skill Scope Color"] || "#E20F2B"); // (Skill Scope Color): Color of the skill scope.
Lecode.S_TBS.skillCellOpacity = Number(parameters["Skill Scope Opacity"] || 175); // (Skill Scope Opacity): Opacity of the skill scope.
Lecode.S_TBS.skillInvalidCellOpacity = Number(parameters["Invalid Skill Scope Opacity"] || 60); // (Invalid Skill Scope Opacity): Opacity of the skill scope when cells are invalid.
Lecode.S_TBS.selectedSkillColorCell = String(parameters["Selected Skill Scope Color"] || "#FB3B54"); // (Selected Skill Scope Color): Color of the selected skill scope.
Lecode.S_TBS.skillSelectedCellOpacity = Number(parameters["Selected Skill Scope Opacity"] || 255); // (Selected Skill Scope Opacity): Opacity of the skill scope when cells are selected.
// Divider: -- Item Action --
Lecode.S_TBS.defaultItemSequence = String(parameters["Default Item Sequence"] || "item"); // (): Default item sequence.
Lecode.S_TBS.defaultItemScope = String(parameters["Default Item Scope"] || "circle(3)"); // (): Default item scope data.
Lecode.S_TBS.defaultItemAoE = String(parameters["Default Item Ao E"] || "circle(0)"); // (): Default item aoe data.
Lecode.S_TBS.ItemColorCell = String(parameters["Item Scope Color"] || "#DF01D7"); // (Item Scope Color): Color of the item scope.
Lecode.S_TBS.ItemCellOpacity = Number(parameters["Item Scope Opacity"] || 175); // (Item Scope Opacity): Opacity of the item scope.
Lecode.S_TBS.ItemInvalidCellOpacity = Number(parameters["Invalid Item Scope Opacity"] || 60); // (Invalid Item Scope Opacity): Opacity of the item scope when cells are invalid.
Lecode.S_TBS.selectedItemColorCell = String(parameters["Selected Item Scope Color"] || "#F969F4"); // (Selected Item Scope Color): Color of selected the item scope.
Lecode.S_TBS.ItemSelectedCellOpacity = Number(parameters["Selected Item Scope Opacity"] || 255); // (Selected Item Scope Opacity): Opacity of the item scope when cells are selected.
// Divider: -- Directional Damage --
Lecode.S_TBS.backDirectionalDamageEffects = Number(parameters["Back Directional Damage Effects"] || 15); // (): Damage % when a battler is hit on the back.
Lecode.S_TBS.sideDirectionalDamageEffects = Number(parameters["Side Directional Damage Effects"] || 0); // (): Damage % when a battler is hit on the sides.
Lecode.S_TBS.faceDirectionalDamageEffects = Number(parameters["Face Directional Damage Effects"] || -10); // (): Damage % when a battler is hit on the face.
// Divider: -- Collision Damage --
Lecode.S_TBS.defaultCollisionFormula = String(parameters["Default Collision Formula"] || "b.mhp * 0.05 * (distance-covered)"); // (): Formula to evaluate collision damage.
Lecode.S_TBS.collissionDamageChainRate = Number(parameters["Collission Damage Chain Rate"] || 0.3); // (): Collision damage chain rate.
// Divider: -- Motions --
Lecode.S_TBS.battlersMoveSpeed = Number(parameters["Battlers Move Speed"] || 4); // (): Default move speed.
Lecode.S_TBS.battlersFrameDelay = Number(parameters["Battlers Frame Delay"] || 10); // (): Default delay value between sprites frames.
// Divider: -- AI --
Lecode.S_TBS.defaultAiPattern = String(parameters["Default Ai Pattern"] || "melee_fighter"); // (): Default AI pattern.
Lecode.S_TBS.aiWaitTime = Number(parameters["Ai Wait Time"] || 5); // (): AI wait time.
Lecode.S_TBS.showScopes = String(parameters["Show Scopes"] || 'false') === 'true';
Lecode.S_TBS.escapeCooldown = Number(parameters["Escape Cooldown"] || 2);
Lecode.S_TBS.supportCooldown = Number(parameters["Support Cooldown"] || 1);
Lecode.S_TBS.aiProcessDelay = Number(parameters["Ai Process Delay"] || 5);
// Divider: -- Actions Restrictions --
Lecode.S_TBS.oneTimeMove = String(parameters["One Time Move"] || 'false') === 'true'; // (): Enable the one time move feature. (See doc)
Lecode.S_TBS.oneTimeOffense = String(parameters["One Time Offense"] || 'true') === 'true'; // (): Enable the one time offense feature. (See doc)
Lecode.S_TBS.autoPass = String(parameters["Auto Pass"] || 'true') === 'true'; // (): Enable the auto pass feature. (See doc)
// Divider: -- Battle End --
Lecode.S_TBS.escapeSound = String(parameters["Escape Sound"] || "Buzzer2"); // (): Sound when the party try to escape.
Lecode.S_TBS.endOfBattleWait = Number(parameters["End Of Battle Wait"] || 60); // (): Wait amount before the end of the battle.
Lecode.S_TBS.collapseAnimation = Number(parameters["Collapse Animation"] || 136); // (): Default collapse animation.
/*-------------------------------------------------------------------------
* Spriteset_BattleTBS
-------------------------------------------------------------------------*/
function Spriteset_BattleTBS() {
this.initialize.apply(this, arguments);
}
Spriteset_BattleTBS.prototype = Object.create(Spriteset_Map.prototype);
Spriteset_BattleTBS.prototype.constructor = Spriteset_BattleTBS;
Spriteset_BattleTBS.prototype.initialize = function () {
Spriteset_Map.prototype.initialize.call(this);
this.createTBSLayer();
this.createBattleLayers();
};
Spriteset_BattleTBS.prototype.createCharacters = function () {
this._characterSprites = [];
$gameMap.events().forEach(function (event) {
if (event.event().note.match(/<TBS Event>/i) || event.event().note.match(/<TBS Neutral (.+)>/i))
this._characterSprites.push(new Sprite_Character(event));
}, this);
for (var i = 0; i < this._characterSprites.length; i++) {
this._tilemap.addChild(this._characterSprites[i]);
}
};
Spriteset_BattleTBS.prototype.createTBSLayer = function () {
this._tbsLayer = new Sprite();
this._tbsLayer.x = this._tilemap.x;
this._tbsLayer.y = this._tilemap.y;
this._tbsLayer.width = this._tilemap.width;
this._tbsLayer.height = this._tilemap.height;
this._baseSprite.addChild(this._tbsLayer);
};
Spriteset_BattleTBS.prototype.createBattleLayers = function () {
//-Scopes
this._scopesLayer = new TBSScopeLayer();
this._scopesLayer.z = 1;
this._tilemap.addChild(this._scopesLayer);
this._scopesLayer.createSelectionLayer();
this._tbsLayer.addChild(this._scopesLayer._selectionLayer);
//-Ground entities
this._groundEntitiesLayer = new Sprite();
this._groundEntitiesLayer.z = 1;
this._tbsLayer.addChild(this._groundEntitiesLayer);
//-Ground
this._groundLayer = new Sprite();
this._groundLayer.z = 2;
this._tbsLayer.addChild(this._groundLayer);
//-Battlers
this._battlersLayer = new Sprite();
this._battlersLayer.z = 3;
this._tilemap.addChild(this._battlersLayer);
//-Animations
this._animationsLayer = new TBSMapAnimation();
this._animationsLayer.z = 4;
this._tbsLayer.addChild(this._animationsLayer);
//-Movable Info
this._movableInfoLayer = new Sprite();
this._movableInfoLayer.z = 6;
this.addChild(this._movableInfoLayer);
//-Fixed Info
this._fixedInfoLayer = new Sprite();
this._fixedInfoLayer.z = 6;
this.addChild(this._fixedInfoLayer);
//-Debug
var bitmap = new Bitmap(Graphics.width, Graphics.height);
this._debugLayer = new Sprite(bitmap);
this._debugLayer.z = 7;
this._tbsLayer.addChild(this._debugLayer);
};
Spriteset_BattleTBS.prototype.update = function () {
Spriteset_Map.prototype.update.call(this);
this.updateEntitiesZ();
};
Spriteset_BattleTBS.prototype.updateTilemap = function () {
Spriteset_Map.prototype.updateTilemap.call(this);
[this._tbsLayer, this._movableInfoLayer, this._battlersLayer,
this._scopesLayer].forEach(function (layer) {
if (layer) {
layer.x = -$gameMap.displayX() * $gameMap.tileWidth();
layer.y = -$gameMap.displayY() * $gameMap.tileHeight();
}
});
};
Spriteset_BattleTBS.prototype.updateEntitiesZ = function () {
if (this._battlersLayer)
this._battlersLayer.children.sort(this.compareEntitiesOrder);
};
Spriteset_BattleTBS.prototype.compareEntitiesOrder = function (a, b) {
if (a.y < b.y) return -1;
if (a.y > b.y) return 1;
return 0;
};
/*-------------------------------------------------------------------------
* TBSScopeLayer
-------------------------------------------------------------------------*/
function TBSScopeLayer() {
this.initialize.apply(this, arguments);
}
TBSScopeLayer.prototype = Object.create(Sprite.prototype);
TBSScopeLayer.prototype.constructor = TBSScopeLayer;
TBSScopeLayer.prototype.initialize = function () {
var w = $gameMap.width() * $gameMap.tileWidth();
var h = $gameMap.height() * $gameMap.tileHeight();
var bitmap = new Bitmap(w, h);
Sprite.prototype.initialize.call(this, bitmap);
this._selectionLayer = null;
this._selectionCells = [];
};
TBSScopeLayer.prototype.createSelectionLayer = function () {
this._selectionLayer = new TBSScopeLayer();
this._selectionLayer.z = 2;
//this.parent.addChild(this._selectionLayer);
};
TBSScopeLayer.prototype.update = function () {
Sprite.prototype.update.call(this);
if (this._selectionLayer) {
//this._selectionLayer.x = this.x;
//this._selectionLayer.y = this.y;
}
};
TBSScopeLayer.prototype.clear = function () {
this.bitmap.clear();
};
TBSScopeLayer.prototype.clearSelection = function () {
this._selectionLayer.clear();
this._selectionLayer.leU_endLoopFlash();
};
TBSScopeLayer.prototype.drawCell = function (x, y, opacity, color) {
var w = Lecode.S_TBS.scopeCellWidth;
var h = Lecode.S_TBS.scopeCellHeight;
var sx = $gameMap.tileWidth() - w;
var sy = $gameMap.tileHeight() - h;
w -= sx;
h -= sy;
sx += x * $gameMap.tileWidth();
sy += y * $gameMap.tileHeight();
this.bitmap.paintOpacity = opacity;
this.bitmap.fillRect(sx, sy, w, h, color);
};
TBSScopeLayer.prototype.drawSelectionCells = function (scope, opacity, color, scolor) {
var boundaries = BattleManagerTBS.getScopeBoundaries(scope);
var w = (Math.abs(boundaries.right - boundaries.left) + 1) * $gameMap.tileWidth();
var h = (Math.abs(boundaries.top - boundaries.bottom) + 1) * $gameMap.tileHeight();
var x = boundaries.left * $gameMap.tileWidth();
var y = boundaries.top * $gameMap.tileHeight();
this._selectionLayer.bitmap = new Bitmap(w, h);
this._selectionLayer.paintOpacity = opacity;
this._selectionLayer.x = x;
this._selectionLayer.y = y;
scope.forEach(function (cell) {
w = Lecode.S_TBS.scopeCellWidth;
h = Lecode.S_TBS.scopeCellHeight;
var sx = $gameMap.tileWidth() - w;
var sy = $gameMap.tileHeight() - h;
w -= sx;
h -= sy;
var cx = cell.x - boundaries.left;
var cy = cell.y - boundaries.top;
sx += cx * $gameMap.tileWidth();
sy += cy * $gameMap.tileHeight();
this._selectionLayer.bitmap.fillRect(sx, sy, w, h, scolor);
}.bind(this));
this._selectionLayer.leU_startLoopFlash([0, 0, 0, 255], 25);
this._selectionLayer.leU_setFlashMode("opacity");
};
TBSScopeLayer.prototype.drawSelectionCell = function (x, y, opacity, color) {
this._selectionLayer.drawCell(x, y, opacity, color);
//this._selectionCells.push({ x: x, y: y, op: opacity, color: color });
};
/*-------------------------------------------------------------------------
* TBSMapAnimation
-------------------------------------------------------------------------*/
function TBSMapAnimation() {
this.initialize.apply(this, arguments);
}
TBSMapAnimation.prototype = Object.create(Sprite_Base.prototype);
TBSMapAnimation.prototype.constructor = TBSMapAnimation;
TBSMapAnimation.prototype.initialize = function (battler) {
Sprite_Base.prototype.initialize.call(this);
this._cell = null;
this._target = null;
};
TBSMapAnimation.prototype.update = function () {
Sprite_Base.prototype.update.call(this);
};
TBSMapAnimation.prototype.newAnimation = function (id, mirror, delay, cell, target) {
this._cell = cell;
this._target = target;
this.startAnimation($dataAnimations[id], mirror, delay);
};
TBSMapAnimation.prototype.startAnimation = function (animation, mirror, delay) {
var sprite = new Sprite_TBSAnimation();
sprite.setup(this._target || this._effectTarget, animation, mirror, delay, this._cell);
this.addChild(sprite);
this._animationSprites.push(sprite);
};
/*-------------------------------------------------------------------------
* Sprite_TBSAnimation
-------------------------------------------------------------------------*/
function Sprite_TBSAnimation() {
this.initialize.apply(this, arguments);
}
Sprite_TBSAnimation.prototype = Object.create(Sprite_Animation.prototype);
Sprite_TBSAnimation.prototype.constructor = Sprite_TBSAnimation;
Sprite_TBSAnimation.prototype.initialize = function () {
Sprite_Animation.prototype.initialize.call(this);
this._cell = null;
};
Sprite_TBSAnimation.prototype.update = function () {
Sprite_Animation.prototype.update.call(this);
};
Sprite_TBSAnimation.prototype.setup = function (target, animation, mirror, delay, cell) {
this._cell = cell;
this._target = target;
this._animation = animation;
this._mirror = mirror;
this._delay = delay;
if (this._animation) {
this.remove();
this.setupRate();
this.setupDuration();
this.loadBitmaps();
this.createSprites();
}
};
Sprite_TBSAnimation.prototype.updatePosition = function () {
if (this._animation.position === 3) {
this.x = this.parent.width / 2;
this.y = this.parent.height / 2;
} else {
var w = $gameMap.tileWidth();
var h = $gameMap.tileHeight();
this.x = this._cell.x * $gameMap.tileWidth() + w / 2;
this.y = this._cell.y * $gameMap.tileHeight() + h / 2;
if (this._animation.position === 2)
this.y += h / 2;
else if (this._animation.position === 0)
this.y -= h / 2;
}
};
/*-------------------------------------------------------------------------
* Sprite_TBSEntityAnimation
-------------------------------------------------------------------------*/
function Sprite_TBSEntityAnimation() {
this.initialize.apply(this, arguments);
}
Sprite_TBSEntityAnimation.prototype = Object.create(Sprite_TBSAnimation.prototype);
Sprite_TBSEntityAnimation.prototype.constructor = Sprite_TBSEntityAnimation;
Sprite_TBSEntityAnimation.prototype.initialize = function () {
Sprite_TBSAnimation.prototype.initialize.call(this);
};
Sprite_TBSEntityAnimation.prototype.setup = function (target, animation, mirror, delay, cell) {
Sprite_TBSAnimation.prototype.setup.call(this, target, animation, mirror, delay, cell);
this.updatePosition();
};
Sprite_TBSEntityAnimation.prototype.updatePosition = function () {
if (this._animation.position === 3) {
this.x = this.parent.width / 2;
this.y = this.parent.height / 2;
} else {
var bounds = this._target.getBounds();
var w = bounds.width;
var h = bounds.height;
this.x = this._target.x + w / 2;
this.y = this._target.y + h / 2;
if (this._animation.position === 2)
this.y += h / 2;
else if (this._animation.position === 0)
this.y -= h / 2;
}
};
/*-------------------------------------------------------------------------
* Scene_Battle
-------------------------------------------------------------------------*/
Lecode.S_TBS.oldSB_create = Scene_Battle.prototype.create;
Scene_Battle.prototype.create = function () {
if (Lecode.S_TBS.commandOn) {
Scene_Base.prototype.create.call(this);
this.createDisplayObjects();
} else {
Lecode.S_TBS.oldSB_create.call(this);
}
};
Lecode.S_TBS.oldSB_createDisplayObjects = Scene_Battle.prototype.createDisplayObjects;
Scene_Battle.prototype.createDisplayObjects = function () {
if (Lecode.S_TBS.commandOn) {
this.createSpriteset();
this.createWindowLayer();
this.createAllWindows();
} else {
Lecode.S_TBS.oldSB_createDisplayObjects.call(this);
}
};
Lecode.S_TBS.oldSB_start = Scene_Battle.prototype.start;
Scene_Battle.prototype.start = function () {
if (Lecode.S_TBS.commandOn) {
Scene_Base.prototype.start.call(this);
this.startFadeIn(this.fadeSpeed(), false);
BattleManager.playBattleBgm();
BattleManagerTBS._spriteset = this._spriteset;
BattleManagerTBS._logWindow = this._logWindow;
this._logWindow.setSpriteset(this._spriteset);
InputHandlerTBS.setup();
this.setMovableWindows();
InputHandlerTBS.addWindowBlockingTouch(this._windowConfirm)
.addWindowBlockingTouch(this._windowCommand)
.addWindowBlockingTouch(this._windowSkill)
.addWindowBlockingTouch(this._windowItem)
.addWindowBlockingTouch(this._windowStatus)
.addWindowBlockingTouch(this._helpWindow)
.addWindowBlockingTouch(this._windowEndCommand)
.addWindowBlockingTouch(this._windowPositioning)
.addWindowBlockingTouch(this._windowPositioningConfirm);
BattleManagerTBS.startBattle();
} else {
Lecode.S_TBS.oldSB_start.call(this);
}
};
Lecode.S_TBS.oldSB_update = Scene_Battle.prototype.update;
Scene_Battle.prototype.update = function () {
if (Lecode.S_TBS.commandOn) {
$gameMap.update(true);
$gameTroop.updateInterpreter();
$gameTimer.update(true);
$gameScreen.update();
InputHandlerTBS.update();
BattleManagerTBS.update();
Scene_Base.prototype.update.call(this);
} else {
Lecode.S_TBS.oldSB_update.call(this);
}
};
Lecode.S_TBS.oldSB_createSpriteset = Scene_Battle.prototype.createSpriteset;
Scene_Battle.prototype.createSpriteset = function () {
if (Lecode.S_TBS.commandOn) {
this._spriteset = new Spriteset_BattleTBS();
this.addChild(this._spriteset);
} else {
Lecode.S_TBS.oldSB_createSpriteset.call(this);
}
};
Lecode.S_TBS.oldSB_createAllWindows = Scene_Battle.prototype.createAllWindows;
Scene_Battle.prototype.createAllWindows = function () {
if (Lecode.S_TBS.commandOn) {
this.createLogWindow();
this.createPositioningWindow();
this.createPositioningConfirmWindow();
this.createPositioningInfoWindow();
this.createConfirmationWindow();
this.createStatusWindow();
this.createCommandWindow();
this.createHelpWindow();
this.createSkillWindow();
this.createItemWindow();
this.createEndCommandWindow();
this.createMessageWindow();
} else {
Lecode.S_TBS.oldSB_createAllWindows.call(this);
}
};
Scene_Battle.prototype.setMovableWindows = function () {
BattleManagerTBS.getLayer("movableInfo").addChild(this._windowCommand);
BattleManagerTBS.getLayer("movableInfo").addChild(this._windowSkill);
BattleManagerTBS.getLayer("movableInfo").addChild(this._windowItem);
};
Scene_Battle.prototype.createPositioningWindow = function () {
this._windowPositioning = new Window_TBSPositioning();
this._windowPositioning.setHandler('ok', this.onPositioningOk.bind(this));
this._windowPositioning.setHandler('cancel', this.onPositioningCancel.bind(this));
this._windowPositioning.setHandler('exit_up', this.onPositioningExitUp.bind(this));
this._windowPositioning.close();
this._windowPositioning.deactivate();
this._windowPositioning.x = 0;
this._windowPositioning.y = Graphics.height / 2 - this._windowPositioning.height / 2;
this.addWindow(this._windowPositioning);
};
Scene_Battle.prototype.createPositioningConfirmWindow = function () {