Le deal à ne pas rater :
Aliexpress : codes promo valables sur tout le site
Voir le deal

Aller en bas
Douk
Douk
Membre

Nombre de messages : 296
Age : 30
Distinction : aucune
Date d'inscription : 23/04/2008
http://www.arcantia.info-a.googlepages.com/index.html

Antilag Amelioré ! Empty Antilag Amelioré !

Dim 6 Juil 2008 - 17:14
Bonjour !

Concept :
Votre jeu lag moins Wink

Auteur :
PRCoders

Traducteur :
Moi

Script :
Partie 1 :
Code:
###############################################################################
############################# PR Coders - AntiLag #############################
###############################################################################
############################# Traduit par Douk ################################
###############################################################################
#==============================================================================
# AntiLag par le groupe PR Coders.
# Seulement copier et utiliser !
#==============================================================================

#===============================================================
#                         
#                rpgmakervx.1fr1.net                                         
#     
#===============================================================

# Ajoute le script AntiLag dans la base de données PR Coders
$PRCoders ||= {}
# Active le script Antilag pour desacriver les faux "deixe"
$PRCoders["AntiLag"] = true

if $PRCoders["AntiLag"]

#==============================================================================
# AntiLag
#==============================================================================

module AntiLag
 
 SPC = Win32API.new("kernel32", "SetPriorityClass", "pi", "i")
 # Peut fonctionner en haute priorité dans ce jeu ?
 @@high_priority = true
 # Utiliser AntiLag événements ?
 @@event = true
 
 if @@high_priority
  SPC.call(-1, 0x80)
 else
  SPC.call(-1, 0x20)
 end
 @@cache = {}
 
 #--------------------------------------------------------------------------
 # Grande Prioritées ?
 #--------------------------------------------------------------------------
 
 def self.high_priority?
  return @@high_priority
 end
 
 #--------------------------------------------------------------------------
 # De haute Priorité
 #--------------------------------------------------------------------------
 
 def self.high_priority
  return @@high_priority
 end
 
 #--------------------------------------------------------------------------
 # AntiLag d'Evenement ?
 #--------------------------------------------------------------------------
 
 def self.event?
  return @@event
 end
 
 #--------------------------------------------------------------------------
 # AntiLag d'Evenement
 #--------------------------------------------------------------------------
 
 def self.event
  return @@event
 end
 
 #--------------------------------------------------------------------------
 # AntiLag d'Evenement = (true / false)
 #--------------------------------------------------------------------------
 
 def self.event=(valor)
  if valor
    @@event = true
  else
    @@event = false
  end
 end
 
 #--------------------------------------------------------------------------
 # Haute priorité = (true / false)
 #--------------------------------------------------------------------------
 
 def self.high_priority=(valor)
  return if @@high_priority == valor
  if valor
    @@high_priority = true
    SPC.call(-1, 0x80)
    return
  end
  @@high_priority = false
  SPC.call(-1, 0x20)
 end
 
 #--------------------------------------------------------------------------
 # Largeur de Bitmap
 #--------------------------------------------------------------------------
 
 def self.bitmap_width(character_name)
  if @@cache[character_name].nil?
    bitmap = Cache.character(character_name)
    sign = character_name[/^[\!\$]./]
    if sign != nil and sign.include?('$')
      cw = bitmap.width / 3
      ch = bitmap.height / 4
    else
      cw = bitmap.width / 12
      ch = bitmap.height / 8
    end
    @@cache[character_name] = [cw, ch]
  end
  return @@cache[character_name][0]
 end
 
 #--------------------------------------------------------------------------
 # Hauteur de Bitmap
 #--------------------------------------------------------------------------
 
 def self.bitmap_height(character_name)
  if @@cache[character_name].nil?
    bitmap = Cache.character(character_name)
    sign = character_name[/^[\!\$]./]
    if sign != nil and sign.include?('$')
      cw = bitmap.width / 3
      ch = bitmap.height / 4
    else
      cw = bitmap.width / 12
      ch = bitmap.height / 8
    end
    @@cache[character_name] = [cw, ch]
  end
  return @@cache[character_name][1]
 end
 
 
end

#==============================================================================
# Game_Character
#==============================================================================

