查看: 4927|回复: 4

[已经过期] va防卡脚本

[复制链接]
梦石
0
星屑
60
在线时间
95 小时
注册时间
2014-10-26
回帖
55
发表于 2015-8-24 00:00:53 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
va防卡脚本
梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2015-8-24 00:27:47 | 显示全部楼层
[fold]
  1. #===============================================================================
  2. # TheoAllen - Insane Anti Lag
  3. # Version : 1.1
  4. # Language : English
  5. #-------------------------------------------------------------------------------
  6. # With help from following people :
  7. # - Tsukihime
  8. # - KilloZapit
  9. # - Galv
  10. #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  11. # Contact :
  12. #-------------------------------------------------------------------------------
  13. # *> http://www.rpgmakerid.com
  14. # *> http://www.rpgmakervxace.net
  15. # *> http://www.theolized.com
  16. #===============================================================================
  17. ($imported ||= {})[:Theo_AntiLag] = true
  18. #===============================================================================
  19. # Change Logs:
  20. # ------------------------------------------------------------------------------
  21. # 2015.02.20 - Added page check enhancer to work with parallel process
  22. # 2015.01.25 - Compatibility with Shaz's Mouse Script. def events_xy now should
  23. #              always return array,
  24. #            - Avoid error 'undefined method delete_sprite for nilClass'
  25. # 2015.01.01 - Avoid unexpected error 'undefined method spriteset for scene'
  26. # 2014.12.05 - Finished
  27. #===============================================================================
  28. =begin

  29.   ------------------------------------------
  30.   *) Introduction :
  31.   ------------------------------------------
  32.   As most of you already know, lag is common problem in RPG Maker games. You may
  33.   started to think it was because you have many events on map. And so, to avoid
  34.   lag, you split your map into part and limiting the event as well.

  35.   It's not entirely wrong because when you have a lot of events, program need
  36.   to checks all events. However, it wasn't done efficienly. This script
  37.   increase the efficiency on how default script works and prevent unecessary
  38.   update when it's not needed to gain speed.
  39.    
  40.   However, I can not guarantee that it will have high compatibility since I
  41.   overwrite most of stuff. I will likely to make compatibility with my own
  42.   scripts. But I'm not sure about someone's script.
  43.   
  44.   ------------------------------------------
  45.   *) How to use :
  46.   ------------------------------------------
  47.   Put this script below material but above main. And it's recommended to put
  48.   this above most of custom script.
  49.   
  50.   Set the type of optimization that you like in config
  51.   You may disable some kind of optimization if you have compatibility issues
  52.   
  53.   ------------------------------------------
  54.   *) Terms of use :
  55.   ------------------------------------------
  56.   Credit me, TheoAllen. You are free to edit this script by your own. As long
  57.   as you don't claim it's yours. For commercial purpose, don't forget to give me
  58.   a free copy of the game.
  59.   
  60.   Additional people to put in credit credit list are listed in header above.
  61.   You should give them a free copy of your game as well if it's commercial ;)
  62.   
  63. =end
  64. #==============================================================================
  65. # Configurations :
  66. #==============================================================================
  67. module Theo
  68.   module AntiLag
  69.    
  70.   #=============================================================================
  71.   # *) Normal optimization
  72.   #-----------------------------------------------------------------------------
  73.   # This kind of optimization is for normal usage. These optimization may works
  74.   # only if the total events on map is around 200 - 300.
  75.   #=============================================================================
  76.   
  77.   #-----------------------------------------------------------------------------
  78.     Optimize_XY     = true
  79.   #-----------------------------------------------------------------------------
  80.   # By default, event position checking is to check ALL the events on the map.
  81.   # If you want to check an event is in x,y position, it ask EVERY event if
  82.   # their position is match. By using this optimization, all events registered
  83.   # to the map table so that the engine won't check all events on map. Instead,
  84.   # it checks if there's event on a certain table.
  85.   #
  86.   # This kind of optimization is recommended to set it to true. However, it may
  87.   # not compatible with any pixel movement since they using box collider instead
  88.   # of using grid.
  89.   #-----------------------------------------------------------------------------
  90.   
  91.   #-----------------------------------------------------------------------------
  92.     Optimize_Event  = true
  93.   #-----------------------------------------------------------------------------
  94.   # By default, if the engine want to check if there's event starting, they
  95.   # checked ALL the events on map. They did it in every frame. If you have 200
  96.   # events in map, they checked 60 x 200 events per second.
  97.   #
  98.   # By using this optimization, if event is triggered, it will be registered
  99.   # into a record. And then engine checked if there is event on the record
  100.   #-----------------------------------------------------------------------------
  101.   
  102.   #-----------------------------------------------------------------------------
  103.     Optimize_Sprite = true
  104.   #-----------------------------------------------------------------------------
  105.   # By default, the engine still update every sprites which located off screen.
  106.   # This might waste the time since updating it is not necessary sometimes. By
  107.   # using this optimization, it ignores character sprite that already off screen
  108.   #-----------------------------------------------------------------------------
  109.    
  110.   #=============================================================================
  111.   # *) Insane optimization
  112.   #-----------------------------------------------------------------------------
  113.   # This kind of optimization is to overcome the problem of using event beyond
  114.   # 230 on the map which normal optimization is failed to do. This optimization
  115.   # uses insane algorithm like table search and dispose any unecessary sprite on
  116.   # the fly.
  117.   #=============================================================================
  118.    
  119.   #-----------------------------------------------------------------------------
  120.     Table_Limit_Search = 230
  121.   #-----------------------------------------------------------------------------
  122.   # Table search is a custom algorithm to grab events based on the map table.
  123.   # Instead of iterating all events and checked them if they're on the screen,
  124.   # it checked the visible map table instead. So, event that located far away
  125.   # from the player won't be updated. But any parallel process or autorun events
  126.   # or move route for an event will still updated.
  127.   #
  128.   # Table limit search means that if the total of events on map is above the
  129.   # limit, this script will switch event update algorithm to table search. So
  130.   # you will not worrying about having 999 or even 10.000 events on map.
  131.   #
  132.   # Table search required Optimize_XY to set to true.
  133.   #
  134.   # If you don't want to use table search algorithm, just put the parameter
  135.   # to nil.
  136.   #-----------------------------------------------------------------------------
  137.   
  138.   #-----------------------------------------------------------------------------
  139.     Table_Range_Search = 2
  140.   #-----------------------------------------------------------------------------
  141.   # This determine how far table search will perform check. Putting 3 means that
  142.   # it will update the event that located 3 tiles away from the screen.
  143.   #
  144.   # Keep in mind that the longer range search will affect the performance as
  145.   # well. It's recommended to put it between 2 - 4
  146.   #-----------------------------------------------------------------------------
  147.   
  148.   #-----------------------------------------------------------------------------
  149.     Dispose_Sprite  = true
  150.   #-----------------------------------------------------------------------------
  151.   # Sometimes, limiting the events which is being updated is not enough. Sprite
  152.   # objects is still being performace killer. Disposing sprite which is already
  153.   # off screen will greatly affect the performance. This kind of optimization
  154.   # is enabled only if the table search is used.
  155.   #
  156.   # Disposing sprite on the fly might be problematic sometimes. When something
  157.   # wrong happened, you can disable dispose sprite be setting this to false.
  158.   #-----------------------------------------------------------------------------
  159.   
  160.   #-----------------------------------------------------------------------------
  161.     PageCheck_Enchancer = true
  162.   #-----------------------------------------------------------------------------
  163.   # When a lot of events put together in one map, and each has 20 pages, and
  164.   # you have parallel process to change the variable or switches, you will see
  165.   # noticable lag.
  166.   #
  167.   # This kind of enhancer only refresh the visible events on the screen or when
  168.   # the event is on the visible range. So that it prevents to refresh all events
  169.   # This concept is a fool proof to the player since they will never know what
  170.   # is in their visible range
  171.   #
  172.   # However, this may ruin some system since this concept is still experimental.
  173.   #-----------------------------------------------------------------------------
  174.   
  175.   end
  176. end

  177. #===============================================================================
  178. # *) Final note :
  179. #-------------------------------------------------------------------------------
  180. # After all, these are just my attempt to speed up the game. Performance are
  181. # still under influence by many factors. These include but may not limited to
  182. #
  183. # - Your CPU speed
  184. # - Your laptop / PC temperature
  185. # - How much power do you give for your CPU
  186. # - Multi tasking
  187. # - Someone's script
  188. #
  189. # I once used RM in old computer. When I switched to more advanced laptop, I
  190. # saw that 60 FPS is really smooth.
  191. #
  192. # If your CPU seems overheat, turn off your laptop / PC for a while for cooling.
  193. # My laptop was once overheat due to broken fan. When I played my own game I
  194. # got 10 FPS. I made my own antilag and no one of them worked until I realized
  195. # my laptop was overheat.
  196. #
  197. # Power saver mode in laptop may affect performance. Try to go high performance
  198. # instead and let see if the lag gone. Once my friend played my game using power
  199. # saver mode, and he got 15 FPS.
  200. #
  201. # If you have many programs running at same time, it may cause a little lag in
  202. # RPG Maker games. Something like the screen won't be updated for a while.
  203. #
  204. # Some scripts can affect performance if it's not done right. This antilag
  205. # script is tested using default script without additional scripts which
  206. # directly affect something on map.
  207. #
  208. #-------------------------------------------------------------------------------
  209. # *) Below this line is sacred place to visit. Unless you have enough skill,
  210. # do not try to enter or any risk is yours.
  211. #===============================================================================

  212. #===============================================================================
  213. # ** MapTable
  214. #-------------------------------------------------------------------------------
  215. #  This class used to register the event into 2D table to increase performance
  216. #===============================================================================

  217. class MapTable
  218.   #-----------------------------------------------------------------------------
  219.   # * Initialize
  220.   #-----------------------------------------------------------------------------
  221.   def initialize
  222.     @table = []
  223.     ($game_map.width + 1).times do |x|
  224.       @table[x] = []
  225.       ($game_map.height + 1).times do |y|
  226.         @table[x][y] = []
  227.       end
  228.     end
  229.   end
  230.   #-----------------------------------------------------------------------------
  231.   # * Set value
  232.   #-----------------------------------------------------------------------------
  233.   def set(x,y,val)
  234.     @table[x][y] << val
  235.   end
  236.   #-----------------------------------------------------------------------------
  237.   # * Get array
  238.   #-----------------------------------------------------------------------------
  239.   def get(x,y)
  240.     @table[x][y]
  241.   end
  242.   
  243. end

  244. #===============================================================================
  245. # ** Array
  246. #===============================================================================

  247. class Array
  248.   
  249.   # Just a fool proof
  250.   def values
  251.     return self
  252.   end
  253.   
  254. end

  255. #===============================================================================
  256. # ** Game_Map
  257. #===============================================================================

  258. class Game_Map
  259.   #-----------------------------------------------------------------------------
  260.   # * Public attributes
  261.   #-----------------------------------------------------------------------------
  262.   attr_accessor :event_redirect     # Redirect events
  263.   attr_reader :forced_update_events # To keep force move route updated
  264.   attr_reader :keep_update_events   # To keep parallel process updated
  265.   attr_reader :cached_events        # To store event that need to be updated
  266.   attr_reader :starting_events      # To store activated event
  267.   attr_reader :table                # 2D Map table
  268.   #-----------------------------------------------------------------------------
  269.   # * Constant
  270.   #-----------------------------------------------------------------------------
  271.   EVENT_LIMIT = Theo::AntiLag::Table_Limit_Search
  272.   RANGE = Theo::AntiLag::Table_Range_Search
  273.   #-----------------------------------------------------------------------------
  274.   # * Alias method : Setup Events
  275.   #-----------------------------------------------------------------------------
  276.   alias theo_antilag_setup_events setup_events
  277.   def setup_events
  278.     @table = MapTable.new
  279.     @forced_update_events = []
  280.     @keep_update_events = []
  281.     @starting_events = []
  282.     @refreshed_events = []
  283.     theo_antilag_setup_events
  284.     select_on_screen_events
  285.   end
  286.   #-----------------------------------------------------------------------------
  287.   # * Overwrite method : Events
  288.   #-----------------------------------------------------------------------------
  289.   def events
  290.     @event_redirect ? @cached_events : @events
  291.   end
  292. #///////////////////////////////////////////////////////////////////////////////
  293.   if Theo::AntiLag::Optimize_XY
  294. #///////////////////////////////////////////////////////////////////////////////
  295.   #-----------------------------------------------------------------------------
  296.   # * Overwrite method : Event XY
  297.   #-----------------------------------------------------------------------------
  298.   def events_xy(x, y)
  299.     @table.get(x,y) || []
  300.   end
  301.   #-----------------------------------------------------------------------------
  302.   # * Overwrite method : Event XY nt
  303.   #-----------------------------------------------------------------------------
  304.   def events_xy_nt(x, y)
  305.     @table.get(x,y).select do |event|
  306.       event.pos_nt?(x, y)
  307.     end
  308.   end
  309. #///////////////////////////////////////////////////////////////////////////////
  310.   end
  311. #///////////////////////////////////////////////////////////////////////////////
  312.   if Theo::AntiLag::Optimize_Event
  313. #///////////////////////////////////////////////////////////////////////////////
  314.   #-----------------------------------------------------------------------------
  315.   # * Overwrite method : Setup starting event
  316.   #-----------------------------------------------------------------------------
  317.   def setup_starting_map_event
  318.     event = @starting_events[0]
  319.     event.clear_starting_flag if event
  320.     @interpreter.setup(event.list, event.id) if event
  321.     event
  322.   end
  323.   #-----------------------------------------------------------------------------
  324.   # * Overwrite method : Any event starting?
  325.   #-----------------------------------------------------------------------------
  326.   def any_event_starting?
  327.     !@starting_events.empty?
  328.   end
  329. #///////////////////////////////////////////////////////////////////////////////
  330.   end
  331. #///////////////////////////////////////////////////////////////////////////////
  332.   #-----------------------------------------------------------------------------
  333.   # * Overwrite method : Refresh
  334.   #-----------------------------------------------------------------------------
  335.   def refresh
  336.     return table_refresh if table_update? && Theo::AntiLag::PageCheck_Enchancer
  337.     @events.each_value {|event| next if event.never_refresh; event.refresh }
  338.     @common_events.each {|event| event.refresh }
  339.     refresh_tile_events
  340.     @need_refresh = false
  341.   end
  342.   #-----------------------------------------------------------------------------
  343.   # * New method : Refresh event by table search
  344.   #-----------------------------------------------------------------------------
  345.   def table_refresh
  346.     @refreshed_events = []
  347.     @tile_events = []
  348.     @common_events.each {|event| event.refresh }
  349.     @need_refresh = false
  350.   end
  351.   #-----------------------------------------------------------------------------
  352.   # * Overwrite method : Update events
  353.   #-----------------------------------------------------------------------------
  354.   def update_events
  355.     last_events = (@cached_events.dup rescue @events.values)
  356.     select_on_screen_events
  357.     events = @cached_events | @keep_update_events | @forced_update_events
  358.     if Theo::AntiLag::Dispose_Sprite
  359.       offscreen_events = last_events - events
  360.       offscreen_events.each {|event| event.delete_sprite}
  361.     end
  362.     events.each {|event| event.update}
  363.     @common_events.each {|event| event.update}
  364.   end
  365.   #-----------------------------------------------------------------------------
  366.   # * New method : Select on screen events
  367.   #-----------------------------------------------------------------------------
  368.   def select_on_screen_events
  369.     unless table_update?
  370.       @cached_events = @events.values
  371.       return
  372.     end
  373.     #---------------------------------------------------------------------------
  374.     # * Table search algorithm
  375.     #---------------------------------------------------------------------------
  376.     new_dpx = display_x.to_i
  377.     new_dpy = display_y.to_i
  378.     dpx = loop_horizontal? ? new_dpx - RANGE : [new_dpx - RANGE, 0].max
  379.     dpy = loop_vertical? ? new_dpy - RANGE : [new_dpy - RANGE, 0].max
  380.     sw = (Graphics.width >> 5) + RANGE * 2
  381.     sh = (Graphics.height >> 5) + RANGE * 2
  382.     @cached_events = []
  383.     sw.times do |x|
  384.       sh.times do |y|
  385.         xpos = loop_horizontal? ? (x + dpx) % width : x + dpx
  386.         ypos = loop_vertical? ? (y + dpy) % height : y + dpy
  387.         next if xpos >= width || ypos >= height
  388.         ary = @table.get(xpos, ypos)
  389.         ary.each do |ev|
  390.           unless @refreshed_events.include?(ev.id)
  391.             ev.refresh
  392.             @tile_events << ev if ev.tile?
  393.             @refreshed_events << ev.id
  394.           end
  395.         end if Theo::AntiLag::PageCheck_Enchancer
  396.         @cached_events += ary
  397.       end
  398.     end
  399.     @cached_events.uniq!
  400.   end
  401.   #-----------------------------------------------------------------------------
  402.   # * Check if table search need to be performed or not
  403.   #-----------------------------------------------------------------------------
  404.   def table_update?
  405.     EVENT_LIMIT && @events.size > EVENT_LIMIT && Theo::AntiLag::Optimize_XY
  406.   end
  407.   
  408. end

  409. #===============================================================================
  410. # ** Game_Temp
  411. #===============================================================================

  412. class Game_Temp
  413.   attr_reader :event_sprites
  414.   #-----------------------------------------------------------------------------
  415.   # * Alias method : Initialize
  416.   #-----------------------------------------------------------------------------
  417.   alias theo_antilag_init initialize
  418.   def initialize
  419.     theo_antilag_init
  420.     @event_sprites = {}
  421.   end
  422.   
  423. end

  424. #===============================================================================
  425. # ** Game_CharacterBase
  426. #===============================================================================

  427. class Game_CharacterBase
  428.   #-----------------------------------------------------------------------------
  429.   # * Empty method : Sprite
  430.   #-----------------------------------------------------------------------------
  431.   def sprite
  432.     return nil
  433.   end
  434.   #-----------------------------------------------------------------------------
  435.   # * Empty method : Sprite =
  436.   #-----------------------------------------------------------------------------
  437.   def sprite=(spr)
  438.   end
  439.   
  440. end

  441. #===============================================================================
  442. # ** Game_Event
  443. #===============================================================================

  444. class Game_Event
  445.   #-----------------------------------------------------------------------------
  446.   # * Never refesh flag
  447.   #-----------------------------------------------------------------------------
  448.   attr_reader :never_refresh
  449.   #-----------------------------------------------------------------------------
  450.   # * Alias method : Initialize
  451.   #-----------------------------------------------------------------------------
  452.   alias theo_antilag_init initialize
  453.   def initialize(map_id, event)
  454.     theo_antilag_init(map_id, event)
  455.     $game_map.table.set(x,y,self)
  456.     @last_x = @x
  457.     @last_y = @y
  458.   end
  459.   #-----------------------------------------------------------------------------
  460.   # * Alias method : Update
  461.   #-----------------------------------------------------------------------------
  462.   alias theo_antilag_update update
  463.   def update
  464.     if (sprite && sprite.disposed?) || sprite.nil?
  465.       spriteset = SceneManager.scene.spriteset
  466.       return unless spriteset
  467.       spriteset.add_sprite(self)
  468.     end
  469.     theo_antilag_update
  470.     if Theo::AntiLag::Optimize_XY && (@last_x != @x || @last_y != @y)
  471.       $game_map.table.get(@last_x, @last_y).delete(self)
  472.       $game_map.table.set(@x,@y,self)
  473.       @last_x = @x
  474.       @last_y = @y
  475.     end
  476.   end
  477.   #-----------------------------------------------------------------------------
  478.   # * Alias method : Start
  479.   #-----------------------------------------------------------------------------
  480.   alias theo_antilag_start start
  481.   def start
  482.     theo_antilag_start
  483.     return unless Theo::AntiLag::Optimize_Event
  484.     $game_map.starting_events << self if @starting
  485.   end
  486.   #-----------------------------------------------------------------------------
  487.   # * Alias method : Clear starting flag
  488.   #-----------------------------------------------------------------------------
  489.   alias theo_antilag_clear_start clear_starting_flag
  490.   def clear_starting_flag
  491.     theo_antilag_clear_start
  492.     return unless Theo::AntiLag::Optimize_Event
  493.     $game_map.starting_events.delete(self)
  494.   end
  495.   #-----------------------------------------------------------------------------
  496.   # * Alias method : Setup page setting
  497.   #-----------------------------------------------------------------------------
  498.   alias theo_antilag_setup_page_settings setup_page_settings
  499.   def setup_page_settings
  500.     theo_antilag_setup_page_settings
  501.     if @event.pages.size == 1 && no_condition?(@event.pages[0].condition)
  502.       @never_refresh = true
  503.     end
  504.     if @trigger == 3 || @interpreter
  505.       $game_map.keep_update_events << self
  506.       $game_map.keep_update_events.uniq!
  507.     else
  508.       $game_map.keep_update_events.delete(self)
  509.     end
  510.   end
  511.   #-----------------------------------------------------------------------------
  512.   # * Check if the events has no page condition
  513.   #-----------------------------------------------------------------------------
  514.   def no_condition?(page)
  515.     !page.switch1_valid && !page.switch2_valid && !page.variable_valid &&
  516.       !page.self_switch_valid && !page.item_valid && !page.actor_valid
  517.   end
  518.   #-----------------------------------------------------------------------------
  519.   # * Delete sprite
  520.   #-----------------------------------------------------------------------------
  521.   def delete_sprite
  522.     sprset = SceneManager.scene.spriteset
  523.     return unless sprset
  524.     SceneManager.scene.spriteset.delete_sprite(sprite)
  525.   end
  526.   #-----------------------------------------------------------------------------
  527.   # * Overwrite method : Force move route
  528.   #-----------------------------------------------------------------------------
  529.   def force_move_route(move_route)
  530.     super
  531.     $game_map.forced_update_events << self
  532.     $game_map.forced_update_events.uniq!
  533.   end
  534.   #-----------------------------------------------------------------------------
  535.   # * Overwrite method : Restore move route
  536.   #-----------------------------------------------------------------------------
  537.   def restore_move_route
  538.     super
  539.     $game_map.forced_update_events.delete(self)
  540.   end
  541.   #-----------------------------------------------------------------------------
  542.   # * Overwrite method : Sprite
  543.   #-----------------------------------------------------------------------------
  544.   def sprite
  545.     $game_temp.event_sprites[@id]
  546.   end
  547.   #-----------------------------------------------------------------------------
  548.   # * Overwrite method : Sprite =
  549.   #-----------------------------------------------------------------------------
  550.   def sprite=(spr)
  551.     $game_temp.event_sprites[@id] = spr
  552.   end
  553.   
  554. end

  555. #===============================================================================
  556. # ** Sprite Character
  557. #===============================================================================

  558. class Sprite_Character
  559.   #-----------------------------------------------------------------------------
  560.   # * Alias method : Initialize
  561.   #-----------------------------------------------------------------------------
  562.   alias theo_antilag_init initialize
  563.   def initialize(viewport, character = nil)
  564.     character.sprite = self if character
  565.     theo_antilag_init(viewport, character)
  566.   end
  567.   #-----------------------------------------------------------------------------
  568.   # * Alias method : Update
  569.   #-----------------------------------------------------------------------------
  570.   alias theo_antilag_update update
  571.   def update
  572.     @sx = @character.screen_x
  573.     @sy = @character.screen_y
  574.     if Theo::AntiLag::Optimize_Sprite && !need_update?
  575.       self.visible = false
  576.       return
  577.     end  
  578.     theo_antilag_update
  579.   end
  580.   #-----------------------------------------------------------------------------
  581.   # * New method : Determine if on screen
  582.   #-----------------------------------------------------------------------------
  583.   def need_update?
  584.     return true if graphic_changed?
  585.     return true if @character.animation_id > 0
  586.     return true if @balloon_sprite
  587.     return true if @character.balloon_id != 0
  588.     w = Graphics.width
  589.     h = Graphics.height
  590.     cw = @cw || 32
  591.     ch = @ch || 32
  592.     @sx.between?(-cw,w+cw) && @sy.between?(0,h+ch)
  593.   end
  594.   #-----------------------------------------------------------------------------
  595.   # * Overwrite update position.
  596.   # To limit screen_x and screen_y to be called many times
  597.   #-----------------------------------------------------------------------------
  598.   def update_position
  599.     move_animation(@sx - x, @sy - y)
  600.     self.x = @sx
  601.     self.y = @sy
  602.     self.z = @character.screen_z
  603.   end
  604.   #-----------------------------------------------------------------------------
  605.   # * Overwrite animation origin
  606.   # Since X and Y axis of sprite is not updated when off screen
  607.   #-----------------------------------------------------------------------------
  608.   def set_animation_origin
  609.     if @animation.position == 3
  610.       if viewport == nil
  611.         @ani_ox = Graphics.width / 2
  612.         @ani_oy = Graphics.height / 2
  613.       else
  614.         @ani_ox = viewport.rect.width / 2
  615.         @ani_oy = viewport.rect.height / 2
  616.       end
  617.     else
  618.       @ani_ox = @sx - ox + width / 2
  619.       @ani_oy = @sy - oy + height / 2
  620.       if @animation.position == 0
  621.         @ani_oy -= height / 2
  622.       elsif @animation.position == 2
  623.         @ani_oy += height / 2
  624.       end
  625.     end
  626.   end
  627.   
  628. end

  629. #===============================================================================
  630. # ** Spriteset_Map
  631. #===============================================================================

  632. class Spriteset_Map
  633.   #-----------------------------------------------------------------------------
  634.   # * Alias method : create character
  635.   #-----------------------------------------------------------------------------
  636.   alias theo_antilag_create_characters create_characters
  637.   def create_characters
  638.     $game_map.event_redirect = Theo::AntiLag::Dispose_Sprite
  639.     theo_antilag_create_characters
  640.     $game_map.event_redirect = false
  641.   end
  642.   #-----------------------------------------------------------------------------
  643.   # * New method : delete sprite
  644.   #-----------------------------------------------------------------------------
  645.   def delete_sprite(spr)
  646.     return unless spr
  647.     return if spr.disposed?
  648.     @character_sprites.delete(spr)
  649.     spr.dispose
  650.   end
  651.   #-----------------------------------------------------------------------------
  652.   # * New method : add sprite
  653.   #-----------------------------------------------------------------------------
  654.   def add_sprite(char)
  655.     spr = Sprite_Character.new(@viewport1, char)
  656.     @character_sprites.push(spr)
  657.   end
  658.   
  659. end

  660. #===============================================================================
  661. # ** Scene_Base
  662. #===============================================================================

  663. class Scene_Base
  664.   attr_reader :spriteset
  665. end
