查看: 3738|回复: 7

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

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

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

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

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

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

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

  1. #==============================================================================

  2. # ** 区域名称

  3. # Author: Hime

  4. # Version: 1.1

  5. # Date: May 5, 2012

  6. #------------------------------------------------------------------------------

  7. # ** Change log

  8. # 1.1

  9. #   -created a custom region window

  10. #   -now shows the party leader by default

  11. # 1.0 May 5, 2012

  12. #   -initial release

  13. #------------------------------------------------------------------------------

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

  15. # 提示

  16. #

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

  18. #    <region names>

  19. #       1: 区域名称

  20. #       2: 区域名称

  21. #       10: 区域名称

  22. #    </region names>

  23. #

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

  25. #------------------------------------------------------------------------------

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

  27. #==============================================================================

  28. $imported = {} if $imported.nil?



  29. module Tsuki

  30.   module Region_Names

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

  32.     Entrance_Message = "已进入: "

  33.    

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

  35.     Use_Gab = true

  36.   end

  37. end



  38. module Tsuki

  39.   module Regex

  40.     module Map

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

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

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

  44.     end

  45.   end

  46. end



  47. class RPG::Map

  48.   attr_accessor :region_names

  49.   

  50.   def load_notetags_region_names

  51.     @region_names = {}

  52.     @region_battlebacks_on = false

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

  54.       case line

  55.       when Tsuki::Regex::Map::Region_Names_On

  56.         @region_names_on = true

  57.       when Tsuki::Regex::Map::Region_Names_Off

  58.         

  59.         @region_names_on = false

  60.       when Tsuki::Regex::Map::Region_Names_ID

  61.         next unless @region_names_on

  62.         rid = $1.to_i

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

  64.         @region_names[rid] = $2.to_s

  65.       end

  66.     end

  67.   end

  68. end



  69. class Game_Map

  70.   

  71.   alias tsuki_regionNames_setup setup

  72.   def setup(map_id)

  73.     tsuki_regionNames_setup(map_id)

  74.     @map.load_notetags_region_names

  75.   end

  76.   

  77.   def region_names

  78.     return @map.region_names

  79.   end

  80.    

  81.   def region_name

  82.     name = region_names[$game_player.region_id]

  83.     return name if name else ""

  84.   end

  85. end



  86. class Game_Player < Game_Character

  87.   

  88.   #attr_reader :last_region

  89.   alias tsuki_regionNames_initialize initialize

  90.   def initialize

  91.     tsuki_regionNames_initialize

  92.     @last_region = 0

  93.     @region_changed = false

  94.   end

  95.   

  96.   alias tsuki_regionNames_update update

  97.   def update

  98.     tsuki_regionNames_update

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

  100.     @last_region = region_id if region_id != 0

  101.   end

  102.   

  103.   def region_changed?

  104.     @region_changed

  105.   end

  106. end



  107. class Scene_Map < Scene_Base

  108.   

  109.   alias tsuki_regionName_update_scene update_scene

  110.   def update_scene

  111.     tsuki_regionName_update_scene

  112.     update_region_change unless scene_changing?

  113.   end

  114.   

  115.   def update_region_change

  116.     if $game_player.region_changed?

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

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

  119.         Game_Interpreter.new.gab(message, 0)

  120.       else

  121.         @region_name_window.open(message)

  122.       end

  123.     end

  124.   end

  125.   

  126.   alias tsuki_regionName_create_all_windows create_all_windows

  127.   def create_all_windows

  128.     tsuki_regionName_create_all_windows

  129.     create_region_location_window

  130.   end

  131.   

  132.   #--------------------------------------------------------------------------

  133.   # * Create Region Name Window

  134.   #--------------------------------------------------------------------------

  135.   def create_region_location_window

  136.     @region_name_window = Window_RegionName.new

  137.   end

  138. end



  139. #==============================================================================

  140. # ** Window_RegionName

  141. #------------------------------------------------------------------------------

  142. #  This window displays the region name on the map.

  143. #==============================================================================



  144. class Window_RegionName < Window_Base

  145.   #--------------------------------------------------------------------------

  146.   # * Object Initialization

  147.   #--------------------------------------------------------------------------

  148.   def initialize

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

  150.     self.opacity = 0

  151.     self.contents_opacity = 0

  152.     @show_count = 0

  153.     refresh

  154.   end

  155.   #--------------------------------------------------------------------------

  156.   # * Get Window Width

  157.   #--------------------------------------------------------------------------

  158.   def window_width

  159.     return 240

  160.   end

  161.   #--------------------------------------------------------------------------

  162.   # * Frame Update

  163.   #--------------------------------------------------------------------------

  164.   def update

  165.     super

  166.     if @show_count > 0 && $game_map.name_display

  167.       update_fadein

  168.       @show_count -= 1

  169.     else

  170.       update_fadeout

  171.     end

  172.   end

  173.   #--------------------------------------------------------------------------

  174.   # * Update Fadein

  175.   #--------------------------------------------------------------------------

  176.   def update_fadein

  177.     self.contents_opacity += 16

  178.   end

  179.   #--------------------------------------------------------------------------

  180.   # * Update Fadeout

  181.   #--------------------------------------------------------------------------

  182.   def update_fadeout

  183.     self.contents_opacity -= 16

  184.   end

  185.   #--------------------------------------------------------------------------

  186.   # * Open Window

  187.   #--------------------------------------------------------------------------

  188.   def open(name)

  189.     refresh(name)

  190.     @show_count = 150

  191.     self.contents_opacity = 0

  192.     self

  193.   end

  194.   #--------------------------------------------------------------------------

  195.   # * Close Window

  196.   #--------------------------------------------------------------------------

  197.   def close

  198.     @show_count = 0

  199.     self

  200.   end

  201.   #--------------------------------------------------------------------------

  202.   # * Refresh

  203.   #--------------------------------------------------------------------------

  204.   def refresh(name="")

  205.     contents.clear

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

  207.       draw_background(contents.rect)

  208.       draw_text(contents.rect, name, 1)

  209.     end

  210.   end

  211.   #--------------------------------------------------------------------------

  212.   # * Draw Background

  213.   #--------------------------------------------------------------------------

  214.   def draw_background(rect)

  215.     temp_rect = rect.clone

  216.     temp_rect.width /= 2

  217.     contents.gradient_fill_rect(temp_rect, back_color2, back_color1)

  218.     temp_rect.x = temp_rect.width

  219.     contents.gradient_fill_rect(temp_rect, back_color1, back_color2)

  220.   end

  221.   #--------------------------------------------------------------------------

  222.   # * Get Background Color 1

  223.   #--------------------------------------------------------------------------

  224.   def back_color1

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

  226.   end

  227.   #--------------------------------------------------------------------------

  228.   # * Get Background Color 2

  229.   #--------------------------------------------------------------------------

  230.   def back_color2

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

  232.   end

  233. end
复制代码

评分

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

查看全部评分

梦石
0
星屑
30103
在线时间
5741 小时
注册时间
2016-3-8
回帖
1662
 楼主| 发表于 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
星屑
30103
在线时间
5741 小时
注册时间
2016-3-8
回帖
1662
 楼主| 发表于 2021-2-23 12:24:01 | 显示全部楼层
本帖最后由 alexncf125 于 2021-2-23 12:27 编辑


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

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

使用道具 举报

老鹰

梦石
40
星屑
38044
在线时间
7127 小时
注册时间
2012-5-26
回帖
3306

极短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
星屑
30103
在线时间
5741 小时
注册时间
2016-3-8
回帖
1662
 楼主| 发表于 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.

在本版发帖返回顶部