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
| =begin
New Character Properties with Calls 2.2
by PK8
Created: 5/12/2009
Modified: 6/11/2012
──────────────────────────────────────────────────────────────────────────────
■ Author's Notes
I wanted to work on letting game creators animate character sprites a little
more through script calls. I noticed certain properties such as angle, color,
mirror, tone, and angle were missing so I wanted to add them in.
──────────────────────────────────────────────────────────────────────────────
■ Introduction & Description
This script adds additional properties from the Sprite class to
Game_Character such as angle, color, mirror, tone, zoom_x, and zoom_y.
For this version, I also combined my Event Angle/Color/Mirror/Tone/Zoom
add-ons and my script calls with this script.
──────────────────────────────────────────────────────────────────────────────
■ Features
o This gives Character sprites additional properties from the Sprite class
such as Angle, Color, Mirror, Tone, Zoom, and Wave.
o Change the angle, color, mirror, tone, and zoom of a character sprite using
script calls.
o Set Angle, Color, Mirror, Tone, Zoom, and Wave of Events using special
comments.
o Change certain properties of a character sprite to a desired value in a
certain number of frames with a script call.
──────────────────────────────────────────────────────────────────────────────
■ Methods Aliased
Sprite_Character.update
Game_Character.initialize
Game_Character.update
Game_Event.refresh
──────────────────────────────────────────────────────────────────────────────
■ Thanks
Charlie Fleed showed me how to create these special comments a few years ago.
This one is more of a shoutout than a thanks. Okay, it's a bit of both. I'd
like to send a shoutout to Prof. Meow Meow who showed me a demo of his a
few years ago making use of a previous version of this script. I thought
it was an awesome experience being able to see how other people would use
it, and I enjoyed how Prof. Meow Meow made use of it. So hey Prof., if
you're still RMing, thanks.
──────────────────────────────────────────────────────────────────────────────
■ Changelog (MM/DD/YYYY)
v1 (05/10/2009): Initial release.
v1.1 (05/10/2009): Replaced attr_reader with attr_accessor.
v1.2 (05/12/2009): Replaced initial zoom_x/zoom_y value of 1.0 with 100
v2 (04/14/2012): Combines Event Angle/Color/Mirror/Tone/Zoom and
changing properties in frames but throws in various
new calls to the mix while some of them are renamed,
such as sizex_change => zoom_x_change.
v2.1 (04/15/2012): Added relative arguments for all methods.
v2.1.1 (06/11/2012): Reduced the lines of code by about about a hundred, and
added new instance variables that can be written into via
script calls such as the @*_target and @*_duration
variables.
v2.2 (06/11/2012): Users can now use Arrays when changing Tones and Colors of
characters via script calls.
(Example: $game_player.tone = [0, -255, 0, 120])
──────────────────────────────────────────────────────────────────────────────
■ Usage
┌──────────────────────────────────────────────────────────────────────────┐
│ ■ Adjusting Character Sprites. │
└┬───────────────┬─────────────────────────────────────────────────────────┘
│ Setting Angle │
└───────────────┘
Syntax
Player: $game_player.angle = value
Event: $game_map.events[id].angle = value
Vehicle: $game_map.vehicle[id].angle = value
Examples
Player: $game_player.angle = 90
Event: $game_map.events[1].angle = 90
Vehicle: $game_map.vehicle[1].angle = 90
└┬───────────────┬─────────────────────────────────────────────────────────┘
│ Setting Color │
└───────────────┘
Min/Max values
r/g/b: 0/255
alpha: 0/255 (Optional)
Syntax (All channels)
Player: $game_player.color = Color.new(red, green, blue[, alpha])
Event: $game_map.events[id].color = Color.new(red, green, blue[, alpha])
Vehicle: $game_map.vehicle[id].color = Color.new(red, green, blue[, alpha])
Examples (All: without Alpha)
Player: $game_player.color = Color.new(255, 255, 255)
Event: $game_map.events[1].color = Color.new(255, 255, 255)
Vehicle: $game_map.vehicle[1].color = Color.new(255, 255, 255)
Examples (All: with Alpha)
Player: $game_player.color = Color.new(255, 255, 255, 255)
Event: $game_map.events[1].color = Color.new(255, 255, 255, 255)
Vehicle: $game_map.vehicle[1].color = Color.new(255, 255, 255, 255)
Syntax (Specific)
Player: $game_player.color.red = value
Player: $game_player.color.green = value
Player: $game_player.color.blue = value
Player: $game_player.color.alpha = value
Event: $game_map.events[id].color.red = value
Event: $game_map.events[id].color.green = value
Event: $game_map.events[id].color.blue = value
Event: $game_map.events[id].color.alpha = value
Vehicle: $game_map.vehicle[id].color.red = value
Vehicle: $game_map.vehicle[id].color.green = value
Vehicle: $game_map.vehicle[id].color.blue = value
Vehicle: $game_map.vehicle[id].color.alpha = value
Examples (Specific)
Player: $game_player.color.red = 60
Player: $game_player.color.green = 120
Player: $game_player.color.blue = 180
Player: $game_player.color.alpha = 255
Event: $game_map.events[1].color.red = 60
Event: $game_map.events[1].color.green = 120
Event: $game_map.events[1].color.blue = 180
Event: $game_map.events[1].color.alpha = 255
Vehicle: $game_map.vehicle[1].color.red = 60
Vehicle: $game_map.vehicle[1].color.green = 120
Vehicle: $game_map.vehicle[1].color.blue = 180
Vehicle: $game_map.vehicle[1].color.alpha = 255
└┬────────────────┬────────────────────────────────────────────────────────┘
│ Setting Mirror │
└────────────────┘
Values
true: Turns Mirror on.
false: Turns Mirror off.
Syntax
Player: $game_player.mirror = value
Event: $game_map.events[id].mirror = value
Vehicle: $game_map.vehicle[id].mirror = value
Examples
Player: $game_player.mirror = true
Event: $game_map.events[1].mirror = true
Vehicle: $game_map.vehicle[1].mirror = true
└┬──────────────┬──────────────────────────────────────────────────────────┘
│ Setting Tone │
└──────────────┘
Min/Max values
r/g/b: -255/255
gray: 0/255 (Optional)
Syntax (All)
Player: $game_player.tone = Tone.new(red, green, blue[, gray])
Event: $game_map.events[id].tone = Tone.new(red, green, blue[, gray])
Vehicle: $game_map.vehicle[id].tone = Tone.new(red, green, blue[, gray])
Examples (All: without Gray)
Player: $game_player.tone = Tone.new(255, 255, 255)
Event: $game_map.events[1].tone = Tone.new(255, 255, 255)
Vehicle: $game_map.vehicle[1].tone = Tone.new(255, 255, 255)
Examples (All: with Gray)
Player: $game_player.tone = Tone.new(255, 255, 255, 255)
Event: $game_map.events[1].tone = Tone.new(255, 255, 255, 255)
Vehicle: $game_map.vehicle[1].tone = Tone.new(255, 255, 255, 255)
Syntax (Specific)
Player: $game_player.tone.red = value
Player: $game_player.tone.green = value
Player: $game_player.tone.blue = value
Player: $game_player.tone.gray = value
Event: $game_map.events[id].tone.red = value
Event: $game_map.events[id].tone.green = value
Event: $game_map.events[id].tone.blue = value
Event: $game_map.events[id].tone.gray = value
Vehicle: $game_map.vehicle[id].tone.red = value
Vehicle: $game_map.vehicle[id].tone.green = value
Vehicle: $game_map.vehicle[id].tone.blue = value
Vehicle: $game_map.vehicle[id].tone.gray = value
Examples (Specific)
Player: $game_player.tone.red = 60
Player: $game_player.tone.green = 120
Player: $game_player.tone.blue = 180
Player: $game_player.tone.gray = 255
Event: $game_map.events[1].tone.red = 60
Event: $game_map.events[1].tone.green = 120
Event: $game_map.events[1].tone.blue = 180
Event: $game_map.events[1].tone.alpha = 255
Vehicle: $game_map.vehicle[1].tone.red = 60
Vehicle: $game_map.vehicle[1].tone.green = 120
Vehicle: $game_map.vehicle[1].tone.blue = 180
Vehicle: $game_map.vehicle[1].tone.alpha = 255
└┬──────────────┬──────────────────────────────────────────────────────────┘
│ Setting Zoom │
└──────────────┘
Values
100: Denotes actual pixel size
Syntax
Player: $game_player.zoom_x = value
Player: $game_player.zoom_y = value
Event: $game_map.events[id].zoom_x = value
Event: $game_map.events[id].zoom_y = value
Vehicle: $game_map.vehicle[id].zoom_x = value
Vehicle: $game_map.vehicle[id].zoom_y = value
Examples
Player: $game_player.zoom_x = 125
Player: $game_player.zoom_y = 125
Event: $game_map.events[1].zoom_x = 125
Event: $game_map.events[1].zoom_y = 125
Vehicle: $game_map.vehicle[1].zoom_x = 125
Vehicle: $game_map.vehicle[1].zoom_y = 125
└┬──────────────┬──────────────────────────────────────────────────────────┘
│ Setting Wave │
└──────────────┘
Values
Wave Length: Minimum is 2
Syntax
Player: $game_player.wave_amp = value
Player: $game_player.wave_length = value
Player: $game_player.wave_speed = value
Event: $game_map.events[id].wave_amp = value
Event: $game_map.events[id].wave_length = value
Event: $game_map.events[id].wave_speed = value
Vehicle: $game_map.vehicle[id].wave_amp = value
Vehicle: $game_map.vehicle[id].wave_length = value
Vehicle: $game_map.vehicle[id].wave_speed = value
┌──────────────────────────────────────────────────────────────────────────┐
│ ■ Special Comments for Events │
└──────────────────────────────────────────────────────────────────────────┘
You get to set up how events would appear.
Angle: $angle value
Color: $color red green blue alpha
Color Red: $color_red value
Color Green: $color_green value
Color Blue: $color_blue value
Color Alpha: $color_alpha value
* Red/Green/Blue/Alpha: 0/255
Mirror: $mirror
Mirror False:$mirror false
Mirror True: $mirror true
Tone: $tone red green blue gray
Tone Red: $tone red
Tone Green: $tone green
Tone Blue: $tone blue
Tone Gray: $tone gray
* Red/Green/Blue: -255/255 | Gray: 0/255
Zoom: $zoom zoom_x zoom_y
Zoom X: $zoom_x value
Zoom Y: $zoom_y value
* 100: Denotes actual pixel size
Wave Amp: $wave_amp value
Wave Length: $wave_length value
* Minimum value: 2
Wave Speed: $wave_speed value
┌──────────────────────────────────────────────────────────────────────────┐
│ ■ Changing properties in frames │
└┬─────────────────────────┬───────────────────────────────────────────────┘
│ Setting Angle in frames │
└─────────────────────────┘
Player: $game_player.angle_change(value, duration, relative)
Event: $game_map.events[id].angle_change(value, duration, relative)
Vehicle: $game_map.vehicle[id].angle_change(value, duration, relative)
* relative: Optional. Set to false by default.
└┬─────────────────────────┬───────────────────────────────────────────────┘
│ Setting Color in frames │
└─────────────────────────┘
Syntax (All)
Player: $game_player.color_change([red, green, blue, alpha], duration,
relative)
Event: $game_map.events[id].color_change([red, green, blue, alpha]),
duration, relative)
Vehicle: $game_map.events[id].color_change([red, green, blue, alpha],
duration, relative)
* alpha: 0 - 255. Optional.
* relative: Optional. Set to false by default.
Syntax (Specific)
Player: $game_player.color_red_change(value, duration, rel)
Player: $game_player.color_green_change(value, duration, rel)
Player: $game_player.color_blue_change(value, duration, rel)
Player: $game_player.color_alpha_change(value, duration, rel)
Event: $game_map.events[id].color_red_change(value, duration, rel)
Event: $game_map.events[id].color_green_change(value, duration, rel)
Event: $game_map.events[id].color_blue_change(value, duration, rel)
Event: $game_map.events[id].color_alpha_change(value, duration, rel)
Vehicle: $game_map.vehicle[id].color_red_change(value, duration, rel)
Vehicle: $game_map.vehicle[id].color_green_change(value, duration, rel)
Vehicle: $game_map.vehicle[id].color_blue_change(value, duration, rel)
Vehicle: $game_map.vehicle[id].color_alpha_change(value, duration, rel)
* relative: Optional. Set to false by default.
└┬────────────────────────┬────────────────────────────────────────────────┘
│ Setting Tone in Frames │
└────────────────────────┘
Syntax (All)
Player: $game_player.tone_change([red, green, blue, gray], duration,
relative)
Event: $game_map.events[id].tone_change([red, green, blue, gray],
duration, relative)
Vehicle: $game_map.vehicle[id].tone_change([red, green, blue, gray],
duration, relative)
* gray: 0 - 255. Optional.
* relative: Optional. Set to false by default.
Syntax (Specific)
Player: $game_player.tone_red_change(value, duration, rel)
Player: $game_player.tone_green_change(value, duration, rel)
Player: $game_player.tone_blue_change(value, duration, rel)
Player: $game_player.tone_gray_change(value, duration, rel)
Event: $game_map.events[id].tone_red_change(value, duration, rel)
Event: $game_map.events[id].tone_green_change(value, duration, rel)
Event: $game_map.events[id].tone_blue_change(value, duration, rel)
Event: $game_map.events[id].tone_gray_change(value, duration, rel)
Vehicle: $game_map.vehicle[id].tone_red_change(value, duration, rel)
Vehicle: $game_map.vehicle[id].tone_green_change(value, duration, rel)
Vehicle: $game_map.vehicle[id].tone_blue_change(value, duration, rel)
Vehicle: $game_map.vehicle[id].tone_gray_change(value, duration, rel)
* relative: Optional. Set to false by default.
└┬────────────────────────┬────────────────────────────────────────────────┘
│ Setting Zoom in Frames │
└────────────────────────┘
Syntax (All)
Player: $game_player.zoom_change(zoom_x, zoom_y, duration, rel)
Event: $game_map.events[id].zoom_change(zoom_x, zoom_y, duration, rel)
Vehicle: $game_map.vehicle[id].zoom_change(zoom_x, zoom_y, duration, rel)
* relative: Optional. Set to false by default.
Syntax (Specific)
Player: $game_player.zoom_x_change(value, duration, rel)
Player: $game_player.zoom_y_change(value, duration, rel)
Event: $game_map.events[id].zoom_x_change(value, duration, rel)
Event: $game_map.events[id].zoom_y_change(value, duration, rel)
Vehicle: $game_map.vehicle[id].zoom_x_change(value, duration, rel)
Vehicle: $game_map.vehicle[id].zoom_y_change(value, duration, rel)
* relative: Optional. Set to false by default.
└┬────────────────────────┬────────────────────────────────────────────────┘
│ Setting Wave in Frames │
└────────────────────────┘
Syntax (Wave Amplitude)
Player: $game_player.wave_amp_change(value, duration, rel)
Event: $game_map.events[id].wave_amp_change(value, duration, rel)
Vehicle: $game_map.vehicle[id].wave_amp_change(value, duration, rel)
Syntax (Wave Length)
Player: $game_player.wave_length_change(value, duration, rel)
Event: $game_map.events[id].wave_length_change(value, duration, rel)
Vehicle: $game_map.vehicle[id].wave_length_change(value, duration, rel)
Syntax (Wave Speed)
Player: $game_player.wave_speed_change(value, duration, rel)
Event: $game_map.events[id].wave_speed_change(value, duration, rel)
Vehicle: $game_map.vehicle[id].wave_speed_change(value, duration, rel)
* relative: Optional. Set to false by default.
──────────────────────────────────────────────────────────────────────────────
■ FAQ
o I am getting a FalseClass error whenever I apply Tone/Color. What do I do?
Add "return true" (no quotes) into the script call.
=end
#==============================================================================
# ** Sprite_Character
#------------------------------------------------------------------------------
# This sprite is used to display the character.It observes the Game_Character
# class and automatically changes sprite conditions.
#==============================================================================
class Sprite_Character < Sprite_Base
#---------------------------------------------------------------------------
# * Alias Listings
#---------------------------------------------------------------------------
alias_method(:pk8_ncp_update, :update) unless method_defined?(:pk8_ncp_update)
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
pk8_ncp_update
super
self.tone = @character.tone
self.angle = @character.angle
self.zoom_x = @character.zoom_x / 100.0
self.zoom_y = @character.zoom_y / 100.0
self.mirror = @character.mirror
self.color = @character.color
self.wave_amp = @character.wave_amp
self.wave_length = @character.wave_length
self.wave_speed = @character.wave_speed
end
end
#==============================================================================
# ** Game_Character
#------------------------------------------------------------------------------
# This class deals with characters. It's used as a superclass for the
# Game_Player and Game_Event classes.
#==============================================================================
class Game_Character
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :tone, :angle, :zoom_x, :zoom_y, :mirror, :color, :wave_amp,
:wave_length, :wave_speed, :angle_target, :angle_duration,
:tone_target, :tone_duration, :tone_red_target,
:tone_red_duration, :tone_green_target, :tone_green_duration,
:tone_blue_target, :tone_blue_duration, :tone_gray_target,
:tone_gray_duration, :color_target, :color_duration,
:color_red_target, :color_red_duration, :color_green_target,
:color_green_duration, :color_blue_target, :color_blue_duration,
:zoom_x_target, :zoom_x_duration, :zoom_y_target,
:zoom_y_duration, :wave_amp_target, :wave_amp_duration,
:wave_length_target, :wave_length_duration, :wave_speed_target,
:wave_speed_duration
#---------------------------------------------------------------------------
# * Alias Listings
#---------------------------------------------------------------------------
unless method_defined?(:pk8_ncp_initialize)
alias_method(:pk8_ncp_initialize, :initialize)
alias_method(:pk8_ncp_update, :update)
end
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
pk8_ncp_initialize
@tone = Tone.new(0, 0, 0, 0)
@angle = 0
@zoom_x, @zoom_y = 100.0, 100.0
@mirror = false
@color = Color.new(0, 0, 0, 0)
@angle_target, @angle_duration = 0, 0
@tone_target, @tone_duration = Tone.new(0,0,0,0), 0
@tone_red_target, @tone_red_duration = 0, 0
@tone_green_target, @tone_green_duration = 0, 0
@tone_blue_target, @tone_blue_duration = 0, 0
@tone_gray_target, @tone_gray_duration = 0, 0
@color_target, @color_duration = Color.new(0,0,0,0), 0
@color_red_target, @color_red_duration = 0, 0
@color_green_target, @color_green_duration = 0, 0
@color_blue_target, @color_blue_duration = 0, 0
@color_alpha_target, @color_alpha_duration = 0, 0
@zoom_x_target, @zoom_x_duration = 0, 0
@zoom_y_target, @zoom_y_duration = 0, 0
@wave_amp_target, @wave_amp_duration = 0, 0
@wave_length_target, @wave_length_duration = 2, 0
@wave_speed_target, @wave_speed_duration = 0, 0
@wave_amp, @wave_length, @wave_speed = 0, 2, 0
end
#--------------------------------------------------------------------------
# * Set Tone
#--------------------------------------------------------------------------
def tone=(value)
value = Tone.new(*value) if value.is_a?(Array)
@tone = value
end
#--------------------------------------------------------------------------
# * Set Color
#--------------------------------------------------------------------------
def color=(value)
value = Color.new(*value) if value.is_a?(Array)
@color = value
end
#--------------------------------------------------------------------------
# * Angle Change
# angle : Picture angle
# duration : Frame amount.
# relative : References current value and adds to it, if true.
#--------------------------------------------------------------------------
def angle_change(angle, duration, relative = false)
@angle_target = (relative == true ? @angle + angle : angle)
@angle_duration = duration
@angle = @angle_target.clone if @angle_duration == 0
end
#--------------------------------------------------------------------------
# * Tone Change
# tone : Target Tone. (Tone.new(red, green, blue[, gray))
# duration : Frame amount.
# relative : References current value and adds to it, if true.
#--------------------------------------------------------------------------
def tone_change(tone, duration, relative = false)
tone = Tone.new(*tone) if tone.is_a?(Array)
if relative == true
tone.red, tone.green = @tone.red + tone.red, @tone.green + tone.green
tone.blue, tone.gray = @tone.blue + tone.blue, @tone.gray + tone.gray
end
@tone_target = tone.clone
@tone_duration = duration
@tone = @tone_target.clone if @tone_duration == 0
end
#--------------------------------------------------------------------------
# * Tone Red Change
# tone_red : Target Red Tone. (-255 - 255)
# duration : Frame amount.
# relative : References current value and adds to it, if true.
#--------------------------------------------------------------------------
def tone_red_change(tone_red, duration, relative = false)
@tone_red_target = (relative == true ? @tone.red + tone_red : tone_red)
@tone_red_duration = duration
@tone.red = @tone_red_target.clone if @tone_red_duration == 0
end
#--------------------------------------------------------------------------
# * Tone Green Change
# tone_green : Target Green Tone. (-255 - 255)
# duration : Frame amount.
# relative : References current value and adds to it, if true.
#--------------------------------------------------------------------------
def tone_green_change(tone_green, duration, relative = false)
@tone_green_target = (relative==true ? @tone.green+tone_green : tone_green)
@tone_green_duration = duration
@tone.green = @tone_green_target.clone if @tone_green_duration == 0
end
#--------------------------------------------------------------------------
# * Tone Blue Change
# tone_blue : Target Blue Tone. (-255 - 255)
# duration : Frame amount.
# relative : References current value and adds to it, if true.
#--------------------------------------------------------------------------
def tone_blue_change(tone_blue, duration, relative = false)
@tone_blue_target = (relative == true ? @tone.blue+tone_blue : tone_blue)
@tone_blue_duration = duration
@tone.blue = @tone_blue_target.clone if @tone_blue_duration == 0
end
#--------------------------------------------------------------------------
# * Tone Gray Change
# tone_blue : Target Gray Tone. (0 - 255)
# duration : Frame amount.
# relative : References current value and adds to it, if true.
#--------------------------------------------------------------------------
def tone_gray_change(tone_gray, duration, relative = false)
@tone_gray_target = (relative == true ? @tone.gray + tone_gray : tone_gray)
@tone_gray_duration = duration
@tone.gray = @tone_gray_target.clone if @tone_gray_duration == 0
end
#--------------------------------------------------------------------------
# * Color Change
# color : Target Color. (Color.new(red, green, blue[, alpha))
# duration : Frame amount.
# relative : References current value and adds to it, if true.
#--------------------------------------------------------------------------
def color_change(color, duration, relative = false)
color = Color.new(*color) if color.is_a?(Array)
if relative == true
color.red, color.green = @color.red+color.red, @color.green+color.green
color.blue, color.alpha = @color.blue+color.blue, @color.alpha+color.alpha
end
@color_target = color.clone
@color_duration = duration
@color = @color_target.clone if @color_duration == 0
end
#--------------------------------------------------------------------------
# * Color Red Change
# color_red : Target Red Color. (0 - 255)
# duration : Frame amount.
# relative : References current value and adds to it, if true.
#--------------------------------------------------------------------------
def color_red_change(color_red, duration, relative = false)
@color_red_target = (relative == true ? @color.red + color_red : color_red)
@color_red_duration = duration
@color.red = @color_red_target.clone if @color_red_duration == 0
end
#--------------------------------------------------------------------------
# * Color Green Change
# color_green : Target Green Color. (0 - 255)
# duration : Frame amount.
# relative : References current value and adds to it, if true.
#--------------------------------------------------------------------------
def color_green_change(color_green, duration, relative = false)
@color_green_target=(relative==true ?@color.green+color_green : color_green)
@color_green_duration = duration
@color.green = @color_green_target.clone if @color_green_duration == 0
end
#--------------------------------------------------------------------------
# * Color Blue Change
# color_blue : Target Blue Color. (0 - 255)
# duration : Frame amount.
# relative : References current value and adds to it, if true.
#--------------------------------------------------------------------------
def color_blue_change(color_blue, duration, relative = false)
@color_blue_target =(relative == true ? @color.blue+color_blue : color_blue)
@color_blue_duration = duration
@color.blue = @color_blue_target.clone if @color_blue_duration == 0
end
#--------------------------------------------------------------------------
# * Color Alpha Change
# color_alpha : Target Alpha. (0 - 255)
# duration : Frame amount.
# relative : References current value and adds to it, if true.
#--------------------------------------------------------------------------
def color_alpha_change(color_alpha, duration, relative = false)
@color_alpha_target=(relative==true ?@color.alpha+color_alpha : color_alpha)
@color_alpha_duration = duration
@color.alpha = @color_alpha_target.clone if @color_alpha_duration == 0
end
#--------------------------------------------------------------------------
# * Zoom Change
# zoom_x : X-Axis Zoom Level
# zoom_y : Y-Axis Zoom Level
# duration : Frame amount.
# relative : References current value and adds to it, if true.
#--------------------------------------------------------------------------
def zoom_change(zoom_x, zoom_y, duration, relative = false)
if relative == true
@zoom_x_target, @zoom_y_target = @zoom_x + zoom_x, @zoom_y + zoom_y
else
@zoom_x_target, @zoom_y_target = zoom_x, zoom_y
end
@zoom_x_duration = duration
@zoom_x = @zoom_x_target.clone if @zoom_x_duration == 0
@zoom_y_duration = duration
@zoom_y = @zoom_y_target.clone if @zoom_y_duration == 0
end
#--------------------------------------------------------------------------
# * Zoom_X Change
# zoom_x : X-Axis Zoom Level
# duration : Frame amount.
# relative : References current value and adds to it, if true.
#--------------------------------------------------------------------------
def zoom_x_change(zoom_x, duration, relative = false)
@zoom_x_target = (relative == true ? @zoom_x + zoom_x : zoom_x)
@zoom_x_duration = duration
@zoom_x = @zoom_x_target.clone if @zoom_x_duration == 0
end
#--------------------------------------------------------------------------
# * Zoom_Y Change
# zoom_y : Y-Axis Zoom Level
# duration : Frame amount.
# relative : References current value and adds to it, if true.
#--------------------------------------------------------------------------
def zoom_y_change(zoom_y, duration, relative = false)
@zoom_y_target = (relative == true ? @zoom_y + zoom_y : zoom_y)
@zoom_y_duration = duration
@zoom_y = @zoom_y_target.clone if @zoom_y_duration == 0
end
#--------------------------------------------------------------------------
# * Wave Amplitude Change
# wave_amp : Target Wave Amplitude. (0 > )
# duration : Frame amount.
# relative : References current value and adds to it, if true.
#--------------------------------------------------------------------------
def wave_amp_change(wave_amp, duration, relative = false)
@wave_amp_target = (relative == true ? @wave_amp + wave_amp : wave_amp)
@wave_amp_duration = duration
@wave_amp = @wave_amp_target.clone if @wave_amp_duration == 0
end
#--------------------------------------------------------------------------
# * Wave Length Change
# wave_length : Target Wave Length. (2 > )
# duration : Frame amount.
# relative : References current value and adds to it, if true.
#--------------------------------------------------------------------------
def wave_length_change(wave_length, duration, relative = false)
@wave_length_target=(relative==true ?@wave_length+wave_length : wave_length)
@wave_length_target = 2 if @wave_length_target < 2
@wave_length_duration = duration
@wave_length = @wave_length_target.clone if @wave_length_duration == 0
end
#--------------------------------------------------------------------------
# * Wave Speed Change
# wave_speed : Target Wave Speed. (0 > )
# duration : Frame amount.
# relative : References current value and adds to it, if true.
#--------------------------------------------------------------------------
def wave_speed_change(wave_speed, duration, relative = false)
@wave_speed_target = (relative==true ? @wave_speed+wave_speed : wave_speed)
@wave_speed_duration = duration
@wave_speed = @wave_speed_target.clone if @wave_speed_duration == 0
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
pk8_ncp_update
if @angle_duration >= 1 # Angle
d = @angle_duration
@angle = (@angle * (d - 1) + @angle_target) / d
@angle_duration -= 1
end
if @color_duration >= 1 # Color
d = @color_duration
@color.red = (@color.red * (d - 1) + @color_target.red) / d
@color.green = (@color.green * (d - 1) + @color_target.green) / d
@color.blue = (@color.blue * (d - 1) + @color_target.blue) / d
@color.alpha = (@color.alpha * (d - 1) + @color_target.alpha) / d
@color_duration -= 1
end
if @color_red_duration >= 1 # Red color
d = @color_red_duration
@color.red = (@color.red * (d - 1) + @color_red_target) / d
@color_red_duration -= 1
end
if @color_green_duration >= 1 # Green color
d = @color_green_duration
@color.green = (@color.green * (d - 1) + @color_green_target) / d
@color_green_duration -= 1
end
if @color_blue_duration >= 1 # Blue color
d = @color_blue_duration
@color.blue = (@color.blue * (d - 1) + @color_blue_target) / d
@color_blue_duration -= 1
end
if @color_alpha_duration >= 1 # Alpha
d = @color_alpha_duration
@color.alpha = (@color.alpha * (d - 1) + @color_alpha_target) / d
@color_alpha_duration -= 1
end
if @tone_duration >= 1 # Tone
d = @tone_duration
@tone.red = (@tone.red * (d - 1) + @tone_target.red) / d
@tone.green = (@tone.green * (d - 1) + @tone_target.green) / d
@tone.blue = (@tone.blue * (d - 1) + @tone_target.blue) / d
@tone.gray = (@tone.gray * (d - 1) + @tone_target.gray) / d
@tone_duration -= 1
end
if @tone_red_duration >= 1 # Red Tone
d = @tone_red_duration
@tone.red = (@tone.red * (d - 1) + @tone_red_target) / d
@tone_red_duration -= 1
end
if @tone_green_duration >= 1 # Green Tone
d = @tone_green_duration
@tone.green = (@tone.green * (d - 1) + @tone_green_target) / d
@tone_green_duration -= 1
end
if @tone_blue_duration >= 1 # Blue Tone
d = @tone_blue_duration
@tone.blue = (@tone.blue * (d - 1) + @tone_blue_target) / d
@tone_blue_duration -= 1
end
if @tone_gray_duration >= 1 # Gray Tone
d = @tone_gray_duration
@tone.gray = (@tone.gray * (d - 1) + @tone_gray_target) / d
@tone_gray_duration -= 1
end
if @zoom_x_duration >= 1 # Zoom X
d = @zoom_x_duration
@zoom_x = (@zoom_x * (d - 1) + @zoom_x_target) / d
@zoom_x_duration -= 1
end
if @zoom_y_duration >= 1 # Zoom Y
d = @zoom_y_duration
@zoom_y = (@zoom_y * (d - 1) + @zoom_y_target) / d
@zoom_y_duration -= 1
end
if @wave_amp_duration >= 1 # Wave Amplitude
d = @wave_amp_duration
@wave_amp = (@wave_amp * (d - 1) + @wave_amp_target) / d
@wave_amp_duration -= 1
end
if @wave_length_duration >= 1 # Wave Length
d = @wave_length_duration
@wave_length = (@wave_length * (d - 1) + @wave_length_target) / d
@wave_length_duration -= 1
end
if @wave_speed_duration >= 1 # Wave Speed
d = @wave_speed_duration
@wave_speed = (@wave_speed * (d - 1) + @wave_speed_target) / d
@wave_speed_duration -= 1
end
end
end
#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
# This class deals with events. It handles functions including event page
# switching via condition determinants, and running parallel process events.
# It's used within the Game_Map class.
#==============================================================================
class Game_Event < Game_Character
#---------------------------------------------------------------------------
# * Alias Listings
#---------------------------------------------------------------------------
alias_method(:pk8_ncp_refresh, :refresh) if !method_defined?(:pk8_ncp_refresh)
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
pk8_ncp_refresh
event_angle_commands(@page) if @page != nil
event_color_commands(@page) if @page != nil
event_color_red_commands(@page) if @page != nil
event_color_green_commands(@page) if @page != nil
event_color_blue_commands(@page) if @page != nil
event_color_alpha_commands(@page) if @page != nil
event_mirror_commands(@page) if @page != nil
event_tone_commands(@page) if @page != nil
event_tone_red_commands(@page) if @page != nil
event_tone_green_commands(@page) if @page != nil
event_tone_blue_commands(@page) if @page != nil
event_tone_gray_commands(@page) if @page != nil
event_zoom_commands(@page) if @page != nil
event_zoom_x_commands(@page) if @page != nil
event_zoom_y_commands(@page) if @page != nil
event_wave_amp_commands(@page) if @page != nil
event_wave_length_commands(@page) if @page != nil
event_wave_speed_commands(@page) if @page != nil
end
#--------------------------------------------------------------------------
# * Event Tone
#--------------------------------------------------------------------------
def event_tone_commands(page)
l = page.list
for i in 0..l.length - 2
c = l[i]
if (c.code == 108 and c.parameters[0][0,5].to_s.downcase.include?("$tone"
) and !c.parameters[0][0,9].to_s.downcase.include?("$tone_red") and
!c.parameters[0][0,11].to_s.downcase.include?("$tone_green") and
!c.parameters[0][0,10].to_s.downcase.include?("$tone_blue") and
!c.parameters[0][0,10].to_s.downcase.include?("$tone_gray"))
c_substrings = c.parameters[0].split(' ')
red = c_substrings[1].to_i
green = c_substrings[2].to_i
blue = c_substrings[3].to_i
gray = c_substrings[4].to_i
@tone = Tone.new(red, green, blue, gray)
end
end
end
#--------------------------------------------------------------------------
# * Event Tone: Red
#--------------------------------------------------------------------------
def event_tone_red_commands(page)
l = page.list
for i in 0..l.length - 2
c = l[i]
if (c.code == 108 and c.parameters[0][0,9].to_s.downcase.include?(
"$tone_red"))
c_substrings = c.parameters[0].split(' ')
@tone.red = c_substrings[1].to_i
end
end
end
#--------------------------------------------------------------------------
# * Event Tone: Green
#--------------------------------------------------------------------------
def event_tone_green_commands(page)
l = page.list
for i in 0..l.length - 2
c = l[i]
if (c.code == 108 and c.parameters[0][0,11].to_s.downcase.include?(
"$tone_green"))
c_substrings = c.parameters[0].split(' ')
@tone.green = c_substrings[1].to_i
end
end
end
#--------------------------------------------------------------------------
# * Event Tone: Blue
#--------------------------------------------------------------------------
def event_tone_blue_commands(page)
l = page.list
for i in 0..l.length - 2
c = l[i]
if (c.code == 108 and c.parameters[0][0,10].to_s.downcase.include?(
"$tone_blue"))
c_substrings = c.parameters[0].split(' ')
@tone.blue = c_substrings[1].to_i
end
end
end
#--------------------------------------------------------------------------
# * Event Tone: Gray
#--------------------------------------------------------------------------
def event_tone_gray_commands(page)
l = page.list
for i in 0..l.length - 2
c = l[i]
if (c.code == 108 and c.parameters[0][0,10].to_s.downcase.include?(
"$tone_gray"))
c_substrings = c.parameters[0].split(' ')
@tone.gray = c_substrings[1].to_i
end
end
end
#--------------------------------------------------------------------------
# * Event Color
#--------------------------------------------------------------------------
def event_color_commands(page)
l = page.list
for i in 0..l.length - 2
c = l[i]
if (c.code == 108 and c.parameters[0][0,6].to_s.downcase.include?(
"$color") and !c.parameters[0][0,10].to_s.downcase.include?("$color_red"
) and !c.parameters[0][0,12].to_s..downcase.include?("$color_green") and
!c.parameters[0][0,11].to_s.downcase.include?("$color_blue") and
!c.parameters[0][0,12].to_s.downcase.include?("$color_alpha"))
c_substrings = c.parameters[0].split(' ')
red, green = c_substrings[1].to_i, c_substrings[2].to_i
blue, alpha = c_substrings[3].to_i, c_substrings[4].to_i
@color = Color.new(red, green, blue, alpha)
end
end
end
#--------------------------------------------------------------------------
# * Event Color: Red
#--------------------------------------------------------------------------
def event_color_red_commands(page)
l = page.list
for i in 0..l.length - 2
c = l[i]
if (c.code == 108 and c.parameters[0][0,10].to_s.downcase.include?(
"$color_red"))
c_substrings = c.parameters[0].split(' ')
@color.red = c_substrings[1].to_i
end
end
end
#--------------------------------------------------------------------------
# * Event Color: Green
#--------------------------------------------------------------------------
def event_color_green_commands(page)
l = page.list
for i in 0..l.length - 2
c = l[i]
if (c.code == 108 and c.parameters[0][0,12].to_s.downcase.include?(
"$color_green"))
c_substrings = c.parameters[0].split(' ')
@color.green = c_substrings[1].to_i
end
end
end
#--------------------------------------------------------------------------
# * Event Color: Blue
#--------------------------------------------------------------------------
def event_color_blue_commands(page)
l = page.list
for i in 0..l.length - 2
c = l[i]
if (c.code == 108 and c.parameters[0][0,11].to_s.downcase.include?(
"$color_blue"))
c_substrings = c.parameters[0].split(' ')
@color.blue = c_substrings[1].to_i
end
end
end
#--------------------------------------------------------------------------
# * Event Color: Alpha
#--------------------------------------------------------------------------
def event_color_alpha_commands(page)
l = page.list
for i in 0..l.length - 2
c = l[i]
if (c.code == 108 and c.parameters[0][0,12].to_s.downcase.include?(
"$color_alpha"))
c_substrings = c.parameters[0].split(' ')
@color.alpha = c_substrings[1].to_i
end
end
end
#--------------------------------------------------------------------------
# * Event Zoom
#--------------------------------------------------------------------------
def event_zoom_commands(page)
l = page.list
for i in 0..l.length - 2
c = l[i]
if (c.code == 108 and c.parameters[0][0,5].to_s.downcase.include?(
"$zoom") and !c.parameters[0][0,7].to_s.downcase.include?("$zoom_x") and
!c.parameters[0][0,7].to_s.downcase.include?("$zoom_y"))
c_substrings = c.parameters[0].split(' ')
@zoom_x, @zoom_y = c_substrings[1].to_i, c_substrings[2].to_i
end
end
end
#--------------------------------------------------------------------------
# * Event Zoom: X
#--------------------------------------------------------------------------
def event_zoom_x_commands(page)
l = page.list
for i in 0..l.length - 2
c = l[i]
if (c.code == 108 and c.parameters[0][0,7].to_s.downcase.include?(
"$zoom_x"))
c_substrings = c.parameters[0].split(' ')
@zoom_x = c_substrings[1].to_i
end
end
end
#--------------------------------------------------------------------------
# * Event Zoom: Y
#--------------------------------------------------------------------------
def event_zoom_y_commands(page)
l = page.list
for i in 0..l.length - 2
c = l[i]
if (c.code == 108 and c.parameters[0][0,7].to_s.downcase.include?(
"$zoom_y"))
c_substrings = c.parameters[0].split(' ')
@zoom_y = c_substrings[1].to_i
end
end
end
#--------------------------------------------------------------------------
# * Event Angle
#--------------------------------------------------------------------------
def event_angle_commands(page)
l = page.list
for i in 0..l.length - 2
c = l[i]
if (c.code == 108 and c.parameters[0][0,6].to_s.downcase.include?(
"$angle"))
c_substrings = c.parameters[0].split(' ')
@angle = c_substrings[1].to_i
end
end
end
#--------------------------------------------------------------------------
# * Event Mirror
#--------------------------------------------------------------------------
def event_mirror_commands(page)
l = page.list
for i in 0..l.length - 2
c = l[i]
if (c.code == 108 and c.parameters[0][0,7].to_s.downcase.include?(
"$mirror"))
c_substrings = c.parameters[0].split(' ')
if c_substrings[1].to_s.downcase.empty?; @mirror = true
else; @mirror = (c_substrings[1].to_s.downcase == "true" ? true : false)
end
end
end
end
#--------------------------------------------------------------------------
# * Event Wave Amplitude
#--------------------------------------------------------------------------
def event_wave_amp_commands(page)
l = page.list
for i in 0..l.length - 2
c = l[i]
if (c.code == 108 and c.parameters[0][0,9].to_s.downcase.include?(
"$wave_amp"))
c_substrings = c.parameters[0].split(' ')
@wave_amp = c_substrings[1].to_i
end
end
end
#--------------------------------------------------------------------------
# * Event Wave Length
#--------------------------------------------------------------------------
def event_wave_length_commands(page)
l = page.list
for i in 0..l.length - 2
c = l[i]
if (c.code == 108 and c.parameters[0][0,12].to_s.downcase.include?(
"$wave_length"))
c_substrings = c.parameters[0].split(' ')
@wave_length = 2 if c_substrings[1].to_i < 2
@wave_length = c_substrings[1].to_i
end
end
end
#--------------------------------------------------------------------------
# * Event Wave Speed
#--------------------------------------------------------------------------
def event_wave_speed_commands(page)
l = page.list
for i in 0..l.length - 2
c = l[i]
if (c.code == 108 and c.parameters[0][0,11].to_s.downcase.include?(
"$wave_speed"))
c_substrings = c.parameters[0].split(' ')
@wave_speed = c_substrings[1].to_i
end
end
end
end |