查看: 2503|回复: 3

[已经解决] 腳本BUG ,跟上次喵大腳本的那個狀況很像

[复制链接]
梦石
0
星屑
2116
在线时间
950 小时
注册时间
2015-7-16
回帖
692

开拓者

发表于 2016-3-11 13:10:04 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 duzine 于 2016-3-11 13:13 编辑

如題
未命名.png

一樣也是找不到觸發原因,今天才發現的
上次的文 https://rpg.blue/thread-390043-1-1.html
附上腳本

  1. #------------------------------------------------------------------------------#
  2. #  Galv's Region Effects
  3. #------------------------------------------------------------------------------#
  4. #  For: RPGMAKER VX ACE
  5. #  Version 1.9
  6. #  Credit to Yanfly and Quack for event spawning method
  7. #------------------------------------------------------------------------------#
  8. #  2014-01-07 - Version 1.9 - upgrade to not stop animations playing when a
  9. #                             region effect is drawn.
  10. #  2013-01-24 - Version 1.8 - minor tweaks
  11. #  2013-01-22 - Version 1.7 - Made effects work during forced move routes
  12. #  2012-11-15 - Version 1.6 - Fixed a major bug caused with last update.
  13. #  2012-11-04 - Version 1.5 - streamline updates and bug fix suggested by Quack
  14. #  2012-10-23 - Version 1.4 - updated alias naming convention for compatability
  15. #  2012-10-09 - Version 1.3 - re-wrote the code to be more efficient when
  16. #                           - using many different region effects.
  17. #  2012-10-09 - Version 1.2 - code tweak that may reduce lag on low-end pc's
  18. #  2012-09-16 - Version 1.1 - now compatible with Yanfly's spawn events
  19. #  2012-09-15 - Version 1.0 - release
  20. #------------------------------------------------------------------------------#
  21. #  Designed to activate effects when regions are stood on.
  22. #  An effect can include:
  23. #     - Sound Effect
  24. #     - An event that appears at the player's location
  25. #     - Activating a common event
  26. #
  27. #
  28. #  INSTRUCTIONS:
  29. #  1. Copy image from /Graphics/Characters/!Other-specials.png to your project
  30. #  2. Copy the map from this demo into your game.
  31. #        - this map has events set up for the pre-made effects
  32. #  3. Check the map ID of the map you copied in your game
  33. #  4. Change the SPAWN_MAP_ID number to this map ID
  34. #  5. Change REGION_EFFECT_SWITCH to a switch you are not using in your game.
  35. #  6. Add some regions to your map to test.
  36. #
  37. #
  38. #
  39. #  To disable region effects use
  40. #  $game_player.region_effects = false
  41. #
  42. #------------------------------------------------------------------------------#

  43. $imported = {} if $imported.nil?
  44. $imported["Region_Effects"] = true

  45. module Region_Effects
  46. #------------------------------------------------------------------------------#
  47. #  SCRIPT SETUP OPTIONS
  48. #------------------------------------------------------------------------------#
  49.    #因為與loading腳本衝突,移至上方觀察
  50.    REGION_EFFECT_SWITCH = 0   # Turn this switch ON to disable the effects.

  51.    MAX_EFFECTS = 20           # Number of effects that can be on screen
  52.                               # before being removed. (To prevent lag)
  53.                               
  54.    SPAWN_MAP_ID = 10           # Map ID of the map you store event effects in.
  55.    #儲存效果的地圖
  56.    

  57. #------------------------------------------------------------------------------#
  58. #  ENVIRONMENT REGIONS SETUP
  59. #------------------------------------------------------------------------------#
  60. #------------------------------------------------------------------------------#
  61. #
  62. #  region => ["sound", vol, pitch, event_id, common_event_id]
  63. #
  64. #  region          -  the region ID the effect will activate on
  65. #  sound           -  the name of the SE file. "" for no sound
  66. #  vol             -  the volume of the SE (0 - 100)
  67. #  pitch           -  the pitch of the SE (50 - 150)
  68. #  event_id        -  event ID called from the spawn map. 0 for none.
  69. #  common_event_id -  common event ID to call. 0 for no common event.
  70. #
  71. #------------------------------------------------------------------------------#
  72.     EFFECT = { # ! don't touch this
  73. #------------------------------------------------------------------------------#

  74.     0 => ["", 0, 0, 0, 0],              # No Effect (no region)
  75.    
  76.     # Pre-made effects (requires demo events)
  77.     #1 => ["", 0, 0, 5, 0],              # Dirt dust
  78.     #2 => ["Blow7", 60, 150, 0, 0],      # Wood surface noise only
  79.     5 => ["Water1", 60, 110, 1, 0],     # Shallow Water 水灘
  80.    
  81.     #18 => ["Earth2", 40, 130, 0, 0],     # Hard surface noise only
  82.     6 => ["Damage3", 40, 150, 2, 0],    # Footprints 雪地
  83.     12 => ["", 50, 130, 3, 0],       # Walking over thick grass 草叢
  84.     7 => ["", 0, 0, 0, 1],              # Calls common event 1 only 坑洞
  85.     8 => ["Fire3", 80, 120, 4, 2],      # Calls fire trap 火爐
  86.     37 => ["", 80, 120, 6, 0],          # Dust cloud 沙地
  87.    
  88.     # You can add more as required. eg:
  89.     # 42 => ["", 0, 0, 0, 0],
  90.     # 18 => ["", 0, 0, 0, 0],
  91.     # etc. etc.
  92.    
  93.     # Only one effect per region number will work
  94.    
  95. #------------------------------------------------------------------------------#
  96.     } # ! don't touch this
  97. #------------------------------------------------------------------------------#
  98. #  END SCRIPT SETUP
  99. #------------------------------------------------------------------------------#
  100.    
  101. end # Region_Effects

  102. module DataManager

  103. #--------------------------------------------------------------------------
  104. # alias method: load_normal_database
  105. #--------------------------------------------------------------------------
  106. class <<self; alias load_normal_database_spawn_alias load_normal_database; end
  107.   def self.load_normal_database
  108.     load_normal_database_spawn_alias
  109.     $data_spawn_map = load_data(sprintf("Data/Map%03d.rvdata2", Region_Effects::SPAWN_MAP_ID))
  110.   end
  111. end

  112. class Game_Player < Game_Character
  113.   attr_accessor :region_effects
  114.   
  115.   alias galv_region_effects_update_update_nonmoving update_nonmoving
  116.   def update_nonmoving(last_moving)
  117.     if last_moving
  118.       galv_region_check unless $game_switches[Region_Effects::REGION_EFFECT_SWITCH] == true
  119.     end
  120.     galv_region_effects_update_update_nonmoving(last_moving)
  121.   end
  122.   
  123.   def galv_region_check
  124.     return if Input.trigger?(:C)
  125.     v = rand(10) - rand(10)
  126.     p = rand(40) - rand(40)
  127.    
  128.     r_id = $game_map.region_id($game_player.x, $game_player.y)
  129.     return if Region_Effects::EFFECT[r_id] == nil
  130.    
  131.     sound = Region_Effects::EFFECT[r_id][0]
  132.     vol = Region_Effects::EFFECT[r_id][1]
  133.       pit = Region_Effects::EFFECT[r_id][2]
  134.       eve = Region_Effects::EFFECT[r_id][3]
  135.       com_eve = Region_Effects::EFFECT[r_id][4]

  136.       RPG::SE.new(sound, vol + v, pit + p).play
  137.       if eve > 0
  138.         $game_map.region_event($game_player.x, $game_player.y, eve, Region_Effects::SPAWN_MAP_ID)
  139.       end
  140.       $game_temp.reserve_common_event(com_eve) unless com_eve == nil
  141.   end
  142.   

  143. end # Game_Player



  144. class Game_Map
  145.   attr_accessor :effectlist
  146.   attr_accessor :r_events

  147.   alias galv_region_effects_setup setup
  148.   def setup(map_id)
  149.     @effectlist = []
  150.     @r_events = {}
  151.     galv_region_effects_setup(map_id)
  152.    
  153.     @eid = 0
  154.   end
  155.   
  156.   def region_event(dx, dy, event_id, map_id)
  157.     map_id = @map_id if map_id == 0
  158.     map = $data_spawn_map
  159.     event = generated_region_event(map, event_id)

  160.     @eid += 1
  161.     @effectlist.push(@eid)
  162.     @effectlist.shift if @effectlist.count > Region_Effects::MAX_EFFECTS

  163.     @r_events[@eid] = Game_Event.new(@map_id, event)
  164.     @r_events[@eid].moveto(dx, dy)
  165.     SceneManager.scene.spriteset.refresh_region_effects

  166.     @eid = 0 if @eid >= Region_Effects::MAX_EFFECTS
  167.   end

  168.   
  169.   def generated_region_event(map, event_id)
  170.     for key in map.events
  171.       event = key[1]
  172.       next if event.nil?
  173.       return event if event.id == event_id
  174.     end
  175.     return nil
  176.   end

  177.   alias galv_region_effects_gm_refresh refresh
  178.   def refresh
  179.     @r_events.each_value {|event| event.refresh }
  180.     galv_region_effects_gm_refresh
  181.   end
  182.   
  183.   alias galv_region_effects_gm_update_events update_events
  184.   def update_events
  185.     @r_events.each_value {|event| event.update }
  186.     galv_region_effects_gm_update_events
  187.   end
  188.   
  189. end # Game_Map



  190. class Spriteset_Map
  191.   def refresh_region_effects
  192.     dispose_region_sprites
  193.     create_region_sprites
  194.   end
  195.   
  196.   alias galv_region_effect_sm_sb_create_characters create_characters
  197.   def create_characters
  198.     create_region_sprites
  199.     galv_region_effect_sm_sb_create_characters
  200.   end
  201.   
  202.   alias galv_region_effect_sm_sb_update_characters update_characters
  203.   def update_characters
  204.     galv_region_effect_sm_sb_update_characters
  205.     @region_sprites.each { |sprite| sprite.update }
  206.   end
  207.   
  208.   alias galv_region_effect_sm_sb_dispose_characters dispose_characters
  209.   def dispose_characters
  210.     dispose_region_sprites
  211.     galv_region_effect_sm_sb_dispose_characters
  212.   end
  213.   
  214.   def create_region_sprites
  215.     @region_sprites = []
  216.     $game_map.effectlist.each_with_index { |id,i|
  217.       @region_sprites[i] = Sprite_Character.new(@viewport1,$game_map.r_events[id])
  218.     }
  219.   end
  220.   
  221.   def dispose_region_sprites
  222.     @region_sprites.each { |sprite| sprite.dispose }
  223.   end
  224. end



  225. class Scene_Map < Scene_Base
  226.   attr_accessor :spriteset
  227.   
  228.   alias galv_region_effects_start start
  229.   def start
  230.     galv_region_effects_start
  231.     SceneManager.scene.spriteset.refresh_region_effects
  232.   end
  233. end # Scene_Map
复制代码
[神性领域扩张:扩张神性领域]
说了等于没说.

梦石
0
星屑
9726
在线时间
2775 小时
注册时间
2008-9-5
回帖
3458

开拓者短篇八RM组冠军短篇九导演组亚军白银编剧

发表于 2016-3-11 13:53:02 | 显示全部楼层
这是加了新脚本后读旧档造成的吧………………
试试看在出错的那行后面加上
  1. if @r_events.is_a?(Hash)
复制代码
(虽然不读旧档就没必要这样……

评分

参与人数 2星屑 +10 梦石 +1 收起 理由
丿梁丶小柒 + 1 认可答案
duzine + 10 希望不會再報錯OWQ

查看全部评分

回复

使用道具 举报

梦石
0
星屑
2116
在线时间
950 小时
注册时间
2015-7-16
回帖
692

开拓者

 楼主| 发表于 2016-3-11 14:22:27 | 显示全部楼层
真的沒有讀取舊檔
這是測試遊戲鍵一按下去就會跳出,然後再按一次就能成功進入遊戲

讀取舊檔之類的蠢事早在很久以前就被改正了,根本不會做啊
[神性领域扩张:扩张神性领域]
说了等于没说.
回复

使用道具 举报

梦石
0
星屑
2116
在线时间
950 小时
注册时间
2015-7-16
回帖
692

开拓者

 楼主| 发表于 2016-3-11 14:24:29 | 显示全部楼层
未命名.png

還是不行,反而直接報錯了

点评

就是试试看全局搜索一下【class Game_Map】看看,在主楼这个脚本下面知不是还有别的脚本  发表于 2016-3-11 23:14
我試試看,不過覆蓋掉setup方法的部分我不是很懂  发表于 2016-3-11 23:03
或者在什么地方使用了$game_map.refresh  发表于 2016-3-11 15:38
不过问题不在这,应该是之后有Game_Map类的脚本覆盖掉了setup方法,不然单独这个脚本的话无论如何,进入新地图setup之后都不会弹主楼那个窗……  发表于 2016-3-11 15:36
是加在句子后面……不是换行啦……  发表于 2016-3-11 15:31
[神性领域扩张:扩张神性领域]
说了等于没说.
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部