Project1

标题: 【求解】这脚本的效率怎么了? [打印本页]

作者: 杂兵天下    时间: 2012-2-10 14:45
标题: 【求解】这脚本的效率怎么了?
本帖最后由 杂兵天下 于 2012-2-10 14:46 编辑
  1. #==============================================================================
  2. # ★ RGSS3_視界制限 Ver1.0
  3. #==============================================================================
  4. =begin

  5. 作者:tomoaky
  6. 作者个人网站:(http://hikimoki.sakura.ne.jp/)

  7. 可以设定烛光范围

  8. 状态、職業、武器(防具)、角色放入<视界补正 32>这类标签
  9. 例)<视界补正 32>
  10. 視界会增加32。
  11. 必须有图像:
  12.   Graphics/System/sight_shadow.png
  13.   
  14. 2012.01.20  Ver1.0
  15.   公開

  16. =end

  17. module TMBLSIGHT
  18.   # 例)SIGHT[3] = 128  # 地图3的视界是128
  19.   SIGHT = {}
  20.   SIGHT[4] = 256
  21. end
  22. class RPG::BaseItem
  23.   def sight_power
  24.     unless @sight_power
  25.       @sight_power = /<视界补正\s*(\-*\d+)\s*>/ =~ @note ? $1.to_i : 0
  26.     end
  27.     @sight_power
  28.   end
  29. end
  30. class Game_Actor
  31.   def sight_power
  32.     result = 0
  33.     p feature_objects
  34.     feature_objects.each {|object| result += object.sight_power}
  35.     result
  36.   end
  37. end
  38. class Sprite_SightShadow < Sprite
  39.   def initialize(viewport = nil)
  40.     super(viewport)
  41.     self.z = 200
  42.     self.bitmap = Bitmap.new(Graphics.width, Graphics.height)
  43.     @bitmap_shadow = Bitmap.new("Graphics/System/sight_shadow")
  44.   end
  45.   def dispose
  46.     self.bitmap.dispose
  47.     @bitmap_shadow.dispose
  48.     super
  49.   end
  50.   def update
  51.     super
  52.     dq=TMBLSIGHT::SIGHT[$game_map.map_id]
  53.     if $game_switches[8]==true
  54.       dq=512 unless dq
  55.     else
  56.       dq=0
  57.     end
  58.     if dq==0
  59.       self.visible = false
  60.     else
  61.       self.visible = true
  62.       self.bitmap.clear
  63.       w = TMBLSIGHT::SIGHT[$game_map.map_id]
  64.       $game_party.battle_members.each{|actor| w = [w + actor.sight_power, 48].max}
  65.       x = $game_player.screen_x - w / 2
  66.       y = $game_player.screen_y - w / 2 - 16
  67.       rect = Rect.new(x, y, w, w)
  68.       self.bitmap.stretch_blt(rect, @bitmap_shadow, @bitmap_shadow.rect)
  69.       color = Color.new(0, 0, 0)
  70.       self.bitmap.fill_rect(0, 0, Graphics.width, y, color)
  71.       self.bitmap.fill_rect(0, y + w, Graphics.width, Graphics.height - y - w, color)
  72.       self.bitmap.fill_rect(0, y, x, w, color)
  73.       self.bitmap.fill_rect(x + w, y, Graphics.width - x - w, w, color)
  74.     end
  75.   end
  76. end
  77. class Spriteset_Map
  78.   alias tmblsight_spriteset_map_initialize initialize
  79.   def initialize
  80.     @sight_shadow_sprite = Sprite_SightShadow.new
  81.     tmblsight_spriteset_map_initialize
  82.   end
  83.   alias tmblsight_spriteset_map_dispose dispose
  84.   def dispose
  85.     tmblsight_spriteset_map_dispose
  86.     @sight_shadow_sprite.dispose
  87.   end
  88.   alias tmblsight_spriteset_map_update update
  89.   def update
  90.     @sight_shadow_sprite.update
  91.     tmblsight_spriteset_map_update
  92.   end
  93. end
复制代码
额其实这脚本已经被修改了一处。
这是日本的烛光系统,只要打开8号开关,FPS就暴跌。。。
另外:一个BUG,按下F1时,地图会整个显示




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