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.
[VX] [SOLVED] Anti-Lag

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 75
RMRK Junior
Request: The script below needs the option to update a special event page and not the whole event.
At first, I'm sure that there is an existing script which updates only one event page. But I need this function in the script below, because else there will be errors.
I can't delete this script!
So, I need the option to make a comment box on an event page, (e.g. for text in a comment: update page) which compels the Anti-Lag to update only that page!
Till now, you have to put "update" as name of the event to update everything which belongs to it.

I hope that it isn't too hard. If you know a better alternative, please tell me! (not a comment box, sth. else)



Code: [Select]
#==============================================================================
#  hellMinor's "Just Anti-Lag"
#  Version : beta v0.6
#  Created by : hellMinor
#  Do NOT redistribute without my permission
#==============================================================================
# To update an event always, call it - "update" - and it will be
# updated permanently. (event name)
#==============================================================================
ADJUST = 10    # How many tiles should be updated around the screen?
FRAMESKIP = 2 # How many frames should be skipped before drawing new sprites?
ALLOW_SCROLL_UPDATE_SWITCH_ID = 20 # The scroll will be updated always.
#==============================================================================
class Game_Map
#==============================================================================
  def update_events
    obere_schranke = @display_y/256 - $game_system.adjust
    untere_schranke = @display_y/256 + 13 + $game_system.adjust
    linke_schranke = @display_x/256 - $game_system.adjust
    rechte_schranke = @display_x/256 + 17 + $game_system.adjust
    for event in @events.values
      event_x = event.x
      event_y = event.y
      if event.name == "update"
        event.update
        next
      end
      event.update if event_x >= linke_schranke and event_x <= rechte_schranke and event_y >= obere_schranke and event_y <= untere_schranke
    end
    for common_event in @common_events.values
      common_event.update
    end
  end 
end
#==============================================================================
class Spriteset_Map
#==============================================================================
  alias create_viewports_just_antilag create_viewports
  alias update_old_update update unless $@
  def create_viewports
    @skip = 0
    create_viewports_just_antilag
  end
 
  def update
    if @skip <= 0
      @skip = FRAMESKIP
      update_old_update
    else
      if $game_switches[ALLOW_SCROLL_UPDATE_SWITCH_ID]
        update_tilemap
      end
      screen_x = $game_map.display_x/256
      screen_y = $game_map.display_y/256
      for sprite in @character_sprites
        sprite_x = sprite.character.x
        sprite_y = sprite.character.y
        if sprite_x > (screen_x - $game_system.adjust) and sprite_x < (screen_x + 17 + $game_system.adjust) and sprite_y > (screen_y - $game_system.adjust) and sprite_y < (screen_y + 13 + $game_system.adjust) && sprite.animation?
          sprite.update
        end
      end
    end
    @skip -= 1
  end
 
  def update_characters
    screen_x = $game_map.display_x/256
    screen_y = $game_map.display_y/256
    for sprite in @character_sprites
      sprite_x = sprite.character.x
      sprite_y = sprite.character.y
      if sprite_x > (screen_x - $game_system.adjust) and sprite_x < (screen_x + 17 + $game_system.adjust) and sprite_y > (screen_y - $game_system.adjust) and sprite_y < (screen_y + 13 + $game_system.adjust)
        sprite.update
      end
    end
    for ally in @allies_sprites.compact
      if ally.character.destroy and !ally.disposed?
        ally.dispose
        $game_allies.delete(ally.character)
        @allies_sprites.delete(ally)
      elsif !ally.disposed?
        ally.update if $game_map.in_range?(ally.character)
      end
    end
    for monster in @monsters_sprites.compact
      if monster.character.destroy and !monster.character.respawn and !monster.disposed?
        monster.dispose
        $game_monsters.delete(monster.character)
        @monsters_sprites.delete(monster)
      elsif !monster.disposed?
        monster.update if $game_map.in_range?(monster.character)
      end
    end
    for range in @range_sprites.compact
      if range.character.destroy and !range.disposed?
        range.dispose
        $game_range.delete(range.character)
        @range_sprites.delete(range)
      elsif !range.disposed?
        range.update if $game_map.in_range?(range.character)
      end
    end
    for drop in @drop_sprites.compact
      if drop.character.destroy and !drop.disposed?
        drop.update
        drop.character.character_name = ""
        unless drop.animation?
          drop.dispose
          $game_drop.delete(drop.character)
          $game_bomb.delete(drop.character)
          @drop_sprites.delete(drop)
        end
      elsif !drop.disposed?
        drop.update if $game_map.in_range?(drop.character)
      end
    end
    for ally in $game_allies.compact
      next if ally.draw
      @allies_sprites.push(Sprite_Character.new(@viewport1, ally))
      @weapon_sprites.push(Sprite_Weapon.new(@viewport1, ally))
      @shield_sprites.push(Sprite_Shield.new(@viewport1 ,ally))
      ally.draw = true
    end
    for range in $game_range.compact
      next unless $game_map.in_range?(range)
      next if range.draw
      @range_sprites.push(Sprite_Character.new(@viewport1, range))
      range.draw = true
    end
    for drop in $game_drop.compact
      next unless $game_map.in_range?(drop)
      next if drop.draw
      @drop_sprites.push(Sprite_Drop.new(@viewport1, drop))
      drop.draw = true
    end
    for bomb in $game_bomb.compact
      next unless $game_map.in_range?(bomb)
      next if bomb.draw
      @drop_sprites.push(Sprite_Drop.new(@viewport1, bomb))
      bomb.draw = true
    end
    for weapon in @weapon_sprites.compact
      next unless $game_map.in_range?(weapon.character)
      weapon.update
    end
    for shield in @shield_sprites.compact
      next unless $game_map.in_range?(shield.character)
      shield.update
    end
    for shadow in @shadow_floor.compact
      next unless $game_map.in_range?(shadow.character)
      shadow.update
    end
  end
 
