-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTyruswoo_AltimitMovement.js
5294 lines (4842 loc) · 165 KB
/
Tyruswoo_AltimitMovement.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
//=============================================================================
// Patched AltimitMovement
// For RPG Maker MZ
// By Tyruswoo
//=============================================================================
/*
* MIT License
*
* Copyright (c) 2024 Altimit Community Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// Signal to other plugins that this plugin is present.
var Imported = Imported || {};
Imported.Tyruswoo_AltimitMovement = true;
// Also signal that AltimitMovement is present, for plugins that look for that.
Imported.AltimitMovement = true;
PluginManager._scripts.push("AltimitMovement");
var Tyruswoo = Tyruswoo || {};
Tyruswoo.AltimitMovement = Tyruswoo.AltimitMovement || {};
/*:
* @target MZ
* @plugindesc MZ v0.9.5 Patched AltimitMovement to work with Tyruswoo_TileControl.
* @author Tyruswoo and Altimit Community
* @url https://www.tyruswoo.com
*
* @help Tyruswoo Patched AltimitMovement for RPG Maker MZ
* ============================================================================
* Usage:
* Plugin will automatically apply when ON.
* About:
* Modified from AltimitMovement Version 0.50 Beta
* Website https://github.com/AltimitSystems/mv-plugins/tree/master/movement
* ============================================================================
* Compatibility Note:
*
* This edition of Tyruswoo Altimit Movement for RPG Maker MZ is expressly
* designed to be compatible with Tyruswoo Tile Control, Tyruswoo Map
* Properties, and MZ3D.
*
* Compatibility with some plugins requires extra steps:
* * If MZ3D is present, place Tyruswoo Altimit Movement above MZ3D in the
* plugin list.
* * If you're using Tyruswoo Tile Control, use Tyruswoo Altimit Movement's
* plugin command "Recalculate Collision Mesh" after using Tile Control to
* change tiles during runtime.
*
* Tyruswoo Altimit Movement aims to be compatible with most other plugins.
* Since it changes RMMZ's core engine more radically than most plugins do,
* we advise putting Tyruswoo Altimit Movement at the top of the plugin list.
*
* If you encounter any compatibility issues, please contact us at Tyruswoo.com
* and we'll do our best to work out a fix.
* ============================================================================
* Player X and Y
*
* Tyruswoo Altimit Movement may interfere with scripts or event commands that
* expect an exact value for $gamePlayer.x or $gamePlayer.y. This is because
* Altimit Movement sets $gamePlayer.x and $gamePlayer.y to a fractional
* (floating point) value that represents the player's exact position.
*
* To get the nearest integer values to the player's coordinates, you can use
* the following phrases in script calls:
* Math.round($gamePlayer.x)
* Math.round($gamePlayer.y)
* ============================================================================
* Collider Definitions
*
* A collider is the shape with which an object in the game bumps into other
* objects. This plugin allows you to define colliders of the following types
* of shapes: Rectangle, Circle, Line, Polygon, and Regular Polygon.
*
* Rectangle:
*
* A rectangle has offsets x and y, and width and height expressed in
* tile-sized units.
* Below is an example of a square that's example one tile in size.
*
* <rect x='0.0' y='0.0' width='1.0' height='1.0' />
*
* Circle:
*
* A circle has offsets cx and cy, and a radius r.
* This example makes a tile-sized circle:
*
* <circle cx='0.5' cy='0.5' r='0.5' />
*
* Line:
*
* A line runs from the coordinates (x1,y1) to (x2,y2).
* The example below makes a line from top-left to bottom-right of one tile:
*
* <line x1='0' y1='0' x2='1' y2='1' />
*
* Polygon:
*
* A polygon collider must be convex and clock-wise-winding.
* The example below makes a triangle.
*
* <polygon points='0.0,1.0 0.5,0.0 1.0,1.0' />
*
* Regular polygon:
*
* A regular polygon has all angles equal and all sides equal.
* The example below makes a 5-pointed polygon, i.e. a pentagon.
*
* <regular cx='0.5' cy='0.5' rx='0.5' ry='0.5' p='5' />
*
* ============================================================================
* Plugin Parameters
* ----------------------------------------------------------------------------
* Player Collider:
*
* This collider determines what shape the player "bumps into" events and
* walls with.
*
* The default player collider is a tile-sized circle centered low and
* written like this:
*
* <circle cx='0.5' cy='0.7' r='0.25' />
*
* ----------------------------------------------------------------------------
* Normalize Player Movement?:
*
* If this parameter has Yes selected (as it has by default),
* diagonal movement speed accounts for Euclidean distance covered.
*
* If No is selected, diagonal movement has the same speed in the X dimension
* as going straight east or west, and the same speed in the Y dimension as
* going straight north or south. Therefore, diagonal movement is faster if
* Normalize Player Movement has No selected.
*
* ----------------------------------------------------------------------------
* Follow Distance:
*
* This specifies how far apart followers should be as the player moves forward
* in a straight line. A distance of 1 results in a tight chain;
* a distance of 2 doubles the spacing. Default follow distance is 1.5.
*
* ----------------------------------------------------------------------------
* Follower Collider:
*
* This collider is used for each of the player's followers.
* The default follower collider is a tile-sized, low-centered circle:
*
* <circle cx='0.5' cy='0.7' r='0.25' />
*
* ----------------------------------------------------------------------------
* Normalize Follower Movement?:
*
* This is like Normalize Player Movement, except that it applies to the
* player's followers. Select Yes for more realistic diagonal movement,
* or No for faster diagonal movement.
*
* ----------------------------------------------------------------------------
* Boat Collider:
*
* This collider is used for the party's boat.
* Its default collider is a small circle, written like this:
*
* <circle cx='0.5' cy='0.5' r='0.333' />
*
* ----------------------------------------------------------------------------
* Ship Collider:
*
* This collider is used for the party's ship.
* Its default collider is a tile-sized circle:
*
* <circle cx='0.5' cy='0.5' r='0.5' />
*
* ----------------------------------------------------------------------------
* Airship Collider:
*
* This is the collider used for the party's airship. Its default collider is a
* small circle:
*
* <circle cx='0.5' cy='0.5' r='0.25' />
*
* ----------------------------------------------------------------------------
* Character Collider:
*
* This is the collider used for all non-player characters, except for those
* whose collider is manually set to something else.
* The default value is a tile-sized, low-centered circle, as written below:
*
* <circle cx='0.5' cy='0.7' r='0.25' />
*
* ----------------------------------------------------------------------------
* Tile Collider:
*
* This is the collider used for all tile events: that is, all events that
* have their appearance set to a tile, to a sprite whose filename starts
* with "!", or to no appearance.
*
* By default this collider is a tile-sized square, as written below:
*
* <rect x='0' y='0' width='1' height='1' />
*
* ----------------------------------------------------------------------------
* Collider Presets:
*
* In this list you can define as many collider shapes as you like.
* To set a character or event to use this collider, use a Change Collider
* plugin command, and enter the number of the collider you want used.
* To use the first collider in the Collider Presets list, put 1, or to use the
* second collider in the list, put 2, and so on.
*
* ----------------------------------------------------------------------------
* Align Move Routes to Grid?
*
* If Yes is selected, a character will always align to the tile they're
* standing on before they step through a move route.
* This is set to Yes by default; to disable it, select No.
*
* ----------------------------------------------------------------------------
* Use Touch/Mouse?
*
* When Use Touch/Mouse has Yes selected, the player can click on the screen
* to choose where to move, and the party will start walking there.
* To turn off this feature and require movement to be done by controller or
* arrow keys, select No.
*
* ----------------------------------------------------------------------------
* Gamepad Mode
*
* This changes what the gamepad's analog stick does. Gamepad mode can be
* Movement + Facing (default), Movement Only, Facing Only, or Disabled.
*
* ============================================================================
* Plugin Commands
*
* ----------------------------------------------------------------------------
* The Change Collider Commands:
*
* The following plugin commands change the collider of a character, event,
* or vehicle:
* - Change Player Collider - Change the collider of the player
* (i.e. the party leader).
* - Change This Collider - Change the collider of the active event.
* - Change Event Collider - Enter the Event ID of any event on the map.
* - Change Vehicle Collider - Change the collider of the Boat, Ship,
* or Airship.
* - Change Follower Collider - Pick a follower from the lineup.
*
* In the command's Change To argument, enter the number of the collider
* preset you want the character, event, or vehicle to start using.
* For instance, if you want to use the second collider in the Collider Presets
* list, enter a 2.
*
* ----------------------------------------------------------------------------
* Change Followers Distance:
*
* Use this to change the followers' distance during gameplay.
* It works like the Follow Distance plugin parameter:
* a larger number makes followers walk farther apart.
*
* ----------------------------------------------------------------------------
* Set Followers Can Follow:
*
* Pick a specific follower, or all followers.
* You can make them stop following, or resume following, the party leader.
* (For more options for controlling follower movement, we recommend the
* Tyruswoo Follower Control plugin, available on Tyruswoo.com.)
*
* ----------------------------------------------------------------------------
* Change Move Route Alignment:
*
* Use this plugin command to change whether characters must align to the grid
* before they begin a move route.
*
* ----------------------------------------------------------------------------
* Move
*
* Use this plugin command to assign advanced movement commands.
* Its Move Command argument has the following sub-arguments:
* - Mover - The entity that should move. You can assign a Move command to
* this event, the player, any event on the map, or even to a follower
* or vehicle.
* - Direction - This can be random, any cardinal or diagonal direction you
* choose, forward, backward, toward other, or away from other.
* - Distance - This is the move distance in tiles.
* - Other - The other character, event, or vehicle that the mover is moving
* toward or away from. This only needs to be set if the Direction is
* "toward other" or "away from other"; otherwise its value doesn't matter.
* - Mover Event Id - If the mover is an event other than this event,
* specify its Event ID here. Otherwise, you can leave this blank.
* - Other Event Id - If the mover is moving toward or away from an event
* that isn't this event, put the other event's ID here.
* Otherwise, you can leave this blank.
*
* In addition to defining the Move Command, you can choose whether the active
* event should Wait For Completion of this move, and whether this command
* should Skip If Cannot Move.
*
* ----------------------------------------------------------------------------
* Change Touch/Mouse Input:
*
* You can use this to turn touch/mouse input on or off during gameplay.
*
* Recalculate Collision Mesh
* Informs AltimitMovement that it needs to recalculate the map's collision
* mesh. Use this after completing any tile changes affecting passability,
* so that the AltimitMovement plugin recognizes the changed tiles.
*
* ============================================================================
* Script calls (Advanced):
*
* $gameMap.recalculateCollisionMesh();
* This is the script call run by the plugin command.
*
* ============================================================================
* Shape examples:
*
* Rectangle (this example makes a tile-sized square)
* <rect x='0.0' y='0.0' width='1.0' height='1.0' />
*
* Circle (this example makes a tile-sized circle)
* <circle cx='0.5' cy='0.5' r='0.5' />
*
* Line (this example makes a line from top-left to bottom-right)
* <line x1='0' y1='0' x2='1' y2='1' />
*
* Polygon must be convex and clock-wise-winding (this example makes a triangle)
* <polygon points='0.0,1.0 0.5,0.0 1.0,1.0' />
*
* Regular polygon (this example makes a 5-pointed polygon; a pentagon)
* <regular cx='0.5' cy='0.5' rx='0.5' ry='0.5' p='5' />
*
* ============================================================================
* Visit Tyruswoo.com to ask for help, donate, or browse more of our plugins.
* ============================================================================
* Version History:
*
* v0.5 10/18/2021
* - This modified version of AltimitMovement 0.50 Beta provides a
* script call for compatibility with Tyruswoo_TileControl.
*
* v0.6 3/11/2023
* - Fixed a bug in which a Show Choices command could happen twice when
* preceded by a Show Text command. (Ensured a command101 alias method
* returns a boolean value as expected by the current MZ corescript.)
*
* v0.6.1 8/30/2023
* - This plugin is now free and open source under the MIT license.
*
* v0.7.0 3/8/2024
* - Fixed issue where two events sometimes triggered at once and
* play out one after the other even when it didn't make sense.
* Now the second event only runs if it's still in range and
* on the correct page when the first event finishes running.
*
* v0.8.0 3/13/2024
* - Removed caching to files, as it was causing crashes and conferring
* no benefit.
*
* v0.9.0 3/27/2024
* - Added VeLee's optional debug overlay, AltimitMovementDebug.js
*
* v0.9.1 4/15/2024
* - Documented all plugin parameters and commands.
*
* v0.9.2 8/9/2024
* - Made Tyruswoo Altimit Movement compatible with Tyruswoo Map
* Properties v2.1.0 and up.
*
* v0.9.3 8/13/2024
* - Fixed a bug where the touch target wasn't clearing at the start of
* a foreground event.
*
* v0.9.4 8/27/2024
* - Made compatible with MZ3D, as long as MZ3D is placed BELOW
* Tyruswoo_AltimitMovement in the plugin list. Credit to Cutievirus
* for this compatibility fix.
* - Fixed a rare crash that said "Assignment to constant variable."
* - Made plugin visible to plugins that look for "AltimitMovement"
* in PluginManager's list of scripts.
*
* v0.9.5 9/20/2024
* - Added note on how this plugin affects player X and Y coordinates.
* ============================================================================
* MIT License
*
* Copyright (c) 2024 Altimit Community Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the “Software”), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
* ============================================================================
* Remember, only you can build your dreams!
* -Tyruswoo
*
* @param player
* @text Player
* @desc Parameters related to player character.
*
* @param player_collider_list
* @text Collider
* @desc Default collider list for player character.
* @parent player
* @type note
* @default "<circle cx='0.5' cy='0.7' r='0.25' />"
*
* @param player_circular_movement
* @text Normalize the movement?
* @desc Should the diagonal movement be the same distance as the straight movement?
* @parent player
* @type boolean
* @on Yes
* @off No
* @default true
*
* @param followers
* @text Followers
* @desc Parameters related to party followers.
*
* @param followers_distance
* @text Follow distance
* @desc Distance of 1 results in a tight chain. Distance of 2 will double the spacing.
* @parent followers
* @type number
* @min 0
* @decimals 2
* @default 1.50
*
* @param followers_collider_list
* @text Collider
* @desc Default collider list for followers.
* @parent followers
* @type note
* @default "<circle cx='0.5' cy='0.7' r='0.25' />"
*
* @param followers_circular_movement
* @text Normalize the movement?
* @desc Should the diagonal movement be the same distance as the straight movement?
* @parent followers
* @type boolean
* @on Yes
* @off No
* @default true
*
*
* @param vehicles
* @text Vehicles
* @desc Parameters related to the vehicles.
*
* @param vehicles_boat_collider_list
* @text Boat collider
* @desc Default collider list for the boat.
* @parent vehicles
* @type note
* @default "<circle cx='0.5' cy='0.5' r='0.333' />"
*
* @param vehicles_ship_collider_list
* @text Ship collider
* @desc Default collider list for the ship.
* @parent vehicles
* @type note
* @default "<circle cx='0.5' cy='0.5' r='0.5' />"
*
* @param vehicles_airship_collider_list
* @text Airship collider
* @desc Default collider list for the airship.
* @parent vehicles
* @type note
* @default "<circle cx='0.5' cy='0.5' r='0.25' />"
*
*
* @param event
* @text Events
* @desc Parameters related to events.
*
* @param event_character_collider_list
* @text Character collider
* @desc Default collider list for character events.
* @parent event
* @type note
* @default "<circle cx='0.5' cy='0.7' r='0.25' />"
*
* @param event_tile_collider_list
* @text Tile collider
* @desc Default collider list for tile events.
* @parent event
* @type note
* @default "<rect x='0' y='0' width='1' height='1' />"
*
*
* @param presets
* @text Collider presets
* @desc Preset colliders to be referenced by events.
* @type note[]
* @default []
*
*
* @param move_route
* @text Move route behaviour
* @desc Parameters related to character move routes.
*
* @param move_route_align_grid
* @text Align move-routes to grid?
* @desc If character is offset on a tile align them to the tile grid when moving.
* @parent move_route
* @type boolean
* @on Yes
* @off No
* @default true
*
*
* @param input_config
* @text Input config
* @desc Configuration for input method.
*
* @param input_config_enable_touch_mouse
* @text Use touch/mouse?
* @desc Enables pointer-based input.
* @parent input_config
* @type boolean
* @on Yes
* @off No
* @default true
*
* @param input_config_gamepad_mode
* @text Gamepad mode
* @desc Gamepad analogue stick input control.
* @parent input_config
* @type select
* @option Movement + Facing
* @value 3
* @option Movement only
* @value 2
* @option Facing only
* @value 1
* @option Disabled
* @value 0
* @default 3
*
* @command setPlayerCollider
* @text Change Player Collider
* @desc Change Player's Collider to another preset.
*
* @arg colliderPreset
* @text Change To
* @type text
* @default 1
* @desc Change the collider to this preset(Defined in plugin settings).
* Numbers are treated as an index into the preset array. 0 is the default collider.
* Text will find a collider with a matching Name field.
*
* @command setThisCollider
* @text Change This Collider
* @desc Change this event's Collider to another preset.
*
* @arg colliderPreset
* @text Change To
* @type text
* @default 1
* @desc Change the collider to this preset(Defined in plugin settings).
* Numbers are treated as an index into the preset array. 0 is the default collider.
* Text will find a collider with a matching Name field.
*
* @command setEventCollider
* @text Change Event Collider
* @desc Change an event's Collider to another preset.
*
* @arg eventId
* @text Event
* @type text
* @default 1
* @desc Enter the event name or the ID number.
*
* @arg colliderPreset
* @text Change To
* @type text
* @default 1
* @desc Change the collider to this preset(Defined in plugin settings).
* Numbers are treated as an index into the preset array. 0 is the default collider.
* Text will find a collider with a matching Name field.
*
* @command setVehicleCollider
* @text Change Vehicle Collider
* @desc Change a vehicle's Collider to another preset.
*
* @arg vehicleId
* @text Vehicle
* @type select
* @option Boat
* @value boat
* @option Ship
* @value ship
* @option Airship
* @value airship
* @default boat
* @desc Select the vehicle to change the collider for.
*
* @arg colliderPreset
* @text Change To
* @type text
* @default 1
* @desc Change the collider to this preset(Defined in plugin settings).
* Numbers are treated as an index into the preset array. 0 is the default collider.
* Text will find a collider with a matching Name field.
*
* @command setFollowerCollider
* @text Change Follower Collider
* @desc Change a Follower's Collider to another preset.
*
* @arg followerId
* @text Follower
* @type select
* @option 1
* @value 1
* @option 2
* @value 2
* @option 3
* @value 3
* @default 1
* @desc Select the follower to change the collider for.
*
* @arg colliderPreset
* @text Change To
* @type text
* @default 1
* @desc Change the collider to this preset(Defined in plugin settings).
* Numbers are treated as an index into the preset array. 0 is the default collider.
* Text will find a collider with a matching Name field.
*
*
* @command setFollowersDistance
* @text Change Followers Distance
* @desc Change a Follower's follow distance from the player.
*
* @arg distance
* @text Following Distance
* @type number
* @decimals 2
* @default 0.25
* @desc The follow distance in tiles.
*
* @command setFollowersFollow
* @text Set Followers Can Follow
* @desc Change if followers can follow the player.
*
* @arg followerId
* @text Follower
* @type select
* @option 1
* @value 1
* @option 2
* @value 2
* @option 3
* @value 3
* @option All
* @value all
* @default 1
* @desc Select the follower to change.
*
* @arg shouldFollow
* @text Should Follow?
* @type boolean
* @on Follow
* @off Don't Follow
* @default true
* @desc Select if the follower should follow the player.
*
* @command setMoveAlign
* @text Change Move Route Alignment
* @desc Change if move routes should align to the grid.
*
* @arg alignToGrid
* @text Align To Grid?
* @type boolean
* @on Align To Grid
* @off Don't Align To Grid
* @default true
* @desc Move route commands will align to the grid.
*
*
* @command move
* @text Move
* @desc Do an advanced movement command
*
* @arg moveCommand
* @text Move Command
* @type struct<MoveStep>
* @desc Enter advanced movement commands
*
* @arg wait
* @text Wait For Completion
* @type boolean
* @on Yes
* @off No
* @default true
* @desc Waits for all movement to finish
*
* @arg isSkippable
* @text Skip If Cannot Move
* @type boolean
* @on Yes
* @off No
* @default false
* @desc Skips any command that would move a character into an impassable location.
*
*
* @command setTouchMouse
* @text Change Touch/Mouse Input
* @desc Change if Touch/Mouse Input is enabled.
*
* @arg value
* @text Touch/Mouse Enabled
* @type boolean
* @default false
* @desc Allows the player can move their character with mouse or touchscreen input.
*
*
* @command recalculateCollisionMesh
* @text Recalculate Collision Mesh
* @desc Forces recalculation of collision mesh. Use if tiles changed.
*/
//=============================================================================
// Struct Definitions
// =============================================================================
/*~struct~MoveStep:
*
* @param mvr
* @text Mover
* @type select
* @default this
* @option Player
* @value player
* @option This
* @value this
* @option Event
* @value event
* @option Follower1
* @value follower1
* @option Follower2
* @value follower2
* @option Follower3
* @value follower3
* @option Boat
* @value boat
* @option Ship
* @value ship
* @option Airship
* @value airship
*
* @desc Select what you want to move.
* If you select event, also fill out the Mover Event Id field.
*
* @param dir
* @text Direction
* @type select
* @default random
* @option Random
* @value random
* @option ↑
* @option ↗
* @option →
* @option ↘
* @option ↓
* @option ↙
* @option ←
* @option ↖
* @option Forward
* @value forward
* @option Backward
* @value backward
* @option Away From Other
* @value away
* @option Towards Other
* @value towards
*
* @param dist
* @text Distance
* @type number
* @decimals 2
* @default 1
* @desc Distance to move in tiles. Or set to the text edge and the character will align to the current tiles edge.
*
* @param other
* @text Other
* @type select
* @default player
* @option Player
* @value player
* @option This
* @value this
* @option Event
* @value event
* @option Boat
* @value boat
* @option Ship
* @value ship
* @option Airship
* @value airship
*
* @param moverEventId
* @text Mover Event Id
* @type text
* @desc Id number or name of event to move. Mover must be set to Event or this will be ignored.
*
* @param otherEventId
* @text Other Event Id
* @type text
* @desc Id number or name of event to move around. Direction must be set to Event or this will be ignored.
*/
(() => {
const pluginName = "Tyruswoo_AltimitMovement";
//=============================================================================
// Parameters, Constants, and Global Variables
//=============================================================================
// True if the collision mesh needs to be recalculated.
Tyruswoo.AltimitMovement._recalculateCollisionMesh = false;
const DOM_PARSER = new DOMParser();
const PARAMETERS = PluginManager.parameters(pluginName);
const GAME_PAD_THRESHOLD = 1 / 5;
const GAME_PAD_LIMIT = 1 - GAME_PAD_THRESHOLD;
/*
* EPSILON
* Smallest floating point number greater than 0
*/
if (Number.EPSILON === undefined) {
Number.EPSILON = Math.pow(2, -52);
}
//-----------------------------------------------------------------------------
// PLAYER
//-----------------------------------------------------------------------------
var PLAYER = {};
PLAYER.CIRCULAR_MOVEMENT =
PARAMETERS['player_circular_movement'] != 'false';
if (PARAMETERS['player_collider_list']) {
PLAYER.COLLIDER_LIST =
'<collider>' + JSON.parse(PARAMETERS['player_collider_list']) + '</collider>';
} else {
PLAYER.COLLIDER_LIST =
"<collider><circle cx='0.5' cy='0.7' r='0.25' /></collider>";
}
//-----------------------------------------------------------------------------
// FOLLOWERS
//-----------------------------------------------------------------------------
var FOLLOWERS = {};
(function() {
FOLLOWERS = {
DISTANCE: Number(PARAMETERS['followers_distance']),
CIRCULAR_MOVEMENT: (PARAMETERS['followers_circular_movement'] != 'false'),
};
let colliderList = PARAMETERS['followers_collider_list'];
if (colliderList) {
FOLLOWERS.COLLIDER_LIST = '<collider>' + JSON.parse(colliderList) + '</collider>';
} else {
FOLLOWERS.COLLIDER_LIST = "<collider><circle cx='0.5' cy='0.7' r='0.25' /></collider>";
}
})();
//-----------------------------------------------------------------------------
// VEHICLES
//-----------------------------------------------------------------------------
var VEHICLES;
(function() {
VEHICLES = {};
let colliderList = PARAMETERS['vehicles_boat_collider_list'];
if (colliderList) {
VEHICLES.BOAT_COLLIDER_LIST = '<collider>' + JSON.parse(colliderList) + '</collider>';
} else {
VEHICLES.BOAT_COLLIDER_LIST = "<collider><circle cx='0.5' cy='0.5' r='0.333' /></collider>";
}
colliderList = PARAMETERS['vehicles_ship_collider_list'];
if (colliderList) {
VEHICLES.SHIP_COLLIDER_LIST = '<collider>' + JSON.parse(colliderList) + '</collider>';
} else {
VEHICLES.SHIP_COLLIDER_LIST = "<collider><circle cx='0.5' cy='0.5' r='0.5' /></collider>";
}
colliderList = PARAMETERS['vehicles_airship_collider_list'];
if (colliderList) {
VEHICLES.AIRSHIP_COLLIDER_LIST = '<collider>' + JSON.parse(colliderList) + '</collider>';
} else {
VEHICLES.AIRSHIP_COLLIDER_LIST = "<collider><circle cx='0.5' cy='0.5' r='0.25' /></collider>";
}
})();
//-----------------------------------------------------------------------------
// EVENT
//-----------------------------------------------------------------------------
var EVENT;
(function() {
EVENT = {};
let colliderList = PARAMETERS['event_character_collider_list'];
if (colliderList) {
EVENT.CHARACTER_COLLIDER_LIST = '<collider>' + JSON.parse(colliderList) + '</collider>';
} else {
EVENT.CHARACTER_COLLIDER_LIST = "<collider><circle cx='0.5' cy='0.7' r='0.25' /></collider>";
}
colliderList = PARAMETERS['event_tile_collider_list'];
if (colliderList) {
EVENT.TILE_COLLIDER_LIST = '<collider>' + JSON.parse(colliderList) + '</collider>';
} else {
EVENT.TILE_COLLIDER_LIST = "<collider><rect x='0' y='0' width='1' height='1' /></collider>";
}
})();
//-----------------------------------------------------------------------------
// PRESETS
//-----------------------------------------------------------------------------
var PRESETS;
(function() {
let presets = PARAMETERS['presets'];
if (presets) {
PRESETS = JSON.parse(presets);
} else {
PRESETS = [];
}
})();
var MOVE_ROUTE = {
ALIGN_GRID: (PARAMETERS['move_route_align_grid'] != 'false'),
};
var INPUT_CONFIG = {
ENABLE_TOUCH_MOUSE: (PARAMETERS['input_config_enable_touch_mouse'] != 'false'),
GAMEPAD_MODE: parseInt(PARAMETERS['input_config_gamepad_mode']),
};
//=============================================================================
// Game_System
//=============================================================================
// Alias
Tyruswoo.AltimitMovement.Game_System_initialize =
Game_System.prototype.initialize;
Game_System.prototype.initialize = function() {
Tyruswoo.AltimitMovement.Game_System_initialize.call(this);
this._eventColliders = [];
this._staticMoveAlignGrid = MOVE_ROUTE.ALIGN_GRID;
this._moveAlignGrid = MOVE_ROUTE.ALIGN_GRID;
this._staticFollowerDistance = FOLLOWERS.DISTANCE;
this._followerDistance = FOLLOWERS.DISTANCE;
this._staticEnableTouchMouse = INPUT_CONFIG.ENABLE_TOUCH_MOUSE;
this._enableTouchMouse = INPUT_CONFIG.ENABLE_TOUCH_MOUSE;
};
// New method
Game_System.prototype.createColliderFromXML = function(xml) {