查看: 2143|回复: 3

[已解決]怎樣改才能感應多個事件?

[复制链接]
头像被屏蔽
梦石
0
星屑
5706
在线时间
922 小时
注册时间
2013-8-29
回帖
1401
发表于 2020-1-24 17:55:00 | 显示全部楼层 |阅读模式
提示: 作者被禁止或删除 内容自动屏蔽
头像被屏蔽
梦石
0
星屑
5706
在线时间
922 小时
注册时间
2013-8-29
回帖
1401
 楼主| 发表于 2020-1-24 21:02:12 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

梦石
0
星屑
17289
在线时间
6068 小时
注册时间
2011-7-18
回帖
153

开拓者

发表于 2020-1-25 03:12:01 | 显示全部楼层
点击展开/收起
  1. #------------------------------------------------------------------------------#
  2. #  Galv's Encounter Pointer 岚风雷(论坛ID:gqxastg)魔改
  3. #------------------------------------------------------------------------------#
  4. #  For: RPGMAKER VX ACE
  5. #  Version 1.2
  6. #------------------------------------------------------------------------------#
  7. #  2013-02-22 - Version 1.2 - hide the pointer while events are running.
  8. #  2013-02-18 - Version 1.1 - fixed bug with changing number of frames
  9. #  2013-02-18 - Version 1.0 - release
  10. #------------------------------------------------------------------------------#
  11. #  This script displays a pointer above the player's head that changes
  12. #  depending on how many steps until the next random encounter will happen.
  13. #  This is based off of the feature in the psone game 'Legend of Dragoon'.
  14. #------------------------------------------------------------------------------#
  15. #  魔改后功能:
  16. #  玩家头上显示一个指针,在带指定注释的事件中,选择离玩家最近的,按照距离变更样式
  17. #------------------------------------------------------------------------------#
  18. #  INSTRUCTIONS
  19. #------------------------------------------------------------------------------#
  20. #  Get image from demo.
  21. #  Put script under Materials and above Main
  22. #  Check settings to see if you want to change anything.
  23. #  Start a new game.
  24. #------------------------------------------------------------------------------#

  25. ($imported ||= {})["Galv_Encounter_Pointer"] = true
  26. module Galv_Enc

  27. #------------------------------------------------------------------------------#  
  28. #  SETUP OPTIONS
  29. #------------------------------------------------------------------------------#
  30.   #---------------------#
  31.   #  Gameplay Options:  #
  32.   #---------------------#
  33.    
  34.   DISABLE_BUTTON = :Y  # Button for player to turn it on and off :Y is "s" key
  35.   DISABLE_SWITCH = 1   # Turn ON to turn pointer OFF.
  36.    
  37.   WARNING_LEVEL = 10   # 魔改后:距离不大于这个值时指针变黄 When pointer turns yellow
  38.   DANGER_LEVEL = 5     # 魔改后:距离不大于这个值时指针变红 When pointer turns red
  39.   
  40.   REGEXP = /<SensorEnemy>/i # 魔改新增:用作判断事件注释的正则表达式
  41.   # The above levels are based on how many steps until encounter and the
  42.   # encounter rate of the area. 0.5 means when steps until encounter has reached
  43.   # 50% of the encounter rate. (So 15 steps in a 30 step zone).
  44.    
  45.   #---------------------#
  46.   #  Graphic Options:   #
  47.   #---------------------#
  48.    
  49.   IMAGE = "encounter_pointer"   # The image to use in /Graphics/System/
  50.    
  51.   FRAMES = 5           # Amount of frames the pointer animation uses
  52.   SPEED = 5            # Speed of animation (higher is slower)
  53.   Z_LEVEL = 100        # Make higher to display above things if it doesn't.
  54.   Y_POSITION = -50     # Y position relevant to the player.
  55.    
  56. #------------------------------------------------------------------------------#  
  57. #  END SETUP OPTIONS
  58. #------------------------------------------------------------------------------#
  59. end


  60. class Spriteset_Map
  61.   alias galv_enc_point_smap_initialize initialize
  62.   def initialize
  63.     create_enc_symbol
  64.     galv_enc_point_smap_initialize
  65.   end
  66.    
  67.   def create_enc_symbol
  68.     @enc_symbol = Sprite_EncSymbol.new(@viewport1, $game_player)
  69.   end
  70.    
  71.   alias galv_enc_point_smap_update update
  72.   def update
  73.     galv_enc_point_smap_update
  74.     @enc_symbol.update
  75.   end

  76.   alias galv_enc_point_smap_dispose dispose
  77.   def dispose
  78.     galv_enc_point_smap_dispose
  79.     dispose_enc_symbol
  80.   end
  81.    
  82.   def dispose_enc_symbol
  83.     @enc_symbol.dispose if @enc_symbol
  84.   end
  85. end # Spriteset_Map


  86. class Sprite_EncSymbol < Sprite_Character
  87.   def initialize(viewport, character = nil)
  88.     super(viewport, character)
  89.     @character = character
  90.     update
  91.   end
  92.    
  93.   def defaults
  94.     @speed_timer = 0
  95.     @enc_pattern = 1
  96.     @enc_rate = $game_map.encounter_step
  97.     @enc_status = $game_player.encounter_count
  98.   end

  99.   def update
  100.     update_enc_status
  101.     set_enc_bitmap if @enc_pattern.nil?
  102.     update_src_rect
  103.     update_position
  104.     update_other
  105.   end

  106.   def update_enc_status # 此处有修改
  107.     distance = $game_map.enemy_sensor_distance
  108.     return @enc_status = 0 if distance.empty?
  109.     distance = distance.min
  110.     if distance <= Galv_Enc::DANGER_LEVEL
  111.       @enc_status = 2
  112.     elsif distance <= Galv_Enc::WARNING_LEVEL
  113.       @enc_status = 1
  114.     else
  115.       @enc_status = 0
  116.     end
  117. #~     steps_left = $game_player.encounter_count.to_f / $game_map.encounter_step.to_f
  118. #~     if steps_left <= Galv_Enc::DANGER_LEVEL
  119. #~       @enc_status = 2
  120. #~     elsif steps_left <= Galv_Enc::WARNING_LEVEL
  121. #~       @enc_status = 1
  122. #~     else
  123. #~       @enc_status = 0
  124. #~     end
  125.   end
  126.    
  127.   def set_enc_bitmap
  128.     @enc_pattern ||= 1
  129.     @speed_timer ||= 0
  130.     self.bitmap = Cache.system(Galv_Enc::IMAGE)
  131.     @cw = bitmap.width / Galv_Enc::FRAMES
  132.     @ch = bitmap.height / 3
  133.     self.ox = @cw / 2
  134.     self.oy = @ch
  135.   end
  136.    
  137.   def update_src_rect
  138.     if @enc_pattern < Galv_Enc::FRAMES
  139.       pattern = @enc_pattern
  140.     else
  141.       @enc_pattern = 1
  142.       pattern = 1
  143.     end
  144.     sx = pattern * @cw
  145.     sy = @enc_status * @ch
  146.     self.src_rect.set(sx, sy, @cw, @ch)
  147.   end
  148.    
  149.   def update_position   
  150.     self.x = @character.screen_x
  151.     self.y = @character.screen_y + Galv_Enc::Y_POSITION
  152.     self.z = Galv_Enc::Z_LEVEL
  153.   end
  154.    
  155.   def update_other
  156.     @speed_timer += 1
  157.     if @speed_timer > Galv_Enc::SPEED
  158.       @enc_pattern += 1
  159.       @speed_timer = 0
  160.     end
  161.     if $game_switches[Galv_Enc::DISABLE_SWITCH] || $game_map.interpreter.running?
  162.       self.opacity = 0
  163.     else
  164.       self.opacity = 255
  165.     end
  166.     self.visible = !@character.transparent
  167.   end
  168.    
  169. end # Sprite_EncSymbol < Sprite_Character


  170. class Game_Player < Game_Character
  171.   attr_reader :encounter_count
  172.    
  173.   alias galv_enc_point_player_move_by_input move_by_input
  174.   def move_by_input
  175.     if Input.trigger?(Galv_Enc::DISABLE_BUTTON)
  176.       $game_switches[1] ^= true
  177.     end
  178.     galv_enc_point_player_move_by_input
  179.   end
  180. end # Game_Player < Game_Character

  181. class Game_Map # 此处为新增
  182.   def enemy_sensor_distance
  183.     list = @events.values.select {|event| event.sensor_enemy }
  184.     return list.collect {|event|
  185.     Math.sqrt(($game_player.x - event.x) ** 2 +
  186.     ($game_player.y - event.y) ** 2).round }
  187.   end
  188. end # Game_Map

  189. class Game_CharacterBase # 此处为新增
  190.   attr_accessor :sensor_enemy
  191.   
  192.   alias galv_enc_point_cb_init_public_members init_public_members
  193.   def init_public_members
  194.     galv_enc_point_cb_init_public_members
  195.     @sensor_enemy = false
  196.   end
  197. end # Game_CharacterBase

  198. class Game_Event < Game_Character # 此处为新增
  199.   alias galv_enc_point_event_refresh refresh
  200.   def refresh
  201.     new_page = @erased ? nil : find_proper_page
  202.     if !new_page
  203.       @sensor_enemy = false
  204.     elsif new_page != @page
  205.       @sensor_enemy = false
  206.       proper_page_get_note.each do |note|
  207.         case note
  208.         when Galv_Enc::REGEXP
  209.           @sensor_enemy = true
  210.         end
  211.       end
  212.     end
  213.     galv_enc_point_event_refresh
  214.   end

  215.   def proper_page_get_note
  216.     return [] if @erased
  217.     list = find_proper_page.list
  218.     notes = []
  219.     if list[0].code == 108
  220.       notes.push(list[0].parameters[0])
  221.       (list.size - 1).times do |i|
  222.         if list[i + 1].code == 408
  223.           notes.push(list[i + 1].parameters[0])
  224.         else
  225.           break
  226.         end
  227.       end
  228.     end
  229.     return notes
  230.   end
  231. end # Game_Event < Game_Character
复制代码

去找了一下原脚本帮忙改好了

评分

参与人数 2星屑 +50 赞 +1 收起 理由
VIPArcher + 50 认可答案
chanszeman1018 + 1 精品文章

查看全部评分

这里岚风·雷,任饭、PM理性粉、UT/DR原作粉、(Trans)Furry自萌,半吊子技术一枚_(:з」∠)_    游戏制作交流工(liao)作(tian)室欢迎来玩!
【无偿/有偿】RGSS3(VA)脚本定制 + 合作招募/同好交友    修正Firefox/火狐浏览器的代码框复制问题(油猴脚本)
Click→←Click
回复

使用道具 举报

头像被屏蔽
梦石
0
星屑
5706
在线时间
922 小时
注册时间
2013-8-29
回帖
1401
 楼主| 发表于 2020-1-25 15:32:20 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部