查看: 3572|回复: 0

[已经过期] 地形特效脚本使用

[复制链接]
梦石
0
星屑
50
在线时间
135 小时
注册时间
2012-6-14
回帖
32
发表于 2014-1-11 20:58:20 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 kkwo 于 2014-1-11 21:00 编辑

我找到一个配合地图区域ID显示不同的效果的脚本
(就是走在不同的地形可以有不同的效果和声音)
不知道哪出了问题
范本中的档案测试没问题
可是我複製到我的档案在测试的时候一踏上地形就出问题...
哪怕开一个新的档案...

我也有照着使用说明将图片跟地图都複製过去了...

调整项目那边我只看到ID跟音效的
也没看到显示效果要在哪调整...
所以想请问有谁能告诉我该怎麽做才能让脚本正常运作?
以下附上脚本和范例
Region Effectsv1.9.rar (1.49 MB, 下载次数: 69)
  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.    REGION_EFFECT_SWITCH = 1   # Turn this switch ON to disable the effects.

  50.    MAX_EFFECTS = 20           # Number of effects that can be on screen
  51.                               # before being removed. (To prevent lag)
  52.                                 
  53.    SPAWN_MAP_ID = 2           # Map ID of the map you store event effects in.
  54.    
  55.    

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

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

  101. module DataManager

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

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

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

  142. end # Game_Player



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

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

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

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

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

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

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



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



  224. class Scene_Map < Scene_Base
  225.   attr_accessor :spriteset
  226.    
  227.   alias galv_region_effects_start start
  228.   def start
  229.     galv_region_effects_start
  230.     SceneManager.scene.spriteset.refresh_region_effects
  231.   end
  232. end # Scene_Map
复制代码
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部