RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
f0tz!baerchen's New Anti-Lag Script

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 88
Random-Idiot
First the script:
Code: [Select]
#===============================================================================
# ** AntiLag Script
#-------------------------------------------------------------------------------
#
# f0tz!baerchen
# 0.5
# 30.12.2006
#
#-------------------------------------------------------------------------------
#
# Credits:
# Chaosg1 (for testing ;) )
# NearFantastica (for the Event AntiLag I used and improved)
#
#-------------------------------------------------------------------------------
#
# Features:
# - Event AntiLag: Event (and their Sprites) which are not on the screen are
#   not updated except they run on "Autostart" or "Parallel Process" or they
#   have an empty comment in the first line
# - High Priority: Game can be run on high priority
# - Smooth Antilag: the Event AntiLag does only work fine if the events are
#   distributed over the whole map, but when there are many events at the same
#   place it lags again. If the script notices lag it will reduce the frame rate
#   to prevent this lag. Maybe the game will run slower, too..
#
#-------------------------------------------------------------------------------
#
# Options:
# can be changed during the game, but once high_priority is true you
# cannot disable it anymore

$antilag_factor = 1.0 # if you make this value smaller the game will be smoother
                      # but eventually slower, too. (you can also increase it)
                      # (only if $antilag_switch is true)
$antilag_switch = false # set this to true if you want the game to be smoother
                        # (but perhaps slower) instead of lagging
$antilag_high_priority = true # set this to true if you want the game to run on
                              # high priority
$antilag = true # set this to true to enable normal anti-lag
#
#===============================================================================

#-------------------------------------------------------------------------------
# * SDK Log Script
#-------------------------------------------------------------------------------
SDK.log('AntiLag', 'f0tz!baerchen', 0.5, '30.12.06')

#-------------------------------------------------------------------------------
# Begin SDK Enabled Check
#-------------------------------------------------------------------------------
if SDK.state('AntiLag') == true
 
#===============================================================================
# FrameRateTest Class
# used for some things with the Frame Rate etc..
#===============================================================================
class FrameRateTest
 
  attr_reader :frame_count_start
 
  #-----------------------------------------------------------------------------
  # initialize
  #-----------------------------------------------------------------------------
  def initialize
    @time_fps = Time.new
    @frame_count_fps = Graphics.frame_count
  end
 
  #-----------------------------------------------------------------------------
  # fps: returns the Frames past since the last call
  # so you should use it once per second..
  # if show is set to true it prints the Frames
  #-----------------------------------------------------------------------------
  def fps(show = false)
   
    if show
      time = Time.new
      p ((Graphics.frame_count - @frame_count_fps) / (time - @time_fps)).round
      time_2 = Time.new
      @time_fps += time_2-time
    else
      return ((Graphics.frame_count - @frame_count_fps) /
              (Time.new - @time_fps)).round
    end
           
    @time_fps = Time.new
    @frame_count_fps = Graphics.frame_count
  end
 
end

#===============================================================================
# Scene_Map class
#===============================================================================
class Scene_Map
 
  #-----------------------------------------------------------------------------
  # main method, initialising of the FrameRateTest-Object added
  #-----------------------------------------------------------------------------
  alias f0tzis_anti_lag_scene_map_main main
  def main
    $antilag = FrameRateTest.new
    f0tzis_anti_lag_scene_map_main
  end
 
  #-----------------------------------------------------------------------------
  # update method, antilag has been added, frame rate is changed to the
  # real frame rate, so everything slows down if the program cannot reach the
  # frame rate anymore
  #-----------------------------------------------------------------------------
  alias f0tzis_anti_lag_scene_map_update update
  def update
    f0tzis_anti_lag_scene_map_update
    if $antilag_switch
      if Graphics.frame_count % Graphics.frame_rate == 0
        Graphics.frame_rate = ($antilag.fps ** 2) * $antilag_factor / 40
      end
    elsif Graphics.frame_rate != 40
      Graphics.frame_rate = 40
    end
  end
end

#===============================================================================
# Game_Event Class
#===============================================================================
class Game_Event
 
  #-----------------------------------------------------------------------------
  # for Anti_Lag, decides, if an event is on the screen or not.
  #-----------------------------------------------------------------------------
  def in_range?
       
    # returns true if $antilag is false or the event is an
    # Autostart/Parallel Process event or it has an empty
    # comment in the first line
    if not $antilag or (@trigger == 3 or @trigger == 4 or
    (@list!=nil and @list[0].code == 108 and @list[0].parameters == ['']))
      return true
    end
     
    screne_x = $game_map.display_x
    screne_x -= 256
    screne_y = $game_map.display_y
    screne_y -= 256
    screne_width = $game_map.display_x
    screne_width += 2816
    screne_height = $game_map.display_y
    screne_height += 2176
   
    return (@real_x > screne_x and @real_x < screne_width and
    @real_y > screne_y and @real_y < screne_height)
           
  end
 
  #-----------------------------------------------------------------------------
  # update method
  #-----------------------------------------------------------------------------
  alias f0tzis_anti_lag_game_event_update update
  def update
    return if not self.in_range?     
    f0tzis_anti_lag_game_event_update
  end
 
