forked from biud436/MV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRS_WaveFilter.js
1061 lines (944 loc) · 36.2 KB
/
RS_WaveFilter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*:
* RS_WaveFilter.js
* @plugindesc This plugin applies the wave effect to the all objects by using the Fragment Shader.
* @date 2016.01.12
*
* @author biud436
*
* @help
*
* =============================================================================
* Sprite
* =============================================================================
* The following properties applies the wave effect to Sprite.
* For Information, Refer to http://biud436.tistory.com/17
*
* - wave : The default value is false.
* - wave_amp : The default value is to 0.05
* - wave_length : The default value is to a maxHeight (deprecated)
* - wave_speed : The default value is to 0.25
* - wave_phase : The default value is to 360
*
* =============================================================================
* Picture
* =============================================================================
* This plugin command would activate the wave effect to your picture:
*
* PictureWave Start picture_id wave_speed wave_amp
* - picture_id : Specify the id of the game picture.
* - wave_speed : The available value is the number between 0 and 1.
* (The default value is to 0.25)
* - wave_amp : The available value is the number between 0 and 1.
* (The default value is to 0.05)
*
* This plugin command would deactivate the wave effect of your picture:
*
* PictureWave Stop picture_id
* - picture_id : Specify the id of the game picture.
*
* =============================================================================
* Tilemap
* =============================================================================
*
* The following plugin commands applies the wave effect to Tilemap.
* This plugin contains these six types the plugin commands.
*
* These plugin commands allow you to enable or disable the wave effect
*
* TilemapWave Enable
* TilemapWave Disable
*
* This plugin command allows you to set the speed of the wave effect.
* the x is a floating-point number between 0 and 2.
* Default value is to 2.0. But the fragment shader does not use this value.
*
* TilemapWave waveSpeed x
*
* This plugin command allows you to set the amplitude of the wave effect.
* the x is a floating-point number between 0 and 1.
* Default value is to 0.02
*
* TilemapWave waveFrequency x
*
* This plugin command allows you to set the UV speed of the wave effect.
* the x is a floating-point number between 0 and 1.
* Default value is to 0.25
*
* TilemapWave UVSpeed x
*
* =============================================================================
* Event Notetags
* =============================================================================
*
* Notetags :
*
* These note tags allow you to enable or disable the wave effect.
* <WAVE true>
* <WAVE false>
*
* This note tag allows you to set the amplitude of the wave effect.
* the x is a floating-point number between 0 and 1.
* the default value is to 0.02
*
* <WAVE_AMP x>
*
* This note tag allows you to set the speed of the wave effect.
* the x is a floating-point number between 0 and 1.
* the default value is to 0.25
*
* <WAVE_SPEED x>
*
* =============================================================================
* Battle Notetags
* =============================================================================
*
* These note tags allow you to set the wave effect.
* You have to put the note tags in the note area of the map properties.
*
* <BATTLEBACK_WAVE : x y>
*
* These values must replace by a real value such as 0.02
* - x : the x value is the same as a waveFrequency.
* - y : the y value is the same as a waveSpeed.
*
* For Example :
* <BATTLEBACK_WAVE : 0.02 0.25>
*
* When using Yanfly's Action Sequence Pack 1, you can enable its filter too.
* This function has the pointer of the Spriteset_Battle and easy to use.
*
* eval: $gameTemp.setBattleBackWaveEffect(cond, waveAmp, waveSpeed);
* - cond : Specify true or false whether the wave effect is used.
* - waveAmp : the default value is to 0.02
* - waveSpeed : the default value is to 0.25
*
* =============================================================================
* Change Log
* =============================================================================
* 2016.01.14 (v1.0.0) - First Release.
* 2016.01.16 (v1.0.1) - Added the function to remove the filter.
* 2016.01.18 (v1.1.0) - Added the plugin command.
* 2016.01.22 (v1.2.0) - Fixed the Save and Load bug
* 2016.02.16 (v1.3.0) - Fixed Bug (After the player came back to Menu, you had to set the wave effect again)
* 2016.02.26 (v1.3.1) - Fixed the default padding value of the sprite. (default value is to 512)
* 2016.03.03 (v1.3.2) - Added new Sprite Properties (wave_amp, wave_speed, wave_length, wave_phase)
* 2016.08.17 (v1.4.0) - Fixed the issue that is not working in RMMV 1.3.0 (This filter does not support for the time being in Tile-map)
* 2016.08.18 (v1.5.0) - Supports a wave filter in ShaderTilemap.
* 2016.10.20 (v1.5.1) - Fixed the issue that is not working in RMMV 1.3.2
* 2016.11.10 (v1.5.2) - Fixed the issue that is not working in Orange Overlay plugin.
* 2016.11.18 (v1.5.3) - Fixed an issue where the original tilemap is rendered when using Orange Overlay plugin.
* 2016.11.26 (v1.5.4) - Added certain code to remove the texture from memory.
* 2016.11.30 (v1.5.5) - Fixed the issue that has the black border in a filter area.
* 2017.12.10 (v1.5.6) - Added the plugin command called 'PictureWave' (it is tested on 1.6.0 beta version)
* 2018.04.12 (v1.5.7) - Fixed a cutting issue.
* 2018.04.13 (v1.5.7c) - Added the event note tags that can have the wave effect directly for an event graphic.
* 2018.04.15 (v1.5.7e) - Added a new feature that can apply the wave filter in the battle background images
* 2018.04.25 (v1.5.7f) - Fixed the note tag error in Battle Test.
* 2018.05.09 (v1.5.8) - Fixed the bug that is not working the wave filter for the battleback image.
* 2018.11.01 (v1.5.9) :
* - Fixed the issue that the wave filter is not working in the game picture.
* - Fixed the issue that the wave effect do a horizontal looping likes as Tiling Sprite.
* 2018.11.29 (v1.5.10) :
* - Fixed the bug that causes an error when calling Erase Event event command.
* =============================================================================
* Terms of Use
* =============================================================================
* Free for commercial and non-commercial use
*
*/
/*:ko
* @plugindesc 셰이더로 맵이나 특정 그림에 웨이브 효과를 만듭니다.
* @author 러닝은빛(biud436)
*
* @help
* 이 플러그인은 GLSL를 이용하여 삼각함수로 간단한 파동 효과를 만들어냅니다.
* 렌더링 파이프라인에 따라 모든 픽셀은 기본 적인 프레그먼트 셰이더를 거칩니다.
* 파동 효과가 ON 상태이면, 파동 효과에 대한 셰이더도 같이 거칩니다.
* 크로미움 기반 브라우저에서는 ANGLE 라이브러리를 통해 GLSL에서 HLSL로 변경됩니다.
*
* =============================================================================
* 스프라이트(Sprite)에 웨이브 효과 만들기
* =============================================================================
*
* 스프라이트 생성 후 바로 웨이브 속성에 접근하여 파동 효과를 만들 수 있습니다.
*
* 자바스크립트는 카멜 표기법(Camel Case)를 사용하지만,
*
* 속성 명은 RPG Maker VX Ace와 동일하게 스네이크 표기법(Snake Case)을 따릅니다.
*
* 다룰 수 있는 속성은 다음과 같습니다.
*
* - wave : 기본 값은 false 입니다.
* - wave_amp : 기본 값은 0.05 입니다.
* - wave_length : 기본 값은 비트맵의 최대 높이 값입니다. (폐지됨)
* - wave_speed : 기본 값은 0.25
* - wave_phase : 기본 값은 360 입니다.
*
* 스네이크 표기법(Snake Case)을 따르는 이유는,
*
* 처음부터 그렇게 만들었기 때문입니다. 갑자기 변경하면 혼란스러울 수 있으니까요.
*
* =============================================================================
* 그림에 웨이브 효과 만들기
* =============================================================================
*
* 그림 이미지에 웨이브 효과를 만드려면 플러그인 명령을 사용하면 됩니다.
*
* 웨이브 효과를 활성화하고, 제거하는 두 가지 명령이 있습니다.
*
* PictureWave Start picture_id wave_speed wave_amp
* - picture_id : 그림의 ID 값 (숫자입니다)
* - wave_speed : 사용할 수 있는 값은 0 ~ 1 사이의 부동소수점 실수값입니다.
* (기본 값은 0.25 입니다)
* - wave_amp : 사용할 수 있는 값은 0 ~ 1 사이의 부동소수점 실수값입니다.
* (기본 값은 0.25 입니다)
*
* 다음 명령은 웨이브 효과를 제거합니다.
*
* PictureWave Stop picture_id
* - picture_id : 그림의 ID 값 (숫자입니다)
*
* =============================================================================
* 맵에 웨이브 효과 주기
* =============================================================================
*
* 맵에 웨이브 효과를 주려면 타일맵 웨이브 명령을 사용하면 됩니다.
*
* 아래는 웨이브 효과를 활성화하고 비활성화하는 명령입니다.
*
* TilemapWave Enable
* TilemapWave Disable
*
* 웨이브 효과의 속도를 조절하는 명령입니다.
* x는 부동 소수점 실수로 0에서 2 사이의 값입니다.
* 기본 값은 2.0 입니다만, 셰이더에선 이 값이 사용되지 않습니다.
*
* TilemapWave waveSpeed x
*
* 이 명령은 파동의 진폭을 설정하는 명령입니다.
* x는 부동 소수점 실수로 0에서 1 사이의 값입니다.
* 기본 값은 0.02입니다.
*
* TilemapWave waveFrequency x
*
* 다음 명령은 텍스쳐(Texture)의 UV 속도를 설정할 수 있는 명령입니다.
* UV라는 텍스쳐 내부의 좌표로 0과 1사이의 부동 소수점 실수 값을 가집니다.
* 기본 값은 0.25 입니다. 0.25는 1/4 속도입니다.
*
* TilemapWave UVSpeed x
*
* =============================================================================
* 이벤트 노트 태그
* =============================================================================
*
* 이벤트에 웨이브 효과를 주려면 노트 태그를 사용하면 됩니다.
* 메모(Comment) 커맨드에서 사용할 수 있습니다.
*
* 노트 태그 :
*
* 웨이브 효과를 활성화하고 비활성화하는 노트 태그입니다.
* <WAVE true>
* <WAVE false>
*
* 이 노트 태그는 파동의 진폭을 설정하는 명령입니다.
* x는 부동 소수점 실수로 0에서 1 사이의 값입니다.
* 기본 값은 0.02입니다.
*
* <WAVE_AMP x>
*
* 다음 노트 태그는 텍스쳐(Texture)의 UV 속도를 설정할 수 있는 명령입니다.
* UV라는 텍스쳐 내부의 좌표로 0과 1사이의 부동 소수점 실수 값을 가집니다.
* 기본 값은 0.25 입니다. 0.25는 1/4 속도입니다.
*
* <WAVE_SPEED x>
*
* =============================================================================
* 전투 노트 태그
* =============================================================================
*
* 다음 노트 태그들은 맵 속성의 메모 란에 설정할 수 있습니다.
*
* 전투 원경에 웨이브 효과를 주려면 다음 노트 태그를 사용하세요.
*
* <BATTLEBACK_WAVE : x y>
*
* - x : x는 웨이브 효과의 진폭 값입니다. (0.02가 기본 값입니다)
* - y : y는 웨이브 효과의 UV 속도 값입니다. (0.25가 기본 값입니다)
*
* For Example :
* <BATTLEBACK_WAVE : 0.02 0.25>
*
* Yanfly님의 액션 시퀀스 팩 1(Action Sequence Pack 1)을 사용하고 있으시다면
* 다음 명령을 사용할 수 있습니다 (모든 오브젝트에 웨이브 효과를 줍니다!)
*
* eval: $gameTemp.setBattleBackWaveEffect(cond, waveAmp, waveSpeed);
* - cond : 웨이브 효과 활성화 여부. true 또는 false를 입력하세요.
* - waveAmp : 진폭. 기본 값은 0.02입니다.
* - waveSpeed : UV 속도. 기본 값은 0.25입니다.
*
* =============================================================================
* 변동 사항
* =============================================================================
* 2016.01.14 (v1.0.0) - First Release.
* 2016.01.16 (v1.0.1) - Added the function to remove the filter.
* 2016.01.18 (v1.1.0) - Added the plugin command.
* 2016.01.22 (v1.2.0) - Fixed the Save and Load bug
* 2016.02.16 (v1.3.0) - Fixed Bug (After the player came back to Menu, you had to set the wave effect again)
* 2016.02.26 (v1.3.1) - Fixed the default padding value of the sprite. (default value is to 512)
* 2016.03.03 (v1.3.2) - Added new Sprite Properties (wave_amp, wave_speed, wave_length, wave_phase)
* 2016.08.17 (v1.4.0) - Fixed the issue that is not working in RMMV 1.3.0 (This filter does not support for the time being in Tile-map)
* 2016.08.18 (v1.5.0) - Supports a wave filter in ShaderTilemap.
* 2016.10.20 (v1.5.1) - Fixed the issue that is not working in RMMV 1.3.2
* 2016.11.10 (v1.5.2) - Fixed the issue that is not working in Orange Overlay plugin.
* 2016.11.18 (v1.5.3) - Fixed an issue where the original tilemap is rendered when using Orange Overlay plugin.
* 2016.11.26 (v1.5.4) - Added certain code to remove the texture from memory.
* 2016.11.30 (v1.5.5) - Fixed the issue that has the black border in a filter area.
* 2017.12.10 (v1.5.6) - Added the plugin command called 'PictureWave' (it is tested on 1.6.0 beta version)
* 2018.04.12 (v1.5.7) - Fixed a cutting issue.
* 2018.04.13 (v1.5.7c) - Added the event note tags that can have the wave effect directly for an event graphic.
* 2018.04.15 (v1.5.7e) - Added a new feature that can apply the wave filter in the battle background images
* 2018.04.25 (v1.5.7f) - Fixed the note tag error in Battle Test.
* 2018.05.09 (v1.5.8) - Fixed the bug that is not working the wave filter for the battleback image.
* 2018.11.01 (v1.5.9) :
* - Fixed the issue that the wave filter is not working in the game picture.
* - Fixed the issue that the wave effect do a horizontal looping likes as Tiling Sprite.
* 2018.11.29 (v1.5.10) :
* - Fixed the bug that causes an error when calling Erase Event event command.
* =============================================================================
* Terms of Use
* =============================================================================
* Free for commercial and non-commercial use
*
*/
var Imported = Imported || {};
Imported.RS_WaveFilter = true;
var RS = RS || {};
RS.WaveConfig = RS.WaveConfig || {};
(function() {
var isFilterPIXI4 = (PIXI.VERSION >= "4.0.0" && Utils.RPGMAKER_VERSION >= "1.3.0");
if(!isFilterPIXI4) {
console.error('This version does not work on your project');
console.error('Please download the compatible version from the following link : ');
console.error('https://github.com/biud436/MV/raw/MV/RS_WaveFilter.js');
return;
}
var isWebGL = PIXI.utils.isWebGLSupported();
var isUseCanvas = Utils.isOptionValid('canvas');
if(isUseCanvas || !isWebGL) {
console.error('This plugin does not support in your project');
return;
}
//----------------------------------------------------------------------------
// PIXI.WaveFilter
//
//
PIXI.WaveFilter = function()
{
var vertexSrc = [
'attribute vec2 aVertexPosition;',
'attribute vec2 aTextureCoord;',
'uniform mat3 projectionMatrix;',
'varying vec2 vTextureCoord;',
'void main(void){',
' gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);',
' vTextureCoord = aTextureCoord;',
'}'
].join('\n');
var fragmentSrc = [
'precision mediump float;',
'varying vec2 vTextureCoord;',
// 'uniform float waveWidth;',
'uniform float waveHeight;',
'uniform float waveFrequency;',
'uniform float waveTime;',
'uniform float wavePhase;',
'uniform float UVSpeed;',
'uniform vec4 filterArea;',
'uniform vec4 filterClamp;',
'uniform vec2 origin;',
'uniform sampler2D uSampler;',
'void main(void) {',
' float time = waveFrequency * sin( wavePhase * (waveTime - vTextureCoord.y / (waveHeight / filterArea.y)) );',
' vec2 vCoord = vec2(vTextureCoord.x + time * UVSpeed, vTextureCoord.y);',
// ' float time = waveFrequency * sin( wavePhase * (waveTime - (vTextureCoord.y + vTextureCoord.x) / (waveHeight / filterArea.y)) );',
// ' vec2 vCoord = vec2(vTextureCoord.x + time * UVSpeed, vTextureCoord.y) - (origin / filterArea.xy);',
' gl_FragColor = texture2D(uSampler, clamp(vCoord, filterClamp.xy, filterClamp.zw));',
'}'
].join('\n');
PIXI.Filter.call( this, vertexSrc, fragmentSrc );
this.padding = 0;
this.uniforms.waveHeight = 0.5;
this.uniforms.waveFrequency = 0.02;
this.uniforms.waveTime = 0.0;
this.uniforms.UVSpeed = 0.25;
this.uniforms.origin = new PIXI.Point(0, 0);
this.uniforms.wavePhase = 3.141592653589793 * 2;
this.enabled = true;
this.resolution = 1;
};
PIXI.WaveFilter.prototype = Object.create( PIXI.Filter.prototype );
PIXI.WaveFilter.prototype.constructor = PIXI.WaveFilter;
PIXI.WaveFilter.prototype.apply = function(filterManager, input, output, clear) {
this.uniforms.waveHeight = input.sourceFrame.height / 4;
filterManager.applyFilter(this, input, output, clear);
};
Object.defineProperties(PIXI.WaveFilter.prototype, {
waveHeight: {
get: function() {
return this.uniforms.waveHeight;
},
set: function(value) {
this.uniforms.waveHeight = value;
}
},
waveSpeed: {
get: function() {
return this.uniforms.UVSpeed;
},
set: function(value) {
this.uniforms.UVSpeed = value;
}
},
waveFrequency: {
get: function() {
return this.uniforms.waveFrequency;
},
set: function(value) {
this.uniforms.waveFrequency = value;
}
},
UVSpeed: {
get: function() {
return this.uniforms.UVSpeed;
},
set: function(value) {
this.uniforms.UVSpeed = value;
}
},
waveTime: {
get: function() {
return this.uniforms.waveTime;
},
set: function(value) {
this.uniforms.waveTime = value;
}
},
wavePhase: {
get: function() {
return this.uniforms.wavePhase;
},
set: function(value) {
this.uniforms.wavePhase = (Math.PI / 180) * Number(value);
}
},
origin: {
get: function() {
return this.uniforms.origin;
},
set: function(value) {
this.uniforms.origin = value;
}
}
});
//============================================================================
// Sprite
//============================================================================
var alias_Sprite_initialize = Sprite.prototype.initialize;
Sprite.prototype.initialize = function(bitmap) {
alias_Sprite_initialize.call(this, bitmap);
this._waveTime = 0;
this._waveHeight = 0.5;
this._waveSpeed = 0.25;
this._waveFrequency = 0.02;
this._wavePhase = 360;
this._waveFilter = new PIXI.WaveFilter();
this._wave = false;
};
var alias_Sprite_update = Sprite.prototype.update;
Sprite.prototype.update = function() {
alias_Sprite_update.call(this);
this.waveUpdate();
};
Sprite.prototype.getWaveFrameTime = function() {
this._waveTime = Date.now() % 10000 / 10000;
return this._waveTime;
};
Sprite.prototype.setWaveHeight = function(n) {
this._waveHeight = this.height;
}
Sprite.prototype.getWaveHeight = function() {
return this._waveHeight;
};
Sprite.prototype.waveUpdate = function() {
if(this._wave) {
this._waveFilter.waveTime = this.getWaveFrameTime();
this._waveFilter.waveHeight = this.getWaveHeight();
this._waveFilter.waveSpeed = this._waveSpeed;
this._waveFilter.waveFrequency = this._waveFrequency;
this._waveFilter.wavePhase = this._wavePhase;
this._waveFilter.origin.x = $gameMap.canvasToMapX(this.x);
this._waveFilter.origin.x = $gameMap.canvasToMapY(this.y);
}
}
Object.defineProperty(Sprite.prototype, 'waveSpeed', {
get: function() {
return this._waveSpeed;
},
set: function(value) {
this._waveSpeed = value;
}
});
Object.defineProperty(Sprite.prototype, 'waveFrequency', {
get: function() {
return this._waveFrequency;
},
set: function(value) {
this._waveFrequency = value;
}
});
Object.defineProperty(Sprite.prototype, 'wave_amp', {
get: function() {
return this._waveFrequency;
},
set: function(value) {
this._waveFrequency = value;
}
});
Object.defineProperty(Sprite.prototype, 'wave_length', {
get: function() {
return this._waveHeight;
},
set: function(value) {
this.setWaveHeight(value);
}
});
Object.defineProperty(Sprite.prototype, 'wave_speed', {
get: function() {
return this._waveSpeed;
},
set: function(value) {
this._waveSpeed = value;
}
});
Object.defineProperty(Sprite.prototype, 'wave_phase', {
get: function() {
return this._wavePhase;
},
set: function(value) {
this._wavePhase = value;
}
});
Object.defineProperty(Sprite.prototype, 'wave', {
get: function() {
return this._wave;
},
set: function(value) {
this._wave = value;
if(this._wave) {
if(!this._waveFilter) {
this._waveFilter = new PIXI.WaveFilter();
}
this.filterArea = new PIXI.Rectangle(0, 0, Graphics.boxWidth, Graphics.boxHeight);
this.filters = [this._waveFilter];
} else {
this.filters = [new PIXI.filters.VoidFilter()];
}
},
configurable: true
});
//============================================================================
// TilingSprite
//============================================================================
var alias_TilingSprite_initialize = TilingSprite.prototype.initialize;
TilingSprite.prototype.initialize = function(bitmap) {
alias_TilingSprite_initialize.call(this, bitmap);
this._waveTime = 0;
this._waveHeight = 0.5;
this._waveSpeed = 0.25;
this._waveFrequency = 0.02;
this._wavePhase = 360;
this._waveFilter = new PIXI.WaveFilter();
this._wave = false;
};
var alias_TilingSprite_update = TilingSprite.prototype.update;
TilingSprite.prototype.update = function() {
alias_TilingSprite_update.call(this);
this.waveUpdate();
};
TilingSprite.prototype.getWaveFrameTime = function() {
this._waveTime = Date.now() % 10000 / 10000;
return this._waveTime;
};
TilingSprite.prototype.setWaveHeight = function(n) {
this._waveHeight = this.height;
}
TilingSprite.prototype.getWaveHeight = function() {
return this._waveHeight;
};
TilingSprite.prototype.waveUpdate = function() {
if(this._wave) {
this._waveFilter.waveTime = this.getWaveFrameTime();
this._waveFilter.waveHeight = this.getWaveHeight();
this._waveFilter.waveSpeed = this._waveSpeed;
this._waveFilter.waveFrequency = this._waveFrequency;
this._waveFilter.wavePhase = this._wavePhase;
}
}
Object.defineProperty(TilingSprite.prototype, 'waveSpeed', {
get: function() {
return this._waveSpeed;
},
set: function(value) {
this._waveSpeed = value;
}
});
Object.defineProperty(TilingSprite.prototype, 'waveFrequency', {
get: function() {
return this._waveFrequency;
},
set: function(value) {
this._waveFrequency = value;
}
});
Object.defineProperty(TilingSprite.prototype, 'wave_amp', {
get: function() {
return this._waveFrequency;
},
set: function(value) {
this._waveFrequency = value;
}
});
Object.defineProperty(TilingSprite.prototype, 'wave_length', {
get: function() {
return this._waveHeight;
},
set: function(value) {
this.setWaveHeight(value);
}
});
Object.defineProperty(TilingSprite.prototype, 'wave_speed', {
get: function() {
return this._waveSpeed;
},
set: function(value) {
this._waveSpeed = value;
}
});
Object.defineProperty(TilingSprite.prototype, 'wave_phase', {
get: function() {
return this._wavePhase;
},
set: function(value) {
this._wavePhase = value;
}
});
Object.defineProperty(TilingSprite.prototype, 'wave', {
get: function() {
return this._wave;
},
set: function(value) {
this._wave = value;
if(this._wave) {
if(!this._waveFilter) {
this._waveFilter = new PIXI.WaveFilter();
}
this.filterArea = new PIXI.Rectangle(0, 0, Graphics.boxWidth, Graphics.boxHeight);
this.filters = [this._waveFilter];
} else {
this.filters = [new PIXI.filters.VoidFilter()];
}
},
configurable: true
});
//============================================================================
// Sprite_Picture
//============================================================================
Sprite_Picture.prototype.updateWave = function() {
var picture = this.picture();
this.wave = picture.wave();
this.wave_speed = picture.waveSpeed();
this.wave_amp = picture.waveAmp();
};
var alias_Sprite_Picture_update = Sprite_Picture.prototype.update;
Sprite_Picture.prototype.update = function() {
alias_Sprite_Picture_update.call(this);
if(this.visible) {
this.updateWave();
}
};
//============================================================================
// Spriteset_Map
//============================================================================
var alias_Spriteset_Map_createLowerLayer = Spriteset_Map.prototype.createLowerLayer;
Spriteset_Map.prototype.createLowerLayer = function() {
alias_Spriteset_Map_createLowerLayer.call(this);
this.overwriteWaveProperty();
};
Spriteset_Map.prototype.overwriteWaveProperty = function () {
if(!this._baseSprite) return false;
var self = this;
Object.defineProperty(this._baseSprite, 'wave', {
get: function () { return this._wave; },
set: function (value) {
this._wave = value;
if(this._wave) {
if(!this._waveFilter) this._waveFilter = new PIXI.WaveFilter();
this.filters = [this._waveFilter, self._toneFilter];
} else {
this.filters = [self._toneFilter];
}
}
});
};
var alias_Spriteset_Map_update = Spriteset_Map.prototype.update;
Spriteset_Map.prototype.update = function () {
alias_Spriteset_Map_update.call(this);
this.updateWaveFilter();
};
Spriteset_Map.prototype.updateWaveFilter = function () {
if($gameSystem && $gameSystem.getWaveEnabled) {
this._baseSprite.wave = $gameSystem.getWaveEnabled() || false;
this._baseSprite.wave_amp = $gameSystem.getWaveFrequency() || 0.02;
this._baseSprite.wave_phase = $gameSystem.getWavePhase() || 360;
this._baseSprite.wave_speed = $gameSystem.getUVSpeed() || 0.25;
}
};
//============================================================================
// Spriteset_Battle
//============================================================================
var alias_Spriteset_Battle_createBattleback = Spriteset_Battle.prototype.createBattleback;
Spriteset_Battle.prototype.createBattleback = function() {
alias_Spriteset_Battle_createBattleback.call(this);
this.initWithWaveEffect();
};
Spriteset_Battle.prototype.initWithWaveEffect = function () {
if(!$dataMap) return;
var note = $dataMap.note.split(/[\r\n]+/);
var self = this;
note.forEach(function (mapNote) {
if($dataMap.note.match(/<BATTLEBACK_WAVE[ ]:[ ]*(.*)[ ](.*)>/i)) {
this._initWaveFilter = true;
self.changeWaveEffect(true, RegExp.$1, RegExp.$2);
}
}, this);
};
Spriteset_Battle.prototype.changeWaveEffect = function (cond, fre, spd) {
if(!this._initWaveFilter) return;
var backs = [this._back1Sprite, this._back2Sprite];
backs.forEach(function (back) {
back.wave = cond;
back.waveFrequency = parseFloat(fre) || 0.02;
back.waveSpeed = parseFloat(spd) || 0.25;
}, this);
};
//============================================================================
// Game_Picture
//============================================================================
var alias_Game_Picture_initBasic = Game_Picture.prototype.initBasic;
Game_Picture.prototype.initBasic = function() {
alias_Game_Picture_initBasic.call(this);
this._wave = false;
this._waveSpeed = 0.25;
this._waveAmp = 0.02;
};
Game_Picture.prototype.wave = function () {
return this._wave;
};
Game_Picture.prototype.waveSpeed = function () {
return this._waveSpeed;
};
Game_Picture.prototype.waveAmp = function () {
return this._waveAmp;
};
Game_Picture.prototype.startWave = function(waveSpeed, waveAmp) {
this._wave = true;
this._waveSpeed = waveSpeed;
this._waveAmp = waveAmp
};
Game_Picture.prototype.stopWave = function() {
this._wave = false;
};
//============================================================================
// Game_Screen
//============================================================================
Game_Screen.prototype.startWave = function(pictureId, waveSpeed, waveAmp) {
var picture = this.picture(pictureId);
if (picture) {
picture.startWave(waveSpeed, waveAmp);
}
};
Game_Screen.prototype.stopWave = function(pictureId) {
var picture = this.picture(pictureId);
if (picture) {
picture.stopWave();
}
};
//============================================================================
// Game_Temp
//============================================================================
/**
* In Action Sequence Pack 1, you can use this function.
* eval: $gameTemp.setBattleBackWaveEffect(cond, waveAmp, waveSpeed);
*/
Game_Temp.prototype.setBattleBackWaveEffect = function (cond, fre, spd) {
if(!$gameParty.inBattle()) return;
var container = SceneManager._scene._spriteset;
if(container) {
container.changeWaveEffect(cond, fre, spd);
}
};
//============================================================================
// Game_System
//============================================================================
var alias_Game_System_initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function() {
alias_Game_System_initialize.call(this);
this.initWaveProperty();
};
Game_System.prototype.initWaveProperty = function () {
this._waveProp = {
'wave': false,
'waveHeight': Graphics.boxHeight,
'waveFrequency': 0.02,
'waveTime': 0.0,
'UVSpeed': 0.25,
'wavePhase': 360
};
};
Game_System.prototype.setWaveProperty = function (name, value) {
if(this._waveProp) {
this._waveProp[name] = value;
return this._waveProp[name];
}
return 0.0;
};
Game_System.prototype.getWaveEnabled = function () {
return this._waveProp.wave;
};
Game_System.prototype.getWaveHeight = function () {
return this._waveProp.waveHeight;
};
Game_System.prototype.getWaveFrequency = function () {
return this._waveProp.waveFrequency;
};
Game_System.prototype.getWaveTime = function () {
return this._waveProp.waveTime;
};
Game_System.prototype.getUVSpeed = function () {
return this._waveProp.UVSpeed;
};
Game_System.prototype.getWavePhase = function () {
return this._waveProp.wavePhase;
};
//============================================================================
// Game_CharacterBase
//============================================================================
var alias_Game_CharacterBase_initMembers = Game_CharacterBase.prototype.initMembers;
Game_CharacterBase.prototype.initMembers = function() {
alias_Game_CharacterBase_initMembers.call(this);
this._wave = false;
this._waveFrequency = 0.02;
this._waveSpeed = 0.25;
};
Game_CharacterBase.prototype.setWave = function (toggle) {
this._wave = toggle;
};
Game_CharacterBase.prototype.setWaveFrequency = function (value) {
this._waveFrequency = value;
};
Game_CharacterBase.prototype.setWaveSpeed = function (value) {
this._waveSpeed = value;
};
Game_CharacterBase.prototype.wave = function () {
return this._wave;
};
Game_CharacterBase.prototype.waveFrequency = function () {
return this._waveFrequency;
};
Game_CharacterBase.prototype.waveSpeed = function () {
return this._waveSpeed;
};
//============================================================================
// Sprite_Character
//============================================================================
var alias_Sprite_Character_updatePosition = Sprite_Character.prototype.updatePosition;
Sprite_Character.prototype.updatePosition = function() {
alias_Sprite_Character_updatePosition.call(this);
if(!this._character) return;
if(!(this._character instanceof Game_Event)) return;
this.wave = this._character.wave();
if(this.wave) {
this.waveFrequency = this._character.waveFrequency();
this.waveSpeed = this._character.waveSpeed();
}
};
//============================================================================
// Game_Map
//============================================================================
var alias_Game_Event_initMembers = Game_Event.prototype.initMembers;
Game_Event.prototype.initMembers = function() {
alias_Game_Event_initMembers.call(this);
this._lastPageIndex = -2;
};
Game_Event.prototype.updateWaveEffect = function() {
var self = this;
if(this._pageIndex === this._lastPageIndex) return;
if(!self.page()) return false;
if(self.findProperPageIndex() < 0) return false;
if(self._trigger > 3) return false;
self.list().forEach(function(list) {
if(list.code === 108 || list.code === 408) {