Project1

标题: 让人无语的“防止事件过多卡机”脚本 [打印本页]

作者: 陆亚    时间: 2007-8-21 00:58
提示: 作者被禁止或删除 内容自动屏蔽
作者: 陆亚    时间: 2007-8-21 00:58
提示: 作者被禁止或删除 内容自动屏蔽
作者: 索尔迦·蓝    时间: 2007-8-21 01:57
提示: 作者被禁止或删除 内容自动屏蔽
作者: 精灵使者    时间: 2007-8-21 02:12
楼上正解。一些大的事件不能及时刷新,把范围扩大128像素左右就能够正常运行了。
我在我的游戏里面也发现了这种现象。于是我用了这个修正版本:

  1. #======================================
  2. # ■ Anti Event Lag Script
  3. #======================================
  4. #  By: Near Fantastica
  5. #   Date: 12.06.05
  6. #   Version: 3
  7. #======================================
  8. #======================================
  9. # ■ Game_Map
  10. #======================================

  11. class Game_Map
  12. #--------------------------------------------------------------------------
  13. def in_range?(object)
  14. screne_x = $game_map.display_x
  15. screne_x -= 256
  16. screne_y = $game_map.display_y
  17. screne_y -= 256
  18. screne_width = $game_map.display_x
  19. screne_width += 2816
  20. screne_height = $game_map.display_y
  21. screne_height += 2176
  22. return false if object.real_x <= screne_x - 128
  23. return false if object.real_x >= screne_width + 128
  24. return false if object.real_y <= screne_y - 128
  25. return false if object.real_y >= screne_height + 128
  26. return true
  27. end
  28. #--------------------------------------------------------------------------
  29. def update
  30. if $game_map.need_refresh
  31.   refresh
  32. end
  33. if @scroll_rest > 0
  34.   distance = 2 ** @scroll_speed
  35.   case @scroll_direction
  36.   when 2
  37.     scroll_down(distance)
  38.   when 4
  39.     scroll_left(distance)
  40.   when 6  
  41.     scroll_right(distance)
  42.   when 8  
  43.     scroll_up(distance)
  44.   end
  45.   @scroll_rest -= distance
  46. end
  47. for event in @events.values
  48.   if in_range?(event) or event.trigger == 3 or event.trigger == 4
  49.     event.update
  50.   end
  51. end
  52. for common_event in @common_events.values
  53.   common_event.update
  54. end
  55. @fog_ox -= @fog_sx / 8.0
  56. @fog_oy -= @fog_sy / 8.0
  57. if @fog_tone_duration >= 1
  58.   d = @fog_tone_duration
  59.   target = @fog_tone_target
  60.   @fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d
  61.   @fog_tone.green = (@fog_tone.green * (d - 1) + target.green) / d
  62.   @fog_tone.blue = (@fog_tone.blue * (d - 1) + target.blue) / d
  63.   @fog_tone.gray = (@fog_tone.gray * (d - 1) + target.gray) / d
  64.   @fog_tone_duration -= 1
  65. end
  66. if @fog_opacity_duration >= 1
  67.   d = @fog_opacity_duration
  68.   @fog_opacity = (@fog_opacity * (d - 1) + @fog_opacity_target) / d
  69.   @fog_opacity_duration -= 1
  70. end
  71. end
  72. end

  73. #======================================
  74. # ■ Spriteset_Map
  75. #======================================

  76. class Spriteset_Map
  77. #--------------------------------------------------------------------------
  78. def in_range?(object)
  79. screne_x = $game_map.display_x
  80. screne_x -= 256
  81. screne_y = $game_map.display_y
  82. screne_y -= 256
  83. screne_width = $game_map.display_x
  84. screne_width += 2816
  85. screne_height = $game_map.display_y
  86. screne_height += 2176
  87. return false if object.real_x <= screne_x - 128
  88. return false if object.real_x >= screne_width + 128
  89. return false if object.real_y <= screne_y - 128
  90. return false if object.real_y >= screne_height + 128
  91. return true
  92. end
  93. #--------------------------------------------------------------------------
  94. def update
  95. if @panorama_name != $game_map.panorama_name or
  96.    @panorama_hue != $game_map.panorama_hue
  97.   @panorama_name = $game_map.panorama_name
  98.   @panorama_hue = $game_map.panorama_hue
  99.   if @panorama.bitmap != nil
  100.     @panorama.bitmap.dispose
  101.     @panorama.bitmap = nil
  102.   end
  103.   if @panorama_name != ""
  104.     @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
  105.   end
  106.   Graphics.frame_reset
  107. end
  108. if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
  109.   @fog_name = $game_map.fog_name
  110.   @fog_hue = $game_map.fog_hue
  111.   if @fog.bitmap != nil
  112.     @fog.bitmap.dispose
  113.     @fog.bitmap = nil
  114.   end
  115.   if @fog_name != ""
  116.     @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
  117.   end
  118.   Graphics.frame_reset
  119. end
  120. @tilemap.ox = $game_map.display_x / 4
  121. @tilemap.oy = $game_map.display_y / 4
  122. @tilemap.update
  123. @panorama.ox = $game_map.display_x / 8
  124. @panorama.oy = $game_map.display_y / 8
  125. @fog.zoom_x = $game_map.fog_zoom / 100.0
  126. @fog.zoom_y = $game_map.fog_zoom / 100.0
  127. @fog.opacity = $game_map.fog_opacity
  128. @fog.blend_type = $game_map.fog_blend_type
  129. @fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
  130. @fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
  131. @fog.tone = $game_map.fog_tone
  132. i=0
  133. for sprite in @character_sprites
  134.   if sprite.character.is_a?(Game_Event)
  135.     if in_range?(sprite.character) or sprite.character.trigger == 3 or sprite.character.trigger == 4
  136.       sprite.update
  137.       i+=1
  138.     end
  139.   else
  140.     sprite.update
  141.     i+=1
  142.   end
  143. end
  144. #p i
  145. @weather.type = $game_screen.weather_type
  146. @weather.max = $game_screen.weather_max
  147. @weather.ox = $game_map.display_x / 4
  148. @weather.oy = $game_map.display_y / 4
  149. @weather.update
  150. for sprite in @picture_sprites
  151.   sprite.update
  152. end
  153. @timer_sprite.update
  154. @viewport1.tone = $game_screen.tone
  155. @viewport1.ox = $game_screen.shake
  156. @viewport3.color = $game_screen.flash_color
  157. @viewport1.update
  158. @viewport3.update
  159. end
  160. end
复制代码

作者: 陆亚    时间: 2007-8-21 02:16
提示: 作者被禁止或删除 内容自动屏蔽
作者: 精灵使者    时间: 2007-8-21 02:17
参考我的上边的脚本,和你的对比一下。
作者: 越前リョーマ    时间: 2007-8-21 02:17
试试精灵的脚本……
作者: 越前リョーマ    时间: 2007-8-21 02:20
好像效果不是很明显……
作者: 精灵使者    时间: 2007-8-21 02:29
那个马车如果还显示的话就改动128为更大的数目。但是提醒一句:数目越大越容易卡,所以你只要改动到最大的事件运行正常就行了。
作者: 陆亚    时间: 2007-8-21 02:43
提示: 作者被禁止或删除 内容自动屏蔽
作者: 精灵使者    时间: 2007-8-21 02:48
这个就在这两段前面加上if end判断就可以了。
if !$game_switches[开关号]
......
elae
return true
end
这样就可以了。
要注意只增加重要部分……
还要我帮你么?
作者: 陆亚    时间: 2007-8-21 03:10
提示: 作者被禁止或删除 内容自动屏蔽
作者: 精灵使者    时间: 2007-8-21 05:58

  1. #======================================
  2. # ■ Anti Event Lag Script
  3. #======================================
  4. #  By: Near Fantastica
  5. #   Date: 12.06.05
  6. #   Version: 3
  7. #======================================
  8. #======================================
  9. # ■ Game_Map
  10. #======================================

  11. class Game_Map
  12. $Switches = 25 #在这里设置开关,开关打开,事件脚本关闭。

  13. #--------------------------------------------------------------------------
  14. def in_range?(object)
  15. screne_x = $game_map.display_x
  16. screne_x -= 256
  17. screne_y = $game_map.display_y
  18. screne_y -= 256
  19. screne_width = $game_map.display_x
  20. screne_width += 2816
  21. screne_height = $game_map.display_y
  22. screne_height += 2176
  23. unless $game_switches[$Switches]
  24. return false if object.real_x <= screne_x - 128
  25. return false if object.real_x >= screne_width + 128
  26. return false if object.real_y <= screne_y - 128
  27. return false if object.real_y >= screne_height + 128
  28. end
  29. return true
  30. end
  31. #--------------------------------------------------------------------------
  32. def update
  33. if $game_map.need_refresh
  34.   refresh
  35. end
  36. if @scroll_rest > 0
  37.   distance = 2 ** @scroll_speed
  38.   case @scroll_direction
  39.   when 2
  40.     scroll_down(distance)
  41.   when 4
  42.     scroll_left(distance)
  43.   when 6  
  44.     scroll_right(distance)
  45.   when 8  
  46.     scroll_up(distance)
  47.   end
  48.   @scroll_rest -= distance
  49. end
  50. for event in @events.values
  51.   if in_range?(event) or event.trigger == 3 or event.trigger == 4
  52.     event.update
  53.   end
  54. end
  55. for common_event in @common_events.values
  56.   common_event.update
  57. end
  58. @fog_ox -= @fog_sx / 8.0
  59. @fog_oy -= @fog_sy / 8.0
  60. if @fog_tone_duration >= 1
  61.   d = @fog_tone_duration
  62.   target = @fog_tone_target
  63.   @fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d
  64.   @fog_tone.green = (@fog_tone.green * (d - 1) + target.green) / d
  65.   @fog_tone.blue = (@fog_tone.blue * (d - 1) + target.blue) / d
  66.   @fog_tone.gray = (@fog_tone.gray * (d - 1) + target.gray) / d
  67.   @fog_tone_duration -= 1
  68. end
  69. if @fog_opacity_duration >= 1
  70.   d = @fog_opacity_duration
  71.   @fog_opacity = (@fog_opacity * (d - 1) + @fog_opacity_target) / d
  72.   @fog_opacity_duration -= 1
  73. end
  74. end
  75. end

  76. #======================================
  77. # ■ Spriteset_Map
  78. #======================================

  79. class Spriteset_Map
  80. #--------------------------------------------------------------------------
  81. def in_range?(object)
  82. screne_x = $game_map.display_x
  83. screne_x -= 256
  84. screne_y = $game_map.display_y
  85. screne_y -= 256
  86. screne_width = $game_map.display_x
  87. screne_width += 2816
  88. screne_height = $game_map.display_y
  89. screne_height += 2176
  90. unless $game_switches[$Switches]
  91. return false if object.real_x <= screne_x - 128
  92. return false if object.real_x >= screne_width + 128
  93. return false if object.real_y <= screne_y - 128
  94. return false if object.real_y >= screne_height + 128
  95. end
  96. return true
  97. end
  98. #--------------------------------------------------------------------------
  99. def update
  100. if @panorama_name != $game_map.panorama_name or
  101.    @panorama_hue != $game_map.panorama_hue
  102.   @panorama_name = $game_map.panorama_name
  103.   @panorama_hue = $game_map.panorama_hue
  104.   if @panorama.bitmap != nil
  105.     @panorama.bitmap.dispose
  106.     @panorama.bitmap = nil
  107.   end
  108.   if @panorama_name != ""
  109.     @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
  110.   end
  111.   Graphics.frame_reset
  112. end
  113. if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue
  114.   @fog_name = $game_map.fog_name
  115.   @fog_hue = $game_map.fog_hue
  116.   if @fog.bitmap != nil
  117.     @fog.bitmap.dispose
  118.     @fog.bitmap = nil
  119.   end
  120.   if @fog_name != ""
  121.     @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)
  122.   end
  123.   Graphics.frame_reset
  124. end
  125. @tilemap.ox = $game_map.display_x / 4
  126. @tilemap.oy = $game_map.display_y / 4
  127. @tilemap.update
  128. @panorama.ox = $game_map.display_x / 8
  129. @panorama.oy = $game_map.display_y / 8
  130. @fog.zoom_x = $game_map.fog_zoom / 100.0
  131. @fog.zoom_y = $game_map.fog_zoom / 100.0
  132. @fog.opacity = $game_map.fog_opacity
  133. @fog.blend_type = $game_map.fog_blend_type
  134. @fog.ox = $game_map.display_x / 4 + $game_map.fog_ox
  135. @fog.oy = $game_map.display_y / 4 + $game_map.fog_oy
  136. @fog.tone = $game_map.fog_tone
  137. i=0
  138. for sprite in @character_sprites
  139.   if sprite.character.is_a?(Game_Event)
  140.     if in_range?(sprite.character) or sprite.character.trigger == 3 or sprite.character.trigger == 4
  141.       sprite.update
  142.       i+=1
  143.     end
  144.   else
  145.     sprite.update
  146.     i+=1
  147.   end
  148. end
  149. #p i
  150. @weather.type = $game_screen.weather_type
  151. @weather.max = $game_screen.weather_max
  152. @weather.ox = $game_map.display_x / 4
  153. @weather.oy = $game_map.display_y / 4
  154. @weather.update
  155. for sprite in @picture_sprites
  156.   sprite.update
  157. end
  158. @timer_sprite.update
  159. @viewport1.tone = $game_screen.tone
  160. @viewport1.ox = $game_screen.shake
  161. @viewport3.color = $game_screen.flash_color
  162. @viewport1.update
  163. @viewport3.update
  164. end
  165. end
复制代码

这个没有测试。请你自己在上面指定开关试试看看。 [LINE]1,#dddddd[/LINE]系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1