Ergebnis 1 bis 4 von 4

Thema: Probleme mit der Kompatibilität zwischen einzelnen Scripten

  1. #1

    Nibel Gast

    Probleme mit der Kompatibilität zwischen einzelnen Scripten

    Hallo Community,

    nun, ich arbeite seit geraumer Zeit mit dem RMXP und bin fasziniert von den vielen neuen Möglichkeiten. Eine ist die Option Mode7 zu aktivieren.

    Ich benutze das NeoMode 7 Script (besteht aus ca. 5 Teilen) und dann hab ich noch ein weitverbreitetes SDK und ein "Extra Move Speed" Script.

    Auf etwas größeren Maps mit vielen Grafiken, die durch das Mode7 Script "hingestellt" werden, kommt es dann doch zu sehr unschönen Framerate-Einbrüchen. Also dachte ich mir, dass ein Anti-Lag Script helfen würde. Ich habe dieses hier ausprobiert:

    Code:
    #===============================================================================
    # ** AntiLag Script
    #-------------------------------------------------------------------------------
    # f0tz!baerchen
    # 0.71
    # 06.01.2007
    #-------------------------------------------------------------------------------
    # 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 that the CPU utilization
    #   gets higher than $antilag.max_cpu_utilization it will slow down the game and
    #   reduce the framerate as long as needed.
    #-------------------------------------------------------------------------------
    # Settings: 
    # can be changed anytime during the game. They are found at the end of the 
    # script.
    #===============================================================================
    #===============================================================================
    # Class for Antilag Settings
    #===============================================================================
    class Antilag_Settings
      
      attr_accessor :event
      attr_accessor :max_cpu_utilization
      attr_accessor :cpu_tolerance
      #-----------------------------------------------------------------------------
      # initializes default settings
      #-----------------------------------------------------------------------------
      def initialize
        @event = true
        @high_priority = true
        @max_cpu_utilization = 100
        @cpu_tolerance = 20
        @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_Map class
    #===============================================================================
    class Scene_Map
      #-----------------------------------------------------------------------------
      # update method, smooth antilag has been added
      #-----------------------------------------------------------------------------
      alias f0tzis_anti_lag_scene_map_update update
      def update
        f0tzis_anti_lag_scene_map_update
        if Graphics.frame_count % 20 == 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, 40].min
          end
        end
      end
    end
    #==============================================================================
    # Game_Event Class
    #===============================================================================
    class Game_Event
      #-----------------------------------------------------------------------------
      # for AntiLag, decides, if an event is on the screen or not.
      #-----------------------------------------------------------------------------
      def in_range?
            
        # returns true if $event_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.event 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 false if @real_x <= screne_x
        return false if @real_x >= screne_width
        return false if @real_y <= screne_y
        return false if @real_y >= screne_height
        return true
                
      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
    #===============================================================================
    # Settings
    #===============================================================================
    $antilag.max_cpu_utilization = 70 # the maximum CPU utilization, the script
                                      # try to stay under this value during changing
                                      # changing the frame rate. The lower this
                                      # value the higher will be the lag reduction
                                      # (and the smoothness, too), a value > 100
                                      # will disable this feature completely
    $antilag.cpu_tolerance = 20       # this value tells the script how many % of
                                      # the CPU utilization change should be ignored
                                      # If you change it too a higher value you,
                                      # your Frame Rate will be more constant but
                                      # smaller lags will be ignored.
    $antilag.high_priority = true     # set this to true if you want the game to run 
                                      # on high priority
    $antilag.event = true             # set this to true to enable normal anti-lag
    #===============================================================================
    # Interpreter Class
    #===============================================================================
    class Interpreter
      #-----------------------------------------------------------------------------
      # * Script
      #-----------------------------------------------------------------------------
      def command_355
        # Set first line to script
        script = @list[@index].parameters[0] + "\n"
        # Loop
        loop do
          # If next event command is second line of script or after
          if @list[@index+1].code == 655
            # Add second line or after to script
            script += @list[@index+1].parameters[0] + "\n"
          # If event command is not second line or after
          else
            # Abort loop
            break
          end
          # Advance index
          @index += 1
        end
        # Evaluation
        result = eval(script)
        #---------------------------------------------------------------------------
        # If return value is false 
        # NEW: the last word of the code mustnt be false!
        #---------------------------------------------------------------------------
        if result == false and script[script.length-6..script.length-2] != 'false'
          # End
          return false
        end
        # Continue
        return true
      end
    end
    Und wie durch ein Wunder ist der Lag verschwunden. Jedoch hat sich durch die Benutzung des Scriptes schlagartig die Geschwindigkeit des Helden verlangsamt. Ich vermute, dass dies mit dem "Extra Move Speed"-Script zusammenhängt, jedoch bin ich mir nicht ganz sicher.. hier nochmal das genannte Script:

    Code:
    #==============================================================================
    # ** Move and Animation Speed
    #------------------------------------------------------------------------------
    # Author    S.S Muu
    # Version   1.0
    # Date      01-04-09 (dd-mm-yy)
    #==============================================================================
    
    #==============================================================================
    # ** Game_Character
    #==============================================================================
    
    class Game_Character
      #--------------------------------------------------------------------------
      # * Frame Update
      #--------------------------------------------------------------------------
      def update
        # Branch with jumping, moving, and stopping
        if jumping?
          update_jump
        elsif moving?
          update_move
        else
          update_stop
        end
        # If animation count exceeds maximum value
        # * Maximum value is move speed * 1 taken from basic value 18
        @animation_speed = 0 if @animation_speed.nil?
        if @anime_count > (18 - @move_speed * 2) + @animation_speed
          # If stop animation is OFF when stopping
          if not @step_anime and @stop_count > 0
            # Return to original pattern
            @pattern = @original_pattern
          # If stop animation is ON when moving
          else
            # Update pattern
            @pattern = (@pattern + 1) % 4
          end
          # Clear animation count
          @anime_count = 0
        end
        # If waiting
        if @wait_count > 0
          # Reduce wait count
          @wait_count -= 1
          return
        end
        # If move route is forced
        if @move_route_forcing
          # Custom move
          move_type_custom
          return
        end
        # When waiting for event execution or locked
        if @starting or lock?
          # Not moving by self
          return
        end
        # If stop count exceeds a certain value (computed from move frequency)
        if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
          # Branch by move type
          case @move_type
          when 1  # Random
            move_type_random
          when 2  # Approach
            move_type_toward_player
          when 3  # Custom
            move_type_custom
          end
        end
      end
    end
    
    
    #==============================================================================
    # ** Game_Event
    #==============================================================================
    
    class Game_Event < Game_Character  
      #--------------------------------------------------------------------------
      # * Refresh
      #--------------------------------------------------------------------------
      alias ss_muus_edited_refresh refresh
      
      def refresh
        ss_muus_edited_refresh
        return if @page == nil
        for i in @page.list
          if i.code == 108 or i.code == 408
            if i.parameters[0].upcase[/MOVESPEED:(.*)/] != nil
              @move_speed = $1.to_i
            elsif i.parameters[0].upcase[/ANIMATIONSPEED:(.*)/] != nil
              @animation_speed = $1.to_i
            end
          end
        end
      end
    end
    Nun ist es sehr wichtig, dass ich den Lag unterdrücken kann und hoffe, dass mir jemand helfen kann..

    Zum Spiel selber: ich muss zugeben, dass es sich um ein sehr aufwendiges Shoot-Kampfsystem handelt mit allerlei Pictures und Events. Ich benutze viele Waits usw., und denke, dass auch eben das ganze komplexe KS evtl. Probleme verursachen könnte.. wenn mir jemand Tipps geben könnte worauf ich achten sollte um eine gute Performance zu erreichen, wäre ich sehr dankbar.

    Das Ganze sieht nämlich so aus.. natürlich unfertig, aber ich hoffe es reicht damit man sich ein Bild vom ganzen machen kann.

  2. #2
    Das Anti-Lag Script hat eine "Smooth Antilag - Funktion", die die Geschwindigkeit regelmäßig auf Werte zwischen 10 und 40 FPS anpasst um gröbere "Lags" zu verhindern.

    Wenn du in deinem Spiel eine höhere Framerate eingestellt hast (z.B. 60) wird diese also bei der ersten Korrektur auf 40 zurückgesetzt.
    Um dieses Freature im Spiel zu deaktivieren müsstest du im Anti-Lag-Script für

    @max_cpu_utilization[FONT=Helvetica Neue]

    [FONT=Arial]einen Wert von mehr als 100 einsetzen.

    Ansonsten wäre mir im geposteten Script nichts verdächtiges aufgefallen.[/FONT]
    [/FONT]

  3. #3

    Nibel Gast
    Yeah, es hat tatsächlich was gebracht, vielen Dank!

    Kann geschlossen werden

  4. #4

    Nibel Gast
    Da habe ich mich wohl etwas zu früh gefreut...

    Es scheint so, als ob das Anti-Lag Script nicht gerade viel Lag beseitigen kann und wie ich lese handelt es sich bei der Version, die ich nutze, um eine ziemlich alte Fassung.. nun, das Problem ist jedoch, dass jedes andere Anti-Lag Script mit NeoMode7 irgendwie inkompatibel ist.. weiß jemand Rat?

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •