查看: 3619|回复: 7

[已经过期] 求教「进入区域时显示信息」脚本如何添加这么的一个效果..

[复制链接]
梦石
0
星屑
29901
在线时间
5734 小时
注册时间
2016-3-8
回帖
1653
发表于 2020-12-13 21:38:17 | 显示全部楼层 |阅读模式

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

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

×
脚本现在的效果是这样子:
进入A区域->显示信息->离开A区域->进入A区域->不显示信息

我想要这么的一个效果:
进入A区域->显示信息->离开A区域->进入A区域->显示信息

研究了很久的
@region_changed
@last_region
region_id
region_changed?
表示虽然看得懂原文那部分的逻辑...
但我要的效果的逻辑是要怎样弄却不懂了...

[pre lang="ruby"]#==============================================================================

# ** 区域名称

# Author: Hime

# Version: 1.1

# Date: May 5, 2012

#------------------------------------------------------------------------------

# ** Change log

# 1.1

#   -created a custom region window

#   -now shows the party leader by default

# 1.0 May 5, 2012

#   -initial release

#------------------------------------------------------------------------------

# 本脚本会自动追踪玩家所处的区域(通过区域id),当玩家进入新区域时显示一个信息

# 提示

#

# 使用方法,使用地图备注:

#    <region names>

#       1: 区域名称

#       2: 区域名称

#       10: 区域名称

#    </region names>

#

# 请将“区域名称”替换为其他文字

#------------------------------------------------------------------------------

# 本脚本和yanfly的“区域战斗背景”兼容,在下面设定。

#==============================================================================

$imported = {} if $imported.nil?



module Tsuki

  module Region_Names

    #进入新区域时显示的信息前半部分

    Entrance_Message = "已进入: "

   

    #你是否使用了 yanfly 闲谈窗口?

    Use_Gab = true

  end

end



module Tsuki

  module Regex

    module Map

      Region_Names_On = /<(?:REGION_NAMES|region names)>/i

      Region_Names_Off = /<\/(?:REGION_NAMES|region names)>/i

      Region_Names_ID = /(\d+):[ ](.*)/i

    end

  end

end



class RPG::Map

  attr_accessor :region_names

  

  def load_notetags_region_names

    @region_names = {}

    @region_battlebacks_on = false

    self.note.split(/[\r\n]+/).each do |line|

      case line

      when Tsuki::Regex::Map::Region_Names_On

        @region_names_on = true

      when Tsuki::Regex::Map::Region_Names_Off

        

        @region_names_on = false

      when Tsuki::Regex::Map::Region_Names_ID

        next unless @region_names_on

        rid = $1.to_i

        @region_names[rid] = "" if @region_names[rid].nil?

        @region_names[rid] = $2.to_s

      end

    end

  end

end



class Game_Map

  

  alias tsuki_regionNames_setup setup

  def setup(map_id)

    tsuki_regionNames_setup(map_id)

    @map.load_notetags_region_names

  end

  

  def region_names

    return @map.region_names

  end

   

  def region_name

    name = region_names[$game_player.region_id]

    return name if name else ""

  end

end



class Game_Player < Game_Character

  

  #attr_reader :last_region

  alias tsuki_regionNames_initialize initialize

  def initialize

    tsuki_regionNames_initialize

    @last_region = 0

    @region_changed = false

  end

  

  alias tsuki_regionNames_update update

  def update

    tsuki_regionNames_update

    @region_changed = @last_region != region_id && region_id != 0

    @last_region = region_id if region_id != 0

  end

  

  def region_changed?

    @region_changed

  end

end



class Scene_Map < Scene_Base

  

  alias tsuki_regionName_update_scene update_scene

  def update_scene

    tsuki_regionName_update_scene

    update_region_change unless scene_changing?

  end

  

  def update_region_change

    if $game_player.region_changed?

      message = Tsuki::Region_Names::Entrance_Message + $game_map.region_name

      if $imported["YEA-GabWindow"] && Tsuki::Region_Names::Use_Gab

        Game_Interpreter.new.gab(message, 0)

      else

        @region_name_window.open(message)

      end

    end

  end

  

  alias tsuki_regionName_create_all_windows create_all_windows

  def create_all_windows

    tsuki_regionName_create_all_windows

    create_region_location_window

  end

  

  #--------------------------------------------------------------------------

  # * Create Region Name Window

  #--------------------------------------------------------------------------

  def create_region_location_window

    @region_name_window = Window_RegionName.new

  end

end



#==============================================================================

# ** Window_RegionName

#------------------------------------------------------------------------------

#  This window displays the region name on the map.

#==============================================================================



class Window_RegionName < Window_Base

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    super(300, 0, window_width, fitting_height(1))

    self.opacity = 0

    self.contents_opacity = 0

    @show_count = 0

    refresh

  end

  #--------------------------------------------------------------------------

  # * Get Window Width

  #--------------------------------------------------------------------------

  def window_width

    return 240

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    super

    if @show_count > 0 && $game_map.name_display

      update_fadein

      @show_count -= 1

    else

      update_fadeout

    end

  end

  #--------------------------------------------------------------------------

  # * Update Fadein

  #--------------------------------------------------------------------------

  def update_fadein

    self.contents_opacity += 16

  end

  #--------------------------------------------------------------------------

  # * Update Fadeout

  #--------------------------------------------------------------------------

  def update_fadeout

    self.contents_opacity -= 16

  end

  #--------------------------------------------------------------------------

  # * Open Window

  #--------------------------------------------------------------------------

  def open(name)

    refresh(name)

    @show_count = 150

    self.contents_opacity = 0

    self

  end

  #--------------------------------------------------------------------------

  # * Close Window

  #--------------------------------------------------------------------------

  def close

    @show_count = 0

    self

  end

  #--------------------------------------------------------------------------

  # * Refresh

  #--------------------------------------------------------------------------

  def refresh(name="")

    contents.clear

    unless name.empty? || @show_count == 150

      draw_background(contents.rect)

      draw_text(contents.rect, name, 1)

    end

  end

  #--------------------------------------------------------------------------

  # * Draw Background

  #--------------------------------------------------------------------------

  def draw_background(rect)

    temp_rect = rect.clone

    temp_rect.width /= 2

    contents.gradient_fill_rect(temp_rect, back_color2, back_color1)

    temp_rect.x = temp_rect.width

    contents.gradient_fill_rect(temp_rect, back_color1, back_color2)

  end

  #--------------------------------------------------------------------------

  # * Get Background Color 1

  #--------------------------------------------------------------------------

  def back_color1

    Color.new(0, 0, 0, 192)

  end

  #--------------------------------------------------------------------------

  # * Get Background Color 2

  #--------------------------------------------------------------------------

  def back_color2

    Color.new(0, 0, 0, 0)

  end

end[/pre]

评分

参与人数 1星屑 +300 收起 理由
fux2 + 300 退回

查看全部评分

梦石
0
星屑
29901
在线时间
5734 小时
注册时间
2016-3-8
回帖
1653
 楼主| 发表于 2020-12-13 21:58:48 | 显示全部楼层
啊这...
原来是因为我把Use_Gab设成了true的关系...
设成false就解决问题了...
@fux2 申请退回悬赏星屑

点评

已经过期?已经解決才是吧...  发表于 2020-12-15 22:42
回复

使用道具 举报

梦石
0
星屑
1107
在线时间
126 小时
注册时间
2020-11-27
回帖
48
发表于 2021-2-23 12:16:06 | 显示全部楼层
我来!
  1. #==============================================================================
  2. # +++ MOG - 事件感应范围 (v1.0) +++
  3. #==============================================================================
  4. # By Moghunter
  5. # https://atelierrgss.wordpress.com/
  6. #==============================================================================
  7. # 在角色接近事件时可以让事件做出不同的动作。
  8. #===============================================================================
  9. # - 使用方式
  10. # 在可以感应角色的事件的事件页中新建一个事件页,并设定出现条件为"独立开关D"
  11. # 开启时。该事件页就会在角色进入事件感应范围时被触发。
  12. #
  13. # 事件名中添加:
  14. #
  15. # <SensorX>
  16. #
  17. # X = 感应的范围
  18. #
  19. #===============================================================================
  20. module MOG_EVENT_SENSOR
  21.   #当角色进入事件感应范围时,触发事件的独立开关.
  22.   SENSOR_SELF_SWITCH = "D"
  23. end

  24. #===============================================================================
  25. # ■ GAME EVENT
  26. #===============================================================================
  27. class Game_Event < Game_Character
  28.   
  29.   attr_reader   :sensor_range
  30.   
  31.   #--------------------------------------------------------------------------
  32.   # ● Initialize
  33.   #--------------------------------------------------------------------------            
  34.   alias mog_event_sensor_initialize initialize
  35.   def initialize(map_id, event)
  36.       mog_event_sensor_initialize(map_id, event)
  37.       setup_event_sensor
  38.   end
  39.   
  40.   #--------------------------------------------------------------------------
  41.   # ● Setup Event Sensor
  42.   #--------------------------------------------------------------------------         
  43.   def setup_event_sensor
  44.       @sensor_range =  @event.name =~ /<Sensor(\d+)>/ ? $1.to_i : 0
  45.   end  
  46.   
  47.   #--------------------------------------------------------------------------
  48.   # ● Update
  49.   #--------------------------------------------------------------------------            
  50.   alias mog_event_sensor_update update
  51.   def update
  52.       mog_event_sensor_update
  53.       update_event_sensor
  54.   end  
  55.   
  56.   #--------------------------------------------------------------------------
  57.   # ● Update Sensor
  58.   #--------------------------------------------------------------------------        
  59.   def update_event_sensor
  60.       return if @sensor_range == 0
  61.       distance = ($game_player.x - self.x).abs + ($game_player.y - self.y).abs
  62.       enable   = (distance <= @sensor_range)
  63.       key = [$game_map.map_id, self.id, MOG_EVENT_SENSOR::SENSOR_SELF_SWITCH]
  64.       last_enable = $game_self_switches[key]
  65.       execute_sensor_effect(enable,key) if enable != last_enable
  66.     end

  67.   #--------------------------------------------------------------------------
  68.   # ● Execute_Sensor Effect
  69.   #--------------------------------------------------------------------------            
  70.   def execute_sensor_effect(enable,key)      
  71.       @pattern = 0 ; @pattern_count = 0               
  72.       $game_self_switches[key] = enable ;  self.refresh
  73.   end
  74.    
  75. end

  76. $mog_rgss3_event_sensor = true
复制代码
回复

使用道具 举报

梦石
0
星屑
29901
在线时间
5734 小时
注册时间
2016-3-8
回帖
1653
 楼主| 发表于 2021-2-23 12:24:01 | 显示全部楼层
本帖最后由 alexncf125 于 2021-2-23 12:27 编辑


你来什么个来...
没看到问题经已解決了么...

再说你这回答的脚本能解決问题?
我看不到能解決~因为问题不涉及事件, 你丟个"事件感应范围"脚本上来, 明显完全没作用
回复

使用道具 举报

老鹰

梦石
40
星屑
37812
在线时间
7091 小时
注册时间
2012-5-26
回帖
3297

极短24评委极短23参与极短22参与极短21评委老司机慢点开短篇十吟唱者组别冠军开拓者剧作品鉴家

发表于 2021-2-23 15:49:34 | 显示全部楼层
大概只要把 209行 的@last_region = region_id if region_id != 0 条件限制去掉

因为只有进入新区域时,才刷新存储已显示的区域
这样就导致反复进出某一个区域时,提示信息只会显示第一次

所以只要进入空区域也能刷新文字就行?
回复

使用道具 举报

梦石
0
星屑
1107
在线时间
126 小时
注册时间
2020-11-27
回帖
48
发表于 2021-2-23 15:53:56 | 显示全部楼层
alexncf125 发表于 2021-2-23 12:24
你来什么个来...
没看到问题经已解決了么...

法克如
回复

使用道具 举报

梦石
0
星屑
29901
在线时间
5734 小时
注册时间
2016-3-8
回帖
1653
 楼主| 发表于 2021-2-23 17:50:26 | 显示全部楼层
本帖最后由 alexncf125 于 2021-2-23 17:59 编辑
百里_飞柳 发表于 2021-2-23 15:49
大概只要把 209行 的@last_region = region_id if region_id != 0 条件限制去掉

因为只有进入新区域时,才 ...


怎么连大佬您也来回复...
我明明都已经说了两遍"问题经已自行解決"啦...

可能是因为我没贴出解決方法, 所以你们以为还未解決

那么我最后再说一次好了...
1.把Use_Gab设成false
2.@last_region = region_id if region_id != 0 的 0 改成 @last_region
3.message = Tsuki::Region_Names::Entrance_Message + $game_map.region_name上方加句return if $game_map.region_name.empty?
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部