#==============================================================================
# ★ RGSS3_视界制限 Ver1.1
#==============================================================================
=begin
作者:tomoaky
首发网站:ひきも记 (http://hikimoki.sakura.ne.jp/)
设定号码的地图限制视野。
写在角色,职业,是在武器(防护具)的备注中的标签
能补正视野限制的尺寸。
例)<视界补正 32>
视界32点扩大広。
只有战斗成员进行视野补正价值的计算。
游戏变量(默认情况下,#9),可以调整大小使用视图领域。
加入上述所有设置,将获得的实际大小限制的能见度。
然而,如果尚未设置能见度限制的地图上都是无效的。
因为每帧都会重绘整个屏幕的Sprite
将会有所加重。
操作所需的图像
Graphics/System/sight_shadow.png
游戏变量使用(默认设置)
0009
2012.02.05 Ver1.1
・调整Z坐标使计时器使不被遮住
・加使用游戏变量补正视野限制尺寸的功能(通过变量可做成开/関效果)
2012.01.20 Ver1.0
公开
=end
#==============================================================================
# □ 设定项目
#==============================================================================
module TMBLSIGHT
# 指定几号的地图进行视界制限
# 例)SIGHT[3] = 128 # 设置地图号码3的视野能见度128点矩形
SIGHT = {}
SIGHT[1] = 128
VN_SIGHT = 1 # 设定尺寸大小补正在游戏中使用的游戏变量
end
#==============================================================================
# □ RPG::BaseItem
#==============================================================================
class RPG::BaseItem
#--------------------------------------------------------------------------
# ○ 视界制限补正値
#--------------------------------------------------------------------------
def sight_power
unless @sight_power
@sight_power = /<视界补正\s*(\-*\d+)\s*>/ =~ @note ? $1.to_i : 0
end
@sight_power
end
end
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor
#--------------------------------------------------------------------------
# ○ 视界制限补正値
#--------------------------------------------------------------------------
def sight_power
result = 0
feature_objects.each {|object| result += object.sight_power}
result
end
end
#==============================================================================
# □ Sprite_SightShadow
#==============================================================================
class Sprite_SightShadow < Sprite
#--------------------------------------------------------------------------
# ● 物件初期化
#--------------------------------------------------------------------------
def initialize(viewport = nil)
super(viewport)
self.z = 199
self.bitmap = Bitmap.new(Graphics.width, Graphics.height)
@bitmap_shadow = Bitmap.new("Graphics/System/sight_shadow")
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
def dispose
self.bitmap.dispose
@bitmap_shadow.dispose
super
end
#--------------------------------------------------------------------------
# ● 帧更新
#--------------------------------------------------------------------------
def update
super
if TMBLSIGHT::SIGHT[$game_map.map_id]
self.visible = true
self.bitmap.clear
w = TMBLSIGHT::SIGHT[$game_map.map_id]
$game_party.battle_members.each{|actor| w = [w + actor.sight_power, 48].max}
w = [w + $game_variables[TMBLSIGHT::VN_SIGHT], 48].max
x = $game_player.screen_x - w / 2
y = $game_player.screen_y - w / 2 - 16
rect = Rect.new(x, y, w, w)
self.bitmap.stretch_blt(rect, @bitmap_shadow, @bitmap_shadow.rect)
color = Color.new(0, 0, 0)
self.bitmap.fill_rect(0, 0, Graphics.width, y, color)
self.bitmap.fill_rect(0, y + w, Graphics.width, Graphics.height - y - w,
color)
self.bitmap.fill_rect(0, y, x, w, color)
self.bitmap.fill_rect(x + w, y, Graphics.width - x - w, w, color)
else
self.visible = false
end
end
end
#==============================================================================
# ■ Spriteset_Map
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# ● 物件初期化
#--------------------------------------------------------------------------
alias tmblsight_spriteset_map_initialize initialize
def initialize
tmblsight_spriteset_map_initialize
create_sight_shadow
end
#--------------------------------------------------------------------------
# ○ 作成视界制限Sprite
#--------------------------------------------------------------------------
def create_sight_shadow
@sight_shadow_sprite = Sprite_SightShadow.new(@viewport2)
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
alias tmblsight_spriteset_map_dispose dispose
def dispose
tmblsight_spriteset_map_dispose
dispose_sight_shadow
end
#--------------------------------------------------------------------------
# ○ 解放视界制限Sprites
#--------------------------------------------------------------------------
def dispose_sight_shadow
@sight_shadow_sprite.dispose
end
#--------------------------------------------------------------------------
# ● 帧更新
#--------------------------------------------------------------------------
alias tmblsight_spriteset_map_update update
def update
update_sight_shadow
tmblsight_spriteset_map_update
end
#--------------------------------------------------------------------------
# ○ 更新视界制限Sprites
#--------------------------------------------------------------------------
def update_sight_shadow
@sight_shadow_sprite.update if @sight_shadow_sprite
end
end
mask.png (40.29 KB, 下载次数: 32)
module TMBLSIGHT # 指定几号的地图进行视界制限 # 例)SIGHT[3] = 128 # 设置地图号码3的视野能见度128点矩形 SIGHT = {} SIGHT[1] = 128 SIGHT[2] = 128 SIGHT[3] = 128 VN_SIGHT = 1 # 设定尺寸大小补正在游戏中使用的游戏变量 end
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |