File size: 40,416 Bytes
99b0de1 | 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 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 | /*:
@target MV MZ
@plugindesc Dot movement system enhancement v1.1.0
@author unagi ootoro
@url https://raw.githubusercontent.com/unagiootoro/RPGMZ/master/DotMoveSystem_FunctionEx.js
@help
It is a plug-in that extends the functions of the dot movement system.
Add the following features.
・ Change player size
・ Adjustment of movement speed
・ Addition of acceleration
・ Addition of inertia
・ Press an event
・ Change of behavior when immersing in an event
・ Jump with collision detection
【How to use】
■ Change player size
Change the size of the player by setting the plug-in parameter "player information".
■ Adjustment of movement speed
You will be able to specify any movement speed.
You can also add acceleration and inertia to the movement.
・ Adjustment of movement speed
In the setting of the movement route
this.setDpf(movement speed);
Specify. The moving speed specifies the moving speed per frame.
(Example) When moving 0.01 squares per frame
this.setDpf(0.01);
If you want to cancel the movement speed adjustment and reflect the movement speed specified by the event command,
this.setDpf(null);
Specify.
■ Addition of acceleration
Acceleration is valid only when the movement speed is adjusted.
To specify the acceleration
this.setAcc(maximum acceleration, degree of influence);
Specify.
(Example) Acceleration between 20 frames, maximum acceleration at 3x speed
this.setAcc(20, 3);
■ Addition of inertia
To specify inertia
this.setInertia;
Specify.
Specify a value of 1 or more for inertia.
This value will continue to decrease every frame by the specified value from the current acceleration.
When set to 1, acceleration and inertia increase / decrease are the same.
(Example) When decelerating 2 times in 1 frame
this.setInertia(2);
■ Press an event
Add the ability to press an event.
In the memo field of the event to be pushed
<PushableEvent>
Please describe.
■ Changes in behavior when immersing yourself in an event
By setting the plugin command "ThroughIfCollided" to true
If you're into an event, make sure it slips through.
■ Jump with collision detection
Jump with collision detection.
Write the following script in the movement route setting.
this.smartJump (addition value in the X-axis direction, addition value in the Y-axis direction, maximum jump height (optional));
* The maximum jump height can be omitted. If omitted, 10 applies.
* The presence or absence of slip-through can be omitted. If omitted, no slip-through is applied.
(Example) When jumping 2 to the left and 3.5 to the top
this.smartJump (2, -3.5);
@param PlayerInfo
@text player information
@type struct <CharacterInfo>
@default {"Width": "1", "Height": "1", "OffsetX": "0", "OffsetY": "0", "SlideLengthX": "0.5", "SlideLengthY": "0.5" }
@desc
Specify various information of the player.
@param FollowerInfo
@text follower information
@type struct <CharacterInfo>
@default {"Width": "1", "Height": "1", "OffsetX": "0", "OffsetY": "0", "SlideLengthX": "0.75", "SlideLengthY": "0.75" }
@desc
Specify various information of followers.
@param ThroughIfCollided
@text slip through when an event collides
@type boolean
@default true
@desc
Setting true allows you to bypass conflicted events.
【License】
This plugin is available under the terms of the MIT license.
*/
/*~struct~CharacterInfo:
@param Width
@text width
@type number
@decimals 2
@default 1
@desc
Specify the width of the character.
@param Height
@text height
@type number
@decimals 2
@default 1
@desc
Specify the width of the character.
@param OffsetX
@text offset X
@type number
@decimals 2
@min -1000
@default 0
@desc
Specifies the display offset of the character along the X axis.
@param OffsetY
@text offset Y
@type number
@decimals 2
@min -1000
@default 0
@desc
Specifies the display offset in the Y-axis direction of the character.
@param SlideLengthX
@text X-axis slide length
@type number
@decimals 2
@default 0.5
@desc
Specifies the slide length of the character in the X-axis direction.
@param SlideLengthY
@text Y-axis slide length
@type number
@decimals 2
@default 0.5
@desc
Specifies the slide length of the character in the Y-axis direction.
*/
/*:ja
@target MV MZ
@plugindesc ドット移動システム機能拡張 v1.1.0
@author うなぎおおとろ
@url https://raw.githubusercontent.com/unagiootoro/RPGMZ/master/DotMoveSystem_FunctionEx.js
@help
ドット移動システムの機能を拡張するプラグインです。
次の機能を追加します。
・プレイヤーサイズの変更
・移動速度の調整
・加速度の追加
・慣性の追加
・イベントを押す
・イベントめり込み時の挙動の変更
・当たり判定付きジャンプ
・地形の半マス当たり判定
【使用方法】
■ プレイヤーサイズの変更
プラグインパラメータ「プレイヤー情報」の設定によりプレイヤーのサイズを変更します。
■ 移動速度の調整
任意の移動速度を指定できるようになります。
また、移動に加速度と慣性をつけることができます。
・移動速度の調整
移動ルートの設定で
this.setDpf(移動速度);
と指定します。移動速度は1フレーム当たりの移動速度を指定します。
(例) 1フレーム当たり0.01マス移動する場合
this.setDpf(0.01);
なお、移動速度の調整をキャンセルしてイベントコマンドで指定する移動速度を反映する場合、
this.setDpf(null);
と指定します。
■ 加速度の追加
加速度は移動速度の調整を行っている場合のみ有効になります。
加速度を指定するには、
this.setAcc(最大加速度, 影響度);
と指定します。
(例) 20フレーム間加速、最高加速で3倍速の場合
this.setAcc(20, 3);
■ 慣性の追加
慣性を指定するには
this.setInertia(慣性);
と指定します。
慣性には1以上の値を指定してください。
この値が現在の加速度から指定した値だけ毎フレーム減り続けることになります。
1を設定した場合は加速と慣性の増減は同じになります。
(例) 1フレームに2減速する場合
this.setInertia(2);
■ イベントを押す
イベントを押す機能を追加します。
押される側のイベントのメモ欄に
<PushableEvent>
と記載してください。
■ イベントめり込み時の挙動の変更
プラグインコマンド「ThroughIfCollided」をtrueに設定することで、
イベントにめり込んでいる場合はそのイベントはすり抜けられるようにします。
■ 当たり判定付きジャンプ
当たり判定付きでジャンプを行います。
移動ルートの設定で以下のスクリプトを記述します。
this.smartJump(X軸方向の加算値, Y軸方向の加算値, 最大のジャンプする高さ(省略可));
※最大のジャンプする高さは省略可能です。省略した場合、10が適用されます。
※すり抜け有無は省略可能です。省略した場合、すり抜け無しが適用されます。
(例) 左方向に2、上方向に3.5ジャンプさせる場合
this.smartJump(2, -3.5);
■ 地形の半マス当たり判定
プラグインパラメータ「HalfCollisionMassInfo」を編集することで、
リージョンまたは地形タグをもとに地形の半マスに当たり判定を設定します。
@param PlayerInfo
@text プレイヤー情報
@type struct<CharacterInfo>
@default {"Width":"1","Height":"1","OffsetX":"0","OffsetY":"0","SlideLengthX":"0.5","SlideLengthY":"0.5"}
@desc
プレイヤーの各種情報を指定します。
@param FollowerInfo
@text フォロワー情報
@type struct<CharacterInfo>
@default {"Width":"1","Height":"1","OffsetX":"0","OffsetY":"0","SlideLengthX":"0.75","SlideLengthY":"0.75"}
@desc
フォロワーの各種情報を指定します。
@param ThroughIfCollided
@text イベント衝突時すり抜け
@type boolean
@default true
@desc
trueを設定すると衝突済みのイベントをすり抜けられるようになります。
@param HalfCollisionMassInfo
@text 半マス当たり判定情報
@type struct<HalfCollisionMassInfo>
@default {"UpCollisionRegionId":"0","RightCollisionRegionId":"0","DownCollisionRegionId":"0","LeftCollisionRegionId":"0","UpRightCollisionRegionId":"0","RightDownCollisionRegionId":"0","DownLeftCollisionRegionId":"0","LeftUpCollisionRegionId":"0","UpRightOpenCollisionRegionId":"0","RightDownOpenCollisionRegionId":"0","DownLeftOpenCollisionRegionId":"0","LeftUpOpenCollisionRegionId":"0","UpCollisionTerrainTagId":"0","RightCollisionTerrainTagId":"0","DownCollisionTerrainTagId":"0","LeftCollisionTerrainTagId":"0","UpRightCollisionTerrainTagId":"0","RightDownCollisionTerrainTagId":"0","DownLeftCollisionTerrainTagId":"0","LeftUpCollisionTerrainTagId":"0","UpRightOpenCollisionTerrainTagId":"0","RightDownOpenCollisionTerrainTagId":"0","DownLeftOpenCollisionTerrainTagId":"0","LeftUpOpenCollisionTerrainTagId":"0"}
@desc
半マス当たり判定の各種情報を指定します。各種情報共通で、0が設定された場合は設定を無効化します。
【ライセンス】
このプラグインは、MITライセンスの条件の下で利用可能です。
*/
/*~struct~CharacterInfo:ja
@param Width
@text 横幅
@type number
@decimals 2
@default 1
@desc
キャラクターの横幅を指定します。
@param Height
@text 縦幅
@type number
@decimals 2
@default 1
@desc
キャラクターの横幅を指定します。
@param OffsetX
@text オフセットX
@type number
@decimals 2
@min -1000
@default 0
@desc
キャラクターのX軸方向の表示オフセットを指定します。
@param OffsetY
@text オフセットY
@type number
@decimals 2
@min -1000
@default 0
@desc
キャラクターのY軸方向の表示オフセットを指定します。
@param SlideLengthX
@text X軸スライド長
@type number
@decimals 2
@default 0.5
@desc
キャラクターのX軸方向のスライド長を指定します。
@param SlideLengthY
@text Y軸スライド長
@type number
@decimals 2
@default 0.5
@desc
キャラクターのY軸方向のスライド長を指定します。
*/
/*~struct~HalfCollisionMassInfo:ja
@param UpCollisionRegionId
@text 上方向当たり判定リージョンID
@type number
@min 0
@default 0
@desc
上方向のマス当たり判定のリージョンIDを設定します。
@param RightCollisionRegionId
@text 右方向当たり判定リージョンID
@type number
@min 0
@default 0
@desc
右方向のマス当たり判定のリージョンIDを設定します。
@param DownCollisionRegionId
@text 下方向当たり判定リージョンID
@type number
@min 0
@default 0
@desc
下方向のマス当たり判定のリージョンIDを設定します。
@param LeftCollisionRegionId
@text 左方向当たり判定リージョンID
@type number
@min 0
@default 0
@desc
左方向のマス当たり判定のリージョンIDを設定します。
@param UpRightCollisionRegionId
@text 右上方向当たり判定リージョンID
@type number
@min 0
@default 0
@desc
右上方向のマス当たり判定のリージョンIDを設定します。
@param RightDownCollisionRegionId
@text 右下方向当たり判定リージョンID
@type number
@min 0
@default 0
@desc
右下方向のマス当たり判定のリージョンIDを設定します。
@param DownLeftCollisionRegionId
@text 左下方向当たり判定リージョンID
@type number
@min 0
@default 0
@desc
左下方向のマス当たり判定のリージョンIDを設定します。
@param LeftUpCollisionRegionId
@text 左上方向当たり判定リージョンID
@type number
@min 0
@default 0
@desc
左上方向のマス当たり判定のリージョンIDを設定します。
@param UpRightOpenCollisionRegionId
@text 右上方向空き当たり判定リージョンID
@type number
@min 0
@default 0
@desc
右上方向の空きマス当たり判定のリージョンIDを設定します。
@param RightDownOpenCollisionRegionId
@text 右下方向当たり判定リージョンID
@type number
@min 0
@default 0
@desc
右下方向の空きマス当たり判定のリージョンIDを設定します。
@param DownLeftOpenCollisionRegionId
@text 左下方向当たり判定リージョンID
@type number
@min 0
@default 0
@desc
左下方向の空きマス当たり判定のリージョンIDを設定します。
@param LeftUpOpenCollisionRegionId
@text 左上方向当たり判定リージョンID
@type number
@min 0
@default 0
@desc
左上方向の空きマス当たり判定のリージョンIDを設定します。
@param UpCollisionRegionId
@text 上方向当たり判定リージョンID
@type number
@min 0
@default 0
@desc
上方向のマス当たり判定のリージョンIDを設定します。
@param RightCollisionRegionId
@text 右方向当たり判定リージョンID
@type number
@min 0
@default 0
@desc
右方向のマス当たり判定のリージョンIDを設定します。
@param DownCollisionRegionId
@text 下方向当たり判定リージョンID
@type number
@min 0
@default 0
@desc
下方向のマス当たり判定のリージョンIDを設定します。
@param LeftCollisionRegionId
@text 左方向当たり判定リージョンID
@type number
@min 0
@default 0
@desc
左方向のマス当たり判定のリージョンIDを設定します。
@param UpRightCollisionRegionId
@text 右上方向当たり判定リージョンID
@type number
@min 0
@default 0
@desc
右上方向のマス当たり判定のリージョンIDを設定します。
@param RightDownCollisionRegionId
@text 右下方向当たり判定リージョンID
@type number
@min 0
@default 0
@desc
右下方向のマス当たり判定のリージョンIDを設定します。
@param DownLeftCollisionRegionId
@text 左下方向当たり判定リージョンID
@type number
@min 0
@default 0
@desc
左下方向のマス当たり判定のリージョンIDを設定します。
@param LeftUpCollisionRegionId
@text 左上方向当たり判定リージョンID
@type number
@min 0
@default 0
@desc
左上方向のマス当たり判定のリージョンIDを設定します。
@param UpRightOpenCollisionRegionId
@text 右上方向空き当たり判定リージョンID
@type number
@min 0
@default 0
@desc
右上方向の空きマス当たり判定のリージョンIDを設定します。
@param RightDownOpenCollisionRegionId
@text 右下方向当たり判定リージョンID
@type number
@min 0
@default 0
@desc
右下方向の空きマス当たり判定のリージョンIDを設定します。
@param DownLeftOpenCollisionRegionId
@text 左下方向当たり判定リージョンID
@type number
@min 0
@default 0
@desc
左下方向の空きマス当たり判定のリージョンIDを設定します。
@param LeftUpOpenCollisionRegionId
@text 左上方向当たり判定リージョンID
@type number
@min 0
@default 0
@desc
左上方向の空きマス当たり判定のリージョンIDを設定します。
@param UpCollisionTerrainTagId
@text 上方向当たり判定地形タグID
@type number
@min 0
@default 0
@desc
上方向のマス当たり判定の地形タグIDを設定します。
@param RightCollisionTerrainTagId
@text 右方向当たり判定地形タグID
@type number
@min 0
@default 0
@desc
右方向のマス当たり判定の地形タグIDを設定します。
@param DownCollisionTerrainTagId
@text 下方向当たり判定地形タグID
@type number
@min 0
@default 0
@desc
下方向のマス当たり判定の地形タグIDを設定します。
@param LeftCollisionTerrainTagId
@text 左方向当たり判定地形タグID
@type number
@min 0
@default 0
@desc
左方向のマス当たり判定の地形タグIDを設定します。
@param UpRightCollisionTerrainTagId
@text 右上方向当たり判定地形タグID
@type number
@min 0
@default 0
@desc
右上方向のマス当たり判定の地形タグIDを設定します。
@param RightDownCollisionTerrainTagId
@text 右下方向当たり判定地形タグID
@type number
@min 0
@default 0
@desc
右下方向のマス当たり判定の地形タグIDを設定します。
@param DownLeftCollisionTerrainTagId
@text 左下方向当たり判定地形タグID
@type number
@min 0
@default 0
@desc
左下方向のマス当たり判定の地形タグIDを設定します。
@param LeftUpCollisionTerrainTagId
@text 左上方向当たり判定地形タグID
@type number
@min 0
@default 0
@desc
左上方向のマス当たり判定の地形タグIDを設定します。
@param UpRightOpenCollisionTerrainTagId
@text 右上方向空き当たり判定地形タグID
@type number
@min 0
@default 0
@desc
右上方向の空きマス当たり判定の地形タグIDを設定します。
@param RightDownOpenCollisionTerrainTagId
@text 右下方向当たり判定地形タグID
@type number
@min 0
@default 0
@desc
右下方向の空きマス当たり判定の地形タグIDを設定します。
@param DownLeftOpenCollisionTerrainTagId
@text 左下方向当たり判定地形タグID
@type number
@min 0
@default 0
@desc
左下方向の空きマス当たり判定の地形タグIDを設定します。
@param LeftUpOpenCollisionTerrainTagId
@text 左上方向当たり判定地形タグID
@type number
@min 0
@default 0
@desc
左上方向の空きマス当たり判定の地形タグIDを設定します。
*/
const DotMoveSystem_FunctionExPluginName = document.currentScript.src.match(/^.*\/(.+)\.js$/)[1];
(() => {
"use strict";
for (const className in DotMoveSystemClassAlias) {
this[className] = DotMoveSystemClassAlias[className];
}
class PluginParamsParser {
static parse(params, typeData, predictEnable = true) {
return new PluginParamsParser(predictEnable).parse(params, typeData);
}
constructor(predictEnable = true) {
this._predictEnable = predictEnable;
}
parse(params, typeData, loopCount = 0) {
if (++loopCount > 255) throw new Error("endless loop error");
const result = {};
for (const name in typeData) {
if (params[name] === "" || params[name] === undefined) {
result[name] = null;
} else {
result[name] = this.convertParam(params[name], typeData[name], loopCount);
}
}
if (!this._predictEnable) return result;
if (typeof params === "object" && !(params instanceof Array)) {
for (const name in params) {
if (result[name]) continue;
const param = params[name];
const type = this.predict(param);
result[name] = this.convertParam(param, type, loopCount);
}
}
return result;
}
convertParam(param, type, loopCount) {
if (typeof type === "string") {
return this.cast(param, type);
} else if (typeof type === "object" && type instanceof Array) {
const aryParam = JSON.parse(param);
if (type[0] === "string") {
return aryParam.map(strParam => this.cast(strParam, type[0]));
} else {
return aryParam.map(strParam => this.parse(JSON.parse(strParam), type[0]), loopCount);
}
} else if (typeof type === "object") {
return this.parse(JSON.parse(param), type, loopCount);
} else {
throw new Error(`${type} is not string or object`);
}
}
cast(param, type) {
switch(type) {
case "any":
if (!this._predictEnable) throw new Error("Predict mode is disable");
return this.cast(param, this.predict(param));
case "string":
return param;
case "number":
if (param.match(/^\-?\d+\.\d+$/)) return parseFloat(param);
return parseInt(param);
case "boolean":
return param === "true";
default:
throw new Error(`Unknow type: ${type}`);
}
}
predict(param) {
if (param.match(/^\-?\d+$/) || param.match(/^\-?\d+\.\d+$/)) {
return "number";
} else if (param === "true" || param === "false") {
return "boolean";
} else {
return "string";
}
}
}
const typeDefine = {
PlayerInfo: {},
FollowerInfo: {},
HalfCollisionMassInfo: {},
};
const PP = PluginParamsParser.parse(PluginManager.parameters(DotMoveSystem_FunctionExPluginName), typeDefine);
/*
* ● 初期化処理
*/
const _CharacterMover_initialize = CharacterMover.prototype.initialize;
CharacterMover.prototype.initialize = function(character) {
_CharacterMover_initialize.call(this, character);
this._lastDirection = character.direction();
this._changeDirectionCount = 0;
this._direction8 = this._character.direction();
};
const _Game_CharacterBase_initMembers = Game_CharacterBase.prototype.initMembers;
Game_CharacterBase.prototype.initMembers = function() {
_Game_CharacterBase_initMembers.call(this);
this._dpf = null;
this._acceleration = 0;
this._inertia = 1;
this._accelerationPlus = null;
this._maxAcceleration = null;
this._jumpXPlus = null;
this._jumpYPlus = null;
};
const _Game_Player_initMembers = Game_Player.prototype.initMembers;
Game_Player.prototype.initMembers = function() {
_Game_Player_initMembers.call(this);
this._width = PP.PlayerInfo.Width;
this._height = PP.PlayerInfo.Height;
this._offsetX = PP.PlayerInfo.OffsetX;
this._offsetY = PP.PlayerInfo.OffsetY;
this._slideLengthX = PP.PlayerInfo.SlideLengthX;
this._slideLengthY = PP.PlayerInfo.SlideLengthY;
};
const _Game_Follower_initMembers = Game_Follower.prototype.initMembers;
Game_Follower.prototype.initMembers = function() {
_Game_Follower_initMembers.call(this);
this._width = PP.FollowerInfo.Width;
this._height = PP.FollowerInfo.Height;
this._offsetX = PP.FollowerInfo.OffsetX;
this._offsetY = PP.FollowerInfo.OffsetY;
this._slideLengthX = PP.FollowerInfo.SlideLengthX;
this._slideLengthY = PP.FollowerInfo.SlideLengthY;
};
/*
* ● 更新処理
*/
const _CharacterMover_update = CharacterMover.prototype.update;
CharacterMover.prototype.update = function() {
_CharacterMover_update.call(this);
// TODO: 斜め慣性処理を実装する
// this.updateChangeDirection();
};
const _Game_CharacterBase_update = Game_CharacterBase.prototype.update;
Game_CharacterBase.prototype.update = function() {
if (this.isJumping() && this.isSmartJumping()) this.updateSmartJump();
if (this.isNeedUpdateAcceleration()) this.updateAcceleration();
_Game_CharacterBase_update.call(this);
};
/*
* ● プレイヤーサイズの変更機能
*/
const CharacterInfo = {
width() {
return this._width;
},
height() {
return this._height;
},
offsetX() {
return this._offsetX;
},
offsetY() {
return this._offsetY;
},
slideLengthX() {
return this._slideLengthX;
},
slideLengthY() {
return this._slideLengthY;
},
};
Object.assign(Game_Player.prototype, CharacterInfo);
Object.assign(Game_Follower.prototype, CharacterInfo);
/*
* ● 移動速度の調整
*/
CharacterMover.prototype.updateChangeDirection = function() {
if (!this._reserveChangeDirection) return;
const direction = this._lastDirection;
if (direction !== this._character.direction()) {
this._changeDirectionCount++;
if (this._changeDirectionCount >= 3) {
this._reserveChangeDirection = false;
const deg = DotMoveUtils.direction2deg(direction);
const direction4 = DotMoveUtils.deg2direction4(deg, this._character.direction());
this.setDirection8(direction);
this.setDirection(direction4);
this._reserveSetDirection = null;
}
}
};
CharacterMover.prototype.setDirection8 = function(direction8) {
this._direction8 = direction8;
};
CharacterMover.prototype.direction8 = function() {
return this._direction8;
};
const _CharacterMover_dotMoveByDeg = CharacterMover.prototype.dotMoveByDeg;
CharacterMover.prototype.dotMoveByDeg = function(deg, opt = { changeDir: true }) {
if (opt.changeDir) {
const direction = DotMoveUtils.deg2direction(deg);
this.changeDirectionWhenDotMove(direction);
}
_CharacterMover_dotMoveByDeg.call(this, deg);
};
const _CharacterMover_dotMoveByDirection = CharacterMover.prototype.dotMoveByDirection;
CharacterMover.prototype.dotMoveByDirection = function(direction, opt = { changeDir: true }) {
if (opt.changeDir) {
this.changeDirectionWhenDotMove(direction);
}
_CharacterMover_dotMoveByDirection.call(this, direction);
};
CharacterMover.prototype.changeDirectionWhenDotMove = function(direction) {
if (this._lastDirection !== direction) {
this._lastDirection = direction;
this._changeDirectionCount = 0;
this._reserveChangeDirection = true;
this.setDirection8(direction);
const deg = DotMoveUtils.direction2deg(direction);
const direction4 = DotMoveUtils.deg2direction4(deg, this._character.direction());
this.setDirection(direction4);
}
};
Game_CharacterBase.prototype.originDistancePerFrame = Game_CharacterBase.prototype.distancePerFrame;
Game_CharacterBase.prototype.distancePerFrame = function() {
const isNeedUpdateAcceleration = this.isNeedUpdateAcceleration();
if (this._dpf == null) return this.originDistancePerFrame();
if (isNeedUpdateAcceleration && this._moverData.targetCount > 1) return this.originDistancePerFrame();
const dashMul = this._dashing ? 2 : 1;
if (isNeedUpdateAcceleration) {
const acc = 1 + this._acceleration / this._maxAcceleration * this._accelerationPlus;
return this._dpf * acc * dashMul;
} else {
return this._dpf * dashMul;
}
};
Game_CharacterBase.prototype.setDpf = function(dpf) {
this._dpf = dpf;
};
Game_CharacterBase.prototype.setAcc = function(maxAcc, accPlus) {
this._maxAcceleration = maxAcc;
this._accelerationPlus = accPlus;
};
Game_CharacterBase.prototype.setInertia = function(inertia) {
this._inertia = inertia;
};
Game_CharacterBase.prototype.isNeedUpdateAcceleration = function() {
return this._dpf != null && this._maxAcceleration != null && this._accelerationPlus != null;
};
Game_CharacterBase.prototype.updateAcceleration = function() {
if ($gameMap.isEventRunning()) {
this.cancelAcceleration();
} else {
if (this.isMoved()) {
if (this._acceleration < this._maxAcceleration) {
this._acceleration++;
}
} else {
if (this._acceleration > 0) {
this._acceleration -= this._inertia;
if (this._acceleration < 0) this._acceleration = 0;
this.mover().dotMoveByDirection(this.mover().direction8(), { changeDir: false });
}
}
}
};
Game_CharacterBase.prototype.cancelAcceleration = function() {
this._acceleration = 0;
};
Game_Player.prototype.distancePerFrame = function() {
if (this.isInVehicle()) return this.originDistancePerFrame();
return Game_CharacterBase.prototype.distancePerFrame.call(this);
};
Game_Player.prototype.isNeedUpdateAcceleration = function() {
if (this.isInVehicle()) return false;
return Game_CharacterBase.prototype.isNeedUpdateAcceleration.call(this);
};
Game_Follower.prototype.distancePerFrame = function() {
if ($gamePlayer.isInVehicle()) return this.originDistancePerFrame();
return Game_CharacterBase.prototype.distancePerFrame.call(this);
};
Game_Follower.prototype.isNeedUpdateAcceleration = function() {
if ($gamePlayer.isInVehicle()) return false;
return Game_CharacterBase.prototype.isNeedUpdateAcceleration.call(this);
};
Game_Follower.prototype.changeFollowerSpeed = function(precedingCharacterFar) {
if ($gamePlayer._dpf) {
this.setDpf(this.calcFollowerDpf(precedingCharacterFar));
} else {
this.setDpf(null);
this.setMoveSpeed(this.calcFollowerSpeed(precedingCharacterFar));
}
};
Game_Follower.prototype.calcFollowerDpf = function(precedingCharacterFar) {
if (precedingCharacterFar >= 2) {
return $gamePlayer.distancePerFrame() * 2;
} else if (precedingCharacterFar >= 1.5) {
return $gamePlayer.distancePerFrame();
} else if (precedingCharacterFar >= 1) {
return $gamePlayer.distancePerFrame() / 2;
} else {
return 0;
}
};
const _Scene_Map_callMenu = Scene_Map.prototype.callMenu;
Scene_Map.prototype.callMenu = function() {
_Scene_Map_callMenu.call(this);
$gamePlayer.cancelAcceleration();
};
/*
* ● イベントを押す
*/
const _PlayerMover_moveProcess = PlayerMover.prototype.moveProcess;
PlayerMover.prototype.moveProcess = function() {
// プレイヤー移動の前にイベントを動かし、その後でプレイヤーを動かす
this.eventPushProcess();
_PlayerMover_moveProcess.call(this);
};
PlayerMover.prototype.eventPushProcess = function() {
const x = this._character._realX;
const y = this._character._realY;
const width = this._character.width();
const height = this._character.height();
const dpf = this._character.distancePerFrame();
const margin = dpf / 2;
const dir = this._character.direction();
const dis = DotMoveUtils.calcDistance(DotMoveUtils.direction2deg(dir), dpf);
const x2 = x + dis.x;
const y2 = y + dis.y;
for (const event of DotMoveUtils.enteringMassesEvents(x2, y2, width, height)) {
if (!event.event().meta.PushableEvent) continue;
const result = this.checkCharacter(x2, y2, dir, event);
if (!(result && result.collisionLengthX() >= margin && result.collisionLengthY() >= margin)) continue;
event.mover().dotMoveByDirection(dir);
}
};
/*
* ● イベントと既に衝突している場合、そのイベントはすり抜けられるようにする
*/
CharacterCollisionChecker.prototype.checkEventsPrepare = function(notCollisionEventIds) {
const collidedEvents = [];
const x = this._character._realX;
const y = this._character._realY;
const width = this._character.width();
const height = this._character.height();
const margin = this._character.distancePerFrame();
const events = DotMoveUtils.enteringMassesEvents(x, y, width, height);
for (const event of events) {
if (event.isNormalPriority() && !event.isThrough() && !notCollisionEventIds.includes(event.eventId())) {
const result = this.checkCharacter(x, y, this._character.direction(), event);
if (result && result.collisionLengthX() >= margin && result.collisionLengthY() >= margin) collidedEvents.push(event);
}
}
return collidedEvents.map(event => event.eventId());
};
const _CharacterCollisionChecker_checkEvents = CharacterCollisionChecker.prototype.checkEvents;
CharacterCollisionChecker.prototype.checkEvents = function(x, y, d, notCollisionEventIds = []) {
if (PP.ThroughIfCollided) {
const collidedEventIds = this.checkEventsPrepare(notCollisionEventIds);
notCollisionEventIds = notCollisionEventIds.concat(collidedEventIds);
}
return _CharacterCollisionChecker_checkEvents.call(this, x, y, d, notCollisionEventIds)
};
FollowerCollisionChecker.prototype.checkEventsPrepare = function(notCollisionEventIds) {
return [];
};
/*
* ● 当たり判定付きジャンプ
*/
Game_CharacterBase.prototype.smartJump = function(xPlus, yPlus, baseJumpPeak = 10) {
this._jumpXPlus = xPlus;
this._jumpYPlus = yPlus;
if (Math.abs(xPlus) > Math.abs(yPlus)) {
if (xPlus !== 0) {
this.setDirection(xPlus < 0 ? 4 : 6);
}
} else {
if (yPlus !== 0) {
this.setDirection(yPlus < 0 ? 8 : 2);
}
}
const distance = Math.round(Math.sqrt(xPlus**2 + yPlus**2));
this._jumpPeak = baseJumpPeak + distance - this._moveSpeed;
this._jumpCount = this._jumpPeak * 2;
this.resetStopCount();
this.straighten();
};
Game_CharacterBase.prototype.isSmartJumping = function() {
return this._jumpXPlus != null && this._jumpYPlus != null;
};
const _Game_CharacterBase_updateJump = Game_CharacterBase.prototype.updateJump;
Game_CharacterBase.prototype.updateJump = function() {
if (!this.isSmartJumping()) _Game_CharacterBase_updateJump.call(this);
};
Game_CharacterBase.prototype.updateSmartJump = function() {
this._jumpCount--;
const x = this._realX + this._jumpXPlus / (this._jumpPeak * 2);
const y = this._realY + this._jumpYPlus / (this._jumpPeak * 2);
const dis = { x: x - this._realX, y: y - this._realY };
this.mover()._controller.dotMoveByDistance(this.direction(), dis);
if (this._jumpCount === 0) {
this._jumpXPlus = null;
this._jumpYPlus = null;
this.setPosition(this._realX, this._realY);
}
};
/*
* ● 半マス通行判定設定
*/
CharacterCollisionChecker.prototype.getMassRects = function(x, y) {
switch (this.getMassCollisionType(x, y)) {
case 1:
return [{ x: x, y: y, width: 1, height: 0.5 }];
case 2:
return [{ x: x + 0.5, y: y, width: 0.5, height: 1 }];
case 3:
return [{ x: x, y: y + 0.5, width: 1, height: 0.5 }];
case 4:
return [{ x: x, y: y, width: 0.5, height: 1 }];
case 5:
return [{ x: x + 0.5, y: y, width: 0.5, height: 0.5 }];
case 6:
return [{ x: x + 0.5, y: y + 0.5, width: 0.5, height: 0.5 }];
case 7:
return [{ x: x, y: y + 0.5, width: 0.5, height: 0.5 }];
case 8:
return [{ x: x, y: y, width: 0.5, height: 0.5 }];
case 9:
return [{ x: x, y: y, width: 0.5, height: 1 }, { x: x + 0.5, y: y + 0.5, width: 0.5, height: 0.5 }];
case 10:
return [{ x: x, y: y, width: 0.5, height: 1 }, { x: x + 0.5, y: y, width: 0.5, height: 0.5 }];
case 11:
return [{ x: x + 0.5, y: y, width: 0.5, height: 1 }, { x: x, y: y, width: 0.5, height: 0.5 }];
case 12:
return [{ x: x + 0.5, y: y, width: 0.5, height: 1 }, { x: x, y: y + 0.5, width: 0.5, height: 0.5 }];
}
return [{ x: x, y: y, width: 1, height: 1 }];
};
CharacterCollisionChecker.prototype.getMassCollisionType = function(x, y) {
const regionId = $gameMap.regionId(x, y);
const terrainTag = $gameMap.terrainTag(x, y);
if (regionId > 0) {
switch (regionId) {
case PP.HalfCollisionMassInfo.UpCollisionRegionId:
return 1;
case PP.HalfCollisionMassInfo.RightCollisionRegionId:
return 2;
case PP.HalfCollisionMassInfo.DownCollisionRegionId:
return 3;
case PP.HalfCollisionMassInfo.LeftCollisionRegionId:
return 4;
case PP.HalfCollisionMassInfo.UpRightCollisionRegionId:
return 5;
case PP.HalfCollisionMassInfo.RightDownCollisionRegionId:
return 6;
case PP.HalfCollisionMassInfo.DownLeftCollisionRegionId:
return 7;
case PP.HalfCollisionMassInfo.LeftUpCollisionRegionId:
return 8;
case PP.HalfCollisionMassInfo.UpRightOpenCollisionRegionId:
return 9;
case PP.HalfCollisionMassInfo.RightDownOpenCollisionRegionId:
return 10;
case PP.HalfCollisionMassInfo.DownLeftOpenCollisionRegionId:
return 11;
case PP.HalfCollisionMassInfo.LeftUpOpenCollisionRegionId:
return 12;
}
}
if (terrainTag > 0) {
switch (terrainTag) {
case PP.HalfCollisionMassInfo.UpCollisionTerrainTagId:
return 1;
case PP.HalfCollisionMassInfo.RightCollisionTerrainTagId:
return 2;
case PP.HalfCollisionMassInfo.DownCollisionTerrainTagId:
return 3;
case PP.HalfCollisionMassInfo.LeftCollisionTerrainTagId:
return 4;
case PP.HalfCollisionMassInfo.UpRightCollisionTerrainTagId:
return 5;
case PP.HalfCollisionMassInfo.RightDownCollisionTerrainTagId:
return 6;
case PP.HalfCollisionMassInfo.DownLeftCollisionTerrainTagId:
return 7;
case PP.HalfCollisionMassInfo.LeftUpCollisionTerrainTagId:
return 8;
case PP.HalfCollisionMassInfo.UpRightOpenCollisionTerrainTagId:
return 9;
case PP.HalfCollisionMassInfo.RightDownOpenCollisionTerrainTagId:
return 10;
case PP.HalfCollisionMassInfo.DownLeftOpenCollisionTerrainTagId:
return 11;
case PP.HalfCollisionMassInfo.LeftUpOpenCollisionTerrainTagId:
return 12;
}
}
return 0;
};
CharacterCollisionChecker.prototype.checkCollisionMass = function(targetRect, d, ix, iy) {
const results = [];
const massRects = this.getMassRects(ix, iy);
if (!this.checkPassMass(ix, iy, d)) {
for (const massRect of massRects) {
const result = this.checkCollidedRectOverComplement(this._character._realX, this._character._realY, d, targetRect, massRect);
if (result) results.push(result);
}
}
return results;
}
CharacterCollisionChecker.prototype.checkPassMass = function(x, y, d) {
const x2 = $gameMap.roundX(x);
const y2 = $gameMap.roundY(y);
if (!$gameMap.isValid(x2, y2)) {
return false;
}
if (this._character.isThrough() || this._character.isDebugThrough()) {
return true;
}
if (this.getMassCollisionType(x2, y2) >= 1 && this.getMassCollisionType(x2, y2) <= 12) {
return false;
}
const prevPoint = DotMoveUtils.prevPointWithDirection({ x: x2, y: y2 }, d);
if (this.getMassCollisionType(prevPoint.x, prevPoint.y) >= 1 && this.getMassCollisionType(prevPoint.x, prevPoint.y) <= 12) {
return true;
}
if (this.isMassCollisionNoTarget(x, y, d)) return true;
if (!this._character.isMapPassable(prevPoint.x, prevPoint.y, d)) {
return false;
}
return true;
};
const _CharacterCollisionChecker_checkCollisionXCliff = CharacterCollisionChecker.prototype.checkCollisionXCliff;
CharacterCollisionChecker.prototype.checkCollisionXCliff = function(targetRect, x, x1, x2, y1, d) {
if (this.getMassCollisionType(x1, y1) >= 1 && this.getMassCollisionType(x1, y1) <= 12 && this.getMassCollisionType(x2, y1) >= 1 && this.getMassCollisionType(x2, y1) <= 12) {
return [];
}
return _CharacterCollisionChecker_checkCollisionXCliff.call(this, targetRect, x, x1, x2, y1, d);
};
const _CharacterCollisionChecker_checkCollisionYCliff = CharacterCollisionChecker.prototype.checkCollisionYCliff;
CharacterCollisionChecker.prototype.checkCollisionYCliff = function(targetRect, y, y1, y2, x1, d) {
if (this.getMassCollisionType(x1, y1) >= 1 && this.getMassCollisionType(x1, y1) <= 12 && this.getMassCollisionType(x1, y2) >= 1 && this.getMassCollisionType(x1, y2) <= 12) {
return [];
}
return _CharacterCollisionChecker_checkCollisionYCliff.call(this, targetRect, y, y1, y2, x1, d);
};
})();
|