#=============================================================================== # # # Fade Opacity.v2 # # #=============================================================================== # #By Vincentmhd #http://vincentmhdmaker.canalblog.com/ # # 1/9/2009 - .v0 creation #22/9/2009 - .v1 optimisation anti-lag # # # # #=====================================NOTE====================================== # # # #------------------------------------------------------------------------------- # # #Ce script permet de changer l'opacité progressivement. Par défault, il change #les opacités en 30 frames. C'est suffissant observer pour la progression... #La méthode crée peut-être appellée par script et le temps de fade changé, il #est en second argument de la méthode. # # # #Le plus intéressant du script est son gestionnaire d'opacité: #Ce script permet de gérer les opacités des maps de manière induite #pour qu'un event devienne translucide selon la position du héros. # #Il y a 2 commentaires à inserer dans l'event pour cela: #Le premier: # #OPACITY CODE 125 Xp>P[0] # #Ce commentaire donne l'opacité escontée et le code de la condition de changement #d'opacité. # + 125 correspond à l'opacité escontée, elle est toujours en 3 chiffres. # + Le code correspond à la chaine après l'espace suivant 125. #Pour le moment, l'interpreter ne connait pas beaucoup de formule. Les besoins #de chacun sont differents et plus l'interpreteur sera long moins le script se #sera rapide à l'execution, donc, je préfère vous laisser finir de compléter #l'interpreteur. Ca ne demande pas beaucoup de connaissance en script. #La méthode se trouve à partir de la ligne 145. # # #Le second commentaire: # #OPACITY PARAM 34 07 # #Ce commentaire contient les paramètres des conditions. #X et Y sont des paramètres exterieurs. Ils sont contenus dans array. #sa taille varie selon le nombre d'arguments présents dans le commentaire: # # #OPACITY PARAM 20 07 5 34 12 49 # #donnera [20, 7, 5, 34, 12, 49] #------------------------------------------------------------------------------- module OPACITY Default_time = 30 #temps du fondu par défault en frame UpDate_rayon = 20 #côté du rectangle autour du player "Updaté" end
#==============================================================================# # # # Gestionnaire d'opacités # # # #==============================================================================# class Gst_Opacity attr_accessor :tab def initialize @tab = [] end #------------------------------------------------------------------------------# #Appelée dans la setup map, vide puis complète le tableau du gestionnaire. # #------------------------------------------------------------------------------# def setup @tab = [] for event in $game_map.events.values next if event.list == nil code = "" for i in 0...event.list.size if event.list[i].code == 108 a = "" a = event.list[i].parameters.to_s #Reconnaissance de if a[0,12] == "OPACITY CODE" target = a[13, 3].to_i code = a[17, a.size - 17].to_s end param = [] if a[0,13] == "OPACITY PARAM" n = 14 j = 0 while (a[n]!= nil) param[j] = a[n,2].to_i j+=1 n+=3 end if (code != "") @tab += [[event.id,code,param,nil,target]] end end end end end update(true,0) end
#------------------------------------------------------------------------------# #Met à jour les opacités des events sur la map. # #------------------------------------------------------------------------------# def update( init = false ,time = OPACITY::Default_time) for i in 0...@tab.size if ((init)||(($game_map.events[@tab[i][0]].x - $game_player.x).abs <= OPACITY::UpDate_rayon)||(($game_map.events[@tab[i][0]].y - $game_player.y).abs <= OPACITY::UpDate_rayon)) interpreter(i,time) end end end #------------------------------------------------------------------------------# #Applique les changements # #------------------------------------------------------------------------------# def Apply(cond,i,time = OPACITY::Default_time) if (@tab[i][3] == nil) #print( @tab[i][0].to_s + ": " + cond.to_s) print(($game_player.x).to_s + " " + ($game_player.y).to_s) @tab[i][3] = cond #pb car à ce moment la position du héros pas encore établie end if (cond) if (@tab[i][3] == true) $game_map.events[@tab[i][0]].op_Change(@tab[i][4], time) @tab[i][3] = false end else if (@tab[i][3] == false) $game_map.events[@tab[i][0]].op_Change (255, time) @tab[i][3] = true end end end #------------------------------------------------------------------------------# #Vérifie si les conditions sont atteintes et applique les changements # #------------------------------------------------------------------------------# def interpreter( i, time = OPACITY::Default_time) case @tab[i][1].to_s when "Xp>P[0]" Apply( ($game_player.x > @tab[i][2][0]) ,i,time) when "Xp<=P[0]" Apply( ($game_player.x <= @tab[i][2][0]) ,i,time) when "Yp<=P[0]" Apply( ($game_player.y <= @tab[i][2][0]) ,i,time) when "Yp>P[0]" Apply( ($game_player.y > @tab[i][2][0]) ,i,time) when "C" #Dans le rectangle Apply( ((($game_player.x >= @tab[i][2][0])&&($game_player.x <= @tab[i][2][1])&&($game_player.y >= @tab[i][2][2])&&($game_player.y <= @tab[i][2][3]))) ,i,time) when "CC" #Dans le rectangle A ou B Apply( (((($game_player.x >= @tab[i][2][0])&&($game_player.x <= @tab[i][2][1])&&($game_player.y >= @tab[i][2][2])&&($game_player.y <= @tab[i][2][3]))||(($game_player.x >= @tab[i][2][4])&&($game_player.x <= @tab[i][2][5])&&($game_player.y >= @tab[i][2][6])&&($game_player.y <= @tab[i][2][7])))) ,i,time) when "C-C" #Dans le rectangle A mais pas dans B Apply( (((($game_player.x >= @tab[i][2][0])&&($game_player.x <= @tab[i][2][1])&&($game_player.y >= @tab[i][2][2])&&($game_player.y <= @tab[i][2][3]))&&!(($game_player.x >= @tab[i][2][4])&&($game_player.x <= @tab[i][2][5])&&($game_player.y >= @tab[i][2][6])&&($game_player.y <= @tab[i][2][7])))) ,i,time) else #rien... end end end
#==============================================================================# # # # Modification de Character # # # #==============================================================================# class Game_Character attr_accessor :target_Op, :Op_count #Modification de l'initialize alias op_initialize initialize def initialize op_initialize @target_Op = 255 @Op_count = 0 end #Création de méthode de changement d'Opacité def op_Change (op , duration = OPACITY::Default_time) @Op_count = duration @target_Op = op if @Op_count == 0 @opacity = op end end #Il n'y a qu'une ligne à modifier mais impossible en alias... #------------------------------------------------------------------------------ # * Move Type : Custom #------------------------------------------------------------------------------ def move_type_custom if stopping? command = @move_route.list[@move_route_index] # Get movement command @move_failed = false if command.code == 0 # End of list if @move_route.repeat # [Repeat Action] @move_route_index = 0 elsif @move_route_forcing # Forced move route @move_route_forcing = false # Cancel forcing @move_route = @original_move_route # Restore original @move_route_index = @original_move_route_index @original_move_route = nil end else case command.code when 1 # Move Down move_down when 2 # Move Left move_left when 3 # Move Right move_right when 4 # Move Up move_up when 5 # Move Lower Left move_lower_left when 6 # Move Lower Right move_lower_right when 7 # Move Upper Left move_upper_left when 8 # Move Upper Right move_upper_right when 9 # Move at Random move_random when 10 # Move toward Player move_toward_player when 11 # Move away from Player move_away_from_player when 12 # 1 Step Forward move_forward when 13 # 1 Step Backwards move_backward when 14 # Jump jump(command.parameters[0], command.parameters[1]) when 15 # Wait @wait_count = command.parameters[0] - 1 when 16 # Turn Down turn_down when 17 # Turn Left turn_left when 18 # Turn Right turn_right when 19 # Turn Up turn_up when 20 # Turn 90° Right turn_right_90 when 21 # Turn 90° Left turn_left_90 when 22 # Turn 180° turn_180 when 23 # Turn 90° Right or Left turn_right_or_left_90 when 24 # Turn at Random turn_random when 25 # Turn toward Player turn_toward_player when 26 # Turn away from Player turn_away_from_player when 27 # Switch ON $game_switches[command.parameters[0]] = true $game_map.need_refresh = true when 28 # Switch OFF $game_switches[command.parameters[0]] = false $game_map.need_refresh = true when 29 # Change Speed @move_speed = command.parameters[0] when 30 # Change Frequency @move_frequency = command.parameters[0] when 31 # Walking Animation ON @walk_anime = true when 32 # Walking Animation OFF @walk_anime = false when 33 # Stepping Animation ON @step_anime = true when 34 # Stepping Animation OFF @step_anime = false when 35 # Direction Fix ON @direction_fix = true when 36 # Direction Fix OFF @direction_fix = false when 37 # Through ON @through = true when 38 # Through OFF @through = false when 39 # Transparent ON @transparent = true when 40 # Transparent OFF @transparent = false when 41 # Change Graphic set_graphic(command.parameters[0], command.parameters[1]) when 42 # Change Opacity op_Change(command.parameters[0]) when 43 # Change Blending @blend_type = command.parameters[0] when 44 # Play SE command.parameters[0].play when 45 # script eval(command.parameters[0]) end if not @move_route.skippable and @move_failed return # [Skip if Cannot Move] OFF & movement failure end @move_route_index += 1 end end end #UpDate de l'opacité def op_update if @Op_count>0 d = @Op_count @opacity = (@opacity * (d - 1) + @target_Op) / d @Op_count -=1 end end #Modification de l'upDate globale alias opacity_update update def update opacity_update op_update end end #==============================================================================# # # # Modification du Player # # # #==============================================================================# class Game_Player attr_accessor :x, :y #utilisée seulement en téléportation alias mhd_op_moveto moveto def moveto(x, y) mhd_op_moveto(x,y) $game_opacity.update() end alias mhd_trans reserve_transfer def reserve_transfer(map_id, x, y, direction) mhd_trans(map_id, x, y, direction) $game_player.x =x $game_player.y =y end
#surcharger les commandes de mouvements du player... toutes! alias op_move_down move_down def move_down(turn_ok = true) op_move_down(turn_ok) $game_opacity.update() end alias op_move_left move_left def move_left(turn_ok = true) op_move_left(turn_ok) $game_opacity.update() end alias op_move_right move_right def move_right(turn_ok = true) op_move_right(turn_ok) $game_opacity.update() end alias op_move_up move_up def move_up(turn_ok = true) op_move_up(turn_ok) $game_opacity.update() end alias op_move_lower_left move_lower_left def move_lower_left op_move_lower_left $game_opacity.update() end alias op_move_lower_right move_lower_right def move_lower_right op_move_lower_right $game_opacity.update() end alias op_move_upper_left move_upper_left def move_upper_left op_move_upper_left $game_opacity.update() end alias op_move_upper_right move_upper_right def move_upper_right op_move_upper_right $game_opacity.update() end end
#==============================================================================# # # # Création du gestionnaire # # # #==============================================================================# class Scene_Title alias opacity_create_game_objects create_game_objects def create_game_objects opacity_create_game_objects $game_player.x =$data_system.start_x $game_player.y =$data_system.start_y $game_opacity = Gst_Opacity.new end end
#==============================================================================# # # # Mise à jour du Gestionnaire à la Map # # # #==============================================================================# class Game_Map alias op_setup_events setup_events def setup_events op_setup_events $game_opacity.setup end end
|