end
#==============================================================================
class Game_Event < Game_Character
  attr_reader   :name
  alias initialize_just_antilag initialize
  def initialize(map_id, event)
    initialize_just_antilag(map_id, event)
    @name = @event.name
  end
end
#============================================
class Game_System
attr_accessor :adjust
alias initialize_adjust initialize unless $@
 def initialize
  initialize_adjust
  @adjust = ADJUST
 end
end
« Last Edit: December 30, 2011, 12:35:23 AM by modern algebra »

**
Rep: +0/-0Level 75
RMRK Junior

**
Rep: +0/-0Level 75
RMRK Junior
Everything solved:
Code: [Select]
class Game_Event < Game_Character
 
  attr_reader  :always_update
 
  unless method_defined?(:refresh_ILC_alwaysUpdateSetPerEventPage)
    alias_method(:refresh_ILC_alwaysUpdateSetPerEventPage, :refresh)
  end
  def refresh
    last_page = @page
    refresh_ILC_alwaysUpdateSetPerEventPage
    if @page != last_page
      @always_update = @event.name == "update" ? true : (@list == nil) ? false :
            @list.any?{ |c| c.code == 108 and c.parameters[0] == "update page" }
    end
  end
end
 
#==============================================================================
class Game_Map
#==============================================================================
  def update_events
    s_oben = (@display_y >> 8) - $game_system.adjust
    s_unten = (@display_y >> 8) + (Graphics.height >> 5) + $game_system.adjust
    s_links = (@display_x >> 8) - $game_system.adjust
    s_rechts = (@display_x >> 8) + (Graphics.width >> 5) + $game_system.adjust
    @events.each_value do |event|
      if event.always_update or (event.x.between?(s_links, s_rechts) and
                                 event.y.between?(s_oben, s_unten))
        event.update
      end
    end
    @common_events.each_value do |common_event|
      common_event.update
    end
  end 
end