Project1
标题:
有没有关于区域不可见的脚本?
[打印本页]
作者:
tianmazhuohui11
时间:
2019-3-30 23:59
标题:
有没有关于区域不可见的脚本?
就比如说在你进入这个房间前,这个房间是显示黑色的,你必须要进入后在能看见房间内的区域?以前有一个这个脚本,后来换电脑就没了。希望哪位大大帮我找一下
作者:
Nil2018
时间:
2019-3-31 02:23
#==============================================================================
# TheoAllen - 不可见区域
# Version : 1.1
# Language : Informal Indonesian
# 需要脚本 : 基础模块 v1.5 - 基础功能
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Contact :
#------------------------------------------------------------------------------
# *> http://www.rpgmakerid.com
# *> http://www.rpgmakervxace.net
# *> http://www.theolized.com
#==============================================================================
($imported ||= {})[:Theo_InvisRegion] = true
# =============================================================================
# Change Logs:
# -----------------------------------------------------------------------------
# 2015.08.01 - Added always visible region
# 2014.11.22 - Finished script
# =============================================================================
=begin
================
*) 介绍 :
----------------
本脚本可以根据玩家所处的位置,只显示其所在的区域,隐藏其他区域,有类似进入
房间而看不见房间外地图的效果。
=====================
*) 使用方法 :
---------------------
将本脚本放在插件脚本和基础模块之下,Main之上
地图备注:
<invisreg>
然后你需要在地图上为同一房间绘制相同ID的区域。例如,当玩家进入1号区域时,其他
ID的区域和没有区域设定的地方就会被隐藏。当玩家进入无区域设定的地方时,有区域
设定的地方会被隐藏。
事件始终可见的事件注释:
<visible>
----------
更新 1.1
可以设定:当玩家不在某区域时,仍然显示该区域。使用地图备注 <visireg: n>
'n'替换为区域ID。
===================
*) 使用条款 :
署名脚本作者, TheoAllen. 你可以自由编辑此脚本,只要你不声明你是脚本的原作者
如果你想用此脚本于商业游戏,请和我共享收益.别忘了给我一份免费的游戏拷贝.
=end
#===============================================================================
# 无设定
#===============================================================================
#===============================================================================
# ** TileMask
#-------------------------------------------------------------------------------
# Sprite that same size as the map size. It's also scrolled alongside the map
# if it's updated. It can be used to draw anything on map. In this script, it
# used to manually draw "Fog of War" on map screen.
#===============================================================================
class TileMask < Plane_Mask
#-----------------------------------------------------------------------------
# * Initialize
#-----------------------------------------------------------------------------
def initialize(vport)
@region_id = $game_player.region_id
super
end
#-----------------------------------------------------------------------------
# * Update
#-----------------------------------------------------------------------------
def update
super
update_invisible if refresh_case
end
#-----------------------------------------------------------------------------
# * Update bitmap
#-----------------------------------------------------------------------------
def update_bitmap
super
update_invisible
end
#-----------------------------------------------------------------------------
# * Update Invisible
#-----------------------------------------------------------------------------
def update_invisible
@region_id = $game_player.region_id
unless $game_map.invisible_region?
bitmap.clear
return
end
bitmap.entire_fill(Color.new(0,0,0,220)) #在这里设定隐藏部分的颜色、不透明度
($game_map.visiregs + [@region_id]).each do |visireg|
$game_map.regions[visireg].each do |pos|
x = pos[0] * 32
y = pos[1] * 32
bitmap.clear_rect(x,y,32,32)
end
end
end
#-----------------------------------------------------------------------------
# * Refresh case
#-----------------------------------------------------------------------------
def refresh_case
if $game_map.refresh_tilemask
$game_map.refresh_tilemask = false
return true
end
@region_id != $game_player.region_id
end
end
#===============================================================================
# ** Game_Map
#===============================================================================
class Game_Map
#-----------------------------------------------------------------------------
# * Public Attributes
#-----------------------------------------------------------------------------
attr_accessor :refresh_tilemask
attr_reader :regions
attr_reader :visiregs
#-----------------------------------------------------------------------------
# * Setup
#-----------------------------------------------------------------------------
alias theo_invistile_setup setup
def setup(map_id)
theo_invistile_setup(map_id)
record_regions
@refresh_tilemask
end
#-----------------------------------------------------------------------------
# * Record / pre-cache regions
#-----------------------------------------------------------------------------
def record_regions
@regions = {}
width.times do |w|
height.times do |h|
regid = region_id(w,h)
(@regions[regid] ||= []) << [w,h]
end
end
@visiregs = []
@map.note.split(/[\r\n]+/).each do |line|
if line =~ /<visireg\s*:\s*(\d+)>/i
@visiregs << $1.to_i
end
end
end
#-----------------------------------------------------------------------------
# * Invisible region?
#-----------------------------------------------------------------------------
def invisible_region?
@map.note[/<invisreg>/i]
end
end
#===============================================================================
# ** Game_Character
#===============================================================================
class Game_Character
#-----------------------------------------------------------------------------
# * Opacity
#-----------------------------------------------------------------------------
def opacity
return @opacity unless $game_map.invisible_region?
return 0 if region_id != $game_player.region_id
return @opacity
end
end
#===============================================================================
# ** Game_Player
#===============================================================================
class Game_Player
#-----------------------------------------------------------------------------
# * Opacity
#-----------------------------------------------------------------------------
def opacity
return @opacity
end
end
#===============================================================================
# ** Game_Event
#===============================================================================
class Game_Event
#-----------------------------------------------------------------------------
# * Stay Visible?
#-----------------------------------------------------------------------------
def stay_visible?
if @last_list != @list
@last_list = @list
return false unless @list
@stay_visible = false
@list.each do |command|
next unless [108,408].include?(command.code)
@stay_visible = true if command.parameters[0] =~ /<visible>/i
end
end
return @stay_visible
end
#-----------------------------------------------------------------------------
# * Opacity
#-----------------------------------------------------------------------------
def opacity
return @opacity if stay_visible? || !$game_map.invisible_region? ||
$game_map.visiregs.include?(region_id)
return 0 if region_id != $game_player.region_id
return @opacity
end
#-----------------------------------------------------------------------------
# * Screen Z value
#-----------------------------------------------------------------------------
def screen_z
return 25 if stay_visible? && region_id != $game_player.region_id
return super
end
end
#===============================================================================
# ** Spriteset_Map
#===============================================================================
class Spriteset_Map
#-----------------------------------------------------------------------------
# * Create Viewports
#-----------------------------------------------------------------------------
alias theo_invistile_create_vport create_viewports
def create_viewports
theo_invistile_create_vport
@tilemask = TileMask.new(@viewport1)
@tilemask.z = 50
end
#-----------------------------------------------------------------------------
# * Update
#-----------------------------------------------------------------------------
alias theo_invistile_update update
def update
theo_invistile_update
@tilemask.update
end
#-----------------------------------------------------------------------------
# * Dispose
#-----------------------------------------------------------------------------
alias theo_invistile_dispose dispose
def dispose
theo_invistile_dispose
@tilemask.dispose
end
end
复制代码
作者:
tianmazhuohui11
时间:
2019-3-31 03:34
有没有别的?这个好复杂...
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1