Day.png);">
Apprendre


Vous êtes
nouveau sur
Oniromancie?

Visite guidée
du site


Découvrir
RPG Maker

RM 95
RM 2000/2003
RM XP
RM VX/VX Ace
RM MV/MZ

Apprendre
RPG Maker

Tutoriels
Guides
Making-of

Dans le
Forum

Section Entraide

Sorties: Star Trek: Glorious Wolf - (...) / Sorties: Dread Mac Farlane - episode 3 / News: Plein d'images cools créées par (...) / Sorties: Star Trek: Glorious Wolf - (...) / Jeux: Final Fantasy 2.0 / Chat

Bienvenue
visiteur !




publicité RPG Maker!

Statistiques

Liste des
membres


Contact

Mentions légales

314 connectés actuellement

29190769 visiteurs
depuis l'ouverture

5820 visiteurs
aujourd'hui



Barre de séparation

Partenaires

Indiexpo

Akademiya RPG Maker

Blog Alioune Fall

Fairy Tail Constellations

Guelnika & E-magination

Hellsoft

New RPG Maker

Eclipso

Tous nos partenaires

Devenir
partenaire



forums

Index du forum > Entraide > [VXAce] compatibilité entre 2 scripts. [Résolu]


Cactus - posté le 18/04/2015 à 15:28:55 (681 messages postés)

❤ 0

Pikactus

Domaine concerné: Script
Logiciel utilisé: VXAce
Salut,

Le script "Character Effects" de Galv permet de faire ça:

Spoiler (cliquez pour afficher)



Le script est plutôt bien, mais il ne prend pas en compte les ajouts du "Extra Movement Frames"
de modern algebra qui permet d'avoir plus de 3 frames pour les sprites.

En gros le bug c'est ça:
image
Le sprite du joueur est divisé en 8
et le sprite du reflet est divisé en 3 comme un sprite classique...


Character Effects:

Portion de code : Tout sélectionner

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
#------------------------------------------------------------------------------#
#  Galv's Character Effects
#------------------------------------------------------------------------------#
#  For: RPGMAKER VX ACE
#  Version 2.0
#------------------------------------------------------------------------------#
#  2013-12-07 - Version 2.0 - Added comments to more easily add event effects
#                           - Fixed shadow facing bug
#  2013-02-24 - Version 1.9 - added z level option for reflection and shadows
#  2013-02-23 - Version 1.8 - added multiple light sources for shadows
#  2013-02-22 - Version 1.7 - bug fixes
#  2013-02-22 - Version 1.6 - added icon effect
#  2013-02-22 - Version 1.5 - fixed mirror bug on large maps
#  2013-02-22 - Version 1.4 - added effects to vehicles
#  2013-02-21 - Version 1.3 - fixed jump reflection and other minor tweaks
#  2013-02-21 - Version 1.2 - bug with less than 4 actors (oops)
#  2013-02-21 - Version 1.1 - updated flicker effect
#  2013-02-21 - Version 1.0 - release
#------------------------------------------------------------------------------#
#  This script was made to provide some additional effects for characters such
#  as events, followers and the player on the map.
#  Currently it includes:
#
#  Shadows
#  Shadows that appear under player and events in a directions depending on
#  a light source that you choose.
#
#  Parallax Reflect
#  Reflections that appear on the parallax layer for events and actors to be
#  used for things like reflections in the water or glass floor etc. To get
#  effects like the demo, you need to edit the charset graphic to make the water
#  partially transparent.
#
#  Parallax Mirrors
#  Much like reflect but are instead actors and event are reflected in a mirror
#  on a wall designated by a region. Both mirror and reflect effects can be
#  changed so actors and events can use different charsets for their reflections
#
#------------------------------------------------------------------------------#
 
 
#------------------------------------------------------------------------------#
#  NEW - First event command as a COMMENT
#------------------------------------------------------------------------------#
#  You can add a comment as the first event command on an event page to set if
#  that event has an icon, shadow or reflection active. The tags to use are
#  below, all must be on the same line in the comment.
#
# <icon:id,x,y>      # set the event to display an icon (x,y position offset)
# <shadow>           # set the event to display a shadow
# <reflect>          # set the event to display reflections
#
#------------------------------------------------------------------------------#
#  EXAMPLE:
# <icon:1,0,0><shadow><reflect>    # to show reflect, shadow and icon 1 on event
#------------------------------------------------------------------------------#
 
 
#------------------------------------------------------------------------------#
#  SCRIPT CALLS:
#------------------------------------------------------------------------------#
#
#  char_effects(x,x,x,status)
#
#------------------------------------------------------------------------------#
#  # each effect can be true or false to enable/disable them during the game.
#  # you can change multiples of effects at once, x being the effect number
#  # 0 = reflect    1 = shadows    2 = mirror    3 = icons
#------------------------------------------------------------------------------#
#  EXAMPLES:
#  char_effects(0,true)              # turn reflections on
#  char_effects(0,2,true)            # turn reflections and mirror on
#  char_effects(1,3,false)           # turn shadows and icons off
#------------------------------------------------------------------------------#
#
#  reflect_sprite(actor_id,filename,pos)    # Change actor's reflect charset
#
#  reflect_esprite(event_id,filename,pos)   # Change event's reflect charset
#
#  reflect_vsprite(vehicle_id,filename,pos) # Change vehicle's reflect charset
#
#------------------------------------------------------------------------------#
#  EXAMPLES:
#  reflect_sprite(1,"Actor2",2)      # change actor 1's charset to use sprite
#                                    # in position 2 of "Actor2" charset.
#  reflect_esprite(3,"Actor4",5)     # event 3 will use sprite in position 5 of
#                                    # "Actor4" charset.
#  reflect_vsprite(1,"Vehicle",5)    # Ship will use sprite in position 5 of
#                                    # "Vehicle" charset.
#------------------------------------------------------------------------------#
 
#------------------------------------------------------------------------------#
#  SCRIPT CALLS to turn effects ON or OFF for chosen EVENTS
#------------------------------------------------------------------------------#
#
#  reflect(x,x,x,status)   # status can be true or false to turn on or off
#                          # use this to specify for mirror and reflect.
#  shadow(x,x,x,status)    # where x is the event ids you want to change
#                          # to change all events use :all
#  icon(x,x,x,icon_id)     # set which icon id to appear above character. Make
#                          # it 0 for no icon.
#
#------------------------------------------------------------------------------#
#  EXAMPLES:
#  reflect(14,17,3,1,true) # Turn events 14, 17, 3 and 1 reflections ON
#  shadow(1,false)         # Turn event 1 shadow OFF
#  reflect(:all,true)      # Turn all event reflections ON
#  icon(1,2,3,4,38)        # Events 1,2,3 and 4 will have icon 38 appear
#
#  NOTE: All events will default to NO shadows and NO reflections when entering
#        a map. This is a design decision to try to keep lag to a minimum. You
#        should use these effects sparingly and only activate them on events
#        that require them.
#------------------------------------------------------------------------------#
 
#------------------------------------------------------------------------------#
#  SCRIPT CALLS to turn effects ON or OFF for ACTORS and VEHICLES
#------------------------------------------------------------------------------#
#
#  actor_reflect(actor_id,status)  # reflections and shadows are ON by default 
#  actor_shadow(actor_id,status)   # for actors and vehicles. Turning them off 
#  actor_icon(actor_id,icon_id)    # or on will permanently change them.
#
#  v_reflect(x,x,x,status)    # use these v_ calls for changing vehicle effects
#  v_shadow(x,x,x,status)     # on and off for vehicles.
#  v_icon(x,x,x,icon_id)
#
#------------------------------------------------------------------------------#
 
#------------------------------------------------------------------------------#
#  SCRIPT CALLS for shadow options
#------------------------------------------------------------------------------#
#
#  shadow_source(x,y,id)       # set the x,y location for the light. id is the 
#                              # light source number you wish to change (for
#                              # more than one). These are reset on map change.
#  shadow_source(event_id,id)  # use an event's x,y location for the light.
#                              # This will need to be in parallel process if you
#                              # want it to be a moving light.
#
#  shadow_options(intensity,fade,flicker)    # descriptions below
#
#    # intensity = opacity when standing next to the light source (255 is black)
#    # fade = amount shadow becomes more transparent the further away you are.
#    # flicker = true or false. Shadows will flicker as if being cast by fire.
#
#------------------------------------------------------------------------------#
#  EXAMPLE:
#  shadow_options(80,10,false)    # This is the default setting.
#------------------------------------------------------------------------------#
 
#------------------------------------------------------------------------------#
#  SCRIPT CALLS for reflect options
#------------------------------------------------------------------------------#
#
#  reflect_options(wave_pwr) 
#
#    # wave_pwr = how strong the wave movement is. 0 is off
#
#------------------------------------------------------------------------------#
#  EXAMPLE:
#  reflect_options(1) # Turn wave power to 1
#------------------------------------------------------------------------------#
 
 
#------------------------------------------------------------------------------#
#  NOTETAG for ACTORS
#------------------------------------------------------------------------------#
#
#  <no_reflect>    # Actor will not have a reflection (for vampires of course!)
#
#  <reflect_sprite: FileName,pos>  # Actor will use this charset for reflections
#                                  # and use the character in position 'pos'
#
#------------------------------------------------------------------------------#
#  EXAMPLES:
#  <reflect_sprite: Actor2,0>    # The first character from Actor2 charset
#  <reflect_sprite: Actor3,7>    # The last character from Actor2 charset
#------------------------------------------------------------------------------#
 
 
($imported ||= {})["Galv_Character_Effects"] = true
module Galv_CEffects
 
#------------------------------------------------------------------------------#  
#  SETUP OPTIONS
#------------------------------------------------------------------------------#
 
  MIRROR_REGION = 4     # Region ID used to determine mirror walls. Paint the
                        # region on the wall you want to make reflective (and
                        # then use tiles/mapping that make the parallax visible)
 
  ICON_OFFSET = -60     # Y offset for icons that are displayed above characters
   
  REFLECT_Z = -10       # Z level of reflections
  SHADOW_Z = 0          # Z level of shadows
 
#------------------------------------------------------------------------------#  
#  END SETUP OPTIONS
#------------------------------------------------------------------------------#
end
 
 
 
 
class Game_Map
  def do_icons(refresh = true)
    @events.values.each { |e|
      next if !e.list
      if e.list[0].code == 108 && e.list[0].parameters[0] =~ /<icon:(.*),(.*),(.*)>/
        e.icon = $1.to_i
        e.icon_offset = [$2.to_i,$3.to_i]
      else
        e.icon = 0
        e.icon_offset = [0,0]
      end
    }
    SceneManager.scene.spriteset.refresh_effects if refresh
  end
  
  
  def do_shadows(refresh = true)
    @events.values.each { |e|
      next if !e.list
      if e.list[0].code == 108 && e.list[0].parameters[0] =~ /<shadow>/
        e.shadow = true
      else
        e.shadow = false
      end
    }
    SceneManager.scene.spriteset.refresh_effects if refresh
  end
  
  def do_reflects(refresh = true)
    @events.values.each { |e|
      next if !e.list
      if e.list[0].code == 108 && e.list[0].parameters[0] =~ /<reflect>/
        e.reflect = true
      else
        e.reflect = false
      end
    }
    SceneManager.scene.spriteset.refresh_effects if refresh
  end
  
  def do_all_chareffects
    do_icons(false)
    do_shadows(false)
    do_reflects(false)
  end
  
end # Game_Map
 
 
 
 
class Game_Interpreter
  
  def remove_icon
    icon(@event_id,0)
  end
 
#-----------------------------------#
#  REFLECTIONS
#-----------------------------------#
 
  # Add/Remove Reflections from selected events
  def reflect(*args,status)
    char_ids = [*args]
    if char_ids == [:all]
      $game_map.events.values.each { |e| e.reflect = status }
    else
      char_ids.each {|c| $game_map.events[c].reflect = status }
    end
    SceneManager.scene.spriteset.refresh_effects
  end
   
  # Change forever actor's reflect status
  def actor_reflect(actor_id,status)
    $game_actors[actor_id].reflect = status
    $game_player.refresh
  end
   
  # Change forever vehicle's reflect status
  def v_reflect(*args,status)
    char_ids = [*args]
    if char_ids == [:all]
      $game_map.vehicles.each { |v| v.reflect = status }
    else
      char_ids.each { |v| $game_map.vehicles[v].reflect = status }
    end
    SceneManager.scene.spriteset.refresh_effects
  end
 
  def reflect_options(*args)
    $game_map.reflect_options = [*args]
    SceneManager.scene.spriteset.refresh_effects
  end
   
  # Actor reflect sprite change
  def reflect_sprite(actor_id,filename,pos)
    $game_actors[actor_id].reflect_sprite = [filename,pos]
    $game_player.refresh
  end
   
  # Event reflect sprite change
  def reflect_esprite(event_id,filename,pos)
    $game_map.events[event_id].reflect_sprite = [filename,pos]
    $game_map.events[event_id].reflect = true
    SceneManager.scene.spriteset.refresh_characters
  end
   
  # Vehicle reflect sprite change
  def reflect_vsprite(v_id,filename,pos)
    $game_map.vehicles[v_id].reflect_sprite = [filename,pos]
    SceneManager.scene.spriteset.refresh_characters
  end
 
#-----------------------------------#
#  SHADOWS
#-----------------------------------#
 
  # Add/Remove Shadows from selected characters
  def shadow(*args,status)
    char_ids = [*args]
    if char_ids == [:all]
      $game_map.events.values.each { |e| e.shadow = status }
    else
      char_ids.each {|c| $game_map.events[c].shadow = status }
    end
    SceneManager.scene.spriteset.refresh_effects
  end
   
  # Change player and follower shadows
  def actor_shadows(status)
    $game_player.shadow = status
    $game_player.followers.each { |f| f.shadow = status }
    SceneManager.scene.spriteset.refresh_effects
  end
   
  # Change vehicle's shadow status
  def v_shadow(*args,status)
    char_ids = [*args]
    if char_ids == [:all]
      $game_map.vehicles.each { |v| v.shadow = status }
    else
      char_ids.each { |v| $game_map.vehicles[v].shadow = status }
    end
    SceneManager.scene.spriteset.refresh_effects
  end
   
  def shadow_options(*args)
    $game_map.shadow_options = [*args]
    SceneManager.scene.spriteset.refresh_effects
  end
 
  def shadow_source(*args,shad_id)
    shadsource = [*args]
 
    if shadsource.count == 1
      $game_map.light_source[shad_id] = [$game_map.events[shadsource[0]].real_x,
        $game_map.events[shadsource[0]].real_y]
    elsif shadsource.count > 1
      $game_map.light_source[shad_id] = shadsource
    else
      $game_map.light_source = []
    end
  end
 
 
#-----------------------------------#
#  ICONS
#-----------------------------------#
 
  # Add/Remove Icons from selected events
  def icon(*args,icon_id)
    char_ids = [*args]
    if char_ids == [:all]
      $game_map.events.values.each { |e|
      if e.icon <= 0
        e.icon = nil
      else
        e.icon = icon_id
      end
    }
    else
      char_ids.each {|c| $game_map.events[c].icon = icon_id }
    end
    SceneManager.scene.spriteset.refresh_effects
  end
   
  # Change forever actor's icon
  def actor_icon(actor_id,icon_id)
    $game_actors[actor_id].icon = icon_id
    $game_player.refresh
  end
   
  # Change forever vehicle's icon
  def v_icon(*args,icon_id)
    char_ids = [*args]
    if char_ids == [:all]
      $game_map.vehicles.each { |v| v.icon = icon_id }
    else
      char_ids.each { |v| $game_map.vehicles[v].icon = icon_id }
    end
    SceneManager.scene.spriteset.refresh_effects
  end
 
