ArthurMaker Rei
Mensagens : 142 MakerCoins : 10321 Data de inscrição : 11/04/2010 Prêmios :
Este membro ainda não
recebeu nenhum prêmio...
| Assunto: [RGSS2] Anti-Lag Sex Jul 09, 2010 2:04 am | |
| [RGSS2] Anti-Lag Por Pr Coders Suporta vários eventos. Ele é ótimo para grandes mapas que há vários eventos. Instruções no Script.Script:- Spoiler:
- Código:
-
############################################################################### ############################# PR Coders - AntiLag ############################# ############################################################################### #============================================================================== # AntiLag do grupo PR Coders. # Somente copie e use #==============================================================================
# Adiciona o script AntiLag ao database do PR Coders $PRCoders ||= {} # Habilita o script, para desabilitar deixe false $PRCoders["AntiLag"] = true
if $PRCoders["AntiLag"]
#============================================================================== # AntiLag #==============================================================================
module AntiLag SPC = Win32API.new("kernel32", "SetPriorityClass", "pi", "i") # Roda o jogo em Alta prioridade? @@high_priority = true # Usa o AntiLag de eventos? @@event = true if @@high_priority SPC.call(-1, 0x80) else SPC.call(-1, 0x20) end @@cache = {} #-------------------------------------------------------------------------- # Alta prioridade? #-------------------------------------------------------------------------- def self.high_priority? return @@high_priority end #-------------------------------------------------------------------------- # Alta prioridade #-------------------------------------------------------------------------- def self.high_priority return @@high_priority end #-------------------------------------------------------------------------- # AntiLag de Evento? #-------------------------------------------------------------------------- def self.event? return @@event end #-------------------------------------------------------------------------- # AntiLag de Evento #-------------------------------------------------------------------------- def self.event return @@event end #-------------------------------------------------------------------------- # AntiLag de Evento = (true / false) #-------------------------------------------------------------------------- def self.event=(valor) if valor @@event = true else @@event = false end end #-------------------------------------------------------------------------- # Alta prioridade = (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 #-------------------------------------------------------------------------- # Largura do 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 #-------------------------------------------------------------------------- # Altura do 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 #-------------------------------------------------------------------------- # Verifica se está na tela (Coordenada 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 #-------------------------------------------------------------------------- # Verifica se está na tela (Coordenada 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 #-------------------------------------------------------------------------- # Verifica se está na tela? #-------------------------------------------------------------------------- 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 #-------------------------------------------------------------------------- # Verifica se colidiu com algum evento? #-------------------------------------------------------------------------- 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 #-------------------------------------------------------------------------- # Verifica se é passável? #-------------------------------------------------------------------------- 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 #-------------------------------------------------------------------------- # Verifica se há eventos no herói #-------------------------------------------------------------------------- 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 #-------------------------------------------------------------------------- # Verifica se há eventos na frente do herói #-------------------------------------------------------------------------- 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 #-------------------------------------------------------------------------- # Verifica se há eventos na posição 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 #-------------------------------------------------------------------------- # Na tela? #-------------------------------------------------------------------------- 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 #-------------------------------------------------------------------------- # Define a nova página do evento #-------------------------------------------------------------------------- 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 #-------------------------------------------------------------------------- # Cria os eventos #-------------------------------------------------------------------------- def setup_events @screen_events = {} pr_coders_antilag_game_map_setup_events end #-------------------------------------------------------------------------- # Verifica se é passável? #-------------------------------------------------------------------------- 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 #-------------------------------------------------------------------------- # Eventos na posição X e Y da tela #-------------------------------------------------------------------------- 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 #-------------------------------------------------------------------------- # Atualiza os Eventos #-------------------------------------------------------------------------- def update_events @screen_events.clear for k, event in @events next unless event.in_screen? @screen_events[k] = event end for event in @screen_events.values event.update end for common_event in @common_events.values common_event.update end end #-------------------------------------------------------------------------- # Atualiza os Verículos #-------------------------------------------------------------------------- def update_vehicles for vehicle in @vehicles next unless vehicle.in_screen? vehicle.update end end end
#============================================================================== # Spriteset_Map #==============================================================================
class Spriteset_Map #-------------------------------------------------------------------------- # Atualiza os Characters #-------------------------------------------------------------------------- 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
Até mais! :cheers: |
|
DragonLord Forasteiro
Mensagens : 22 MakerCoins : 63 Data de inscrição : 16/07/2010 Mensagem Pessoal : You DIE
| Assunto: Re: [RGSS2] Anti-Lag Sáb Jul 24, 2010 9:34 pm | |
| Legal mas na proxima põe os devidos creditos!
Ass: |
|
Murakami Chokyu Rei
Mensagens : 19 MakerCoins : 27 Data de inscrição : 09/07/2010 Idade : 31 Mensagem Pessoal : Honra. Localização : Okinawa, Japão
| Assunto: Re: [RGSS2] Anti-Lag Sáb Jul 24, 2010 10:00 pm | |
| DragonLord - Dá mais uma lida no começo do tópico - Arthur escreveu:
[RGSS2] Anti-Lag Por Pr Coders Mais atenção da próxima vez, não se importe muito em postar muita coisa, o importante no momento é conteudo, quantidade é o de menos. Evite flood. |
|
Hisamitsu Sato Forasteiro
Mensagens : 6 MakerCoins : 7 Data de inscrição : 28/07/2010
| Assunto: Re: [RGSS2] Anti-Lag Qua Jul 28, 2010 4:32 pm | |
| deixa o trab pros admins e moderadores õ/ |
|
baoyama Lorde
Mensagens : 88 MakerCoins : 314 Data de inscrição : 18/04/2010 Idade : 31 Mensagem Pessoal : Tentando chegar aos 100 posts! Localização : Na frente do meu PC
| Assunto: Re: [RGSS2] Anti-Lag Seg Ago 16, 2010 8:54 pm | |
| nem sabia que existia anti-lag xD! È só pros jogos onlines do rmvx? ou pode pro rmvx normal mesmo? |
|
Conteúdo patrocinado
| Assunto: Re: [RGSS2] Anti-Lag | |
| |
|