class Game_Character
 
 #--------------------------------------------------------------------------
 # Vérifier si elle est sur l'écran (Coordonnée X)
 #--------------------------------------------------------------------------
 
 def in_screen_x?(add_x=0)
  ax = @x * 256
  min_ax = ax
  max_ax = ax
  if add_x > 0
    min_ax = ax - add_x / 2
    max_ax = ax + add_x / 2
  end
  if $game_map.loop_horizontal?
    if $game_map.display_x > ($game_map.width - 17) * 256
      w = ($game_map.width * 256)
      min_x = ($game_map.display_x - 2 * 256) % w
      max_x = ($game_map.display_x + 19 * 256) % w
      if max_x == 0
        max_x = w
      end
      if min_ax > min_x
        return true
      end
      if max_ax < max_x
        return true
      end
      return false
    end
  end
  return false if (min_ax < $game_map.display_x - 2 * 256)
  return false if (max_ax > $game_map.display_x + 19 * 256)
  return true
 end
 
 #--------------------------------------------------------------------------
 # Vérifier si elle est sur l'écran (Coordonnée Y)
 #--------------------------------------------------------------------------
 
 def in_screen_y?(add_y=0)
  ay = @y * 256
  min_ay = ay
  max_ay = ay
  if add_y > 0
    min_ay = ay - add_y
  end
  if $game_map.loop_vertical?
    if $game_map.display_y > ($game_map.height - 13) * 256
      h = ($game_map.height * 256)
      min_y = ($game_map.display_y - 2 * 256) % h
      max_y = ($game_map.display_y + 15 * 256) % h
      if max_y == 0
        max_y = h
      end
      if min_ay > min_y
        return true
      end
      if max_ay < max_y
        return true
      end
      return false
    end
  end
  return false if (min_ay < $game_map.display_y - 2 * 256)
  return false if (max_ay > $game_map.display_y + 15 * 256)
  return true
 end
 
 #--------------------------------------------------------------------------
 # Est sur l'écran ?
 #--------------------------------------------------------------------------
 
 def in_screen?(add_x=0, add_y=0)
  return false unless in_screen_x?(add_x)
  return false unless in_screen_y?(add_y)
  return true
 end
 
 #--------------------------------------------------------------------------
 # Vérifie si il y a collision avec un événement
 #--------------------------------------------------------------------------
 
 def collide_with_screen_characters?(x, y)
  for event in $game_map.screen_events_xy(x, y)  # ??????????
    unless event.through                          # ???? OFF?
      return true if self.is_a?(Game_Event)      # ???????
      return true if event.priority_type == 1    # ????????
    end
  end
  if @priority_type == 1                          # ????????
    return true if $game_player.pos_nt?(x, y)    # ???????????
    return true if $game_map.boat.pos_nt?(x, y)  # ?????????
    return true if $game_map.ship.pos_nt?(x, y)  # ?????????
  end
  return false
 end
Douk
Douk
Membre

Nombre de messages : 296
Age : 30
Distinction : aucune
Date d'inscription : 23/04/2008
http://www.arcantia.info-a.googlepages.com/index.html

Antilag Amelioré ! Empty Re: Antilag Amelioré !

Dim 6 Juil 2008 - 17:15
Partie 2 :
Code:
 
 #--------------------------------------------------------------------------
 # Verifie si c'est traversable
 #--------------------------------------------------------------------------
 
 def passable?(x, y)
  x = $game_map.round_x(x)                   
  y = $game_map.round_y(y)                 
  return false unless $game_map.valid?(x, y)
  return true if @through or debug_through?
  return false unless map_passable?(x, y)
  if self.in_screen?
    return false if collide_with_screen_characters?(x, y)
  else
    return false if collide_with_characters?(x, y)
  end
  return true                                   
 end
 
end

#==============================================================================
# Game_Player
#==============================================================================

class Game_Player < Game_Character
 
 #--------------------------------------------------------------------------
 # Vérifier s'il ya des événements pour le héros
 #--------------------------------------------------------------------------
 
 def check_event_trigger_here(triggers)
  return false if $game_map.interpreter.running?
  result = false
  for event in $game_map.screen_events_xy(@x, @y)
    if triggers.include?(event.trigger) and event.priority_type != 1
      event.start
      result = true if event.starting
    end
  end
  return result
 end
 
 #--------------------------------------------------------------------------
 # Verifie si il y a des événements en face du héro
 #--------------------------------------------------------------------------
 
 def check_event_trigger_there(triggers)
  return false if $game_map.interpreter.running?
  result = false
  front_x = $game_map.x_with_direction(@x, @direction)
  front_y = $game_map.y_with_direction(@y, @direction)
  for event in $game_map.screen_events_xy(front_x, front_y)
    if triggers.include?(event.trigger) and event.priority_type == 1
      event.start
      result = true
    end
  end
  if result == false and $game_map.counter?(front_x, front_y)
    front_x = $game_map.x_with_direction(front_x, @direction)
    front_y = $game_map.y_with_direction(front_y, @direction)
    for event in $game_map.screen_events_xy(front_x, front_y)
      if triggers.include?(event.trigger) and event.priority_type == 1
        event.start
        result = true
      end
    end
  end
  return result
 end
 
 #--------------------------------------------------------------------------
 # Vérifie s'il y a des événements en position X, Y
 #--------------------------------------------------------------------------
 
 def check_event_trigger_touch(x, y)
  return false if $game_map.interpreter.running?
  result = false
  for event in $game_map.screen_events_xy(x, y)
    if [1,2].include?(event.trigger) and event.priority_type == 1
      event.start
      result = true
    end
  end
  return result
 end

end

#==============================================================================
# Game_Event
#==============================================================================

class Game_Event < Game_Character
 
 #--------------------------------------------------------------------------
 # alias
 #--------------------------------------------------------------------------
 
 alias pr_coders_antilag_game_event_setup setup
 
 #--------------------------------------------------------------------------
 # A l'écran ?
 #--------------------------------------------------------------------------
 
 def in_screen?(*args)
  return true if @antilag_always_update
  if @large_bitmap
    return super(AntiLag.bitmap_width(@character_name), AntiLag.bitmap_height(@character_name))
  end
  return super
 end
 
 #--------------------------------------------------------------------------
 # Defini une nouvelle page d'evenements
 #--------------------------------------------------------------------------
 
 def setup(new_page)
  pr_coders_antilag_game_event_setup(new_page)
  @large_bitmap = false
  @antilag_always_update = false
  @antilag_always_update |= (not AntiLag.event?)
  @antilag_always_update |= [3, 4].include?(@trigger)
  return if @list.nil?
  for item in @list
    if item.code == 108 or item.code == 408
      case item.parameters[0].downcase
      when "always_update"
        @antilag_always_update |= true
      when "large_bitmap"
        @large_bitmap = true
      end
    end
  end
 end
 
end

#==============================================================================
# Game_Map
#==============================================================================

class Game_Map
 
 attr_reader :screen_events
 
 #--------------------------------------------------------------------------
 # alias
 #--------------------------------------------------------------------------
 
 alias pr_coders_antilag_game_map_setup_events setup_events
 
 #--------------------------------------------------------------------------
 # Creé les evenements
 #--------------------------------------------------------------------------
 
 def setup_events
  @screen_events = {}
  pr_coders_antilag_game_map_setup_events
 end
 
 #--------------------------------------------------------------------------
 # Verifie si c'est trasversable
 #--------------------------------------------------------------------------
 
 def passable?(x, y, flag = 0x01)
  for event in screen_events_xy(x, y)            # ???????????????
    next if event.tile_id == 0            # ??????????????
    next if event.priority_type > 0      # [???????] ????
    next if event.through                # ??????
    pass = @passages[event.tile_id]      # ???????
    next if pass & 0x10 == 0x10          # [?] : ????????
    return true if pass & flag == 0x00    # [?] : ???
    return false if pass & flag == flag  # [×] : ????
  end
  for i in [2, 1, 0]                      # ?????????????
    tile_id = @map.data[x, y, i]          # ??? ID ???
    return false if tile_id == nil        # ??? ID ???? : ????
    pass = @passages[tile_id]            # ???????
    next if pass & 0x10 == 0x10          # [?] : ????????
    return true if pass & flag == 0x00    # [?] : ???
    return false if pass & flag == flag  # [×] : ????
  end
  return false                            # ????
 end
 
 #--------------------------------------------------------------------------
 # Events en position X et Y sur l'écran
 #--------------------------------------------------------------------------
 
 def screen_events_xy(x, y)
  result = []
  for event in @screen_events.values
    result.push(event) if event.pos?(x, y)
  end
  return result
 end
 
 #--------------------------------------------------------------------------
 # Actualise les Evenements
 #--------------------------------------------------------------------------
 
 def update_events
  @screen_events.clear
  for k, event in @events
    next unless event.in_screen?
    @screen_events[k] = event
    event.update
  end
  for common_event in @common_events.values
    common_event.update
  end
 end
 
 #--------------------------------------------------------------------------
 # Actualise les Vehicules
 #--------------------------------------------------------------------------
 
 def update_vehicles
  for vehicle in @vehicles
    next unless vehicle.in_screen?
    vehicle.update
  end
 end
 