end

#===============================================================================
# Sprite_Character Class
#===============================================================================
class Sprite_Character < RPG::Sprite
 
  #-----------------------------------------------------------------------------
  # update method, parameters added for Loop_Map, rebuild for 8dirs
  #-----------------------------------------------------------------------------
  alias f0tzis_anti_lag_sprite_char_update update
  def update
    return if @character.is_a?(Game_Event) and not @character.in_range?
    f0tzis_anti_lag_sprite_char_update
  end
 
end

#===============================================================================
# High Priority?
#===============================================================================
if $antilag_high_priority
  @SetCurrentProcess = Win32API.new('kernel32','GetCurrentProcess',[],'i').call
  @SetPriorityClass = Win32API.new('kernel32','SetPriorityClass',['p', 'i'],'i')
  @SetPriorityClass.call(@GetCurrentProcess, 0x00000080)
end

end

Features:
- Event AntiLag: Event (and their Sprites) which are not on the screen are
  not updated except they run on "Autostart" or "Parallel Process" or they
  have an empty comment in the first line
- High Priority: Game can be run on high priority
- Smooth Antilag: the Event AntiLag does only work fine if the events are
  distributed over the whole map, but when there are many events at the same
  place it lags again. If the script notices lag it will reduce the frame rate
  to prevent this lag. Maybe the game will run slower, too..


Just place it under the SDK and above the rest of your scripts.

CREDITS: f0tz!baerchen
Chaosg1 (for testing ;) )
NearFantastica (for the Event AntiLag I used and improved)


(original thread: http://www.hbgames.org/forums/showthread.php?t=11639 )
ALL HAIL ME™

***
Rep:
Level 89
I am yourself!
Don't forget to say :
"This Script Requires Standard Development Kit (SDK)"
Symphony of Alderra : Memoirs of Life

Storyline : 200% (Overimaginatives)
Scripting : 100% (At last...)
Eventing  : 100%
Mapping   : 0.125%

***
Rep:
Level 88
Random-Idiot
Quote
Just place it under the SDK

I am more like... read the post and youll know.
ALL HAIL ME™

***
Rep:
Level 88
Hell... What did I mess up now... I'm Back!
sdk... ahh... how much i hate converting that into my games... cuz they never work... XD I'll give it a shot anyway...
----Current Games working on----
--Rage O' Delusion - Overall Percentage Finished : 4% -- Expected release... Unknown
--The Other Dimension - Overall Percentage done : 1 - Expected Release : No time soon...
v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^
Feildmaster Productions
Made By One Man Run by the Same...
Making Games for Everyone...
Oh yeah, and everything else web based
For a charge... Of course...

*****
Ancient Mummy
Rep:
Level 90
Yeah >.< I think i got it somewhere but hate to install it if necessary.

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
Nice job. Although nothing lags on my computer. (15 tb storrage and 23 gig ram.)

....

Lol xD j/k
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They’re bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I’m the only one, I’m the only one."

***
Rep:
Level 88
Hell... What did I mess up now... I'm Back!
hahaa... i beleaved u for a second... XD
----Current Games working on----
--Rage O' Delusion - Overall Percentage Finished : 4% -- Expected release... Unknown
--The Other Dimension - Overall Percentage done : 1 - Expected Release : No time soon...
v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^
Feildmaster Productions
Made By One Man Run by the Same...
Making Games for Everyone...
Oh yeah, and everything else web based
For a charge... Of course...

***
Rep:
Level 88
Smarter than the average bear
sdk... ahh... how much i hate converting that into my games... cuz they never work... XD I'll give it a shot anyway...

Just remove the SDK logs and the last end in the script to use it without SDK.

(SDK logs)
Code: [Select]
#-------------------------------------------------------------------------------
# * SDK Log Script
#-------------------------------------------------------------------------------
SDK.log('AntiLag', 'f0tz!baerchen', 0.5, '30.12.06')

#-------------------------------------------------------------------------------
# Begin SDK Enabled Check
#-------------------------------------------------------------------------------
if SDK.state('AntiLag') == true

***
Rep:
Level 89
I am yourself!
Hehe...
That's right!

Just remove the SDK header and footer...
But I was so lazy to do that!
Symphony of Alderra : Memoirs of Life

Storyline : 200% (Overimaginatives)
Scripting : 100% (At last...)
Eventing  : 100%
Mapping   : 0.125%