Biasanya script ini di gunakan agar tidak ngelag saat bermain.Biasanya lag tersebut di akibatkan script yang terlalu banyak. Berikut adalah scriptnya :
# † [VX] † Rei Evil Anti-Lag (REAL) † †
# † Sebuah Anti-Lag campuran yang ampuh untuk VX! †
#-------------------------------------------------------------------------------
# † by reijubv [aruyasoft@comic.com]
# † RMID (Rpgmakerid.forumotion.com)
# † Dipublikasikan pada : 12/08/2009
# † Versi: 1.2 (21 September 2009)
#-------------------------------------------------------------------------------
# Peringatan :
# Kalau pilihan "AUTO_KILL" kamu set true :
# SEMUA EVENT TANPA SPRITESET/CHARSET akan otomatis DIHAPUS dari permainan (Ke-
# cuali event yang Autorun dan Parallel)
# Untuk menghindari hal ini, semua event yang mau kamu pakai setidaknya HARUS
# memakai spriteset, untuk membuat event yang tidak terlihat, sebaiknya kamu mem
# buat sebuah charset kosong tanpa sprite untuk event itu.
#-------------------------------------------------------------------------------
# Tambahan :
# > Beri sebuah event nama "!" (Tanpa tanda kutip) supaya event itu tidak perlu
# diupdate sama sekali.
# > Beri sebuah event nama "@" (Tanpa tanda kutip) supaya event itu SELALU diup
# date.
#-------------------------------------------------------------------------------
# Changelog :
# V.1.0 => Awal pembuatan script
# V.1.1 => Meningkatkan performa dan menambahkan fitur "Frame Rate Viewer"
# V.1.2 => Membuat script ini lebih stabil dan membuat demo lebih "Ramai"
#-------------------------------------------------------------------------------
# Credits:
# reijubv untuk mencampur 2 script ini + mengoptimalkannya.
# Blizzard & f0tz!baerchen karena script ini adalah hasil campuran kedua script
# mereka yang aku modif lalu convert ke VX!
#-------------------------------------------------------------------------------
# ? Pemasangan:
# Taroh diatas Main, edit di Rei Module
#==============================================================================
$imported = {} if $imported == nil
$imported["Rei_"+"EAL"] = true
#---------------------------------------------------------------------------
# ** Rei Module
#---------------------------------------------------------------------------
module Rei
module EAL
# Masukkan map Id dimana kamu tidak mau ada event anti-lag. Pisahkan dengan
# koma.
MAP_ID = []
# Hapus event-event kosong tanpa grafik secara otomatis? (Baca peringatan
# diatas)
AUTO_KILL = false
# Jalankan Game.exe pada High Priority?
HIGH_PRIORITY = true
# Atur frame rate secara otomatis?
FRAME_ADJUST = true
# Fungsi2 dibawah hanya berguna kalau FRAME_ADJUST = true
# Script akan memastikan Game kamu tidak akan membuat CPU jadi terlalu ter-
# bebani. Angka ini adalah CPU usage tertinggi yang bisa dicapai game.
# Script akan otomatis mengatur frame rate sehingga mengurangi LAG secara
# drastis.
# Angka lebih dari 100 akan menon-aktifkan fitur ini.
MAX_CPU = 90
# Ini adalah jumlah minimal dari pemakaian CPU yang tidak akan di perdulikan
# Semakin tinggi akan semakin stabil frame-rate mu, tapi lag akan semakin
# keliatan.
MIN_CPU = 10
# Reset frame rate setiap berubah scene?
RESET_FPS = true
end
end
#==============================================================================
# Game_Character
#==============================================================================
class Game_Character;attr_accessor :sprite_size;alias rei_gc_el_int initialize
def initialize;@sprite_size = [0,1600,0,1600];rei_gc_el_int;end
end
#==============================================================================
# Game_Event
#==============================================================================
class Game_Event < Game_Character
attr_reader :event
alias rei_ge_el_upd update
def update
return if self.event.name == '!'
rei_ge_el_upd if self.update? || self.moving?
end
def update?
return true if Rei::EAL::MAP_ID.include?($game_map.map_id)
return true if self.event.name == '@'
return true if [3, 4].include?(self.trigger)
return false if Rei::EAL::AUTO_KILL && @character_name == '' && @tile_id ==0
return false if @real_x > $game_map.display_x + @sprite_size[0] + 30 * 156
return false if @real_x < $game_map.display_x - @sprite_size[1]
return false if @real_y > $game_map.display_y + @sprite_size[2] + 25 * 156
return false if @real_y < $game_map.display_y - @sprite_size[3]
return true
end
end
#==============================================================================
# Control_Sprite_Character
#==============================================================================
class Control_Sprite_Character
attr_reader :character
def initialize(viewport, character = nil)
self.character = character
@viewport = viewport
end
def character=(char)
@character = char
@sprite.character = char unless @sprite == nil
end
def update
if @character != nil && (@character.is_a?(Game_Event) &&
@character.update? || !@character.is_a?(Game_Event))
if @sprite == nil || @sprite.disposed?
@sprite = A_REALized_Sprite.new(@viewport, @character)
else
@sprite.update
end
if @sprite.bitmap != nil
@character.sprite_size = [128-@sprite.src_rect.width*2,
128+@sprite.src_rect.width*2, 256-@sprite.src_rect.height*4, 248]
if @character.is_a?(Game_Event) && !@character.update?
@sprite.dispose unless @sprite.disposed?
@sprite = nil
end
else
@character.size = [0, 124, 0, 124]
end
elsif @sprite != nil
@sprite.dispose unless @sprite.disposed?
@sprite = nil
end
end
def dispose
unless @sprite == nil || @sprite.disposed?
@sprite.dispose
@sprite = nil
end
end
end
#==============================================================================
# A_REALized_Sprite
#==============================================================================
class A_REALized_Sprite < Sprite_Character
end
#==============================================================================
# Sprite_Character
#==============================================================================
class Sprite_Character < Control_Sprite_Character
end
#===============================================================================
# Class for Antilag Settings (By f0tz!baerchen)
#===============================================================================
class Antilag_Settings
attr_accessor :max_cpu_utilization
attr_accessor :cpu_tolerance
#-----------------------------------------------------------------------------
# initializes default settings
#-----------------------------------------------------------------------------
def initialize
@high_priority = Rei::EAL::HIGH_PRIORITY
@max_cpu_utilization = Rei::EAL::MAX_CPU
@cpu_tolerance = Rei::EAL::MIN_CPU
@SetPriorityClass = Win32API.new('kernel32', 'SetPriorityClass',
['p', 'i'], 'i')
@GetProcessTimes = Win32API.new('kernel32', 'GetProcessTimes',
['i','p','p','p','p'], 'i')
end
#-----------------------------------------------------------------------------
# turns high priority on/off
#-----------------------------------------------------------------------------
def high_priority=(value)
@high_priority = value
if @high_priority
@SetPriorityClass.call(-1, 0x00000080) # High Priority
else
@SetPriorityClass.call(-1, 0x00000020) # Normal Priority
end
end
#-----------------------------------------------------------------------------
# returns the current CPU Utilization
#-----------------------------------------------------------------------------
def get_cpu_utilization
# uses API Call to get the Kernel and User Time
creation_time = '0' * 10
exit_time = '0' * 10
kernel_time = '0' * 10
user_time = '0' * 10
@GetProcessTimes.call(-1, creation_time, exit_time, kernel_time, user_time)
# converts times into integer (in 100ns)
kernel_time = kernel_time.unpack('l2')
user_time = user_time.unpack('l2')
kernel_time = kernel_time[0] + kernel_time[1]
user_time = user_time[0] + user_time[1]
# takes differences to calculate cpu utilization
if @old_time != nil
timer_difference = Time.new - @old_timer
time_difference = kernel_time + user_time - @old_time
result = time_difference / timer_difference / 100000
else
result = $antilag.max_cpu_utilization
end
# saves values (to calculate the differences, s.a.)
@old_timer = Time.new
@old_time = kernel_time + user_time
return result
end
end
$antilag = Antilag_Settings.new
#==============================================================================
# ** Scene_Base
#==============================================================================
if Rei::EAL::RESET_FPS
class Scene_Base
alias rei_eal_scm_main main
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
rei_eal_scm_main
Graphics.frame_reset
Graphics.frame_rate = 60
end
end
end
#===============================================================================
# Scene_Map class
#===============================================================================
class Scene_Map
#-----------------------------------------------------------------------------
# update method, smooth antilag has been added
#-----------------------------------------------------------------------------
alias rei_scm_el_updt update
def update
if Rei::EAL::FRAME_ADJUST
if Graphics.frame_count % 30 == 0 and $antilag.max_cpu_utilization <= 100
# calculates difference between max utilization and current utilization
abs = $antilag.max_cpu_utilization - $antilag.get_cpu_utilization
# changes Frame Rate if difference is bigger than the tolerance
if abs.abs >= $antilag.max_cpu_utilization * $antilag.cpu_tolerance/100.0
Graphics.frame_rate = [[10, Graphics.frame_rate + abs / 2].max, 60].min
end
end
end
rei_scm_el_updt
end
end
#===============================================================================
#-------------------------------------------------------------------------------
# * END OF SCRIPT
#-------------------------------------------------------------------------------
#===============================================================================
# ● [VX] ◦ Frame-rate Viewer ◦ □
# * Ini adalah HUD yang akan menampilkan jumlah frame-rate mu, supaya kamu
# tau apa game kamu ngeLag atau tidak. . .
# Hanya berguna kalau kamu pakai script REAL
#---------------------------------------------------------------
# HUD hanya muncul saat play-testing
#---------------------------------------------------------------
# by reijubv
#--------------------------------------------------------------
if $TEST
class FPSViewer
def initialize
@sprite = Sprite.new
@sprite2 = Sprite.new
@sprite.bitmap = Bitmap.new(96,48)
@sprite2.bitmap = Bitmap.new(128,48)
@sprite.z = 2
@sprite2.z = 1
@fps = 0
@sprite2.bitmap.fill_rect(0,0,60+32,33,Color.new(255,0,0,255))
@sprite2.bitmap.fill_rect(1,1,58+32,31,Color.new(255,255,255,255))
@sprite2.bitmap.gradient_fill_rect(2,2,56+32,29,Color.new(16,16,32,32),Color.new(64,64,128,255),true)
refresh
end
def refresh
@sprite.bitmap.clear
if @fps != Graphics.frame_rate
@fps = Graphics.frame_rate
i = ( (Graphics.frame_rate / 60) * 100 )
a = 255/100*i
c = Color.new(255-a,a,0)
@sprite.bitmap.font.bold = true
@sprite.bitmap.font.color = c
@sprite.bitmap.draw_text(6,0, @sprite.bitmap.width, 32, "FPS : #{@fps}")
end
end
def update
refresh if @fps != Graphics.frame_rate
return
end
def dispose
@sprite.bitmap.dispose
@sprite2.bitmap.dispose
@sprite.dispose
@sprite2.dispose
end
end
class Scene_Map < Scene_Base
alias fps_viewer_start start
alias fps_viewer_upd update
alias fps_viewer_ter terminate
def start
fps_viewer_start
@fps_viewer = FPSViewer.new
end
def update
fps_viewer_upd
@fps_viewer.update
end
def terminate
@fps_viewer.dispose
fps_viewer_ter
end
end
end
Gak percaya ?? nih buktinya !!! " rei anti lag "
Sekian dulu postingan kami. Tunggu postingan kami berikutnya ya !?
Tidak ada komentar:
Posting Komentar