end

#==============================================================================
# Spriteset_Map
#==============================================================================

class Spriteset_Map
 
 #--------------------------------------------------------------------------
 # Actualise les Chara
 #--------------------------------------------------------------------------
 
 def update_characters
  for sprite in @character_sprites
    next if sprite.character.nil?
    next unless sprite.character.in_screen?
    sprite.update
  end
 end

end

end
Widowan
Widowan
Fondateur
Nombre de messages : 1435
Age : 41
Localisation : France
Distinction : Sergent
Tyran professionnel
Date d'inscription : 15/12/2007
https://www.rpgmakervx-fr.com

Antilag Amelioré ! Empty Re: Antilag Amelioré !

Dim 6 Juil 2008 - 17:50
J'ai un gros problème avec ce script, c'est vrai qu'il diminue considérablement le lag, mais j'ai des arbres en charas, et lorsque le champs de vision se déplace avec le chara, je suis suivi par mes arbres xD...
Dans la notice, il est indiqué qu'il faut placer le commentaire "large_bitmap" dans l'event pour eviter le problème, mais ca change rien du tout....
:...:

Edit: c'est bon !
Lorsque certains events de grande taille vous posent des problèmes, insérez le commentaire : Allways_update
Pour les affichages de pictures de grandes tailles inserez en commentaire : large_bitmap
Lifa
Lifa
Membre

Nombre de messages : 95
Age : 38
Localisation : Falénia, ou bien sud-ouest de la France ^^'
Distinction : aucune
Date d'inscription : 25/06/2008
http://www.teradem.net

Antilag Amelioré ! Empty Re: Antilag Amelioré !

Mer 9 Juil 2008 - 14:46
Joli ^^
Je peux enfin combiner une vingtaine d'événements en processus parallèle avec autants d'événements communs sans que ça rame d'un poil lol!
Merci pour ce script !
Devorer
Devorer
Membre

Nombre de messages : 9
Age : 33
Distinction : aucune
Date d'inscription : 01/03/2008

Antilag Amelioré ! Empty Re: Antilag Amelioré !

Jeu 30 Oct 2008 - 3:06
Ouais il est pas mal, mais j'ai malheureusement le même problème que Widowan. Il dérègle certains arbres d'évènements... Neutral
Berka
Berka
Staffeux retraité

Nombre de messages : 1832
Age : 33
Localisation : Paris
Distinction : rubyste déglingué
9ème dan en scripting-no-jutsu

Nouveau Justine Beber ;P
Date d'inscription : 16/12/2007
http://rpgruby.olympe-network.com

Antilag Amelioré ! Empty Re: Antilag Amelioré !

Jeu 30 Oct 2008 - 13:37
Necropost !
regarde la date avant de poster !
Skatino
Skatino
Membre

Nombre de messages : 9
Age : 28
Localisation : Saint-Petersbourg, Russia
Distinction : aucune
Date d'inscription : 20/07/2013
http://chroniclesofmasdes.jimdo.com/

Antilag Amelioré ! Empty Re: Antilag Amelioré !

Sam 20 Juil 2013 - 23:27
De mon coté c'est a peu près résolu lol
Contenu sponsorisé

Antilag Amelioré ! Empty Re: Antilag Amelioré !

Revenir en haut
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum