查看: 2080|回复: 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
星屑
17038
在线时间
6058 小时
注册时间
2011-7-18
回帖
152

开拓者

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

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

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


class Spriteset_Map
  alias galv_enc_point_smap_initialize initialize
  def initialize
    create_enc_symbol
    galv_enc_point_smap_initialize
  end
   
  def create_enc_symbol
    @enc_symbol = Sprite_EncSymbol.new(@viewport1, $game_player)
  end
   
  alias galv_enc_point_smap_update update
  def update
    galv_enc_point_smap_update
    @enc_symbol.update
  end

  alias galv_enc_point_smap_dispose dispose
  def dispose
    galv_enc_point_smap_dispose
    dispose_enc_symbol
  end
   
  def dispose_enc_symbol
    @enc_symbol.dispose if @enc_symbol
  end
end # Spriteset_Map


class Sprite_EncSymbol < Sprite_Character
  def initialize(viewport, character = nil)
    super(viewport, character)
    @character = character
    update
  end
   
  def defaults
    @speed_timer = 0
    @enc_pattern = 1
    @enc_rate = $game_map.encounter_step
    @enc_status = $game_player.encounter_count
  end

  def update
    update_enc_status
    set_enc_bitmap if @enc_pattern.nil?
    update_src_rect
    update_position
    update_other
  end

  def update_enc_status # 此处有修改
    distance = $game_map.enemy_sensor_distance
    return @enc_status = 0 if distance.empty?
    distance = distance.min
    if distance <= Galv_Enc::DANGER_LEVEL
      @enc_status = 2
    elsif distance <= Galv_Enc::WARNING_LEVEL
      @enc_status = 1
    else
      @enc_status = 0
    end
#~     steps_left = $game_player.encounter_count.to_f / $game_map.encounter_step.to_f
#~     if steps_left <= Galv_Enc::DANGER_LEVEL
#~       @enc_status = 2
#~     elsif steps_left <= Galv_Enc::WARNING_LEVEL
#~       @enc_status = 1
#~     else
#~       @enc_status = 0
#~     end
  end
   
  def set_enc_bitmap
    @enc_pattern ||= 1
    @speed_timer ||= 0
    self.bitmap = Cache.system(Galv_Enc::IMAGE)
    @cw = bitmap.width / Galv_Enc::FRAMES
    @ch = bitmap.height / 3
    self.ox = @cw / 2
    self.oy = @ch
  end
   
  def update_src_rect
    if @enc_pattern < Galv_Enc::FRAMES
      pattern = @enc_pattern
    else
      @enc_pattern = 1
      pattern = 1
    end
    sx = pattern * @cw
    sy = @enc_status * @ch
    self.src_rect.set(sx, sy, @cw, @ch)
  end
   
  def update_position   
    self.x = @character.screen_x
    self.y = @character.screen_y + Galv_Enc::Y_POSITION
    self.z = Galv_Enc::Z_LEVEL
  end
   
  def update_other
    @speed_timer += 1
    if @speed_timer > Galv_Enc::SPEED
      @enc_pattern += 1
      @speed_timer = 0
    end
    if $game_switches[Galv_Enc::DISABLE_SWITCH] || $game_map.interpreter.running?
      self.opacity = 0
    else
      self.opacity = 255
    end
    self.visible = !@character.transparent
  end
   
end # Sprite_EncSymbol < Sprite_Character


class Game_Player < Game_Character
  attr_reader :encounter_count
   
  alias galv_enc_point_player_move_by_input move_by_input
  def move_by_input
    if Input.trigger?(Galv_Enc::DISABLE_BUTTON)
      $game_switches[1] ^= true
    end
    galv_enc_point_player_move_by_input
  end
end # Game_Player < Game_Character

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

class Game_CharacterBase # 此处为新增
  attr_accessor :sensor_enemy
  
  alias galv_enc_point_cb_init_public_members init_public_members
  def init_public_members
    galv_enc_point_cb_init_public_members
    @sensor_enemy = false
  end
end # Game_CharacterBase

class Game_Event < Game_Character # 此处为新增
  alias galv_enc_point_event_refresh refresh
  def refresh
    new_page = @erased ? nil : find_proper_page
    if !new_page
      @sensor_enemy = false
    elsif new_page != @page
      @sensor_enemy = false
      proper_page_get_note.each do |note|
        case note
        when Galv_Enc::REGEXP
          @sensor_enemy = true
        end
      end
    end
    galv_enc_point_event_refresh
  end

  def proper_page_get_note
    return [] if @erased
    list = find_proper_page.list
    notes = []
    if list[0].code == 108
      notes.push(list[0].parameters[0])
      (list.size - 1).times do |i|
        if list[i + 1].code == 408
          notes.push(list[i + 1].parameters[0])
        else
          break
        end
      end
    end
    return notes
  end
end # Game_Event < Game_Character[/pre]

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

评分

参与人数 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.

在本版发帖返回顶部