复制代码
[/fold]

点评

真是普渡众生。  发表于 2015-8-24 09:13
回复

使用道具 举报

梦石
0
星屑
60
在线时间
95 小时
注册时间
2014-10-26
回帖
55
 楼主| 发表于 2015-8-24 22:06:11 | 显示全部楼层
tseyik 发表于 2015-8-24 00:27
[fold][/fold]

放上去并没有什么用,游戏还是卡的很
回复

使用道具 举报

梦石
0
星屑
5241
在线时间
760 小时
注册时间
2009-1-21
回帖
236
发表于 2015-8-24 22:14:52 | 显示全部楼层
本帖最后由 御之嵐 于 2015-8-24 22:29 编辑

試試看 YAMI的Simple Anti-lag Event 吧

因為禁止轉載
所以你得自己找找看了

官網腳本的網址似乎掛了

===================================
MOG - Simple Anti Lag
http://atelier-rgss.com/RGSS/System/ACE_SYS09.html
回复

使用道具 举报

梦石
1
星屑
23236
在线时间
9564 小时
注册时间
2012-6-19
回帖
7018

开拓者短篇九导演组冠军

发表于 2015-8-24 22:20:37 | 显示全部楼层
wwwxuanye 发表于 2015-8-24 22:06
放上去并没有什么用,游戏还是卡的很

这个脚本所做的是通过提升代码的效率来在一定程度上解决地图太大事件太多导致的游戏卡顿(实际上,大部分防卡脚本都是这么做的),正如脚本180行最后的注释所写的,以下情况造成的游戏卡顿是脚本解决不了的:
# - CPU速度
# - 电脑温度
# - CPU供电
# - 同时运行了太多其他程序
# - 其他人的脚本

点评

代码和注释都在上面了好骑个头自己去看啊,一般事件造成的卡顿主要是地图太大事件太多导致的  发表于 2015-8-26 00:33
很好奇这个”提升代码的效率“是怎么提升?在我看来与其找防卡脚本,还不如优化自己的事件,真有一些优化不了的,直接用脚本来解决才是王道  发表于 2015-8-26 00:09
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部