#-----------------------------------#
#  GENERAL
#-----------------------------------#
 
  # Turn on/off effects
    # 0 = reflect
    # 1 = shadow
    # 2 = mirror
    # 3 = icon
     
  def char_effects(*args,status)
    [*args].each { |e| $game_map.char_effects[e] = status }
    SceneManager.scene.spriteset.refresh_effects
  end
 
   
end # Game_Interpreter
 
 
#-------------------------------------------------------------------------------
#  Spriteset_Map
#-------------------------------------------------------------------------------
 
class Spriteset_Map
  alias galv_reflect_sm_initialize initialize
  def initialize
    create_effects
    galv_reflect_sm_initialize
    refresh_characters
  end
   
  alias galv_reflect_sm_refresh_characters refresh_characters
  def refresh_characters
    galv_reflect_sm_refresh_characters
    create_effects
  end
   
  def refresh_effects
    dispose_effects
    create_effects
  end
   
  def create_effects
    @shadow_sprites = []
    @reflect_sprites = []
    @mirror_sprites = []
    @icon_sprites = []
     
    # Do reflections
    if $game_map.char_effects[0]
      $game_map.events.values.each { |e|
        @reflect_sprites.push(Sprite_Reflect.new(@viewport1, e)) if e.reflect
      }
      $game_player.followers.each { |f|
        @reflect_sprites.push(Sprite_Reflect.new(@viewport1, f)) if f.reflect
      }
      if $game_player.reflect
        @reflect_sprites.push(Sprite_Reflect.new(@viewport1, $game_player))
      end
      $game_map.vehicles.each { |v|
        @reflect_sprites.push(Sprite_Reflect.new(@viewport1, v)) if v.reflect
      }
    end
     
    # Do mirrors
    if $game_map.char_effects[2]
      $game_map.events.values.each { |e|
        @mirror_sprites.push(Sprite_Mirror.new(@viewport1, e)) if e.reflect
      }
      $game_player.followers.each { |f|
        @mirror_sprites.push(Sprite_Mirror.new(@viewport1, f)) if f.reflect
      }
      if $game_player.reflect
        @mirror_sprites.push(Sprite_Mirror.new(@viewport1, $game_player))
      end
      $game_map.vehicles.each { |v|
        @mirror_sprites.push(Sprite_Mirror.new(@viewport1, v)) if v.reflect
      }
    end
     
    # Do Shadows
    if $game_map.char_effects[1]
      return if $game_map.light_source.empty?
      $game_map.light_source.count.times { |s|
        $game_map.events.values.each { |e|
          @shadow_sprites.push(Sprite_Shadow.new(@viewport1, e, s)) if e.shadow
        }
        $game_player.followers.each { |f|
          @shadow_sprites.push(Sprite_Shadow.new(@viewport1, f, s)) if f.shadow
        }
        if $game_player.shadow
          @shadow_sprites.push(Sprite_Shadow.new(@viewport1, $game_player, s))
        end
        $game_map.vehicles.each { |v|
          @shadow_sprites.push(Sprite_Shadow.new(@viewport1, v, s)) if v.shadow
        }
      }
    end
     
    # Do icons
    if $game_map.char_effects[3]
      $game_map.events.values.each { |e|
        @icon_sprites.push(Sprite_Icon.new(@viewport1, e)) if e.icon
      }
      $game_player.followers.each { |f|
        @icon_sprites.push(Sprite_Icon.new(@viewport1, f)) if f.icon
      }
      if $game_player.icon
        @icon_sprites.push(Sprite_Icon.new(@viewport1, $game_player))
      end
      $game_map.vehicles.each { |v|
        @icon_sprites.push(Sprite_Icon.new(@viewport1, v)) if v.icon
      }
    end
  end
   
  alias galv_reflect_sm_update update
  def update
    galv_reflect_sm_update
    @reflect_sprites.each {|s| s.update} if $game_map.char_effects[0]
    @mirror_sprites.each {|s| s.update} if $game_map.char_effects[2]
    @shadow_sprites.each {|s| s.update} if $game_map.char_effects[1]
    @icon_sprites.each {|s| s.update} if $game_map.char_effects[3]
  end
 
  alias galv_reflect_sm_dispose_characters dispose_characters
  def dispose_characters
    galv_reflect_sm_dispose_characters
    dispose_effects
  end
   
  def dispose_effects
    @reflect_sprites.each {|s| s.dispose}
    @shadow_sprites.each {|s| s.dispose}
    @mirror_sprites.each {|s| s.dispose}
    @icon_sprites.each {|s| s.dispose}
  end
end # Spriteset_Map
 
 
#-------------------------------------------------------------------------------
#  Sprite_Reflect 
#-------------------------------------------------------------------------------
 
class Sprite_Reflect < Sprite_Character
  def initialize(viewport, character = nil)
    super(viewport, character)
  end
 
  def update
    super
  end
   
  def update_balloon; end
  def setup_new_effect; end
   
  def set_character_bitmap
    if @character.reflect_sprite
      self.bitmap = Cache.character(@character.reflect_sprite[0])
    else
      self.bitmap = Cache.character(@character_name)
    end
    self.mirror = true
    self.angle = 180
    self.opacity = 220
    self.z = Galv_CEffects::REFLECT_Z
    self.wave_amp = $game_map.reflect_options[0]
     
    sign = @character_name[/^[\!\$]./]
    if sign && sign.include?('$')
      @cw = bitmap.width / 3
      @ch = bitmap.height / 4
    else
      @cw = bitmap.width / 12
      @ch = bitmap.height / 8
    end
    self.ox = @cw / 2
    self.oy = @ch
  end
 
  def update_position
    self.x = @character.screen_x
    jump = @character.jumping? ? @character.jump_height * 2 : 0
    alt = @character.altitude ? @character.altitude * 2 : 0
    self.y = @character.screen_y - 3 + jump + alt
  end
 
  def update_other
    self.blend_type = @character.blend_type
    self.visible = !@character.transparent
  end
   
  def update_src_rect
    if @character.reflect_sprite
      index = @character.reflect_sprite[1]
    else
      index = @character.character_index
    end
    pattern = @character.pattern < 3 ? @character.pattern : 1
    sx = (index % 4 * 3 + pattern) * @cw
    sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
    self.src_rect.set(sx, sy, @cw, @ch)
  end
end # Sprite_Reflect < Sprite_Character
 
 
#-------------------------------------------------------------------------------
#  Sprite_Mirror
#-------------------------------------------------------------------------------
 
class Sprite_Mirror < Sprite_Character
  def initialize(viewport, character = nil)
    @distance = 0
    super(viewport, character)
  end
 
  def update
    super
  end
   
  def update_balloon; end
  def setup_new_effect; end
   
  def set_character_bitmap
    if @character.reflect_sprite
      self.bitmap = Cache.character(@character.reflect_sprite[0])
    else
      self.bitmap = Cache.character(@character_name)
    end
    self.mirror = true
    self.opacity = 255
    self.z = Galv_CEffects::REFLECT_Z
     
    sign = @character_name[/^[\!\$]./]
    if sign && sign.include?('$')
      @cw = bitmap.width / 3
      @ch = bitmap.height / 4
    else
      @cw = bitmap.width / 12
      @ch = bitmap.height / 8
    end
    self.ox = @cw / 2
    self.oy = @ch
  end
 
  def update_src_rect
    if @character.reflect_sprite
      index = @character.reflect_sprite[1]
    else
      index = @character.character_index
    end
    pattern = @character.pattern < 3 ? @character.pattern : 1
    sx = (index % 4 * 3 + pattern) * @cw
    sy = (index / 4 * 4 + (10 - @character.direction - 2) / 2) * @ch
    self.src_rect.set(sx, sy, @cw, @ch)
  end
   
  def get_mirror_y
    20.times {|i|
      if $game_map.region_id(@character.x, @character.y - i) == Galv_CEffects::MIRROR_REGION
        @distance = (i - 1) * 0.05
        @display = @character.y - i - $game_map.display_y + $game_map.height
        self.opacity = 255
        return (@character.y - i + 1 - $game_map.display_y) * 32 - i * 4
      end
    }
    self.opacity = 0
    return @ch
  end
   
  def update_position
    self.x = @character.screen_x
    self.y = get_mirror_y - 6
    self.zoom_x = 1 - @distance
    self.zoom_y = 1 - @distance
  end
 
  def update_other
    self.blend_type = @character.blend_type
    self.visible = !@character.transparent
  end
end # Sprite_Mirror < Sprite_Character
 
 
#-------------------------------------------------------------------------------
#  Sprite_Shadow
#-------------------------------------------------------------------------------
 
class Sprite_Shadow < Sprite_Character
  def initialize(viewport, character = nil, source)
    @flicker = 0
    @famount = 0
    @aamount = 0
    @source = source
    super(viewport, character)
  end
 
  def update
    super
    update_bitmap
    update_src_rect
    update_position
    update_other
    update_facing
  end
  
  def set_character_bitmap
    self.bitmap = Cache.character(@character_name)
    
    self.color = Color.new(0, 0, 0, 255)
    self.z = Galv_CEffects::SHADOW_Z
    self.wave_amp = 1 if $game_map.shadow_options[2]
    self.wave_speed = 1000
     
    sign = @character_name[/^[\!\$]./]
    if sign && sign.include?('$')
      @cw = bitmap.width / 3
      @ch = bitmap.height / 4
    else
      @cw = bitmap.width / 12
      @ch = bitmap.height / 8
    end
    self.ox = @cw / 2
    self.oy = @ch
  end
 
  def update_position
    self.x = @character.screen_x
    self.y = @character.screen_y - 10
    get_angle
  end
   
  def get_angle
    x = $game_map.light_source[@source][0] - @character.real_x
    y = $game_map.light_source[@source][1] - @character.real_y
    self.opacity = $game_map.shadow_options[0] - 
      Math::sqrt(x * x + y * y) * $game_map.shadow_options[1]
     
    if x == 0 && y == 0 || self.opacity <= 0
      self.opacity = 0
    else 
      self.angle = Math::atan2(x, y) * 180 / Math::PI + @aamount
    end
  end
  
  def update_facing
    if @character.y < $game_map.light_source[@source][1]
      self.mirror = false
    else
      self.mirror = true
    end
  end
   
  def update_other
    self.blend_type = @character.blend_type
    self.visible = !@character.transparent
  end
end # Sprite_Shadow < Sprite_Character
 
 
#-------------------------------------------------------------------------------
#  Sprite_Icon
#-------------------------------------------------------------------------------
 
class Sprite_Icon < Sprite_Character
  def initialize(viewport, character = nil)
    @icon_sprite ||= Sprite.new
    @icon_sprite.bitmap ||= Cache.system("Iconset")
    @icon = nil
    super(viewport, character)
  end
 
  def dispose
    super
    if @icon_sprite
      @icon_sprite.dispose
      @icon_sprite = nil
    end
  end
   
  def update
    super
    update_icon
  end
   
  def update_icon
    return if !@character.icon
    draw_icon(@character.icon)
  end
   
  def draw_icon(icon_index)
    return if !@icon.nil?
    rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
    @icon_sprite.src_rect  = rect
    @icon = icon_index
  end
   
  def update_position
    @icon_sprite.x = @character.screen_x - 12
    @icon_sprite.y = @character.screen_y + Galv_CEffects::ICON_OFFSET
  end
 
  def update_other
    self.blend_type = @character.blend_type
    @icon_sprite.visible = !@character.transparent
  end
end # Sprite_Icon < Sprite_Character
 
 
#-------------------------------------------------------------------------------
#  Other Stuff
#-------------------------------------------------------------------------------
 
 
class Game_Character < Game_CharacterBase
  attr_reader    :altitude
  attr_accessor  :reflect
  attr_accessor  :reflect_sprite
  attr_accessor  :shadow
  attr_accessor  :icon
  attr_accessor  :icon_offset
end
 
 
class Game_Event < Game_Character
  alias galv_reflect_ge_initialize initialize
  def initialize(map_id, event)
    @reflect = false
    @shadow = false
    @icon_offset = [0,0]
    galv_reflect_ge_initialize(map_id, event)
  end
end # Game_Event < Game_Character
 
 
class Game_Vehicle < Game_Character
  attr_reader :map_id
   
  alias galv_reflect_gv_initialize initialize
  def initialize(type)
    @reflect = true
    @shadow = true
    @icon_offset = [0,0]
    galv_reflect_gv_initialize(type)
  end
end # Game_Vehicle < Game_Character
 
 
class Game_Follower < Game_Character
  alias galv_reflect_gf_initialize initialize
  def initialize(member_index, preceding_character)
    galv_reflect_gf_initialize(member_index, preceding_character)
    @reflect = true
    @shadow = true
  end
   
  alias galv_reflect_gf_refresh refresh
  def refresh
    galv_reflect_gf_refresh
    return if actor.nil?
    @reflect = actor.reflect
    @reflect_sprite = actor.reflect_sprite
    @icon = actor.icon
    if SceneManager.scene_is?(Scene_Map)
      SceneManager.scene.spriteset.refresh_effects
    end
  end
end # Game_Follower < Game_Character
 
 
class Game_Player < Game_Character
  alias galv_reflect_gp_initialize initialize
  def initialize
    galv_reflect_gp_initialize
    @reflect = true
    @shadow = true
  end
   
  alias galv_reflect_gp_refresh refresh
  def refresh
    galv_reflect_gp_refresh
    @reflect = actor.reflect
    @reflect_sprite = actor.reflect_sprite
    @icon = actor.icon
    if SceneManager.scene_is?(Scene_Map)
      SceneManager.scene.spriteset.refresh_effects
    end
  end
end # Game_Player < Game_Character
 
 
class Scene_Map < Scene_Base
  attr_accessor :spriteset
end # Scene_Map
 
 
class Game_Map
  attr_accessor :char_effects
  attr_accessor :light_source
  attr_accessor :shadow_options
  attr_accessor :reflect_options
   
  alias galv_reflect_game_map_initialize initialize
  def initialize
    @light_source = []
    @shadow_options = [80,10,false]
    @reflect_options = [0]
    @char_effects = [false,false,false,false]
    #[reflect,shadow,mirror,icon]
    galv_reflect_game_map_initialize
  end
  
   
  alias galv_reflect_game_map_setup setup
  def setup(map_id)
    galv_reflect_game_map_setup(map_id)
    reset_char_effects
    do_all_chareffects
    if SceneManager.scene_is?(Scene_Map)
      SceneManager.scene.spriteset.refresh_effects
    end
  end
   
  def reset_char_effects
    @light_source = []
    @events.values.each { |e|
      e.reflect = false
      e.icon = nil }
  end
end # Game_Map
 
 
class Game_Actor < Game_Battler
  attr_accessor :reflect
  attr_accessor :reflect_sprite
  attr_accessor :icon
   
  alias galv_reflect_game_actor_initialize initialize
  def initialize(actor_id)
    galv_reflect_game_actor_initialize(actor_id)
    @reflect = $data_actors[actor_id].reflect
    @reflect_sprite = $data_actors[actor_id].reflect_sprite
    @icon_offset = [0,0]
  end
end # Game_Actor < Game_Battler
 
 
class RPG::Actor
  def reflect_sprite
    if @reflect_sprite.nil?
      if @note =~ /<reflect_sprite:[ ](.*),(.*)>/i
        @reflect_sprite = [$1.to_s,$2.to_i]
      else
        @reflect_sprite = nil
      end
    end
    @reflect_sprite
  end
  def reflect
    if @reflect.nil?
      if @note =~ /<no_reflect>/i
        @reflect = false
      else
        @reflect = true
      end
    end
    @reflect
  end
end # RPG::Actor



Extra Movement Frames:

Portion de code : Tout sélectionner

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
#==============================================================================
#    Extra Movement Frames
#    Version: 1.0.1
#    Author: modern algebra (rmrk.net)
#    Date: 26 September 2012
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#    
#    This script allows you to import character sprites with more than 3 frames 
#  for movement animation. In other words, it allows you to animate sprites a 
#  little more smoothly. One use for it is it allows RMXP format characters to 
#  be imported directly into a VXA game without editing (although you will need 
#  to rename the file).
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#    
#    Paste this script into its own slot in the Script Editor, above Main but
#   below Materials. If you are using my Composite Graphics script, then this
#   script must be placed in a slot below Composite Graphics.
#
#    To create a sprite with extra movement frames, all you need to do is 
#   rename the character graphic to something of the form:
#
#      Regular_Name%(x)
#        where:
#          x is the number of frames in each character sprite
#  
#  EXAMPLES:
#
#    $001-Fighter01%(4)
#      This graphic is a single character with four frames of animation. [XP]
#    022-Actors12%(6)
#      This graphic would be interpreted as a character sheet of 8 characters,
#      each having six frames of animation.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#    Additionally, this script also allows you to specify the "idle" frame (the
#   frame where the sprite is not moving), and also the pattern if wish to so
#   specify. In essence, all you need to do is add those integers after the
#   number of frames:
#
#      Regular_Name%(x y1 y2 y3 ... yx)
#        where:
#          x is the number of frames in each character sprite
#          y1 is the idle frame (the frame shown when sprite is not moving)
#          y2 ... yx are the pattern.
#
#   Keep in mind that the first frame in a sprite is index 0, the second frame
#   is index 1, etc.
#
#    Where y1 is excluded, it is assumed to be 0. Where y2 ... yx are excluded,
#   the pattern is assumed to simply cycle through the frames one by one until
#   it repeats.
#
#  EXAMPLES:
#
#    $003-Fighter03%(4 2)
#      This graphic is a single character with four frames of animation. The 
#      idle frame is 2 (the third one over). The pattern when moving would be
#      2 3 0 1, 2 3 0 1, etc.
#    032-People05%(4 0 1 0 3 2 1)
#      This graphic would be interpreted as a character sheet of 8 characters,
#      each having four frames of animation. The idle frame is 0 (the first
#      in the sheet), and the pattern is 0 1 0 3 2 1, 0 1 0 3 2 1, etc.
#==============================================================================
 
$imported = {} unless $imported
$imported[:MA_ExtraMovementFrames] = true
 
#==============================================================================
# *** MA_ExtraMovementFrames
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This module holds a method for calculating width and height of an emf
# character frame
#==============================================================================
 
module MA_ExtraMovementFrames
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Check if Character has extra movement frames
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_char_is_emf_sprite?(character_name)
    character_name && !character_name[/\%[\(\[].+?[\)\]]/].nil?
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Derive Frames Array
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def maemf_get_frames(character_name)
    character_name = "" unless character_name
    frames = !character_name[/\%[\(\[](.+?)[\)\]]/] ? [] : 
      $1.scan(/\d+/).collect { |s| s.to_i }
    frames[0] = 3 unless frames[0] # If empty, then set to default 3
    frames.push(1, 2, 1, 0) if frames[0] == 3 && frames.size < 2
    frames[1] = 0 unless frames[1] # Set idle frame
    if frames.size < 3
      # Create pattern 
      (frames[0] - 1).times {|i| frames.push((frames[1] + i + 1) % frames[0]) } 
    end
    return frames
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Calculate Frame Size
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def maemf_calc_frame_size(character_name, bitmap, frames = [])
    character_name = "" unless character_name
    frames = maemf_get_frames(character_name) if frames.empty?
    cw = bitmap.width / (frames[0] ? frames[0] : 3)
    ch = bitmap.height / 4
    sign = character_name[/^[\!\$]./]
    if !sign || !sign.include?('$')
      cw /= 4
      ch /= 2
    end
    return cw, ch
  end
end
 
# Compatibility with Composite Graphics
if $imported[:MA_CompositeGraphics]
  #============================================================================
  # *** Cache
  #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  #  Summary of Changes:
  #    aliased method - macgve_make_unique_name
  #============================================================================
  class << Cache
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # * Make Unique Name
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    alias macgemf_uniqname_3tc8 macgve_make_unique_name
    def macgve_make_unique_name(cg_array = [], *args)
      result = macgemf_uniqname_3tc8(cg_array, *args) # Call Original Method
      # Add %(x) code to name if the first graphic in the array contains it.
      result += $1 if cg_array[0] && cg_array[0].filename[/(\%[\(\[].+?[\)\]])/]
      result
    end
  end
end
 
#==============================================================================
# ** Game_CharacterBase
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - straighten; update_anime_pattern; initialize;
#      set_graphic; character_name=
#    new methods - maemf_init_char_frames
#==============================================================================
 
class Game_CharacterBase
  include MA_ExtraMovementFrames
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Straighten
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maemf_straghtn_5sb3 straighten
  def straighten(*args, &block)
    maemf_straghtn_5sb3(*args, &block) # Run original method
    @pattern = @original_pattern if @walk_anime || @step_anime
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Anime Pattern
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maemf_updanim_ptrn_2yv5 update_anime_pattern
  def update_anime_pattern(*args)
    if @ma_char_is_emf_sprite # If an emf sprite
      if !@step_anime && @stop_count > 0 # Reset to stationary
        @maemf_frame_index = 0
        @pattern = @original_pattern
      else
        # Next Pattern
        @maemf_frame_index = (@maemf_frame_index + 1) % @maemf_character_pattern.size
        @pattern = @maemf_character_pattern[@maemf_frame_index]
      end
    else
      maemf_updanim_ptrn_2yv5(*args) # Call original method
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Initialize Character Frames
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def maemf_init_char_frames
    @maemf_frame_index = 0 # Initialize Index
    # Save this value for faster reference
    @ma_char_is_emf_sprite = ma_char_is_emf_sprite?(character_name)
    if @ma_char_is_emf_sprite
      # Get pattern
      @maemf_character_pattern = maemf_get_frames(character_name)
      @maemf_character_pattern.shift # Remove frame number
      @original_pattern = @maemf_character_pattern[0]
    else
      @maemf_character_pattern = []
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Initialize Character Frames Proc
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def self.maemf_init_char_frames_proc
    Proc.new { |method_name|
      alias_method(:"maemf_#{method_name}_2ev9", method_name) # Alias
      define_method(method_name) do |*args| # Define method
        send(:"maemf_#{method_name}_2ev9", *args) # Call original method
        maemf_init_char_frames
      end
    }
  end
  proc = maemf_init_char_frames_proc
  [:initialize, :set_graphic].each { |name| proc.call(name) }
end
 
#==============================================================================
# ** Game_Player/Follower/Vehicle/Event
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This aliases methods in these classes that change @character_name in order
# to call maemf_init_char_frames
#==============================================================================
 
class Game_Player
  # Refresh
  maemf_init_char_frames_proc.call(:refresh)
end
 
class Game_Follower
  # Refresh
  maemf_init_char_frames_proc.call(:refresh)
end
 
class Game_Vehicle
  # Load System Settings
  maemf_init_char_frames_proc.call(:load_system_settings)
end
 
class Game_Event  
  proc = maemf_init_char_frames_proc
  # Clear Page Settings & Setup Page Settings
  [:clear_page_settings, :setup_page_settings].each { |name| proc.call(name) }
end
 
#==============================================================================
# ** Sprite_Character
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - set_character_bitmap; update_src_rect
#    new methods - ma_set_emf_character_bitmap; ma_update_emf_src_rect
#==============================================================================
 
class Sprite_Character
  include MA_ExtraMovementFrames
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Set Character Bitmap
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maemf_setcharbmp_4rm6 set_character_bitmap
  def set_character_bitmap(*args)
    @emf_char = ma_char_is_emf_sprite?(@character_name)
    @emf_char ? ma_set_emf_character_bitmap : maemf_setcharbmp_4rm6(*args)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Transfer Origin Rectangle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maemf_updtsrcrect_2kq5 update_src_rect
  def update_src_rect(*args)
    @emf_char ? ma_update_emf_src_rect : maemf_updtsrcrect_2kq5(*args)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Set Character Bitmap
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_set_emf_character_bitmap
    self.bitmap = Cache.character(@character_name)
    @emf_char_frames = maemf_get_frames(@character_name)
    @cw, @ch = maemf_calc_frame_size(@character_name, bitmap, @emf_char_frames)
    self.ox = @cw / 2
    self.oy = @ch
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Transfer Origin Rectangle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_update_emf_src_rect
    if @tile_id == 0
      index = @character.character_index
      pattern = @character.pattern < @emf_char_frames[0] ? @character.pattern : @emf_char_frames[1]
      sx = (index % 4 * @emf_char_frames[0] + pattern) * @cw
      sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
      self.src_rect.set(sx, sy, @cw, @ch)
    end
  end
end
 
#==============================================================================
# ** Window_Base
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes: 
#    aliased method - draw_character
#    new method - ma_draw_emf_character
#==============================================================================
 
class Window_Base
  include MA_ExtraMovementFrames
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Draw Character Graphic
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maemf_drawcharct_3kq6 draw_character
  def draw_character(character_name, *args)
    character_name[/\%[\(\[].+?[\)\]]/] ? ma_draw_emf_character(character_name, *args) :
      maemf_drawcharct_3kq6(character_name, *args)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Draw Extra Movement Frames Character Graphic
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_draw_emf_character(character_name, character_index, x, y)
    return unless character_name
    if !ma_char_is_emf_sprite?(character_name)
      # Draw regular if there is no frame specification in the name
      maemf_drawcharct_3kq6(character_name, *args)
    else
      bitmap = Cache.character(character_name)
      frames = maemf_get_frames(character_name)
      cw, ch = maemf_calc_frame_size(character_name, bitmap, frames)
      n = character_index
      src_rect = Rect.new((n%4*frames[0]+frames[1])*cw, (n/4*4)*ch, cw, ch)
      contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
    end
  end
end



Un CactusPoints pour celui qui parvient a corriger le problème.

Merci d'avance ! :)


cortez - posté le 19/04/2015 à 21:56:19 (523 messages postés)

❤ 0

