#============================================================================== # # Anti-lag Mhd.v1 # #=============================================================================== # #Vincentmhd #26/10/09 #http://vincentmhdmaker.canalblog.com/ # #v0 -> v1Mise en thread de certaines commandes # #=====================================NOTE====================================== # # #------------------------------------------------------------------------------- # #===============================================================================
=begin
Ce script passerelle permettrerait de mettre toutes les setup d'event de mes script dans une seule boucle, donc de gagner du FPS.
Cet anti-lag est assez different des autres, il n'a pas de rayon d'action. Il se base sur l'utilité de l'event que vous définissez en commentaire. Les updates seront redéfinies en fonction.
Le script reconnait les flags mis en commentaire et agit en fonction.
Flag:: - DECO Présent sur la map seulement pour décorer, pas de mouvements, pas d'animations, pas de commandes, pas de pages multiples. C'est la base. Juste une sprite. - OPACITY Cet event réagira au changement d'opacité. S'il le flag OPACITY CODE ou OPACITY PARAM est déjà présent pas la peine de le ré-écrire. - ANIM Cet event pourra être animé. Son animation dépend du rayon anti-lag. - MOVABLE Cet event pourra être déplacé automatiquement ou manuellement. - PAGE Cet event a plusieurs pages. Mais ne contient pas de commandes d'events. - COMMANDE Cet event a des commandes à réaliser. Les flags sont cumullables et pas de flag fera que votre event fonctionnera normalement.
=end
#==============================================================================# # # #Cet alias me permet de mettre tous les alias de la setup_events dans une seule# #boucle pour gagner en rapidité. # # # #==============================================================================# class Game_Event def movable_update if jumping? # Jumping update_jump elsif moving? # Moving update_move else # Stopped update_stop end if @wait_count > 0 # Waiting @wait_count -= 1 elsif @move_route_forcing # Forced move route move_type_custom elsif not @locked # Not locked update_self_movement end end def anim_update #J'ai du diviser par 2!? je ne comprend pas vraiment pourquoi. if moving? if @walk_anime @anime_count += 0.75 elsif @step_anime @anime_count += 0.5 end else if @step_anime @anime_count += 0.5 elsif @pattern != @original_pattern @anime_count += 0.75 end end update_animation end
def command_update check_event_trigger_auto # Check autorun event if @interpreter != nil # Now parallel processing? unless @interpreter.running? # Not running @interpreter.setup(@list, @event.id) # Set up end @interpreter.update # Update interpreter end end end
class Game_Map ANIM_R = 20
def opacity_update_all for i in 0...$game_map_opacities.size @events[$game_map_opacities[i]].op_update end end def anim_update_all for i in 0...$game_map_animations.size if (((@events[$game_map_animations[i]].x - $game_player.x).abs <= ANIM_R)||((@events[$game_map_animations[i]].y - $game_player.y).abs <= ANIM_R)) @events[$game_map_animations[i]].anim_update end end end def movable_update_all for i in 0...$game_map_movables.size @events[$game_map_movables[i]].movable_update end end def setup_events #script d'opacité progressive $game_opacity.tab = [] # Tableau des opacités #script d'Anti-lag $game_map_events = [] # Tableau des events normaux $game_map_decorations = [] # Tableau des décorations $game_map_opacities = [] # Tableau des opacités variables $game_map_animations = [] # Tableau des events animables $game_map_movables = [] # Tableau des events déplaçables $game_map_multipages = [] # Tableau des events à pls pages $game_map_commandes = [] # Tableau des events à commandes
@events = {} # Map event for i in @map.events.keys @events[i] = Game_Event.new(@map_id, @map.events[i]) if @events[i] != nil type = 0 anti = 0 recurrance = true if @events[i].list != nil for j in 0...@events[i].list.size if @events[i].list[j].code == 108 a = "" a = @events[i].list[j].parameters.to_s #==================================================================# # PASSABILITY # #==================================================================# if a[0,11] == "PASSABILITY" ligne = "" ligne = @events[i].list[j].parameters.to_s for j in 0...4 info = "" info = ligne[(12 + j), 1] if info == "T" @events[i].p[j]=true else @events[i].p[j]=false end end end #==================================================================# # OPACITY # #==================================================================# 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 != "") $game_opacity.tab += [[@events[i].id,code,param,nil,target]] end end #==================================================================# # ANTI-LAG # #==================================================================# if a[0,4] == "DECO" type = 1 recurrance = false end if a[0,7] == "OPACITY" type = 2 recurrance = false end if a[0,5] == "ANIM" type = 3 recurrance = false end if a[0,7] == "MOVABLE" type = 4 recurrance = false end if a[0,4] == "PAGE" type = 5 recurrance = false end if a[0,4] == "COMMANDE" type = 6 recurrance = false end if type != anti if recurrance == false case type when 1 $game_map_decorations += [@events[i].id] when 2 $game_map_opacities += [@events[i].id] when 3 $game_map_animations += [@events[i].id] when 4 $game_map_movables += [@events[i].id] when 5 $game_map_multipages += [@events[i].id] when 6 $game_map_commandes += [@events[i].id] end recurrance = true anti = type end end end end end if type==0 $game_map_events += [@events[i].id] end end end @common_events = {} # Common event for i in 1...$data_common_events.size @common_events[i] = Game_CommonEvent.new(i) end $game_opacity.update(true,0) end #------------------------------------------------------------------------------- # * Update Events #------------------------------------------------------------------------------- def update_events for i in 0...$game_map_events.size @events[$game_map_events[i]].update #print(" event n°" + $game_map_events[i].to_s) end $opacity_runner = Thread.new {$game_map.opacity_update_all} $amin_runner = Thread.new {$game_map.anim_update_all} $movable_runner = Thread.new {$game_map.movable_update_all} for i in 0...$game_map_commandes.size @events[$game_map_commandes[i]].command_update end for common_event in @common_events.values common_event.update end end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh if @map_id > 0 for i in 0...$game_map_events.size @events[$game_map_events[i]].refresh #print(" event n°" + $game_map_events[i].to_s) end for i in 0...$game_map_multipages.size @events[$game_map_multipages[i]].refresh #print(" event n°" + $game_map_events[i].to_s) end for i in 0...$game_map_commandes.size @events[$game_map_commandes[i]].refresh #print(" event n°" + $game_map_events[i].to_s) end for common_event in @common_events.values common_event.refresh end end @need_refresh = false end
end |