设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1473|回复: 1
打印 上一主题 下一主题

[已经过期] 如何更改腳印方向

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
12 小时
注册时间
2014-2-4
帖子
5
跳转到指定楼层
1
发表于 2015-3-9 11:53:43 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
我把下面这个脚本修改成让npc走路时会出现效果~
http://galvs-scripts.com/galvs-region-effects/

但是~显示出​​来的方向却是主角走动的方向~

该怎么更改成npc走动的方向呢?
下面是我修改过后的脚本~
  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.    CHARACTER_ID = 002

  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_Event < Game_Character
  112.   
  113.   attr_accessor :region_effects
  114.   
  115. #  alias galv_region_effects_update_update_nonmoving update_nonmoving
  116.   #def update_nonmoving(last_moving)
  117.   def move_type_toward_player
  118.       galv_region_check unless $game_switches[Region_Effects::REGION_EFFECT_SWITCH] == true
  119.       if near_the_player?
  120.         case rand(6)
  121.         when 0..3;  move_toward_player
  122.         when 4;     move_random
  123.         when 5;     move_forward
  124.       end
  125.       else
  126.         move_random
  127.       end
  128.     end
  129.   end
  130.   
  131.   def galv_region_check
  132.     return if Input.trigger?(:C)
  133.     v = rand(10) - rand(10)
  134.     p = rand(40) - rand(40)
  135.    
  136.     r_id = $game_map.region_id($game_map.events[002].x, $game_map.events[002].y)
  137.     return if Region_Effects::EFFECT[r_id] == nil
  138.    
  139.     sound = Region_Effects::EFFECT[r_id][0]
  140.     vol = Region_Effects::EFFECT[r_id][1]
  141.       pit = Region_Effects::EFFECT[r_id][2]
  142.       eve = Region_Effects::EFFECT[r_id][3]
  143.       com_eve = Region_Effects::EFFECT[r_id][4]

  144.       RPG::SE.new(sound, vol + v, pit + p).play
  145.       if eve > 0
  146.         $game_map.region_event($game_map.events[002].x, $game_map.events[002].y, eve, Region_Effects::SPAWN_MAP_ID)
  147.       end
  148.       $game_temp.reserve_common_event(com_eve) unless com_eve == nil
  149.   end
  150.   
  151. #end

  152. #class Game_Player < Game_Character
  153. #  attr_accessor :region_effects
  154. #  
  155. #  alias galv_region_effects_update_update_nonmoving update_nonmoving
  156. #  def update_nonmoving(last_moving)
  157. #    if last_moving
  158. #      galv_region_check unless $game_switches[Region_Effects::REGION_EFFECT_SWITCH] == true
  159. #    end
  160. #    galv_region_effects_update_update_nonmoving(last_moving)
  161. #  end
  162. #  
  163. #  def galv_region_check
  164. #    return if Input.trigger?(:C)
  165. #    v = rand(10) - rand(10)
  166. #    p = rand(40) - rand(40)
  167. #   
  168. #    r_id = $game_map.region_id($game_player.x, $game_player.y)
  169. #    return if Region_Effects::EFFECT[r_id] == nil
  170. #   
  171. #    sound = Region_Effects::EFFECT[r_id][0]
  172. #    vol = Region_Effects::EFFECT[r_id][1]
  173. #      pit = Region_Effects::EFFECT[r_id][2]
  174. #      eve = Region_Effects::EFFECT[r_id][3]
  175. #      com_eve = Region_Effects::EFFECT[r_id][4]
  176. #
  177. #      RPG::SE.new(sound, vol + v, pit + p).play
  178. #      if eve > 0
  179. #        $game_map.region_event($game_player.x, $game_player.y, eve, Region_Effects::SPAWN_MAP_ID)
  180. #      end
  181. #      $game_temp.reserve_common_event(com_eve) unless com_eve == nil
  182. #  end
  183. #  
  184. #
  185. #end # Game_Player



  186. class Game_Map
  187.   attr_accessor :effectlist
  188.   attr_accessor :r_events

  189.   alias galv_region_effects_setup setup
  190.   def setup(map_id)
  191.     @effectlist = []
  192.     @r_events = {}
  193.     galv_region_effects_setup(map_id)
  194.    
  195.     @eid = 0
  196.   end
  197.   
  198.   def region_event(dx, dy, event_id, map_id)
  199.     map_id = @map_id if map_id == 0
  200.     map = $data_spawn_map
  201.     event = generated_region_event(map, event_id)

  202.     @eid += 1
  203.     @effectlist.push(@eid)
  204.     @effectlist.shift if @effectlist.count > Region_Effects::MAX_EFFECTS

  205.     @r_events[@eid] = Game_Event.new(@map_id, event)
  206.     @r_events[@eid].moveto(dx, dy)
  207.     SceneManager.scene.spriteset.refresh_region_effects

  208.     @eid = 0 if @eid >= Region_Effects::MAX_EFFECTS
  209.   end

  210.   
  211.   def generated_region_event(map, event_id)
  212.     for key in map.events
  213.       event = key[1]
  214.       next if event.nil?
  215.       return event if event.id == event_id
  216.     end
  217.     return nil
  218.   end

  219.   alias galv_region_effects_gm_refresh refresh
  220.   def refresh
  221.     @r_events.each_value {|event| event.refresh }
  222.     galv_region_effects_gm_refresh
  223.   end
  224.   
  225.   alias galv_region_effects_gm_update_events update_events
  226.   def update_events
  227.     @r_events.each_value {|event| event.update }
  228.     galv_region_effects_gm_update_events
  229.   end
  230.   
  231. end # Game_Map



  232. class Spriteset_Map
  233.   def refresh_region_effects
  234.     dispose_region_sprites
  235.     create_region_sprites
  236.   end
  237.   
  238.   alias galv_region_effect_sm_sb_create_characters create_characters
  239.   def create_characters
  240.     create_region_sprites
  241.     galv_region_effect_sm_sb_create_characters
  242.   end
  243.   
  244.   alias galv_region_effect_sm_sb_update_characters update_characters
  245.   def update_characters
  246.     galv_region_effect_sm_sb_update_characters
  247.     @region_sprites.each { |sprite| sprite.update }
  248.   end
  249.   
  250.   alias galv_region_effect_sm_sb_dispose_characters dispose_characters
  251.   def dispose_characters
  252.     dispose_region_sprites
  253.     galv_region_effect_sm_sb_dispose_characters
  254.   end
  255.   
  256.   def create_region_sprites
  257.     @region_sprites = []
  258.     $game_map.effectlist.each_with_index { |id,i|
  259.       @region_sprites[i] = Sprite_Character.new(@viewport1,$game_map.r_events[id])
  260.     }
  261.   end
  262.   
  263.   def dispose_region_sprites
  264.     @region_sprites.each { |sprite| sprite.dispose }
  265.   end
  266. end



  267. class Scene_Map < Scene_Base
  268.   attr_accessor :spriteset
  269.   
  270.   alias galv_region_effects_start start
  271.   def start
  272.     galv_region_effects_start
  273.     SceneManager.scene.spriteset.refresh_region_effects
  274.   end
  275. end # Scene_Map
复制代码

点评

你的角色不动,难道NPC走路就没有脚印吗···  发表于 2015-3-22 12:16

Lv3.寻梦者 (版主)

…あたしは天使なんかじゃないわ

梦石
0
星屑
2208
在线时间
4033 小时
注册时间
2010-10-4
帖子
10779

开拓者贵宾

2
发表于 2015-3-22 09:31:25 | 只看该作者
翻了整个脚本我都没看到有设置脚印的方向。

看看你的事件设置吧。
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-11-15 21:02

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表