Si je ne dis pas de bêtise : (je ne peux pas tester car j'ai pas VXace)

A la ligne 642 du script de reflet tu as :

Portion de code : Tout sélectionner

1
2
3
4
5
6
7
8
9
10
    sign = @character_name[/^[\!\$]./]
    if sign && sign.include?('$')
      @cw = bitmap.width / 3
      @ch = bitmap.height / 4
    else
      @cw = bitmap.width / 12
      @ch = bitmap.height / 8
    end
    self.ox = @cw / 2
    self.oy = @ch



Tu le remplace par :

Portion de code : Tout sélectionner

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
    #On récupère le nombres frames du personnage
    character_name = "" unless character_name
    frames = !character_name[/\%[\(\[](.+?)[\)\]]/] ? [] : 
      $1.scan(/\d+/).collect { |s| s.to_i }
    frames[0] = 3 unless frames[0] # If empty, then set to default 3
    frames.push(1, 2, 1, 0) if frames[0] == 3 && frames.size < 2
    frames[1] = 0 unless frames[1] # Set idle frame
    if frames.size < 3
      # Create pattern 
      (frames[0] - 1).times {|i| frames.push((frames[1] + i + 1) % frames[0]) } 
    end
    return frames
 
    sign = @character_name[/^[\!\$]./]
    if sign && sign.include?('$')
      if frames == 3 # Uniquement si le charset est de 3 frames.
         @cw = bitmap.width / 3
         @ch = bitmap.height / 4
      else # Pour les charset de plus de 3 frames.
         @cw = bitmap.width / (frames[0] ? frames[0] : 3)
         @ch = bitmap.height / 4
      end
    else
      @cw = bitmap.width / 12
      @ch = bitmap.height / 8
    end
    self.ox = @cw / 2
    self.oy = @ch



Cette manipulation devrait fonctionner. Si s'est le cas tu peux aussi faire le même remplacement dans la Classe Reflect (ligne 577) et la Classe Shadow (ligne 723)

Le principe est simple, c'est aux endroits que j'ai indiqué que je script reflect & Co
calcule la taille des frames du reflet/ombre/mirroir donc si j’introduis le calcul d'
extra frames dans ces méthodes, on obtient logiquement un bon découpage.


Cactus - posté le 19/04/2015 à 22:44:37 (681 messages postés)

❤ 0

Pikactus

Merci cortez !

Cependant un petit problème persiste encore.
image
Apres il n'est pas impossible que j'ai merdé quelques part...


cortez - posté le 19/04/2015 à 23:48:16 (523 messages postés)

❤ 0

Quel est le nom complet du chara de tes perso. Sont-ils regroupé sur 1 planche de 12 character ?

J'attends ta réponse avant de modifier le script.


Cactus - posté le 20/04/2015 à 00:08:51 (681 messages postés)

❤ 0

Pikactus

tst%(8)

Spoiler (cliquez pour afficher)


Ils sont sur une planche de 8.


cortez - posté le 20/04/2015 à 10:23:29 (523 messages postés)

❤ 0

Ok je comprends essaye ça : (remplace le code précédent par celui-ci)

Portion de code : Tout sélectionner

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
 
    #On récupère le nombres frames du personnage
    character_name = "" unless character_name
    frames = !character_name[/\%[\(\[](.+?)[\)\]]/] ? [] : 
      $1.scan(/\d+/).collect { |s| s.to_i }
    frames[0] = 3 unless frames[0] # If empty, then set to default 3
    frames.push(1, 2, 1, 0) if frames[0] == 3 && frames.size < 2
    frames[1] = 0 unless frames[1] # Set idle frame
    if frames.size < 3
      # Create pattern 
      (frames[0] - 1).times {|i| frames.push((frames[1] + i + 1) % frames[0]) } 
    end
    return frames
 
    sign = @character_name[/^[\!\$]./]
    if sign && sign.include?('$')
      if frames == 3 # Uniquement si le charset est de 3 frames.
         @cw = bitmap.width / 3
         @ch = bitmap.height / 4
      else # Pour les charset de plus de 3 frames.
         @cw = bitmap.width / (frames[0] ? frames[0] : 3)
         @ch = bitmap.height / 4
      end
    else
    @cw = bitmap.width / (frames[0] ? frames[0] : 3)
    @ch = bitmap.height / 4
      @cw /= 4
      @ch /= 2
    end
    self.ox = @cw / 2
    self.oy = @ch
 



Le problème venais du fait que tu as placé les chara en planche donc avec la
modification tout devrais marcher.


Cactus - posté le 20/04/2015 à 21:31:59 (681 messages postés)

❤ 0

Pikactus

Merci de prendre de ton temps pour m'aider.
image
L'erreur apparaît des que j'appelle:

Portion de code : Tout sélectionner

1
2
char_effects(2,3,true)
char_effects(0,1,false)



:-/


cortez - posté le 20/04/2015 à 23:20:18 (523 messages postés)

❤ 0

Reprends un script de reflet neuf et on vas le modifier.
Une fois la modification faite, teste juste l'affichage du
mirroir seul sans les autres effets, Et dis moi ce que tu
obtiens.
Je pense que mon erreur est corrigée, maintenant les
arguments de "frames" sont tous définis.


Cette fois remplace le code : (ligne 629)

Portion de code : Tout sélectionner

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  def update_balloon; end
  def setup_new_effect; end
   
  def set_character_bitmap
    if @character.reflect_sprite
      self.bitmap = Cache.character(@character.reflect_sprite[0])
    else
      self.bitmap = Cache.character(@character_name)
    end
    self.mirror = true
    self.opacity = 255
    self.z = Galv_CEffects::REFLECT_Z
     
    sign = @character_name[/^[\!\$]./]
    if sign && sign.include?('$')
      @cw = bitmap.width / 3
      @ch = bitmap.height / 4
    else
      @cw = bitmap.width / 12
      @ch = bitmap.height / 8
    end
    self.ox = @cw / 2
    self.oy = @ch
  end



Par celui-ci :

Portion de code : Tout sélectionner

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
 
  def update_balloon; end
  def setup_new_effect; end
 
  def maemf_get_frames(character_name)
    character_name = "" unless character_name
    frames = !character_name[/\%[\(\[](.+?)[\)\]]/] ? [] : 
      $1.scan(/\d+/).collect { |s| s.to_i }
    frames[0] = 3 unless frames[0] # If empty, then set to default 3
    frames.push(1, 2, 1, 0) if frames[0] == 3 && frames.size < 2
    frames[1] = 0 unless frames[1] # Set idle frame
    if frames.size < 3
      # Create pattern 
      (frames[0] - 1).times {|i| frames.push((frames[1] + i + 1) % frames[0]) } 
    end
    return frames
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Calculate Frame Size
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def maemf_calc_frame_size(character_name, bitmap, frames = [])
    character_name = "" unless character_name
    frames = maemf_get_frames(character_name) if frames.empty?
    @cw = bitmap.width / (frames[0] ? frames[0] : 3)
    @ch = bitmap.height / 4
    sign = character_name[/^[\!\$]./]
    if !sign || !sign.include?('$')
      @cw /= 4
      @ch /= 2
    end
    return @cw, @ch
  end
 
  def set_character_bitmap
    if @character.reflect_sprite
      self.bitmap = Cache.character(@character.reflect_sprite[0])
    else
      self.bitmap = Cache.character(@character_name)
    end
    self.mirror = true
    self.opacity = 255
    self.z = Galv_CEffects::REFLECT_Z
    self.ox = @cw / 2
    self.oy = @ch
  end




Cactus - posté le 20/04/2015 à 23:31:29 (681 messages postés)

❤ 0

Pikactus

image
En appelant seulement

Portion de code : Tout sélectionner

1
char_effects(2,true)




cortez - posté le 21/04/2015 à 17:08:09 (523 messages postés)

❤ 0

J'ai résolu le problème !
Dans le script d'extra frames remplace ça : (ligne 102)

Portion de code : Tout sélectionner

1
2
3
4
5
6
7
8
9
10
11
12
13
  def maemf_calc_frame_size(character_name, bitmap, frames = [])
    character_name = "" unless character_name
    frames = maemf_get_frames(character_name) if frames.empty?
    cw = bitmap.width / (frames[0] ? frames[0] : 3)
    ch = bitmap.height / 4
    sign = character_name[/^[\!\$]./]
    if !sign || !sign.include?('$')
      cw /= 4
      ch /= 2
    end
    return cw, ch
  end
end



par ceci :

Portion de code : Tout sélectionner

1
2
3
4
5
6
7
8
9
10
11
12
13
  def maemf_calc_frame_size(character_name, bitmap, frames = [])
    character_name = "" unless character_name
    frames = maemf_get_frames(character_name) if frames.empty?
    $cw = bitmap.width / (frames[0] ? frames[0] : 3)
    $ch = bitmap.height / 4
    sign = character_name[/^[\!\$]./]
    if !sign || !sign.include?('$')
      $cw /= 4
      $ch /= 2
    end
    return $cw, $ch
  end
end



J'ai aussi modifié le script de reflet : (remplace-le en entier)

Portion de code : Tout sélectionner

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
#------------------------------------------------------------------------------#
#  Galv's Character Effects
#------------------------------------------------------------------------------#
#  For: RPGMAKER VX ACE
#  Version 2.0
#------------------------------------------------------------------------------#
#  2013-12-07 - Version 2.0 - Added comments to more easily add event effects
#                           - Fixed shadow facing bug
#  2013-02-24 - Version 1.9 - added z level option for reflection and shadows
#  2013-02-23 - Version 1.8 - added multiple light sources for shadows
#  2013-02-22 - Version 1.7 - bug fixes
#  2013-02-22 - Version 1.6 - added icon effect
#  2013-02-22 - Version 1.5 - fixed mirror bug on large maps
#  2013-02-22 - Version 1.4 - added effects to vehicles
#  2013-02-21 - Version 1.3 - fixed jump reflection and other minor tweaks
#  2013-02-21 - Version 1.2 - bug with less than 4 actors (oops)
#  2013-02-21 - Version 1.1 - updated flicker effect
#  2013-02-21 - Version 1.0 - release
#------------------------------------------------------------------------------#
#  This script was made to provide some additional effects for characters such
#  as events, followers and the player on the map.
#  Currently it includes:
#
#  Shadows
#  Shadows that appear under player and events in a directions depending on
#  a light source that you choose.
#
#  Parallax Reflect
#  Reflections that appear on the parallax layer for events and actors to be
#  used for things like reflections in the water or glass floor etc. To get
#  effects like the demo, you need to edit the charset graphic to make the water
#  partially transparent.
#
#  Parallax Mirrors
#  Much like reflect but are instead actors and event are reflected in a mirror
#  on a wall designated by a region. Both mirror and reflect effects can be
#  changed so actors and events can use different charsets for their reflections
#
#------------------------------------------------------------------------------#
 
 
#------------------------------------------------------------------------------#
#  NEW - First event command as a COMMENT
#------------------------------------------------------------------------------#
#  You can add a comment as the first event command on an event page to set if
#  that event has an icon, shadow or reflection active. The tags to use are
#  below, all must be on the same line in the comment.
#
# <icon:id,x,y>      # set the event to display an icon (x,y position offset)
# <shadow>           # set the event to display a shadow
# <reflect>          # set the event to display reflections
#
#------------------------------------------------------------------------------#
#  EXAMPLE:
# <icon:1,0,0><shadow><reflect>    # to show reflect, shadow and icon 1 on event
#------------------------------------------------------------------------------#
 
 
#------------------------------------------------------------------------------#
#  SCRIPT CALLS:
#------------------------------------------------------------------------------#
#
#  char_effects(x,x,x,status)
#
#------------------------------------------------------------------------------#
#  # each effect can be true or false to enable/disable them during the game.
#  # you can change multiples of effects at once, x being the effect number
#  # 0 = reflect    1 = shadows    2 = mirror    3 = icons
#------------------------------------------------------------------------------#
#  EXAMPLES:
#  char_effects(0,true)              # turn reflections on
#  char_effects(0,2,true)            # turn reflections and mirror on
#  char_effects(1,3,false)           # turn shadows and icons off
#------------------------------------------------------------------------------#
#
#  reflect_sprite(actor_id,filename,pos)    # Change actor's reflect charset
#
#  reflect_esprite(event_id,filename,pos)   # Change event's reflect charset
#
#  reflect_vsprite(vehicle_id,filename,pos) # Change vehicle's reflect charset
#
#------------------------------------------------------------------------------#
#  EXAMPLES:
#  reflect_sprite(1,"Actor2",2)      # change actor 1's charset to use sprite
#                                    # in position 2 of "Actor2" charset.
#  reflect_esprite(3,"Actor4",5)     # event 3 will use sprite in position 5 of
#                                    # "Actor4" charset.
#  reflect_vsprite(1,"Vehicle",5)    # Ship will use sprite in position 5 of
#                                    # "Vehicle" charset.
#------------------------------------------------------------------------------#
 
#------------------------------------------------------------------------------#
#  SCRIPT CALLS to turn effects ON or OFF for chosen EVENTS
#------------------------------------------------------------------------------#
#
#  reflect(x,x,x,status)   # status can be true or false to turn on or off
#                          # use this to specify for mirror and reflect.
#  shadow(x,x,x,status)    # where x is the event ids you want to change
#                          # to change all events use :all
#  icon(x,x,x,icon_id)     # set which icon id to appear above character. Make
#                          # it 0 for no icon.
#
#------------------------------------------------------------------------------#
#  EXAMPLES:
#  reflect(14,17,3,1,true) # Turn events 14, 17, 3 and 1 reflections ON
#  shadow(1,false)         # Turn event 1 shadow OFF
#  reflect(:all,true)      # Turn all event reflections ON
#  icon(1,2,3,4,38)        # Events 1,2,3 and 4 will have icon 38 appear
#
#  NOTE: All events will default to NO shadows and NO reflections when entering
#        a map. This is a design decision to try to keep lag to a minimum. You
#        should use these effects sparingly and only activate them on events
#        that require them.
#------------------------------------------------------------------------------#
 
#------------------------------------------------------------------------------#
#  SCRIPT CALLS to turn effects ON or OFF for ACTORS and VEHICLES
#------------------------------------------------------------------------------#
#
#  actor_reflect(actor_id,status)  # reflections and shadows are ON by default 
#  actor_shadow(actor_id,status)   # for actors and vehicles. Turning them off 
#  actor_icon(actor_id,icon_id)    # or on will permanently change them.
#
#  v_reflect(x,x,x,status)    # use these v_ calls for changing vehicle effects
#  v_shadow(x,x,x,status)     # on and off for vehicles.
#  v_icon(x,x,x,icon_id)
#
#------------------------------------------------------------------------------#
 
#------------------------------------------------------------------------------#
#  SCRIPT CALLS for shadow options
#------------------------------------------------------------------------------#
#
#  shadow_source(x,y,id)       # set the x,y location for the light. id is the 
#                              # light source number you wish to change (for
#                              # more than one). These are reset on map change.
#  shadow_source(event_id,id)  # use an event's x,y location for the light.
#                              # This will need to be in parallel process if you
#                              # want it to be a moving light.
#
#  shadow_options(intensity,fade,flicker)    # descriptions below
#
#    # intensity = opacity when standing next to the light source (255 is black)
#    # fade = amount shadow becomes more transparent the further away you are.
#    # flicker = true or false. Shadows will flicker as if being cast by fire.
#
#------------------------------------------------------------------------------#
#  EXAMPLE:
#  shadow_options(80,10,false)    # This is the default setting.
#------------------------------------------------------------------------------#
 
#------------------------------------------------------------------------------#
#  SCRIPT CALLS for reflect options
#------------------------------------------------------------------------------#
#
#  reflect_options(wave_pwr) 
#
#    # wave_pwr = how strong the wave movement is. 0 is off
#
#------------------------------------------------------------------------------#
#  EXAMPLE:
#  reflect_options(1) # Turn wave power to 1
#------------------------------------------------------------------------------#
 
 
#------------------------------------------------------------------------------#
#  NOTETAG for ACTORS
#------------------------------------------------------------------------------#
#
#  <no_reflect>    # Actor will not have a reflection (for vampires of course!)
#
#  <reflect_sprite: FileName,pos>  # Actor will use this charset for reflections
#                                  # and use the character in position 'pos'
#
#------------------------------------------------------------------------------#
#  EXAMPLES:
#  <reflect_sprite: Actor2,0>    # The first character from Actor2 charset
#  <reflect_sprite: Actor3,7>    # The last character from Actor2 charset
#------------------------------------------------------------------------------#
 
 
($imported ||= {})["Galv_Character_Effects"] = true
module Galv_CEffects
 
#------------------------------------------------------------------------------#  
#  SETUP OPTIONS
#------------------------------------------------------------------------------#
 
  MIRROR_REGION = 4     # Region ID used to determine mirror walls. Paint the
                        # region on the wall you want to make reflective (and
                        # then use tiles/mapping that make the parallax visible)
 
  ICON_OFFSET = -60     # Y offset for icons that are displayed above characters
   
  REFLECT_Z = -10       # Z level of reflections
  SHADOW_Z = 0          # Z level of shadows
 
#------------------------------------------------------------------------------#  
#  END SETUP OPTIONS
#------------------------------------------------------------------------------#
end
 
 
 
 
class Game_Map
  def do_icons(refresh = true)
    @events.values.each { |e|
      next if !e.list
      if e.list[0].code == 108 && e.list[0].parameters[0] =~ /<icon:(.*),(.*),(.*)>/
        e.icon = $1.to_i
        e.icon_offset = [$2.to_i,$3.to_i]
      else
        e.icon = 0
        e.icon_offset = [0,0]
      end
    }
    SceneManager.scene.spriteset.refresh_effects if refresh
  end
  
  
  def do_shadows(refresh = true)
    @events.values.each { |e|
      next if !e.list
      if e.list[0].code == 108 && e.list[0].parameters[0] =~ /<shadow>/
        e.shadow = true
      else
        e.shadow = false
      end
    }
    SceneManager.scene.spriteset.refresh_effects if refresh
  end
  
  def do_reflects(refresh = true)
    @events.values.each { |e|
      next if !e.list
      if e.list[0].code == 108 && e.list[0].parameters[0] =~ /<reflect>/
        e.reflect = true
      else
        e.reflect = false
      end
    }
    SceneManager.scene.spriteset.refresh_effects if refresh
  end
  
  def do_all_chareffects
    do_icons(false)
    do_shadows(false)
    do_reflects(false)
  end
  
end # Game_Map
 
 
 
 
class Game_Interpreter
  
  def remove_icon
    icon(@event_id,0)
  end
 
#-----------------------------------#
#  REFLECTIONS
#-----------------------------------#
 
  # Add/Remove Reflections from selected events
  def reflect(*args,status)
    char_ids = [*args]
    if char_ids == [:all]
      $game_map.events.values.each { |e| e.reflect = status }
    else
      char_ids.each {|c| $game_map.events[c].reflect = status }
    end
    SceneManager.scene.spriteset.refresh_effects
  end
   
  # Change forever actor's reflect status
  def actor_reflect(actor_id,status)
    $game_actors[actor_id].reflect = status
    $game_player.refresh
  end
   
  # Change forever vehicle's reflect status
  def v_reflect(*args,status)
    char_ids = [*args]
    if char_ids == [:all]
      $game_map.vehicles.each { |v| v.reflect = status }
    else
      char_ids.each { |v| $game_map.vehicles[v].reflect = status }
    end
    SceneManager.scene.spriteset.refresh_effects
  end
 
  def reflect_options(*args)
    $game_map.reflect_options = [*args]
    SceneManager.scene.spriteset.refresh_effects
  end
   
  # Actor reflect sprite change
  def reflect_sprite(actor_id,filename,pos)
    $game_actors[actor_id].reflect_sprite = [filename,pos]
    $game_player.refresh
  end
   
  # Event reflect sprite change
  def reflect_esprite(event_id,filename,pos)
    $game_map.events[event_id].reflect_sprite = [filename,pos]
    $game_map.events[event_id].reflect = true
    SceneManager.scene.spriteset.refresh_characters
  end
   
  # Vehicle reflect sprite change
  def reflect_vsprite(v_id,filename,pos)
    $game_map.vehicles[v_id].reflect_sprite = [filename,pos]
    SceneManager.scene.spriteset.refresh_characters
  end
 
#-----------------------------------#
#  SHADOWS
#-----------------------------------#
 
  # Add/Remove Shadows from selected characters
  def shadow(*args,status)
    char_ids = [*args]
    if char_ids == [:all]
      $game_map.events.values.each { |e| e.shadow = status }
    else
      char_ids.each {|c| $game_map.events[c].shadow = status }
    end
    SceneManager.scene.spriteset.refresh_effects
  end
   
  # Change player and follower shadows
  def actor_shadows(status)
    $game_player.shadow = status
    $game_player.followers.each { |f| f.shadow = status }
    SceneManager.scene.spriteset.refresh_effects
  end
   
  # Change vehicle's shadow status
  def v_shadow(*args,status)
    char_ids = [*args]
    if char_ids == [:all]
      $game_map.vehicles.each { |v| v.shadow = status }
    else
      char_ids.each { |v| $game_map.vehicles[v].shadow = status }
    end
    SceneManager.scene.spriteset.refresh_effects
  end
   
  def shadow_options(*args)
    $game_map.shadow_options = [*args]
    SceneManager.scene.spriteset.refresh_effects
  end
 
  def shadow_source(*args,shad_id)
    shadsource = [*args]
 
    if shadsource.count == 1
      $game_map.light_source[shad_id] = [$game_map.events[shadsource[0]].real_x,
        $game_map.events[shadsource[0]].real_y]
    elsif shadsource.count > 1
      $game_map.light_source[shad_id] = shadsource
    else
      $game_map.light_source = []
    end
  end
 
 
#-----------------------------------#
#  ICONS
#-----------------------------------#
 
  # Add/Remove Icons from selected events
  def icon(*args,icon_id)
    char_ids = [*args]
    if char_ids == [:all]
      $game_map.events.values.each { |e|
      if e.icon <= 0
        e.icon = nil
      else
        e.icon = icon_id
      end
    }
    else
      char_ids.each {|c| $game_map.events[c].icon = icon_id }
    end
    SceneManager.scene.spriteset.refresh_effects
  end
   
  # Change forever actor's icon
  def actor_icon(actor_id,icon_id)
    $game_actors[actor_id].icon = icon_id
    $game_player.refresh
  end
   
  # Change forever vehicle's icon
  def v_icon(*args,icon_id)
    char_ids = [*args]
    if char_ids == [:all]
      $game_map.vehicles.each { |v| v.icon = icon_id }
    else
      char_ids.each { |v| $game_map.vehicles[v].icon = icon_id }
    end
    SceneManager.scene.spriteset.refresh_effects
  end
 
#-----------------------------------#
#  GENERAL
#-----------------------------------#
 
  # Turn on/off effects
    # 0 = reflect
    # 1 = shadow
    # 2 = mirror
    # 3 = icon
     
  def char_effects(*args,status)
    [*args].each { |e| $game_map.char_effects[e] = status }
    SceneManager.scene.spriteset.refresh_effects
  end
 
   
end # Game_Interpreter
 
 
#-------------------------------------------------------------------------------
#  Spriteset_Map
#-------------------------------------------------------------------------------
 
class Spriteset_Map
  alias galv_reflect_sm_initialize initialize
  def initialize
    create_effects
    galv_reflect_sm_initialize
    refresh_characters
  end
   
  alias galv_reflect_sm_refresh_characters refresh_characters
  def refresh_characters
    galv_reflect_sm_refresh_characters
    create_effects
  end
   
  def refresh_effects
    dispose_effects
    create_effects
  end
   
  def create_effects
    @shadow_sprites = []
    @reflect_sprites = []
    @mirror_sprites = []
    @icon_sprites = []
     
    # Do reflections
    if $game_map.char_effects[0]
      $game_map.events.values.each { |e|
        @reflect_sprites.push(Sprite_Reflect.new(@viewport1, e)) if e.reflect
      }
      $game_player.followers.each { |f|
        @reflect_sprites.push(Sprite_Reflect.new(@viewport1, f)) if f.reflect
      }
      if $game_player.reflect
        @reflect_sprites.push(Sprite_Reflect.new(@viewport1, $game_player))
      end
      $game_map.vehicles.each { |v|
        @reflect_sprites.push(Sprite_Reflect.new(@viewport1, v)) if v.reflect
      }
    end
     
    # Do mirrors
    if $game_map.char_effects[2]
      $game_map.events.values.each { |e|
        @mirror_sprites.push(Sprite_Mirror.new(@viewport1, e)) if e.reflect
      }
      $game_player.followers.each { |f|
        @mirror_sprites.push(Sprite_Mirror.new(@viewport1, f)) if f.reflect
      }
      if $game_player.reflect
        @mirror_sprites.push(Sprite_Mirror.new(@viewport1, $game_player))
      end
      $game_map.vehicles.each { |v|
        @mirror_sprites.push(Sprite_Mirror.new(@viewport1, v)) if v.reflect
      }
    end
     
    # Do Shadows
    if $game_map.char_effects[1]
      return if $game_map.light_source.empty?
      $game_map.light_source.count.times { |s|
        $game_map.events.values.each { |e|
          @shadow_sprites.push(Sprite_Shadow.new(@viewport1, e, s)) if e.shadow
        }
        $game_player.followers.each { |f|
          @shadow_sprites.push(Sprite_Shadow.new(@viewport1, f, s)) if f.shadow
        }
        if $game_player.shadow
          @shadow_sprites.push(Sprite_Shadow.new(@viewport1, $game_player, s))
        end
        $game_map.vehicles.each { |v|
          @shadow_sprites.push(Sprite_Shadow.new(@viewport1, v, s)) if v.shadow
        }
      }
    end
     
    # Do icons
    if $game_map.char_effects[3]
      $game_map.events.values.each { |e|
        @icon_sprites.push(Sprite_Icon.new(@viewport1, e)) if e.icon
      }
      $game_player.followers.each { |f|
        @icon_sprites.push(Sprite_Icon.new(@viewport1, f)) if f.icon
      }
      if $game_player.icon
        @icon_sprites.push(Sprite_Icon.new(@viewport1, $game_player))
      end
      $game_map.vehicles.each { |v|
        @icon_sprites.push(Sprite_Icon.new(@viewport1, v)) if v.icon
      }
    end
  end
   
  alias galv_reflect_sm_update update
  def update
    galv_reflect_sm_update
    @reflect_sprites.each {|s| s.update} if $game_map.char_effects[0]
    @mirror_sprites.each {|s| s.update} if $game_map.char_effects[2]
    @shadow_sprites.each {|s| s.update} if $game_map.char_effects[1]
    @icon_sprites.each {|s| s.update} if $game_map.char_effects[3]
  end
 
  alias galv_reflect_sm_dispose_characters dispose_characters
  def dispose_characters
    galv_reflect_sm_dispose_characters
    dispose_effects
  end
   
  def dispose_effects
    @reflect_sprites.each {|s| s.dispose}
    @shadow_sprites.each {|s| s.dispose}
    @mirror_sprites.each {|s| s.dispose}
    @icon_sprites.each {|s| s.dispose}
  end
end # Spriteset_Map
 
 
#-------------------------------------------------------------------------------
#  Sprite_Reflect 
#-------------------------------------------------------------------------------
 
class Sprite_Reflect < Sprite_Character
  def initialize(viewport, character = nil)
    super(viewport, character)
  end
 
  def update
    super
  end
   
  def update_balloon; end
  def setup_new_effect; end
   
  def set_character_bitmap
    if @character.reflect_sprite
      self.bitmap = Cache.character(@character.reflect_sprite[0])
    else
      self.bitmap = Cache.character(@character_name)
    end
    self.mirror = true
    self.angle = 180
    self.opacity = 220
    self.z = Galv_CEffects::REFLECT_Z
    self.wave_amp = $game_map.reflect_options[0]
    
    sign = @character_name[/\%[\(\[](.+?)[\)\]]/]
  if sign && sign.include?('%')
    sign = @character_name[/^[\!\$]./]
    if sign && sign.include?('$')
      @cw = $cw
      @ch = bitmap.height / 4
    else
      @cw = $cw
      @ch = bitmap.height / 8
    end
  else
    sign = @character_name[/^[\!\$]./]
    if sign && sign.include?('$')
      @cw = bitmap.width / 3
      @ch = bitmap.height / 4
    else
      @cw = bitmap.width / 12
      @ch = bitmap.height / 8
    end 
  end
    self.ox = @cw / 2
    self.oy = @ch
  end
 
  def update_position
    self.x = @character.screen_x
    jump = @character.jumping? ? @character.jump_height * 2 : 0
    alt = @character.altitude ? @character.altitude * 2 : 0
    self.y = @character.screen_y - 3 + jump + alt
  end
 
  def update_other
    self.blend_type = @character.blend_type
    self.visible = !@character.transparent
  end
   
  def update_src_rect
    if @character.reflect_sprite
      index = @character.reflect_sprite[1]
    else
      index = @character.character_index
    end
    sign = @character_name[/\%[\(\[](.+?)[\)\]]/]
  if sign && sign.include?('%')
    pattern = @character.pattern < @cw ? @character.pattern : 1
  else
    pattern = @character.pattern < 3 ? @character.pattern : 1
  end
    sx = (index % 4 * 3 + pattern) * @cw
    sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
    self.src_rect.set(sx, sy, @cw, @ch)
  end
end # Sprite_Reflect < Sprite_Character
 
 
#-------------------------------------------------------------------------------
#  Sprite_Mirror
#-------------------------------------------------------------------------------
 
class Sprite_Mirror < Sprite_Character
  def initialize(viewport, character = nil)
    @distance = 0
    super(viewport, character)
  end
 
  def update
    super
  end
   
  def update_balloon; end
  def setup_new_effect; end
   
  def set_character_bitmap
    if @character.reflect_sprite
      self.bitmap = Cache.character(@character.reflect_sprite[0])
    else
      self.bitmap = Cache.character(@character_name)
    end
    self.mirror = true
    self.opacity = 255
    self.z = Galv_CEffects::REFLECT_Z
     
    sign = @character_name[/\%[\(\[](.+?)[\)\]]/]
  if sign && sign.include?('%')
    sign = @character_name[/^[\!\$]./]
    if sign && sign.include?('$')
      @cw = $cw
      @ch = bitmap.height / 4
    else
      @cw = $cw
      @ch = bitmap.height / 8
    end
  else
    sign = @character_name[/^[\!\$]./]
    if sign && sign.include?('$')
      @cw = bitmap.width / 3
      @ch = bitmap.height / 4
    else
      @cw = bitmap.width / 12
      @ch = bitmap.height / 8
    end 
  end
    self.ox = @cw / 2
    self.oy = @ch
 
  end
 
  def update_src_rect
    if @character.reflect_sprite
      index = @character.reflect_sprite[1]
    else
      index = @character.character_index
    end
    sign = @character_name[/\%[\(\[](.+?)[\)\]]/]
  if sign && sign.include?('%')
    pattern = @character.pattern < @cw ? @character.pattern : 1
  else
    pattern = @character.pattern < 3 ? @character.pattern : 1
  end
    sx = (index % 4 * 3 + pattern) * @cw
    sy = (index / 4 * 4 + (10 - @character.direction - 2) / 2) * @ch
    self.src_rect.set(sx, sy, @cw, @ch)
  end
   
  def get_mirror_y
    20.times {|i|
      if $game_map.region_id(@character.x, @character.y - i) == Galv_CEffects::MIRROR_REGION
        @distance = (i - 1) * 0.05
        @display = @character.y - i - $game_map.display_y + $game_map.height
        self.opacity = 255
        return (@character.y - i + 1 - $game_map.display_y) * 32 - i * 4
      end
    }
    self.opacity = 0
    return @ch
  end
   
  def update_position
    self.x = @character.screen_x
    self.y = get_mirror_y - 6
    self.zoom_x = 1 - @distance
    self.zoom_y = 1 - @distance
  end
 
  def update_other
    self.blend_type = @character.blend_type
    self.visible = !@character.transparent
  end
end # Sprite_Mirror < Sprite_Character
 
 
#-------------------------------------------------------------------------------
#  Sprite_Shadow
#-------------------------------------------------------------------------------
 
class Sprite_Shadow < Sprite_Character
  def initialize(viewport, character = nil, source)
    @flicker = 0
    @famount = 0
    @aamount = 0
    @source = source
    super(viewport, character)
  end
 
  def update
    super
    update_bitmap
    update_src_rect
    update_position
    update_other
    update_facing
  end
  
  def set_character_bitmap
    self.bitmap = Cache.character(@character_name)
    
    self.color = Color.new(0, 0, 0, 255)
    self.z = Galv_CEffects::SHADOW_Z
    self.wave_amp = 1 if $game_map.shadow_options[2]
    self.wave_speed = 1000
     
    sign = @character_name[/\%[\(\[](.+?)[\)\]]/]
  if sign && sign.include?('%')
    sign = @character_name[/^[\!\$]./]
    if sign && sign.include?('$')
      @cw = $cw
      @ch = bitmap.height / 4
    else
      @cw = $cw
      @ch = bitmap.height / 8
    end
  else
    sign = @character_name[/^[\!\$]./]
    if sign && sign.include?('$')
      @cw = bitmap.width / 3
      @ch = bitmap.height / 4
    else
      @cw = bitmap.width / 12
      @ch = bitmap.height / 8
    end 
  end
    self.ox = @cw / 2
    self.oy = @ch
  end
 
  def update_position
    self.x = @character.screen_x
    self.y = @character.screen_y - 10
    get_angle
  end
   
  def get_angle
    x = $game_map.light_source[@source][0] - @character.real_x
    y = $game_map.light_source[@source][1] - @character.real_y
    self.opacity = $game_map.shadow_options[0] - 
      Math::sqrt(x * x + y * y) * $game_map.shadow_options[1]
     
    if x == 0 && y == 0 || self.opacity <= 0
      self.opacity = 0
    else 
      self.angle = Math::atan2(x, y) * 180 / Math::PI + @aamount
    end
  end
  
  def update_facing
    if @character.y < $game_map.light_source[@source][1]
      self.mirror = false
    else
      self.mirror = true
    end
  end
   
  def update_other
    self.blend_type = @character.blend_type
    self.visible = !@character.transparent
  end
end # Sprite_Shadow < Sprite_Character
 
 
#-------------------------------------------------------------------------------
#  Sprite_Icon
#-------------------------------------------------------------------------------
 
class Sprite_Icon < Sprite_Character
  def initialize(viewport, character = nil)
    @icon_sprite ||= Sprite.new
    @icon_sprite.bitmap ||= Cache.system("Iconset")
    @icon = nil
    super(viewport, character)
  end
 
  def dispose
    super
    if @icon_sprite
      @icon_sprite.dispose
      @icon_sprite = nil
    end
  end
   
  def update
    super
    update_icon
  end
   
  def update_icon
    return if !@character.icon
    draw_icon(@character.icon)
  end
   
  def draw_icon(icon_index)
    return if !@icon.nil?
    rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
    @icon_sprite.src_rect  = rect
    @icon = icon_index
  end
   
  def update_position
    @icon_sprite.x = @character.screen_x - 12
    @icon_sprite.y = @character.screen_y + Galv_CEffects::ICON_OFFSET
  end
 
  def update_other
    self.blend_type = @character.blend_type
    @icon_sprite.visible = !@character.transparent
  end
end # Sprite_Icon < Sprite_Character
 
 
#-------------------------------------------------------------------------------
#  Other Stuff
#-------------------------------------------------------------------------------
 
 
class Game_Character < Game_CharacterBase
  attr_reader    :altitude
  attr_accessor  :reflect
  attr_accessor  :reflect_sprite
  attr_accessor  :shadow
  attr_accessor  :icon
  attr_accessor  :icon_offset
end
 
 
class Game_Event < Game_Character
  alias galv_reflect_ge_initialize initialize
  def initialize(map_id, event)
    @reflect = false
    @shadow = false
    @icon_offset = [0,0]
    galv_reflect_ge_initialize(map_id, event)
  end
end # Game_Event < Game_Character
 
 
class Game_Vehicle < Game_Character
  attr_reader :map_id
   
  alias galv_reflect_gv_initialize initialize
  def initialize(type)
    @reflect = true
    @shadow = true
    @icon_offset = [0,0]
    galv_reflect_gv_initialize(type)
  end
end # Game_Vehicle < Game_Character
 
 
class Game_Follower < Game_Character
  alias galv_reflect_gf_initialize initialize
  def initialize(member_index, preceding_character)
    galv_reflect_gf_initialize(member_index, preceding_character)
    @reflect = true
    @shadow = true
  end
   
  alias galv_reflect_gf_refresh refresh
  def refresh
    galv_reflect_gf_refresh
    return if actor.nil?
    @reflect = actor.reflect
    @reflect_sprite = actor.reflect_sprite
    @icon = actor.icon
    if SceneManager.scene_is?(Scene_Map)
      SceneManager.scene.spriteset.refresh_effects
    end
  end
end # Game_Follower < Game_Character
 
 
class Game_Player < Game_Character
  alias galv_reflect_gp_initialize initialize
  def initialize
    galv_reflect_gp_initialize
    @reflect = true
    @shadow = true
  end
   
  alias galv_reflect_gp_refresh refresh
  def refresh
    galv_reflect_gp_refresh
    @reflect = actor.reflect
    @reflect_sprite = actor.reflect_sprite
    @icon = actor.icon
    if SceneManager.scene_is?(Scene_Map)
      SceneManager.scene.spriteset.refresh_effects
    end
  end
end # Game_Player < Game_Character
 
 
class Scene_Map < Scene_Base
  attr_accessor :spriteset
end # Scene_Map
 
 
class Game_Map
  attr_accessor :char_effects
  attr_accessor :light_source
  attr_accessor :shadow_options
  attr_accessor :reflect_options
   
  alias galv_reflect_game_map_initialize initialize
  def initialize
    @light_source = []
    @shadow_options = [80,10,false]
    @reflect_options = [0]
    @char_effects = [false,false,false,false]
    #[reflect,shadow,mirror,icon]
    galv_reflect_game_map_initialize
  end
  
   
  alias galv_reflect_game_map_setup setup
  def setup(map_id)
    galv_reflect_game_map_setup(map_id)
    reset_char_effects
    do_all_chareffects
    if SceneManager.scene_is?(Scene_Map)
      SceneManager.scene.spriteset.refresh_effects
    end
  end
   
  def reset_char_effects
    @light_source = []
    @events.values.each { |e|
      e.reflect = false
      e.icon = nil }
  end
end # Game_Map
 
 
class Game_Actor < Game_Battler
  attr_accessor :reflect
  attr_accessor :reflect_sprite
  attr_accessor :icon
   
  alias galv_reflect_game_actor_initialize initialize
  def initialize(actor_id)
    galv_reflect_game_actor_initialize(actor_id)
    @reflect = $data_actors[actor_id].reflect
    @reflect_sprite = $data_actors[actor_id].reflect_sprite
    @icon_offset = [0,0]
  end
end # Game_Actor < Game_Battler
 
 
class RPG::Actor
  def reflect_sprite
    if @reflect_sprite.nil?
      if @note =~ /<reflect_sprite:[ ](.*),(.*)>/i
        @reflect_sprite = [$1.to_s,$2.to_i]
      else
        @reflect_sprite = nil
      end
    end
    @reflect_sprite
  end
  def reflect
    if @reflect.nil?
      if @note =~ /<no_reflect>/i
        @reflect = false
      else
        @reflect = true
      end
    end
    @reflect
  end
end # RPG::Actor




zeus81 - posté le 21/04/2015 à 17:28:04 (11071 messages postés)

❤ 0

:moinsun


Cactus - posté le 21/04/2015 à 21:20:30 (681 messages postés)

❤ 0

Pikactus

Désolé de répondre si tard (je finis a 20h :triste2 )
J'ai essayé... et ça marche !
Merci beaucoup cortez, c'est vraiment sympas de ta part. :)

Edit: Ah bah non, c'est pas encore bon :F
image
Tu me dis si je te fais chier.


cortez - posté le 22/04/2015 à 10:47:27 (523 messages postés)

❤ 0

J'ai encore un bug d'affichage pour des évent avec un $ (1 seul par planche) mais
pour les event en planche de 8 aucun souci ! Donc je te propose cette version,
elle fonctionne pour tes perso et les character uniquement en planche.

Nouveau script Extra frames :

Portion de code : Tout sélectionner

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
#==============================================================================
#    Extra Movement Frames
#    Version: 1.0.1
#    Author: modern algebra (rmrk.net)
#    Date: 26 September 2012
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#    
#    This script allows you to import character sprites with more than 3 frames 
#  for movement animation. In other words, it allows you to animate sprites a 
#  little more smoothly. One use for it is it allows RMXP format characters to 
#  be imported directly into a VXA game without editing (although you will need 
#  to rename the file).
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#    
#    Paste this script into its own slot in the Script Editor, above Main but
#   below Materials. If you are using my Composite Graphics script, then this
#   script must be placed in a slot below Composite Graphics.
#
#    To create a sprite with extra movement frames, all you need to do is 
#   rename the character graphic to something of the form:
#
#      Regular_Name%(x)
#        where:
#          x is the number of frames in each character sprite
#  
#  EXAMPLES:
#
#    $001-Fighter01%(4)
#      This graphic is a single character with four frames of animation. [XP]
#    022-Actors12%(6)
#      This graphic would be interpreted as a character sheet of 8 characters,
#      each having six frames of animation.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#    Additionally, this script also allows you to specify the "idle" frame (the
#   frame where the sprite is not moving), and also the pattern if wish to so
#   specify. In essence, all you need to do is add those integers after the
#   number of frames:
#
#      Regular_Name%(x y1 y2 y3 ... yx)
#        where:
#          x is the number of frames in each character sprite
#          y1 is the idle frame (the frame shown when sprite is not moving)
#          y2 ... yx are the pattern.
#
#   Keep in mind that the first frame in a sprite is index 0, the second frame
#   is index 1, etc.
#
#    Where y1 is excluded, it is assumed to be 0. Where y2 ... yx are excluded,
#   the pattern is assumed to simply cycle through the frames one by one until
#   it repeats.
#
#  EXAMPLES:
#
#    $003-Fighter03%(4 2)
#      This graphic is a single character with four frames of animation. The 
#      idle frame is 2 (the third one over). The pattern when moving would be
#      2 3 0 1, 2 3 0 1, etc.
#    032-People05%(4 0 1 0 3 2 1)
#      This graphic would be interpreted as a character sheet of 8 characters,
#      each having four frames of animation. The idle frame is 0 (the first
#      in the sheet), and the pattern is 0 1 0 3 2 1, 0 1 0 3 2 1, etc.
#==============================================================================
 
$imported = {} unless $imported
$imported[:MA_ExtraMovementFrames] = true
 
#==============================================================================
# *** MA_ExtraMovementFrames
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This module holds a method for calculating width and height of an emf
# character frame
#==============================================================================
 
module MA_ExtraMovementFrames
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Check if Character has extra movement frames
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_char_is_emf_sprite?(character_name)
    character_name && !character_name[/\%[\(\[].+?[\)\]]/].nil?
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Derive Frames Array
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def maemf_get_frames(character_name)
    character_name = "" unless character_name
    frames = !character_name[/\%[\(\[](.+?)[\)\]]/] ? [] : 
      $1.scan(/\d+/).collect { |s| s.to_i }
    frames[0] = 3 unless frames[0] # If empty, then set to default 3
    frames.push(1, 2, 1, 0) if frames[0] == 3 && frames.size < 2
    frames[1] = 0 unless frames[1] # Set idle frame
    if frames.size < 3
      # Create pattern 
      (frames[0] - 1).times {|i| frames.push((frames[1] + i + 1) % frames[0]) } 
    end
    return frames
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Calculate Frame Size
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def maemf_calc_frame_size(character_name, bitmap, frames = [])
    character_name = "" unless character_name
    frames = maemf_get_frames(character_name) if frames.empty?
    $cw = bitmap.width / (frames[0] ? frames[0] : 3)
    $ch = bitmap.height / 4
    sign = character_name[/^[\!\$]./]
    if !sign || !sign.include?('$')
      $cw /= 4
      $ch /= 2
    end
    return $cw, $ch
  end
end
 
# Compatibility with Composite Graphics
if $imported[:MA_CompositeGraphics]
  #============================================================================
  # *** Cache
  #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  #  Summary of Changes:
  #    aliased method - macgve_make_unique_name
  #============================================================================
  class << Cache
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # * Make Unique Name
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    alias macgemf_uniqname_3tc8 macgve_make_unique_name
    def macgve_make_unique_name(cg_array = [], *args)
      result = macgemf_uniqname_3tc8(cg_array, *args) # Call Original Method
      # Add %(x) code to name if the first graphic in the array contains it.
      result += $1 if cg_array[0] && cg_array[0].filename[/(\%[\(\[].+?[\)\]])/]
      result
    end
  end
end
 
#==============================================================================
# ** Game_CharacterBase
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - straighten; update_anime_pattern; initialize;
#      set_graphic; character_name=
#    new methods - maemf_init_char_frames
#==============================================================================
 
class Game_CharacterBase
  include MA_ExtraMovementFrames
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Straighten
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maemf_straghtn_5sb3 straighten
  def straighten(*args, &block)
    maemf_straghtn_5sb3(*args, &block) # Run original method
    @pattern = @original_pattern if @walk_anime || @step_anime
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Anime Pattern
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maemf_updanim_ptrn_2yv5 update_anime_pattern
  def update_anime_pattern(*args)
    if @ma_char_is_emf_sprite # If an emf sprite
      if !@step_anime && @stop_count > 0 # Reset to stationary
        @maemf_frame_index = 0
        @pattern = @original_pattern
      else
        # Next Pattern
        @maemf_frame_index = (@maemf_frame_index + 1) % @maemf_character_pattern.size
        @pattern = @maemf_character_pattern[@maemf_frame_index]
      end
    else
      maemf_updanim_ptrn_2yv5(*args) # Call original method
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Initialize Character Frames
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def maemf_init_char_frames
    @maemf_frame_index = 0 # Initialize Index
    # Save this value for faster reference
    @ma_char_is_emf_sprite = ma_char_is_emf_sprite?(character_name)
    if @ma_char_is_emf_sprite
      # Get pattern
      @maemf_character_pattern = maemf_get_frames(character_name)
      @maemf_character_pattern.shift # Remove frame number
      @original_pattern = @maemf_character_pattern[0]
    else
      @maemf_character_pattern = []
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Initialize Character Frames Proc
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def self.maemf_init_char_frames_proc
    Proc.new { |method_name|
      alias_method(:"maemf_#{method_name}_2ev9", method_name) # Alias
      define_method(method_name) do |*args| # Define method
        send(:"maemf_#{method_name}_2ev9", *args) # Call original method
        maemf_init_char_frames
      end
    }
  end
  proc = maemf_init_char_frames_proc
  [:initialize, :set_graphic].each { |name| proc.call(name) }
end
 
#==============================================================================
# ** Game_Player/Follower/Vehicle/Event
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This aliases methods in these classes that change @character_name in order
# to call maemf_init_char_frames
#==============================================================================
 
class Game_Player
  # Refresh
  maemf_init_char_frames_proc.call(:refresh)
end
 
class Game_Follower
  # Refresh
  maemf_init_char_frames_proc.call(:refresh)
end
 
class Game_Vehicle
  # Load System Settings
  maemf_init_char_frames_proc.call(:load_system_settings)
end
 
class Game_Event  
  proc = maemf_init_char_frames_proc
  # Clear Page Settings & Setup Page Settings
  [:clear_page_settings, :setup_page_settings].each { |name| proc.call(name) }
end
 
#==============================================================================
# ** Sprite_Character
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - set_character_bitmap; update_src_rect
#    new methods - ma_set_emf_character_bitmap; ma_update_emf_src_rect
#==============================================================================
 
class Sprite_Character
  include MA_ExtraMovementFrames
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Set Character Bitmap
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maemf_setcharbmp_4rm6 set_character_bitmap
  def set_character_bitmap(*args)
    @emf_char = ma_char_is_emf_sprite?(@character_name)
    @emf_char ? ma_set_emf_character_bitmap : maemf_setcharbmp_4rm6(*args)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Transfer Origin Rectangle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maemf_updtsrcrect_2kq5 update_src_rect
  def update_src_rect(*args)
    @emf_char ? ma_update_emf_src_rect : maemf_updtsrcrect_2kq5(*args)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Set Character Bitmap
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_set_emf_character_bitmap
    self.bitmap = Cache.character(@character_name)
    @emf_char_frames = maemf_get_frames(@character_name)
    $emf_char_frames = @emf_char_frames
    @cw, @ch = maemf_calc_frame_size(@character_name, bitmap, @emf_char_frames)
    self.ox = @cw / 2
    self.oy = @ch
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Transfer Origin Rectangle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_update_emf_src_rect
    if @tile_id == 0
      index = @character.character_index
      pattern = @character.pattern < @emf_char_frames[0] ? @character.pattern : @emf_char_frames[1]
      sx = (index % 4 * @emf_char_frames[0] + pattern) * @cw
      sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
      self.src_rect.set(sx, sy, @cw, @ch)
    end
  end
end
 
#==============================================================================
# ** Window_Base
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes: 
#    aliased method - draw_character
#    new method - ma_draw_emf_character
#==============================================================================
 
class Window_Base
  include MA_ExtraMovementFrames
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Draw Character Graphic
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maemf_drawcharct_3kq6 draw_character
  def draw_character(character_name, *args)
    character_name[/\%[\(\[].+?[\)\]]/] ? ma_draw_emf_character(character_name, *args) :
      maemf_drawcharct_3kq6(character_name, *args)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Draw Extra Movement Frames Character Graphic
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_draw_emf_character(character_name, character_index, x, y)
    return unless character_name
    if !ma_char_is_emf_sprite?(character_name)
      # Draw regular if there is no frame specification in the name
      maemf_drawcharct_3kq6(character_name, *args)
    else
      bitmap = Cache.character(character_name)
      frames = maemf_get_frames(character_name)
      cw, ch = maemf_calc_frame_size(character_name, bitmap, frames)
      n = character_index
      src_rect = Rect.new((n%4*frames[0]+frames[1])*cw, (n/4*4)*ch, cw, ch)
      contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
    end
  end
end



Nouveau script Reflet :

Portion de code : Tout sélectionner

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
#------------------------------------------------------------------------------#
#  Galv's Character Effects
#------------------------------------------------------------------------------#
#  For: RPGMAKER VX ACE
#  Version 2.0
#------------------------------------------------------------------------------#
#  2013-12-07 - Version 2.0 - Added comments to more easily add event effects
#                           - Fixed shadow facing bug
#  2013-02-24 - Version 1.9 - added z level option for reflection and shadows
#  2013-02-23 - Version 1.8 - added multiple light sources for shadows
#  2013-02-22 - Version 1.7 - bug fixes
#  2013-02-22 - Version 1.6 - added icon effect
#  2013-02-22 - Version 1.5 - fixed mirror bug on large maps
#  2013-02-22 - Version 1.4 - added effects to vehicles
#  2013-02-21 - Version 1.3 - fixed jump reflection and other minor tweaks
#  2013-02-21 - Version 1.2 - bug with less than 4 actors (oops)
#  2013-02-21 - Version 1.1 - updated flicker effect
#  2013-02-21 - Version 1.0 - release
#------------------------------------------------------------------------------#
#  This script was made to provide some additional effects for characters such
#  as events, followers and the player on the map.
#  Currently it includes:
#
#  Shadows
#  Shadows that appear under player and events in a directions depending on
#  a light source that you choose.
#
#  Parallax Reflect
#  Reflections that appear on the parallax layer for events and actors to be
#  used for things like reflections in the water or glass floor etc. To get
#  effects like the demo, you need to edit the charset graphic to make the water
#  partially transparent.
#
#  Parallax Mirrors
#  Much like reflect but are instead actors and event are reflected in a mirror
#  on a wall designated by a region. Both mirror and reflect effects can be
#  changed so actors and events can use different charsets for their reflections
#
#------------------------------------------------------------------------------#
 
 
#------------------------------------------------------------------------------#
#  NEW - First event command as a COMMENT
#------------------------------------------------------------------------------#
#  You can add a comment as the first event command on an event page to set if
#  that event has an icon, shadow or reflection active. The tags to use are
#  below, all must be on the same line in the comment.
#
# <icon:id,x,y>      # set the event to display an icon (x,y position offset)
# <shadow>           # set the event to display a shadow
# <reflect>          # set the event to display reflections
#
#------------------------------------------------------------------------------#
#  EXAMPLE:
# <icon:1,0,0><shadow><reflect>    # to show reflect, shadow and icon 1 on event
#------------------------------------------------------------------------------#
 
 
#------------------------------------------------------------------------------#
#  SCRIPT CALLS:
#------------------------------------------------------------------------------#
#
#  char_effects(x,x,x,status)
#
#------------------------------------------------------------------------------#
#  # each effect can be true or false to enable/disable them during the game.
#  # you can change multiples of effects at once, x being the effect number
#  # 0 = reflect    1 = shadows    2 = mirror    3 = icons
#------------------------------------------------------------------------------#
#  EXAMPLES:
#  char_effects(0,true)              # turn reflections on
#  char_effects(0,2,true)            # turn reflections and mirror on
#  char_effects(1,3,false)           # turn shadows and icons off
#------------------------------------------------------------------------------#
#
#  reflect_sprite(actor_id,filename,pos)    # Change actor's reflect charset
#
#  reflect_esprite(event_id,filename,pos)   # Change event's reflect charset
#
#  reflect_vsprite(vehicle_id,filename,pos) # Change vehicle's reflect charset
#
#------------------------------------------------------------------------------#
#  EXAMPLES:
#  reflect_sprite(1,"Actor2",2)      # change actor 1's charset to use sprite
#                                    # in position 2 of "Actor2" charset.
#  reflect_esprite(3,"Actor4",5)     # event 3 will use sprite in position 5 of
#                                    # "Actor4" charset.
#  reflect_vsprite(1,"Vehicle",5)    # Ship will use sprite in position 5 of
#                                    # "Vehicle" charset.
#------------------------------------------------------------------------------#
 
#------------------------------------------------------------------------------#
#  SCRIPT CALLS to turn effects ON or OFF for chosen EVENTS
#------------------------------------------------------------------------------#
#
#  reflect(x,x,x,status)   # status can be true or false to turn on or off
#                          # use this to specify for mirror and reflect.
#  shadow(x,x,x,status)    # where x is the event ids you want to change
#                          # to change all events use :all
#  icon(x,x,x,icon_id)     # set which icon id to appear above character. Make
#                          # it 0 for no icon.
#
#------------------------------------------------------------------------------#
#  EXAMPLES:
#  reflect(14,17,3,1,true) # Turn events 14, 17, 3 and 1 reflections ON
#  shadow(1,false)         # Turn event 1 shadow OFF
#  reflect(:all,true)      # Turn all event reflections ON
#  icon(1,2,3,4,38)        # Events 1,2,3 and 4 will have icon 38 appear
#
#  NOTE: All events will default to NO shadows and NO reflections when entering
#        a map. This is a design decision to try to keep lag to a minimum. You
#        should use these effects sparingly and only activate them on events
#        that require them.
#------------------------------------------------------------------------------#
 
#------------------------------------------------------------------------------#
#  SCRIPT CALLS to turn effects ON or OFF for ACTORS and VEHICLES
#------------------------------------------------------------------------------#
#
#  actor_reflect(actor_id,status)  # reflections and shadows are ON by default 
#  actor_shadow(actor_id,status)   # for actors and vehicles. Turning them off 
#  actor_icon(actor_id,icon_id)    # or on will permanently change them.
#
#  v_reflect(x,x,x,status)    # use these v_ calls for changing vehicle effects
#  v_shadow(x,x,x,status)     # on and off for vehicles.
#  v_icon(x,x,x,icon_id)
#
#------------------------------------------------------------------------------#
 
#------------------------------------------------------------------------------#
#  SCRIPT CALLS for shadow options
#------------------------------------------------------------------------------#
#
#  shadow_source(x,y,id)       # set the x,y location for the light. id is the 
#                              # light source number you wish to change (for
#                              # more than one). These are reset on map change.
#  shadow_source(event_id,id)  # use an event's x,y location for the light.
#                              # This will need to be in parallel process if you
#                              # want it to be a moving light.
#
#  shadow_options(intensity,fade,flicker)    # descriptions below
#
#    # intensity = opacity when standing next to the light source (255 is black)
#    # fade = amount shadow becomes more transparent the further away you are.
#    # flicker = true or false. Shadows will flicker as if being cast by fire.
#
#------------------------------------------------------------------------------#
#  EXAMPLE:
#  shadow_options(80,10,false)    # This is the default setting.
#------------------------------------------------------------------------------#
 
#------------------------------------------------------------------------------#
#  SCRIPT CALLS for reflect options
#------------------------------------------------------------------------------#
#
#  reflect_options(wave_pwr) 
#
#    # wave_pwr = how strong the wave movement is. 0 is off
#
#------------------------------------------------------------------------------#
#  EXAMPLE:
#  reflect_options(1) # Turn wave power to 1
#------------------------------------------------------------------------------#
 
 
#------------------------------------------------------------------------------#
#  NOTETAG for ACTORS
#------------------------------------------------------------------------------#
#
#  <no_reflect>    # Actor will not have a reflection (for vampires of course!)
#
#  <reflect_sprite: FileName,pos>  # Actor will use this charset for reflections
#                                  # and use the character in position 'pos'
#
#------------------------------------------------------------------------------#
#  EXAMPLES:
#  <reflect_sprite: Actor2,0>    # The first character from Actor2 charset
#  <reflect_sprite: Actor3,7>    # The last character from Actor2 charset
#------------------------------------------------------------------------------#
 
 
($imported ||= {})["Galv_Character_Effects"] = true
module Galv_CEffects
 
#------------------------------------------------------------------------------#  
#  SETUP OPTIONS
#------------------------------------------------------------------------------#
 
  MIRROR_REGION = 4     # Region ID used to determine mirror walls. Paint the
                        # region on the wall you want to make reflective (and
                        # then use tiles/mapping that make the parallax visible)
 
  ICON_OFFSET = -60     # Y offset for icons that are displayed above characters
   
  REFLECT_Z = -10       # Z level of reflections
  SHADOW_Z = 0          # Z level of shadows
 
#------------------------------------------------------------------------------#  
#  END SETUP OPTIONS
#------------------------------------------------------------------------------#
end
 
 
 
 
class Game_Map
  def do_icons(refresh = true)
    @events.values.each { |e|
      next if !e.list
      if e.list[0].code == 108 && e.list[0].parameters[0] =~ /<icon:(.*),(.*),(.*)>/
        e.icon = $1.to_i
        e.icon_offset = [$2.to_i,$3.to_i]
      else
        e.icon = 0
        e.icon_offset = [0,0]
      end
    }
    SceneManager.scene.spriteset.refresh_effects if refresh
  end
  
  
  def do_shadows(refresh = true)
    @events.values.each { |e|
      next if !e.list
      if e.list[0].code == 108 && e.list[0].parameters[0] =~ /<shadow>/
        e.shadow = true
      else
        e.shadow = false
      end
    }
    SceneManager.scene.spriteset.refresh_effects if refresh
  end
  
  def do_reflects(refresh = true)
    @events.values.each { |e|
      next if !e.list
      if e.list[0].code == 108 && e.list[0].parameters[0] =~ /<reflect>/
        e.reflect = true
      else
        e.reflect = false
      end
    }
    SceneManager.scene.spriteset.refresh_effects if refresh
  end
  
  def do_all_chareffects
    do_icons(false)
    do_shadows(false)
    do_reflects(false)
  end
  
end # Game_Map
 
 
 
 
class Game_Interpreter
  
  def remove_icon
    icon(@event_id,0)
  end
 
#-----------------------------------#
#  REFLECTIONS
#-----------------------------------#
 
  # Add/Remove Reflections from selected events
  def reflect(*args,status)
    char_ids = [*args]
    if char_ids == [:all]
      $game_map.events.values.each { |e| e.reflect = status }
    else
      char_ids.each {|c| $game_map.events[c].reflect = status }
    end
    SceneManager.scene.spriteset.refresh_effects
  end
   
  # Change forever actor's reflect status
  def actor_reflect(actor_id,status)
    $game_actors[actor_id].reflect = status
    $game_player.refresh
  end
   
  # Change forever vehicle's reflect status
  def v_reflect(*args,status)
    char_ids = [*args]
    if char_ids == [:all]
      $game_map.vehicles.each { |v| v.reflect = status }
    else
      char_ids.each { |v| $game_map.vehicles[v].reflect = status }
    end
    SceneManager.scene.spriteset.refresh_effects
  end
 
  def reflect_options(*args)
    $game_map.reflect_options = [*args]
    SceneManager.scene.spriteset.refresh_effects
  end
   
  # Actor reflect sprite change
  def reflect_sprite(actor_id,filename,pos)
    $game_actors[actor_id].reflect_sprite = [filename,pos]
    $game_player.refresh
  end
   
  # Event reflect sprite change
  def reflect_esprite(event_id,filename,pos)
    $game_map.events[event_id].reflect_sprite = [filename,pos]
    $game_map.events[event_id].reflect = true
    SceneManager.scene.spriteset.refresh_characters
  end
   
  # Vehicle reflect sprite change
  def reflect_vsprite(v_id,filename,pos)
    $game_map.vehicles[v_id].reflect_sprite = [filename,pos]
    SceneManager.scene.spriteset.refresh_characters
  end
 
#-----------------------------------#
#  SHADOWS
#-----------------------------------#
 
  # Add/Remove Shadows from selected characters
  def shadow(*args,status)
    char_ids = [*args]
    if char_ids == [:all]
      $game_map.events.values.each { |e| e.shadow = status }
    else
      char_ids.each {|c| $game_map.events[c].shadow = status }
    end
    SceneManager.scene.spriteset.refresh_effects
  end
   
  # Change player and follower shadows
  def actor_shadows(status)
    $game_player.shadow = status
    $game_player.followers.each { |f| f.shadow = status }
    SceneManager.scene.spriteset.refresh_effects
  end
   
  # Change vehicle's shadow status
  def v_shadow(*args,status)
    char_ids = [*args]
    if char_ids == [:all]
      $game_map.vehicles.each { |v| v.shadow = status }
    else
      char_ids.each { |v| $game_map.vehicles[v].shadow = status }
    end
    SceneManager.scene.spriteset.refresh_effects
  end
   
  def shadow_options(*args)
    $game_map.shadow_options = [*args]
    SceneManager.scene.spriteset.refresh_effects
  end
 
  def shadow_source(*args,shad_id)
    shadsource = [*args]
 
    if shadsource.count == 1
      $game_map.light_source[shad_id] = [$game_map.events[shadsource[0]].real_x,
        $game_map.events[shadsource[0]].real_y]
    elsif shadsource.count > 1
      $game_map.light_source[shad_id] = shadsource
    else
      $game_map.light_source = []
    end
  end
 
 
#-----------------------------------#
#  ICONS
#-----------------------------------#
 
  # Add/Remove Icons from selected events
  def icon(*args,icon_id)
    char_ids = [*args]
    if char_ids == [:all]
      $game_map.events.values.each { |e|
      if e.icon <= 0
        e.icon = nil
      else
        e.icon = icon_id
      end
    }
    else
      char_ids.each {|c| $game_map.events[c].icon = icon_id }
    end
    SceneManager.scene.spriteset.refresh_effects
  end
   
  # Change forever actor's icon
  def actor_icon(actor_id,icon_id)
    $game_actors[actor_id].icon = icon_id
    $game_player.refresh
  end
   
  # Change forever vehicle's icon
  def v_icon(*args,icon_id)
    char_ids = [*args]
    if char_ids == [:all]
      $game_map.vehicles.each { |v| v.icon = icon_id }
    else
      char_ids.each { |v| $game_map.vehicles[v].icon = icon_id }
    end
    SceneManager.scene.spriteset.refresh_effects
  end
 
#-----------------------------------#
#  GENERAL
#-----------------------------------#
 
  # Turn on/off effects
    # 0 = reflect
    # 1 = shadow
    # 2 = mirror
    # 3 = icon
     
  def char_effects(*args,status)
    [*args].each { |e| $game_map.char_effects[e] = status }
    SceneManager.scene.spriteset.refresh_effects
  end
 
   
end # Game_Interpreter
 
 
#-------------------------------------------------------------------------------
#  Spriteset_Map
#-------------------------------------------------------------------------------
 
class Spriteset_Map
  alias galv_reflect_sm_initialize initialize
  def initialize
    create_effects
    galv_reflect_sm_initialize
    refresh_characters
  end
   
  alias galv_reflect_sm_refresh_characters refresh_characters
  def refresh_characters
    galv_reflect_sm_refresh_characters
    create_effects
  end
   
  def refresh_effects
    dispose_effects
    create_effects
  end
   
  def create_effects
    @shadow_sprites = []
    @reflect_sprites = []
    @mirror_sprites = []
    @icon_sprites = []
     
    # Do reflections
    if $game_map.char_effects[0]
      $game_map.events.values.each { |e|
        @reflect_sprites.push(Sprite_Reflect.new(@viewport1, e)) if e.reflect
      }
      $game_player.followers.each { |f|
        @reflect_sprites.push(Sprite_Reflect.new(@viewport1, f)) if f.reflect
      }
      if $game_player.reflect
        @reflect_sprites.push(Sprite_Reflect.new(@viewport1, $game_player))
      end
      $game_map.vehicles.each { |v|
        @reflect_sprites.push(Sprite_Reflect.new(@viewport1, v)) if v.reflect
      }
    end
     
    # Do mirrors
    if $game_map.char_effects[2]
      $game_map.events.values.each { |e|
        @mirror_sprites.push(Sprite_Mirror.new(@viewport1, e)) if e.reflect
      }
      $game_player.followers.each { |f|
        @mirror_sprites.push(Sprite_Mirror.new(@viewport1, f)) if f.reflect
      }
      if $game_player.reflect
        @mirror_sprites.push(Sprite_Mirror.new(@viewport1, $game_player))
      end
      $game_map.vehicles.each { |v|
        @mirror_sprites.push(Sprite_Mirror.new(@viewport1, v)) if v.reflect
      }
    end
     
    # Do Shadows
    if $game_map.char_effects[1]
      return if $game_map.light_source.empty?
      $game_map.light_source.count.times { |s|
        $game_map.events.values.each { |e|
          @shadow_sprites.push(Sprite_Shadow.new(@viewport1, e, s)) if e.shadow
        }
        $game_player.followers.each { |f|
          @shadow_sprites.push(Sprite_Shadow.new(@viewport1, f, s)) if f.shadow
        }
        if $game_player.shadow
          @shadow_sprites.push(Sprite_Shadow.new(@viewport1, $game_player, s))
        end
        $game_map.vehicles.each { |v|
          @shadow_sprites.push(Sprite_Shadow.new(@viewport1, v, s)) if v.shadow
        }
      }
    end
     
    # Do icons
    if $game_map.char_effects[3]
      $game_map.events.values.each { |e|
        @icon_sprites.push(Sprite_Icon.new(@viewport1, e)) if e.icon
      }
      $game_player.followers.each { |f|
        @icon_sprites.push(Sprite_Icon.new(@viewport1, f)) if f.icon
      }
      if $game_player.icon
        @icon_sprites.push(Sprite_Icon.new(@viewport1, $game_player))
      end
      $game_map.vehicles.each { |v|
        @icon_sprites.push(Sprite_Icon.new(@viewport1, v)) if v.icon
      }
    end
  end
   
  alias galv_reflect_sm_update update
  def update
    galv_reflect_sm_update
    @reflect_sprites.each {|s| s.update} if $game_map.char_effects[0]
    @mirror_sprites.each {|s| s.update} if $game_map.char_effects[2]
    @shadow_sprites.each {|s| s.update} if $game_map.char_effects[1]
    @icon_sprites.each {|s| s.update} if $game_map.char_effects[3]
  end
 
  alias galv_reflect_sm_dispose_characters dispose_characters
  def dispose_characters
    galv_reflect_sm_dispose_characters
    dispose_effects
  end
   
  def dispose_effects
    @reflect_sprites.each {|s| s.dispose}
    @shadow_sprites.each {|s| s.dispose}
    @mirror_sprites.each {|s| s.dispose}
    @icon_sprites.each {|s| s.dispose}
  end
end # Spriteset_Map
 
 
#-------------------------------------------------------------------------------
#  Sprite_Reflect 
#-------------------------------------------------------------------------------
 
class Sprite_Reflect < Sprite_Character
  def initialize(viewport, character = nil)
    super(viewport, character)
  end
 
  def update
    super
  end
   
  def update_balloon; end
  def setup_new_effect; end
   
  def set_character_bitmap
    if @character.reflect_sprite
      self.bitmap = Cache.character(@character.reflect_sprite[0])
    else
      self.bitmap = Cache.character(@character_name)
    end
    self.mirror = true
    self.angle = 180
    self.opacity = 220
    self.z = Galv_CEffects::REFLECT_Z
    self.wave_amp = $game_map.reflect_options[0]
    
    sign = @character_name[/\%[\(\[](.+?)[\)\]]/]
  if sign && sign.include?('%')
    sign = @character_name[/^[\!\$]./]
    if sign && sign.include?('$')
      @cw = $cw
      @ch = bitmap.height / 4
    else
      @cw = $cw
      @ch = bitmap.height / 8
    end
  else
    sign = @character_name[/^[\!\$]./]
    if sign && sign.include?('$')
      @cw = bitmap.width / 3
      @ch = bitmap.height / 4
    else
      @cw = bitmap.width / 12
      @ch = bitmap.height / 8
    end 
  end
    self.ox = @cw / 2
    self.oy = @ch
  end
 
  def update_position
    self.x = @character.screen_x
    jump = @character.jumping? ? @character.jump_height * 2 : 0
    alt = @character.altitude ? @character.altitude * 2 : 0
    self.y = @character.screen_y - 3 + jump + alt
  end
 
  def update_other
    self.blend_type = @character.blend_type
    self.visible = !@character.transparent
  end
   
  def update_src_rect
    if @character.reflect_sprite
      index = @character.reflect_sprite[1]
    else
      index = @character.character_index
    end
    sign = @character_name[/\%[\(\[](.+?)[\)\]]/]
  if sign && sign.include?('%')
    pattern = @character.pattern < @cw ? @character.pattern : 1
  else
    pattern = @character.pattern < 3 ? @character.pattern : 1
  end
    sx = (index % 4 * $emf_char_frames[0] + pattern) * @cw
    #sx = (index % 4 * @cw + pattern) * @cw
    sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
    self.src_rect.set(sx, sy, @cw, @ch)
  end
end # Sprite_Reflect < Sprite_Character
 
 
#-------------------------------------------------------------------------------
#  Sprite_Mirror
#-------------------------------------------------------------------------------
 
class Sprite_Mirror < Sprite_Character
  def initialize(viewport, character = nil)
    @distance = 0
    super(viewport, character)
  end
 
  def update
    super
  end
   
  def update_balloon; end
  def setup_new_effect; end
   
  def set_character_bitmap
    if @character.reflect_sprite
      self.bitmap = Cache.character(@character.reflect_sprite[0])
    else
      self.bitmap = Cache.character(@character_name)
    end
    self.mirror = true
    self.opacity = 255
    self.z = Galv_CEffects::REFLECT_Z
     
    sign = @character_name[/\%[\(\[](.+?)[\)\]]/]
  if sign && sign.include?('%')
    sign = @character_name[/^[\!\$]./]
    if sign && sign.include?('$')
      @cw = $cw
      @ch = bitmap.height / 4
    else
      @cw = $cw
      @ch = bitmap.height / 8
    end
  else
    sign = @character_name[/^[\!\$]./]
    if sign && sign.include?('$')
      @cw = $cw#bitmap.width / 3
      @ch = bitmap.height / 4
    else
      @cw = $cw#bitmap.width / 12
      @ch = bitmap.height / 8
    end 
  end
    self.ox = @cw / 2
    self.oy = @ch
 
  end
 
  def update_src_rect
    if @character.reflect_sprite
      index = @character.reflect_sprite[1]
    else
      index = @character.character_index
    end
    sign = @character_name[/\%[\(\[](.+?)[\)\]]/]
  if sign && sign.include?('%')
    pattern = @character.pattern < @cw ? @character.pattern : 1
  else
    pattern = @character.pattern < 3 ? @character.pattern : 1
  end
    sx = (index % 4 * $emf_char_frames[0] + pattern) * @cw
    #sx = (index % 4 * 3 + pattern) * @cw
    sy = (index / 4 * 4 + (10 - @character.direction - 2) / 2) * @ch
    self.src_rect.set(sx, sy, @cw, @ch)
  end
   
  def get_mirror_y
    20.times {|i|
      if $game_map.region_id(@character.x, @character.y - i) == Galv_CEffects::MIRROR_REGION
        @distance = (i - 1) * 0.05
        @display = @character.y - i - $game_map.display_y + $game_map.height
        self.opacity = 255
        return (@character.y - i + 1 - $game_map.display_y) * 32 - i * 4
      end
    }
    self.opacity = 0
    return @ch
  end
   
  def update_position
    self.x = @character.screen_x
    self.y = get_mirror_y - 6
    self.zoom_x = 1 - @distance
    self.zoom_y = 1 - @distance
  end
 
  def update_other
    self.blend_type = @character.blend_type
    self.visible = !@character.transparent
  end
end # Sprite_Mirror < Sprite_Character
 
 
#-------------------------------------------------------------------------------
#  Sprite_Shadow
#-------------------------------------------------------------------------------
 
class Sprite_Shadow < Sprite_Character
  def initialize(viewport, character = nil, source)
    @flicker = 0
    @famount = 0
    @aamount = 0
    @source = source
    super(viewport, character)
  end
 
  def update
    super
    update_bitmap
    update_src_rect
    update_position
    update_other
    update_facing
  end
  
  def set_character_bitmap
    self.bitmap = Cache.character(@character_name)
    
    self.color = Color.new(0, 0, 0, 255)
    self.z = Galv_CEffects::SHADOW_Z
    self.wave_amp = 1 if $game_map.shadow_options[2]
    self.wave_speed = 1000
     
    sign = @character_name[/\%[\(\[](.+?)[\)\]]/]
  if sign && sign.include?('%')
    sign = @character_name[/^[\!\$]./]
    if sign && sign.include?('$')
      @cw = $cw
      @ch = bitmap.height / 4
    else
      @cw = $cw
      @ch = bitmap.height / 8
    end
  else
    sign = @character_name[/^[\!\$]./]
    if sign && sign.include?('$')
      @cw = bitmap.width / 3
      @ch = bitmap.height / 4
    else
      @cw = bitmap.width / 12
      @ch = bitmap.height / 8
    end 
  end
    self.ox = @cw / 2
    self.oy = @ch
  end
 
  def update_position
    self.x = @character.screen_x
    self.y = @character.screen_y - 10
    get_angle
  end
   
  def get_angle
    x = $game_map.light_source[@source][0] - @character.real_x
    y = $game_map.light_source[@source][1] - @character.real_y
    self.opacity = $game_map.shadow_options[0] - 
      Math::sqrt(x * x + y * y) * $game_map.shadow_options[1]
     
    if x == 0 && y == 0 || self.opacity <= 0
      self.opacity = 0
    else 
      self.angle = Math::atan2(x, y) * 180 / Math::PI + @aamount
    end
  end
  
  def update_facing
    if @character.y < $game_map.light_source[@source][1]
      self.mirror = false
    else
      self.mirror = true
    end
  end
   
  def update_other
    self.blend_type = @character.blend_type
    self.visible = !@character.transparent
  end
end # Sprite_Shadow < Sprite_Character
 
 
#-------------------------------------------------------------------------------
#  Sprite_Icon
#-------------------------------------------------------------------------------
 
class Sprite_Icon < Sprite_Character
  def initialize(viewport, character = nil)
    @icon_sprite ||= Sprite.new
    @icon_sprite.bitmap ||= Cache.system("Iconset")
    @icon = nil
    super(viewport, character)
  end
 
  def dispose
    super
    if @icon_sprite
      @icon_sprite.dispose
      @icon_sprite = nil
    end
  end
   
  def update
    super
    update_icon
  end
   
  def update_icon
    return if !@character.icon
    draw_icon(@character.icon)
  end
   
  def draw_icon(icon_index)
    return if !@icon.nil?
    rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
    @icon_sprite.src_rect  = rect
    @icon = icon_index
  end
   
  def update_position
    @icon_sprite.x = @character.screen_x - 12
    @icon_sprite.y = @character.screen_y + Galv_CEffects::ICON_OFFSET
  end
 
  def update_other
    self.blend_type = @character.blend_type
    @icon_sprite.visible = !@character.transparent
  end
end # Sprite_Icon < Sprite_Character
 
 
#-------------------------------------------------------------------------------
#  Other Stuff
#-------------------------------------------------------------------------------
 
 
class Game_Character < Game_CharacterBase
  attr_reader    :altitude
  attr_accessor  :reflect
  attr_accessor  :reflect_sprite
  attr_accessor  :shadow
  attr_accessor  :icon
  attr_accessor  :icon_offset
end
 
 
class Game_Event < Game_Character
  alias galv_reflect_ge_initialize initialize
  def initialize(map_id, event)
    @reflect = false
    @shadow = false
    @icon_offset = [0,0]
    galv_reflect_ge_initialize(map_id, event)
  end
end # Game_Event < Game_Character
 
 
class Game_Vehicle < Game_Character
  attr_reader :map_id
   
  alias galv_reflect_gv_initialize initialize
  def initialize(type)
    @reflect = true
    @shadow = true
    @icon_offset = [0,0]
    galv_reflect_gv_initialize(type)
  end
end # Game_Vehicle < Game_Character
 
 
class Game_Follower < Game_Character
  alias galv_reflect_gf_initialize initialize
  def initialize(member_index, preceding_character)
    galv_reflect_gf_initialize(member_index, preceding_character)
    @reflect = true
    @shadow = true
  end
   
  alias galv_reflect_gf_refresh refresh
  def refresh
    galv_reflect_gf_refresh
    return if actor.nil?
    @reflect = actor.reflect
    @reflect_sprite = actor.reflect_sprite
    @icon = actor.icon
    if SceneManager.scene_is?(Scene_Map)
      SceneManager.scene.spriteset.refresh_effects
    end
  end
end # Game_Follower < Game_Character
 
 
class Game_Player < Game_Character
  alias galv_reflect_gp_initialize initialize
  def initialize
    galv_reflect_gp_initialize
    @reflect = true
    @shadow = true
  end
   
  alias galv_reflect_gp_refresh refresh
  def refresh
    galv_reflect_gp_refresh
    @reflect = actor.reflect
    @reflect_sprite = actor.reflect_sprite
    @icon = actor.icon
    if SceneManager.scene_is?(Scene_Map)
      SceneManager.scene.spriteset.refresh_effects
    end
  end
end # Game_Player < Game_Character
 
 
class Scene_Map < Scene_Base
  attr_accessor :spriteset
end # Scene_Map
 
 
class Game_Map
  attr_accessor :char_effects
  attr_accessor :light_source
  attr_accessor :shadow_options
  attr_accessor :reflect_options
   
  alias galv_reflect_game_map_initialize initialize
  def initialize
    @light_source = []
    @shadow_options = [80,10,false]
    @reflect_options = [0]
    @char_effects = [false,false,false,false]
    #[reflect,shadow,mirror,icon]
    galv_reflect_game_map_initialize
  end
  
   
  alias galv_reflect_game_map_setup setup
  def setup(map_id)
    galv_reflect_game_map_setup(map_id)
    reset_char_effects
    do_all_chareffects
    if SceneManager.scene_is?(Scene_Map)
      SceneManager.scene.spriteset.refresh_effects
    end
  end
   
  def reset_char_effects
    @light_source = []
    @events.values.each { |e|
      e.reflect = false
      e.icon = nil }
  end
end # Game_Map
 
 
class Game_Actor < Game_Battler
  attr_accessor :reflect
  attr_accessor :reflect_sprite
  attr_accessor :icon
   
  alias galv_reflect_game_actor_initialize initialize
  def initialize(actor_id)
    galv_reflect_game_actor_initialize(actor_id)
    @reflect = $data_actors[actor_id].reflect
    @reflect_sprite = $data_actors[actor_id].reflect_sprite
    @icon_offset = [0,0]
  end
end # Game_Actor < Game_Battler
 
 
class RPG::Actor
  def reflect_sprite
    if @reflect_sprite.nil?
      if @note =~ /<reflect_sprite:[ ](.*),(.*)>/i
        @reflect_sprite = [$1.to_s,$2.to_i]
      else
        @reflect_sprite = nil
      end
    end
    @reflect_sprite
  end
  def reflect
    if @reflect.nil?
      if @note =~ /<no_reflect>/i
        @reflect = false
      else
        @reflect = true
      end
    end
    @reflect
  end
end # RPG::Actor




Cactus - posté le 22/04/2015 à 20:59:47 (681 messages postés)

❤ 0

Pikactus

Ah! cette fois c'est parfait

Citation:

J'ai encore un bug d'affichage pour des évent avec un $ (1 seul par planche)


Pas grave t'as déjà fait beaucoup et puis au pire je réadapte les charas en planche.

Encore merci ! :)

