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
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
| #========================#
# Advanced Move System #
# ULTIMATE 1.3 #
# Script créé par Zeus81 #
# © 2007-2008 #
#========================#
# Vous pouvez choisir les touches pour sprinter et sauter aux lignes 35 et 36
# Les touches possibles sont Input::A, B, C, X, Y, Z, L, R
# Pour choisir à quelle touche ça correspond sur le clavier lancez le jeu puis appuyez sur F1
# Si les touches qui vous sont proposées ne vous conviennent pas vous pouvez toujours télécharger
# le script : "Input Ultimate" qui vous permettra de choisir n'importe quelle touche du clavier
# Si vous voulez désactiver le sprint écrivez : Dash_Input = 0
# Si vous voulez désactiver les sauts écrivez : Jump_Input = 0
# Vous pouvez initialiser le héros lignes 40 à 55
# @position => façon dont est positionnée l'image par rapport à ses coordonnées (voir tutorial)
# @move_speed => vitesse de déplacement, comprise entre 0 et 7
# @move_animation_speed => vitesse de l'animation du personnage, >= 0
# si = 0, la vitesse de l'animation sera automatiquement égale à la vitesse de déplacement
# @jump_power => puissance des sauts, doit être supérieure à la hauteur des murs que l'on veut pouvoir sauter
# @zoom => zoom en pourcentage : 1 => 100%, 0.5 => 50%, 2 => 200%
# @step_anime => animée à l'arrêt ? true => oui : false => non
# @spec_anime => animation spéciale qui se déclenche de manière aléatoire quand on est à l'arrêt
# @walk_anime => animée pendant mouvement ? true => oui : false => non
# @jump_anime => animée pendant saut ? true => oui : false => non
# @fall_anime => animée pendant chute ? true => oui : false => non
# @down_anime => animation spéciale qui se déclenche quand on tombe de trop haut
# @shadow => ombre activée ? true => oui : false => non
# @walk_steps => nombre de pas dans une animation
# @walk_terrain => force un terrain spécifique quel que soit l'endroit où l'on marche
# si = 0, le terrain est celui sur lequel on marche
# @walk_audio => bruits de pas activés ? true => oui : false => non
# @walk_graphics => traces de pas activées ? true => oui : false => non
class Game_Player
def turn_down
end
def turn_up
end
Dash_Input = Input::C
Jump_Input = Input::A
Jump_Audio = RPG::AudioFile.new("Data System/JumpAudio")
def initialize
super
@position = 8
@move_speed = 4
@move_animation_speed = 0
@jump_power = 2.5
@zoom = 1
@step_anime = true
@spec_anime = true
@walk_anime = true
@jump_anime = true
@fall_anime = true
@down_anime = true
@shadow = true
@walk_steps = 2
@walk_terrain = 0
@walk_audio = true
@walk_graphics = true
end
end
# Vous pouvez choisir les valeurs par défaut pour la gravité ligne 84.
# Vous pouvez choisir les valeurs par défaut pour les terrains lignes 87 à 107 :
# Default_Terrain[0][ X] = ["nom du fichier audio A", "volume" , "tempo" ]
# Default_Terrain[0][-X] = ["nom du fichier audio B", "volume" , "tempo" ]
# Default_Terrain[1][ X] = ["nom du fichier image" , "durée 1", "durée 2"]
# X = numéro du terrain
# audio A = audio joué lors du premier pas sur ce terrain
# audio B = audio joué lors du second pas sur ce terrain (S'il y a deux pas)
# durée 1 = durée d'affichage quand marche en nombre de frames (40 frames = 1 sec)
# durée 2 = durée d'affichage quand court en nombre de frames (40 frames = 1 sec)
# Vous pouvez configurer des terrains spéciaux à partir de la ligne 109 de la même façon que pour les terrains :
# Special_Terrain[0][ X] = ["nom du fichier audio A", "volume" , "tempo" ]
# Special_Terrain[0][-X] = ["nom du fichier audio B", "volume" , "tempo" ]
# Special_Terrain[1][ X] = ["nom du fichier image" , "durée 1", "durée 2"]
# Rappel :
# Si la variable @walk_terrain d'un évènement ou du héros est égale à 0
# Le terrain sur lequel il marche sera conforme à ce qui a été réglé dans les chipsets
# Si la variable @walk_terrain est comprise entre 1 et 7
# Le terrain sera celui indiqué par la variable sans tenir compte des chipsets
# Par contre si la variable @walk_terrain > 7 le terrain utilisé sera un terrain spécial
# Si @walk_terrain = 8, ce sera le terrain spécial 1
# Si @walk_terrain = 9, ce sera le terrain spécial 2
# etc ...
# Moi j'en ai mis que 2 mais vous pouvez en mettre à volonté
# Vous pouvez initialiser les évènements des alliés lignes 120 à 138 de la même façon que pour le héros
class Game_Map
Default_Gravity = 10
Default_Depth = [100, 100, 0, 0, 0]
Default_Terrain = [{}, {}]
Default_Terrain[0][ 1] = ["Data System/StepAudio_Terre01_a" , 100, 100]
Default_Terrain[0][-1] = ["Data System/StepAudio_Terre01_b" , 100, 100]
Default_Terrain[1][ 1] = ["Data System/StepGraphic_Terre01" , 0, 40]
Default_Terrain[0][ 2] = ["Data System/StepAudio_Herbe01_a" , 100, 100]
Default_Terrain[0][-2] = ["Data System/StepAudio_Herbe01_b" , 100, 100]
Default_Terrain[1][ 2] = ["Data System/StepGraphic_Herbe01" , 40, 60]
Default_Terrain[0][ 3] = ["Data System/StepAudio_Bois01_a" , 100, 100]
Default_Terrain[0][-3] = ["Data System/StepAudio_Bois01_b" , 100, 100]
Default_Terrain[1][ 3] = ["" , 0, 0]
Default_Terrain[0][ 4] = ["Data System/StepAudio_Pierre01_a", 100, 100]
Default_Terrain[0][-4] = ["Data System/StepAudio_Pierre01_b", 100, 100]
Default_Terrain[1][ 4] = ["" , 0, 0]
Default_Terrain[0][ 5] = ["Data System/StepAudio_Métal01_a" , 100, 100]
Default_Terrain[0][-5] = ["Data System/StepAudio_Métal01_b" , 100, 100]
Default_Terrain[1][ 5] = ["" , 0, 0]
Default_Terrain[0][ 6] = ["Data System/StepAudio_Neige01_a" , 100, 100]
Default_Terrain[0][-6] = ["Data System/StepAudio_Neige01_b" , 100, 100]
Default_Terrain[1][ 6] = ["Data System/StepGraphic_Neige01" , 60, 80]
Default_Terrain[0][ 7] = ["Data System/StepAudio_Eau01_a" , 100, 100]
Default_Terrain[0][-7] = ["Data System/StepAudio_Eau01_b" , 100, 100]
Default_Terrain[1][ 7] = ["Data System/StepGraphic_Eau01" , 40, 60]
Special_Terrain = [{}, {}]
Special_Terrain[0][ 1] = ["Data System/StepAudioS1" , 100, 100]
Special_Terrain[0][-1] = ["Data System/StepAudioS1" , 100, 80]
Special_Terrain[1][ 1] = ["" , 0, 0]
Special_Terrain[0][ 2] = ["Data System/StepAudioS2" , 100, 100]
Special_Terrain[0][-2] = ["Data System/StepAudioS2" , 100, 80]
Special_Terrain[1][ 2] = ["" , 0, 0]
def setup_train_actors
map_event = RPG::Event.new(0, 0)
for i in 1001..1003
map_event.id = i
@events[i] = Game_Event.new(0, map_event)
@events[i].position = 8
@events[i].move_speed = 4
@events[i].move_frequency = 6
@events[i].move_animation_speed = 0
@events[i].jump_power = 3.5 #1.5
@events[i].zoom = 1
@events[i].follow_event_id = 0
@events[i].follow_distance = 1.5
@events[i].step_anime = false
@events[i].spec_anime = false
@events[i].walk_anime = true
@events[i].jump_anime = false
@events[i].fall_anime = false
@events[i].down_anime = false
@events[i].shadow = true
@events[i].walk_steps = 2
@events[i].walk_terrain = 0
@events[i].walk_audio = true
@events[i].walk_graphics = true
end
$game_party.train_actors($game_party.train_actors_visible)
end
end
# Pour que les alliés soient visibles par défaut, remplacez la ligne 152 :
# @train_actors_visible = false par @train_actors_visible = true
class Game_Party
MAX_DISTANCE = 9999999 * 128
attr_reader :distance, :train_actors_visible
alias amsu_game_party_initialize initialize
def initialize
amsu_game_party_initialize
@distance = @real_distance = 0
@train_actors_visible = false
end
def train_actors(visible)
@train_actors_visible = visible
for i in 1001..1003
actor = $game_party.actors[i-1000]
if $game_party.train_actors_visible and actor
$game_map.events[i].move_type = 2
$game_map.events[i].character_name = actor.character_name
$game_map.events[i].character_hue = actor.character_hue
else $game_map.events[i].move_type = 4
end
end
end
def increase_distance
@real_distance = Math.min(@real_distance+2**$game_player.real_move_speed, MAX_DISTANCE)
@distance = (@real_distance / 128.0).round
end
end
class Game_Map
attr_reader :tile_events, :amsu_height, :amsu_depth, :walk_audio, :walk_graphics,
:gravity, :zoom_max, :zoom_min, :zoom_factor, :zoom_origin, :zoom_default
alias amsu_game_map_setup setup
def setup(map_id)
setup_data_system(map_id)
amsu_game_map_setup(map_id)
setup_train_actors
end
def setup_data_system(map_id = @map_id)
@tile_events = []
data = load_data("Data/Data System/Map%03dH.rxdata" % map_id) rescue data=nil
if data
@gravity, @floors = data
@gravity, @amsu_height = @gravity * 0.1, true
else @gravity, @amsu_height = Default_Gravity * 0.1, false
end
data = load_data("Data/Data System/Map%03dD.rxdata" % map_id) rescue data=nil
if data
@zoom_max = data[0] * 0.01
@zoom_min = data[1] * 0.01
@zoom_factor = data[2] * 0.001
@zoom_origin = (1 - data[3] * 0.01) * (load_data("Data/Map%03d.rxdata" % map_id).height - 1)
@zoom_default = data[4] * 0.01 + 1
@amsu_depth = true
else @amsu_depth = false
end
data = load_data("Data/Data System/Map%03dT.rxdata" % map_id) rescue data=nil
terrain = data || Default_Terrain
for i in 1..Special_Terrain[1].size
j = i + 7
terrain[0][j] = Special_Terrain[0][i]
terrain[0][-j] = Special_Terrain[0][-i]
terrain[1][j] = Special_Terrain[1][i]
end
@walk_audio, @walk_graphics = {}, terrain[1]
terrain[0].each_key {|i| @walk_audio[i] = RPG::AudioFile.new(*terrain[0][i])}
end
def scroll_down(d) @display_y = Math.min(@display_y+d, (height-15)*128) end
def scroll_left(d) @display_x = Math.max(@display_x-d, 0) end
def scroll_right(d) @display_x = Math.min(@display_x+d, (width-20)*128) end
def scroll_up(d) @display_y = Math.max(@display_y-d, 0) end
def passable?(x, y, d, self_event = nil)
return false unless valid?(x, y)
bit = d / 2 - 1
for event in @tile_events
if !event.through and event != self_event and event.x == x and event.y == y
if @passages[event.tile_id][bit] == 1 or @passages[event.tile_id] & 0x0f == 0x0f
return false
elsif @priorities[event.tile_id] == 0
return true
end
end
end
for i in 0..2
tile_id = data[x, y, 2-i]
if !tile_id or @passages[tile_id][bit] == 1 or @passages[tile_id] & 0x0f == 0x0f
return false
elsif @priorities[tile_id] == 0
return true
end
end
return true
end
def bush?(x, y)
if @map_id != 0
for event in @tile_events
if event.x == x and event.y == y
return true if @passages[event.tile_id][6] == 1
end
end
for i in 0..2
tile_id = data[x, y, 2-i]
if !tile_id
return false
elsif @passages[tile_id][6] == 1
return true
end
end
end
return false
end
def counter?(x, y)
if @map_id != 0
for event in @tile_events
if event.x == x and event.y == y
return true if @passages[event.tile_id][7] == 1
end
end
for i in 0..2
tile_id = data[x, y, 2-i]
if !tile_id
return false
elsif @passages[tile_id][7] == 1
return true
end
end
end
return false
end
def terrain_tag(x, y)
if @map_id != 0
for event in @tile_events
if event.x == x and event.y == y
return @terrain_tags[event.tile_id] if @terrain_tags[event.tile_id] > 0
end
end
for i in 0..2
tile_id = data[x, y, 2-i]
if !tile_id
return 0
elsif @terrain_tags[tile_id] > 0
return @terrain_tags[tile_id]
end
end
end
return 0
end
def floor(x, y, self_event = nil)
if @amsu_height
for event in @tile_events
if !event.through and event != self_event and event.x == x and event.y == y
return event.floor if event.floor != 0
end
end
return @floors[x, y] if @floors[x, y]
end
return 0
end
end
class Game_Character
@@names_cache ||= {}
attr_reader :x2, :y2, :z, :real_zoom, :real_move_speed
attr_accessor :character_hue, :pattern_max, :direction_max, :position, :through,
:move_speed, :move_frequency, :move_type, :move_animation_speed, :real_z, :floor,
:jump_power, :zoom, :follow_event_id, :follow_distance, :dash, :trails, :shadow,
:step_anime, :spec_anime, :walk_anime, :jump_anime, :fall_anime, :down_anime,
:special_trail_name, :special_trail_hue, :special_trail_blend_type,
:special_trail_opacity, :special_trail_duration, :special_trail_activate,
:walk_steps, :walk_terrain, :walk_audio, :walk_graphics
alias amsu_game_character_initialize initialize
def initialize
amsu_game_character_initialize
@x2 = @y2 = 0
@phase, @original_character_name = 0, ""
@move_animation_speed, @real_move_speed, @real_direction = 0, 4, 2
@position, @direction_max, @pattern_max = 8, 4, 4
@z, @real_z, @floor, @fall_count, @jump_power = 0, 0, 0, 0, 1.5
@zoom = @real_zoom = 1
@follow_event_id, @follow_distance = 0, 1.5
@dash = @spec_anime = @jump_anime = @fall_anime = @down_anime = false
@trails, @shadow = [], false
@special_trail_name, @special_trail_hue = "", 0
@special_trail_activate, @special_trail_blend_type = false, 0
@special_trail_opacity, @special_trail_duration = 255, 40
@walk_steps, @walk_terrain, @walk_audio, @walk_graphics = 0, 0, true, true
end
def character_name=(n) @original_character_name = @character_name = n end
def moving?() @real_x != @x2 or @real_y != @y2 end
def new_jumping?() @z != 0 or @real_z != 0 end
def passable?(x, y, d)
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
return false unless $game_map.valid?(new_x, new_y)
return true if @through
y_plus = change_floor(@x, @y, new_x, new_y, @real_z/128.0, d)
if y_plus == 0
return false unless $game_map.passable?(x, y, d, self)
return false unless $game_map.passable?(new_x, new_y, 10 - d)
else
new_y += y_plus
return false unless $game_map.passable?(new_x, new_y, 0)
end
return event_passable?(new_x, new_y)
end
def event_passable?(new_x, new_y)
for event in $game_map.events.values
if event.x == new_x and event.y == new_y and !event.character_name.empty?
if @id < 1000 and event.id > 1000
event.move_away_from_event(@id) unless event.moving?
else return false unless event.through
end
end
end
if $game_player.x == new_x and $game_player.y == new_y
return false if !$game_player.through and !@character_name.empty?
end
return true
end
def change_floor(last_x, last_y, new_x, new_y, z, d)
return 0 unless $game_map.amsu_height
last_floor = $game_map.floor(last_x, last_y, self)
new_floor = $game_map.floor(new_x, new_y, self)
if d != 0 and new_floor != last_floor
if new_floor < 0
if d == 2 or d == 8; sens = d == 2 ? 1 : -1
else sens = (new_floor == -4 or new_floor == -d/2) ? -1 : 1
end
else
if d == 2 or d == 8; return 0
else sens = new_floor < last_floor ? 1 : -1
end
end
y_plus = 0
loop do
y_plus += sens
new_floor = $game_map.floor(new_x, new_y+y_plus, self)
break if new_floor >= 0 and (sens == 1 ? (last_floor <= new_floor+y_plus) : (last_floor >= new_floor+y_plus))
end
return y_plus if $game_map.valid?(new_x, new_y+y_plus) and new_floor != last_floor and new_floor < last_floor+z
end
return 0
end
def need_new_jump?(d = @real_direction)
return false if !$game_map.amsu_height or d % 2 == 1
new_x = @x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = @y + (d == 2 ? 1 : d == 8 ? -1 : 0)
new_z = @z + @jump_power * (2-$game_map.gravity) * @zoom
y_plus = change_floor(@x, @y, new_x, new_y, new_z, d)
return (y_plus < 0 ? passable?(new_x, new_y + y_plus, 0) : false)
end
def lock
return if @locked
@prelock_direction, @locked = @direction, true
turn_toward_event(0)
end
def moveto(x, y)
@x, @y = x % $game_map.width, y % $game_map.height
@real_x = @x2 = @x * 128
@real_y = @y2 = @y * 128
@prelock_direction = 0
@last_real_y = nil
update_zoom
end
def screen_y
sy = (@real_y - $game_map.display_y + 3) / 4 + 32
if jumping?
n = @jump_count >= @jump_peak ? (@jump_count-@jump_peak) : (@jump_peak-@jump_count)
sy -= (@jump_peak * @jump_peak - n * n) / 2
elsif new_jumping?; sy -= @real_z / 4.0
end
return sy
end
def screen_z(height = 0)
return 999 if @always_on_top
return 0 if @tile_id > 0 and $game_map.priorities[@tile_id] == 0
z = (@real_y - $game_map.display_y + 3) / 4 + 32
return z+(@tile_id > 0 ? ($game_map.priorities[@tile_id]*32) : (height > 32 ? 31 : 0))
end
def bush_depth
return 0 if @tile_id > 0 or @always_on_top
return (!jumping? and !new_jumping? and $game_map.bush?(@x, @y)) ? 12 : 0
end
def update
if jumping? ; update_jump
elsif new_jumping?; update_new_jump
elsif moving? ; update_move
else update_stop
end
update_animation
update_zoom
update_character_name
update_walk
return if @phase == 6
return @wait_count -= 1 if @wait_count > 0
return move_type_custom if @move_route_forcing
return if @starting or lock?
return if @id != 0 and (@move_type == 1 or @move_type == 2) and updating_new_jump?
if (@move_frequency == 6 and !moving?) or (@stop_count > (40-@move_frequency*2)*(6-@move_frequency))
case @move_type
when 1; move_type_random
when 2; move_type_toward_event
when 3; move_type_custom
when 4; move_type_fusion_with_event
end
end
end
def update_jump
@trails.push([3]) if special_trail_activate
@jump_count -= 1
@real_x = (@real_x * @jump_count + @x2) / (@jump_count + 1)
@real_y = (@real_y * @jump_count + @y2) / (@jump_count + 1)
@phase = (@jump_count > @jump_peak ? 4 : 5)
@anime_count += 1.5 if (@phase == 5 ? @fall_anime : @jump_anime)
if @jump_count == 0 and @walk_steps > 0
make_step(0, true)
make_step(1, true)
end
end
def update_new_jump
if @z * 128 > @real_z
distance = 48 * Math.max(1-@real_z/@z/128.0, 0.1) * $game_map.gravity * @real_zoom
@real_z = Math.min(@real_z + distance, @z * 128)
else
@fall_count += 2 * $game_map.gravity
distance = @fall_count * $game_map.gravity * @real_zoom
@real_z = Math.max(@real_z - distance, 0)
@z = @real_z/128.0
end
@phase = (@z * 128 > @real_z ? 4 : 5)
@anime_count += 1.5 if (@phase == 5 ? @fall_anime : @jump_anime)
if @real_z == 0
if @down_anime and @fall_count * $game_map.gravity > 48
@phase, @pattern, @anim_count = 6, 0, 0
end
@fall_count = 0
if @walk_steps > 0
make_step(0, true)
make_step(1, true)
end
end
update_move
end
def updating_new_jump?
if new_jumping?
last_direction, @direction = @direction, @real_direction
move_forward(3)
@direction = last_direction
elsif need_new_jump?; new_jump
else return false
end; return true
end
def update_move
@trails.push([3]) if special_trail_activate
distance = 2 ** @real_move_speed
@y2 = Math.max(@y2 - distance, @y * 128) if @y2 > @y * 128 and !passable?(@x, @y, 2)
@x2 = Math.min(@x2 + distance, @x * 128) if @x2 < @x * 128 and !passable?(@x, @y, 4)
@x2 = Math.max(@x2 - distance, @x * 128) if @x2 > @x * 128 and !passable?(@x, @y, 6)
@y2 = Math.min(@y2 + distance, @y * 128) if @y2 < @y * 128 and !passable?(@x, @y, 8)
@real_y = Math.min(@real_y + distance, @y2) if @y2 > @real_y
@real_x = Math.max(@real_x - distance, @x2) if @x2 < @real_x
@real_x = Math.min(@real_x + distance, @x2) if @x2 > @real_x
@real_y = Math.max(@real_y - distance, @y2) if @y2 < @real_y
unless new_jumping? or @phase == 6
@phase = @dash ? 3 : 2
@anime_count += (@walk_anime ? 1.5 : @step_anime ? 1 : 0)
end
end
def update_stop
if @phase == 1 or @phase == 6
@anime_count += 1.5
elsif @spec_anime and @stop_count > 100 and @stop_count % (rand(1000)+1) == 0
@phase, @pattern = 1, 0
else
@phase = 0
if @step_anime; @anime_count += 1
elsif @pattern != @original_pattern; @anime_count += 1.5
end
@stop_count += 1 unless @starting or lock?
end
end
def update_animation
mas = (@move_animation_speed == 0 ? @move_speed : @move_animation_speed) + (@dash ? 1 : 0)
if @anime_count * @pattern_max/4.0 > 18 - mas * 2
if @phase == 0 and !@step_anime
@pattern = @original_pattern
else
@pattern = (@pattern + 1) % @pattern_max
if @pattern == 0 and (@phase == 1 or @phase == 6)
@pattern, @phase = @original_pattern, 0
end
end
@anime_count = 0
end
end
def update_zoom
if $game_map.amsu_depth
if @last_real_y != @real_y
@last_real_y = @real_y
origin = $game_map.zoom_origin - @real_y/128.0
@depth_zoom = Math.middle($game_map.zoom_min, $game_map.zoom_default-origin*$game_map.zoom_factor, $game_map.zoom_max)
@depth_speed = (@depth_zoom + 2) / 3
end
@real_zoom = @zoom * @depth_zoom
@real_move_speed = Math.middle(0, (@move_speed+(@dash ?1:0))*@depth_speed, 7)
else
@real_zoom = @zoom
@real_move_speed = Math.middle(0, @move_speed+(@dash ?1:0), 7)
end
end
def update_character_name
if @last_character_name != @original_character_name or @last_phase != @phase
@last_character_name, @last_phase = @original_character_name, @phase
name = case @phase
when 1; "#{@original_character_name}_spec"
when 2; "#{@original_character_name}_walk"
when 3; "#{@original_character_name}_dash"
when 4; "#{@original_character_name}_jump"
when 5; "#{@original_character_name}_fall"
when 6; "#{@original_character_name}_down"
else @original_character_name
end
unless @@names_cache[name]
@@names_cache[name] = name
RPG::Cache.character(name, 0) rescue @@names_cache[name] = @original_character_name
end
@character_name = @@names_cache[name]
end
end
def update_walk
if @pattern != @last_pattern
@last_pattern = @pattern
return if @walk_steps == 0 or @phase == 1 or @phase == 4 or @phase == 5 or @phase == 6
if screen_x.between?(0, 640) and screen_y.between?(0, 480)
n = Math.max(@pattern_max / @walk_steps, 1)
make_step(@pattern/n%2, @dash) if @pattern % n == 1 or n == 1
end
end
end
def make_step(step, dash)
terrain = @walk_terrain == 0 ? terrain_tag : @walk_terrain
return if terrain == 0
if @walk_audio
audio = $game_map.walk_audio[terrain * (step == 0 ? 1 : -1)]
last_volume = audio.volume
audio.volume *= 0.8 unless dash
$game_system.se_play(audio)
audio.volume = last_volume
end
if @walk_graphics
graphics = $game_map.walk_graphics[terrain]
picture = graphics[0]
duration = graphics[(dash ? 2 : 1)]
step += 2 if dash
@trails.push([2, picture, duration, step]) if !picture.empty? and duration > 0
end
end
def move_type_random
if @move_frequency == 6
speed = Math.max(@real_move_speed, 4)
case rand(10)
when 0; move_random(speed)
when 1; @stop_count = 0
else
last_direction, @direction = @direction, @real_direction
move_forward(speed)
@direction = last_direction
end
else
case rand(6)
when 0
last_direction, @direction = @direction, @real_direction
move_forward
@direction = last_direction
when 1; @stop_count = 0
else move_random
end
end
end
def move_type_toward_event
event = (@follow_event_id == 0) ? $game_player : $game_map.events[@follow_event_id]
return unless event
sx, sy= (@x2 - event.x2).abs, (@y2 - event.y2).abs
distance = Math.hypot(sx, sy)
if distance > 15 * 128
@dash = false
@id > 1000 ? moveto($game_player.x, $game_player.y) : move_type_random
return
end
@dash = (distance > @follow_distance * 256)
speed = @move_frequency == 6 ? @real_move_speed : 7
if distance > @follow_distance * 128
move_toward_event(@follow_event_id, speed)
elsif distance < @follow_distance * 128 - 2**speed * 2
move_away_from_event(@follow_event_id)
elsif !moving?
turn_toward_event(@follow_event_id)
end
end
def move_type_custom
return if jumping? or moving?
while @move_route_index < @move_route.list.size
command = @move_route.list[@move_route_index]
case command.code
when 0
unless @move_route.repeat
@stop_count = 0
if @move_route_forcing
@move_route, @move_route_index = @original_move_route, @original_move_route_index
@move_route_forcing, @original_move_route = false
end
else @move_route_index = 0
end ; return
when 1; move_down
when 2; move_left
when 3; move_right
when 4; move_up
when 5; move_lower_left
when 6; move_lower_right
when 7; move_upper_left
when 8; move_upper_right
when 9; move_random
when 10; move_toward_event(0)
when 11; move_away_from_event(0)
when 12; move_forward
when 13; move_backward
when 14; jump(command.parameters[0], command.parameters[1])
when 15; @wait_count = command.parameters[0] * 2 - 1
when 16; turn_down
when 17; turn_left
when 18; turn_right
when 19; turn_up
when 20; turn_right_90
when 21; turn_left_90
when 22; turn_180
when 23; turn_right_or_left_90
when 24; turn_random
when 25; turn_toward_event(0)
when 26; turn_away_from_event(0)
when 27; $game_switches[command.parameters[0]], $game_map.need_refresh = true, true
when 28; $game_switches[command.parameters[0]], $game_map.need_refresh = false, true
when 29; @move_speed = command.parameters[0]
when 30; @move_frequency = command.parameters[0]
when 31; @walk_anime = true
when 32; @walk_anime = false
when 33; @step_anime = true
when 34; @step_anime = false
when 35; @direction_fix = true
when 36; @direction_fix = false
when 37; @through = true
when 38; @through = false
when 39; @always_on_top = true
when 40; @always_on_top = false
when 41
@tile_id = 0
self.character_name, @character_hue = command.parameters[0], command.parameters[1]
if @original_direction != command.parameters[2]
@original_direction = @direction = command.parameters[2]
@prelock_direction = 0
end
if @original_pattern != command.parameters[3]
@original_pattern = @pattern = command.parameters[3]
end
when 42; @opacity = command.parameters[0]
when 43; @blend_type = command.parameters[0]
when 44; $game_system.se_play(command.parameters[0])
when 45; eval(command.parameters[0])
end
return if command.code < 15 and !@move_route.skippable and !moving? and !jumping?
@move_route_index += 1
return if command.code < 27
end
end
def move_type_fusion_with_event
event = (@follow_event_id == 0) ? $game_player : $game_map.events[@follow_event_id]
return unless event
@x, @y, @x2, @y2 = event.x, event.y, event.x2, event.y2
unless @character_name.empty?
sx, sy = (@real_x - event.real_x).abs, (@real_y - event.real_y).abs
speed = (@move_frequency == 6) ? @real_move_speed : 7
if Math.hypot(sx, sy) < 2**speed * 2; self.character_name = ""
else turn_toward_event(@follow_event_id)
end
else @real_x, @real_y = @x2, @y2
end
end
def move_down(turn_enabled = true, speed = 7)
turn_down if turn_enabled
y_max = @y + 1
unless passable?(@x, @y, 2)
if @y2 == @y*128
check_event_trigger_touch(@x, @y+1)
return false
else
speed -= 1
y_max -= 1
end
end
turn_down
last_x, last_y = @x, @y
@y2 = Math.min(@y2+2**speed, y_max*128)
@y = (@y2/128.0).round
if $game_map.amsu_height
y_plus = change_floor(last_x, last_y, @x, @y, @z, 2)
@y += y_plus
@y2 += y_plus * 128
@real_y += y_plus * 128
@z += y_plus
@real_z += y_plus * 128
end
increase_steps
return true
end
def move_left(turn_enabled = true, speed = 7)
turn_left if turn_enabled
x_max = @x - 1
unless passable?(@x, @y, 4)
if @x2 == @x*128
check_event_trigger_touch(@x-1, @y)
return false
else
speed -= 1
x_max += 1
end
end
turn_left
last_x, last_y = @x, @y
@x2 = Math.max(@x2-2**speed, x_max*128)
@x = (@x2/128.0).round
if $game_map.amsu_height
y_plus = change_floor(last_x, last_y, @x, @y, @z, 4)
@y += y_plus
@y2 += y_plus * 128
@real_y += y_plus * 128
@z += y_plus
@real_z += y_plus * 128
end
increase_steps
return true
end
def move_right(turn_enabled = true, speed = 7)
turn_right if turn_enabled
x_max = @x + 1
if passable?(@x, @y, 6) == false
if @x2 == @x*128
check_event_trigger_touch(@x+1, @y)
return false
else
speed -= 1
x_max -= 1
end
end
turn_right
last_x, last_y = @x, @y
@x2 = Math.min(@x2+2**speed, x_max*128)
@x = (@x2/128.0).round
if $game_map.amsu_height
y_plus = change_floor(last_x, last_y, @x, @y, @z, 6)
@y += y_plus
@y2 += y_plus * 128
@real_y += y_plus * 128
@z += y_plus
@real_z += y_plus * 128
end
increase_steps
return true
end
def move_up(turn_enabled = true, speed = 7)
turn_up if turn_enabled
y_min = @y - 1
if passable?(@x, @y, 8) == false
if @y2 == @y*128
check_event_trigger_touch(@x, @y-1)
return false
else
speed -= 1
y_min += 1
end
end
turn_up
last_x, last_y = @x, @y
@y2 = Math.max(@y2-2**speed, y_min*128)
@y = (@y2/128.0).round
if $game_map.amsu_height
y_plus = change_floor(last_x, last_y, @x, @y, @z, 8)
@y += y_plus
@y2 += y_plus * 128
@real_y += y_plus * 128
@z += y_plus
@real_z += y_plus * 128
end
increase_steps
return true
end
def move_lower_left(turn_enabled = true, speed = 7)
turn_lower_left if turn_enabled
move1 = move_down(false, speed)
move2 = move_left(false, speed)
turn_lower_left if move1 and move2
end
def move_lower_right(turn_enabled = true, speed = 7)
turn_lower_right if turn_enabled
move1 = move_down(false, speed)
move2 = move_right(false, speed)
turn_lower_right if move1 and move2
end
def move_upper_left(turn_enabled = true, speed = 7)
turn_upper_left if turn_enabled
move1 = move_up(false, speed)
move2 = move_left(false, speed)
turn_upper_left if move1 and move2
end
def move_upper_right(turn_enabled = true, speed = 7)
turn_upper_right if turn_enabled
move1 = move_up(false, speed)
move2 = move_right(false, speed)
turn_upper_right if move1 and move2
end
def move_middle
if @x2 > @x * 128
if @y2 > @y * 128 ; move_upper_left(true, @real_move_speed)
elsif @y2 < @y * 128; move_lower_left(true, @real_move_speed)
else move_left(true, @real_move_speed)
end
elsif @x2 < @x * 128
if @y2 > @y * 128 ; move_upper_right(true, @real_move_speed)
elsif @y2 < @y * 128; move_lower_right(true, @real_move_speed)
else move_right(true, @real_move_speed)
end
else
if @y2 > @y * 128 ; move_up(true, @real_move_speed)
elsif @y2 < @y * 128; move_down(true, @real_move_speed)
end
end
@x2, @y2 = @x * 128, @y * 128
end
def move_random(speed = 7)
case rand(8)
when 0; move_lower_left(false, speed)
when 1; move_down(false, speed)
when 2; move_lower_right(false, speed)
when 3; move_left(false, speed)
when 4; move_upper_left(false, speed)
when 5; move_right(false, speed)
when 6; move_upper_right(false, speed)
when 7; move_up(false, speed)
end
end
def move_toward_event(event_id = 0, speed = 7)
event = (event_id == 0) ? $game_player : $game_map.events[event_id]
return unless event
sx, sy = @x2 - event.x2, @y2 - event.y2
return if sx == 0 and sy == 0
abs_sx, abs_sy = sx.abs, sy.abs
if (abs_sx - abs_sy).abs <= 128
if sy > 0; sx > 0 ? move_upper_left(true, speed) : move_upper_right(true, speed)
else sx > 0 ? move_lower_left(true, speed) : move_lower_right(true, speed)
end
end
if !moving? and !need_new_jump?
if abs_sx > abs_sy
sx > 0 ? move_left(true, speed) : move_right(true, speed)
if !moving? and !need_new_jump? and sy != 0
sy > 0 ? move_up : move_down
end
else
sy > 0 ? move_up(true, speed) : move_down(true, speed)
if !moving? and !need_new_jump? and sx != 0
sx > 0 ? move_left : move_right
end
end
move_random if !moving? and !need_new_jump?
end
end
def move_away_from_event(event_id = 0, speed = 7)
event = (event_id == 0) ? $game_player : $game_map.events[event_id]
return unless event
sx, sy = @x2 - event.x2, @y2 - event.y2
return move_random if sx == 0 and sy == 0
abs_sx, abs_sy = sx.abs, sy.abs
if (abs_sx - abs_sy).abs <= 128
if sy > 0; sx > 0 ? move_lower_right(true, speed) : move_lower_left(true, speed)
else sx > 0 ? move_upper_right(true, speed) : move_upper_left(true, speed)
end
end
if !moving? and !need_new_jump?
if abs_sx > abs_sy
sx > 0 ? move_right(true, speed) : move_left(true, speed)
if !moving? and !need_new_jump? and sy != 0
sy > 0 ? move_down : move_up
end
else
sy > 0 ? move_down(true, speed) : move_up(true, speed)
if !moving? and !need_new_jump? and sx != 0
sx > 0 ? move_right : move_left
end
end
move_random if !moving? and !need_new_jump?
end
end
def move_forward(speed = 7)
case @direction
when 1; move_lower_left(false, speed)
when 2; move_down(false, speed)
when 3; move_lower_right(false, speed)
when 4; move_left(false, speed)
when 5; move_upper_left(false, speed)
when 6; move_right(false, speed)
when 7; move_upper_right(false, speed)
when 8; move_up(false, speed)
end
end
def move_backward(speed = 7)
last_direction_fix, @direction_fix = @direction_fix, true
case @direction
when 1; move_upper_right(false, speed)
when 2; move_up(false, speed)
when 3; move_upper_left(false, speed)
when 4; move_right(false, speed)
when 5; move_lower_right(false, speed)
when 6; move_left(false, speed)
when 7; move_lower_left(false, speed)
when 8; move_down(false, speed)
end
@direction_fix = last_direction_fix
end
def new_jump
@z += @jump_power * (2-$game_map.gravity) * @real_zoom
if @walk_steps > 0
make_step(0, true)
make_step(1, true)
end
@stop_count = 0
end
def jump(x_plus = 0, y_plus = 0)
if x_plus != 0 or y_plus != 0
if x_plus.abs > y_plus.abs; x_plus < 0 ? turn_left : turn_right
else y_plus < 0 ? turn_up : turn_down
end
end
x_plus += (x_plus > 0 ? -1 : 1) until $game_map.valid?(@x + x_plus, @y)
y_plus += (y_plus > 0 ? -1 : 1) until $game_map.valid?(@x, @y + y_plus)
loop do
new_x, new_y = @x + x_plus, @y + y_plus
if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
if @walk_steps > 0
make_step(0, true)
make_step(1, true)
end
straighten
@x += x_plus
@x2 += x_plus * 128
@y += y_plus
@y2 += y_plus * 128
@jump_peak = 10 + Math.hypot(x_plus, y_plus).round - @move_speed
@jump_count = @jump_peak * 2
@stop_count = 0
return
end
x_plus -= 1 if x_plus > 0
x_plus += 1 if x_plus < 0
y_plus -= 1 if y_plus > 0
y_plus += 1 if y_plus < 0
end
end
def turn_down
@real_direction = 2
@direction, @stop_count = 2, 0 unless @direction_fix or @direction == 2
end
def turn_left
@real_direction = 4
@direction, @stop_count = 4, 0 unless @direction_fix or @direction == 4
end
def turn_right
@real_direction = 6
@direction, @stop_count = 6, 0 unless @direction_fix or @direction == 6
end
def turn_up
@real_direction = 8
@direction, @stop_count = 8, 0 unless @direction_fix or @direction == 8
end
def turn_lower_left
@real_direction = 1
unless @direction_fix
last_direction = @direction
@direction = @direction_max==4 ? @direction==6 ? 4 : @direction==8 ? 2 : @direction : 1
@stop_count = 0 if last_direction != @direction
end
end
def turn_lower_right
@real_direction = 3
unless @direction_fix
last_direction = @direction
@direction = @direction_max==4 ? @direction==4 ? 6 : @direction==8 ? 2 : @direction : 3
@stop_count = 0 if last_direction != @direction
end
end
def turn_upper_left
@real_direction = 5
unless @direction_fix
last_direction = @direction
@direction = @direction_max==4 ? @direction==6 ? 4 : @direction==2 ? 8 : @direction : 5
@stop_count = 0 if last_direction != @direction
end
end
def turn_upper_right
@real_direction = 7
unless @direction_fix
last_direction = @direction
@direction = @direction_max==4 ? @direction==4 ? 6 : @direction==2 ? 8 : @direction : 7
@stop_count = 0 if last_direction != @direction
end
end
def turn_right_90
case @direction
when 1; turn_upper_left
when 2; turn_left
when 3; turn_lower_left
when 4; turn_up
when 5; turn_upper_right
when 6; turn_down
when 7; turn_lower_right
when 8; turn_right
end
end
def turn_left_90
case @direction
when 1; turn_lower_right
when 2; turn_right
when 3; turn_upper_right
when 4; turn_down
when 5; turn_lower_left
when 6; turn_up
when 7; turn_upper_left
when 8; turn_left
end
end
def turn_180
case @direction
when 1; turn_upper_right
when 2; turn_up
when 3; turn_upper_left
when 4; turn_right
when 5; turn_lower_right
when 6; turn_left
when 7; turn_lower_left
when 8; turn_down
end
end
def turn_random
case rand(8)
when 0; turn_lower_left
when 1; turn_down
when 2; turn_lower_right
when 3; turn_left
when 4; turn_upper_left
when 5; turn_right
when 6; turn_upper_right
when 7; turn_up
end
end
def turn_toward_event(event_id = 0)
event = (event_id == 0) ? $game_player : $game_map.events[event_id]
return unless event
sx, sy = @x - event.x, @y - event.y
return if sx == 0 and sy == 0
if sx.abs == sy.abs
if sy > 0; sx > 0 ? turn_upper_left : turn_upper_right
else sx > 0 ? turn_lower_left : turn_lower_right
end
else
if sx.abs > sy.abs; sx > 0 ? turn_left : turn_right
else sy > 0 ? turn_up : turn_down
end
end
end
def turn_away_from_event(event_id = 0)
event = (event_id == 0) ? $game_player : $game_map.events[event_id]
return unless event
sx, sy = @x - event.x, @y - event.y
return if sx == 0 and sy == 0
if sx.abs == sy.abs
if sy > 0; sx > 0 ? turn_lower_right : turn_lower_left
else sx > 0 ? turn_upper_right : turn_upper_left
end
else
if sx.abs > sy.abs; sx > 0 ? turn_right : turn_left
else sy > 0 ? turn_down : turn_up
end
end
end
end
class Game_Event
alias amsu_game_event_initialize initialize
def initialize(map_id, event)
@name = event.name.downcase
amsu_game_event_initialize(map_id, event)
end
alias amsu_game_event_refresh refresh
def refresh
amsu_game_event_refresh
self.character_name = @character_name
@down_anime = true if @name[/\\ad/]
@fall_anime = true if @name[/\\af/]
@jump_anime = true if @name[/\\aj/]
@spec_anime = true if @name[/\\as/]
@floor = $1.to_i if @name[/\\f\[([0-9-]+)\]/]
@follow_distance = $1.to_f if @name[/\\fd\[([0-9.]+)\]/]
@follow_event_id = $1.to_i if @name[/\\fe\[([0-9-]+)\]/]
@jump_power = $1.to_f if @name[/\\jp\[([0-9.]+)\]/]
@move_animation_speed = $1.to_f if @name[/\\ma\[([0-9.]+)\]/]
@move_speed = Math.min($1.to_f, 7) if @name[/\\ms\[([0-9.]+)\]/]
@position = $1.to_i if @name[/\\p\[([1-9])\]/]
@shadow = true if @name[/\\s/]
@walk_audio = false if @name[/\\wa/]
@walk_graphics = false if @name[/\\wg/]
@walk_steps = $1.to_i if @name[/\\ws\[([0-9]+)\]/]
@walk_terrain = $1.to_i if @name[/\\wt\[([0-9-]+)\]/]
@zoom = $1.to_f if @name[/\\z\[([0-9.]+)\]/]
$game_map.tile_events.delete(self)
$game_map.tile_events.push(self) if @tile_id > 0
end
end
class Game_Player
alias amsu_game_player_moveto moveto
def moveto(x, y)
amsu_game_player_moveto(x, y)
(1001..1003).each {|i| $game_map.events[i].moveto(x, y)}
end
alias amsu_game_player_refresh refresh
def refresh
amsu_game_player_refresh
self.character_name = @character_name
$game_party.train_actors($game_party.train_actors_visible)
end
def update
last_x, last_y, last_real_x, last_real_y = @x, @y, @real_x, @real_y-@real_z
update_inputs if @phase != 6
super
if @real_y-@real_z > last_real_y and @real_y-@real_z-$game_map.display_y > CENTER_Y
$game_map.scroll_down(@real_y-@real_z-last_real_y)
elsif @real_y-@real_z < last_real_y and @real_y-@real_z-$game_map.display_y < CENTER_Y
$game_map.scroll_up(last_real_y-@real_y+@real_z)
end
if @real_x < last_real_x and @real_x-$game_map.display_x < CENTER_X
$game_map.scroll_left(last_real_x-@real_x)
elsif @real_x > last_real_x and @real_x-$game_map.display_x > CENTER_X
$game_map.scroll_right(@real_x-last_real_x)
end
unless moving?
if last_x != @x or last_y != @y
unless check_event_trigger_here([1,2])
unless $DEBUG and Input.press?(Input::CTRL)
@encounter_count -= 1 if @encounter_count > 0
end
end
end
if Input.trigger?(Input::C) and !new_jumping?
check_event_trigger_here([0])
check_event_trigger_there([0,1,2])
end
end
end
def update_inputs
unless moving? or $game_system.map_interpreter.running? or @move_route_forcing or $game_temp.message_window_showing
case Input.dir8
when 1; move_lower_left(true, @real_move_speed)
when 2; move_down(true, @real_move_speed)
when 3; move_lower_right(true, @real_move_speed)
when 4; move_left(true, @real_move_speed)
when 6; move_right(true, @real_move_speed)
when 7; move_upper_left(true, @real_move_speed)
when 8; move_up(true, @real_move_speed)
when 9; move_upper_right(true, @real_move_speed)
end
unless new_jumping?
@dash = (Input.press?(Dash_Input) and Input.dir8 > 0)
new_jump if Input.trigger?(Jump_Input)
end
end
end
def make_step(step, dash) super; $game_party.increase_steps if @phase == 2 or @phase == 3 end
def increase_steps
super
d = $game_party.distance
$game_party.increase_distance
$game_party.check_map_slip_damage if d != $game_party.distance and $game_party.distance % 2 == 0
end
def jump(x_plus = 0, y_plus = 0) super; $game_system.se_play(Jump_Audio) end
def new_jump() super; $game_system.se_play(Jump_Audio) end
end
class Sprite_Character
alias amsu_sprite_character_initialize initialize
def initialize(viewport, character)
@trails = [Sprite_Trail.new(viewport, [1], character)]
amsu_sprite_character_initialize(viewport, character)
end
def update
super
update_bitmap
update_sprite
update_trails
update_animation0
end
def update_bitmap
if @tile_id != @character.tile_id or @character_name != @character.character_name or @character_hue != @character.character_hue or @position != @character.position
@tile_id, @character_name, @character_hue, @position = @character.tile_id, @character.character_name, @character.character_hue, @character.position
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name, @tile_id, @character_hue)
@cw = @ch = 32
self.src_rect.set(0, 0, @cw, @ch)
self.ox, self.oy = @cw / 2, @ch
else
self.bitmap = RPG::Cache.character(@character_name, @character_hue)
@character.direction_max = (@character_name[/_dir\[([0-9]+)\]/] ? $1.to_i : 4)
@character.pattern_max = (@character_name[/_mvt\[([0-9]+)\]/] ? $1.to_i : 4)
@cw, @ch = bitmap.width/@character.pattern_max, bitmap.height/@character.direction_max
pos_x, pos_y = (@position - 1) % 3, (@position - 1) / 3
self.ox, self.oy = @cw*(pos_x/2.0)+16*(1-pos_x), @ch*(pos_y/2.0)+16*(2-pos_y)
end
@trails[0].update_shadow_size(@cw, @ch)
end
end
def update_sprite
self.visible = !@character.transparent
if @tile_id == 0
sx = @character.pattern * @cw
if @character.direction_max == 4; sy = (@character.direction - 2) / 2 * @ch
else sy = (Math.min(@character.direction, @character.direction_max) - 1) * @ch
end
self.src_rect.set(sx, sy, @cw, @ch)
self.zoom_x = self.zoom_y = @character.real_zoom
end
self.x = @character.screen_x
self.y = @character.screen_y
self.z = @character.screen_z(@ch)
self.opacity = @character.opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
end
def update_trails
@character.trails.each {|t| @trails.push(Sprite_Trail.new(viewport, t, @character))}
@character.trails.clear
@trails.each {|t| t.update; @trails[@trails.index(t)] = t.dispose if t.opacity == 0}
@trails.compact!
end
def update_animation0
if @character.animation_id != 0
animation($data_animations[@character.animation_id], true)
@character.animation_id = 0
end
end
end
class Sprite_Trail < Sprite
def initialize(viewport, trail, character)
super(viewport)
@character, @type = character, trail[0]
case @type
when 0; self.opacity = 0
when 1
self.bitmap = RPG::Cache.picture("Data System/Shadow")
self.ox, self.oy = bitmap.width / 2, bitmap.height - 6
when 2
self.bitmap = RPG::Cache.picture(trail[1])
@real_opacity = 255
@opacity_fade = @real_opacity.to_f / Math.max(trail[2] + 1, 1)
cw, ch = bitmap.width / 4, bitmap.height / 8
sx, sy = trail[3] * cw, (@character.direction - 1) * ch
self.src_rect.set(sx, sy, cw, ch)
self.ox, self.oy = cw / 2, ch
self.zoom_x = self.zoom_y = @character.real_zoom
@real_x, @real_y = @character.real_x, @character.real_y
@y_plus = 0
when 3
character_name = @character.special_trail_name
character_name = @character.character_name if character_name.empty?
self.bitmap = RPG::Cache.character(character_name, @character.special_trail_hue)
self.blend_type = @character.special_trail_blend_type
self.opacity = @real_opacity = @character.special_trail_opacity
@opacity_fade = @real_opacity.to_f / Math.max(@character.special_trail_duration + 1, 1)
direction_max = (character_name[/_dir\[([0-9]+)\]/] ? $1.to_i : 4)
pattern_max = (character_name[/_mvt\[([0-9]+)\]/] ? $1.to_i : 4)
cw, ch = bitmap.width / pattern_max, bitmap.height / direction_max
sx = @character.pattern % pattern_max * cw
if direction_max == 4; sy = (@character.direction - 2) / 2 * ch
else sy = (Math.min(@character.direction, direction_max) - 1) * ch
end
self.src_rect.set(sx, sy, cw, ch)
self.ox, self.oy = cw / 2, ch
self.zoom_x = self.zoom_y = @character.real_zoom
@real_x, @real_y = @character.real_x, @character.real_y
@y_plus = @character.screen_y - (@real_y - $game_map.display_y + 3) / 4 - 32
end
end
def update_shadow_size(cw, ch) @cw, @ch = cw, ch end
def update
case @type
when 1
self.visible = (!@character.transparent and @character.shadow and !@character.character_name.empty?)
self.x = @character.screen_x
self.y = (@character.real_y - $game_map.display_y + 3) / 4 + 32
self.zoom_x = @character.real_zoom * @cw / 40.0 / Math.max(@character.real_z / 256.0, 1)
self.zoom_y = self.zoom_x / 2.0
when 2, 3
self.visible = !@character.transparent
self.x = (@real_x - $game_map.display_x + 3)/4 + 16
self.y = (@real_y - $game_map.display_y + 3)/4 + 32 + @y_plus
@real_opacity -= @opacity_fade
self.opacity = @real_opacity.round
end
end
end
module Math
def self.min(x, max) x < max ? x : max end
def self.max(x, min) x > min ? x : min end
def self.middle(min, x, max) x > min ? x < max ? x : max : min end
end |