Index du forum > Entraide > [VXAce] compatibilité entre 2 scripts. [Résolu]

repondre up

Suite à de nombreux abus, le post en invités a été désactivé. Veuillez vous inscrire si vous souhaitez participer à la conversation.

Haut de page

Merci de ne pas reproduire le contenu de ce site sans autorisation.
Contacter l'équipe - Mentions légales

Plan du site

Communauté: Accueil | Forum | Chat | Commentaires | News | Flash-news | Screen de la semaine | Sorties | Tests | Gaming-Live | Interviews | Galerie | OST | Blogs | Recherche
Apprendre: Visite guidée | RPG Maker 95 | RPG Maker 2003 | RPG Maker XP | RPG Maker VX | RPG Maker MV | Tutoriels | Guides | Making-of
Télécharger: Programmes | Scripts/Plugins | Ressources graphiques / sonores | Packs de ressources | Midis | Eléments séparés | Sprites
Jeux: Au hasard | Notre sélection | Sélection des membres | Tous les jeux | Jeux complets | Le cimetière | RPG Maker 95 | RPG Maker 2000 | RPG Maker 2003 | RPG Maker XP | RPG Maker VX | RPG Maker VX Ace | RPG Maker MV | Autres | Proposer
Ressources RPG Maker 2000/2003: Chipsets | Charsets | Panoramas | Backdrops | Facesets | Battle anims | Battle charsets | Monstres | Systems | Templates
Ressources RPG Maker XP: Tilesets | Autotiles | Characters | Battlers | Window skins | Icônes | Transitions | Fogs | Templates
Ressources RPG Maker VX: Tilesets | Charsets | Facesets | Systèmes
Ressources RPG Maker MV: Tilesets | Characters | Faces | Systèmes | Title | Battlebacks | Animations | SV/Ennemis
Archives: Palmarès | L'Annuaire | Livre d'or | Le Wiki | Divers