本帖最后由 我为鱼肉 于 2022-9-1 22:02 编辑  
 
@encounter_count是Game_Player类定义的变量,用途是记录遇敌步数 
默认脚本75~80行定义了 
#--------------------------------------------------------------------------   # * Get Encounter Count   #--------------------------------------------------------------------------   def encounter_count     return @encounter_count   end 
 
 #--------------------------------------------------------------------------  
  # * Get Encounter Count  
  #--------------------------------------------------------------------------  
  def encounter_count  
    return @encounter_count  
  end  
 
  
也就是可以通过$game_player.encounter_count来访问这个数值。 
默认脚本81~90行定义了@encounter_count的赋值方法 
#--------------------------------------------------------------------------   # * Make Encounter Count   #--------------------------------------------------------------------------   def make_encounter_count     # Image of two dice rolling     if $game_map.map_id != 0       n = $game_map.encounter_step       @encounter_count = rand(n) + rand(n) + 1     end   end 
 
 #--------------------------------------------------------------------------  
  # * Make Encounter Count  
  #--------------------------------------------------------------------------  
  def make_encounter_count  
    # Image of two dice rolling  
    if $game_map.map_id != 0  
      n = $game_map.encounter_step  
      @encounter_count = rand(n) + rand(n) + 1  
    end  
  end  
 
  
也就是@encounter_count = @encounter_count = rand(n) + rand(n) + 1  哪怕不算rand随机数,只看 + 1 就可知这个数值绝对不可能在“初始化时赋值为0” 
 
默认脚本update方法定义了@encounter_count的改变。265行左右 
也就是每次玩家移动步数减去1,直到减少到0遇敌战斗 
# If not moving     unless moving?       # If player was moving last time       if last_moving         # Event determinant is via touch of same position event         result = check_event_trigger_here([1,2])         # If event which started does not exist         if result == false           # Disregard if debug mode is ON and ctrl key was pressed           unless $DEBUG and Input.press?(Input::CTRL)             # Encounter countdown             if @encounter_count > 0               @encounter_count -= 1             end           end         end       end 
 
 # If not moving  
    unless moving?  
      # If player was moving last time  
      if last_moving  
        # Event determinant is via touch of same position event  
        result = check_event_trigger_here([1,2])  
        # If event which started does not exist  
        if result == false  
          # Disregard if debug mode is ON and ctrl key was pressed  
          unless $DEBUG and Input.press?(Input::CTRL)  
            # Encounter countdown  
            if @encounter_count > 0  
              @encounter_count -= 1  
            end  
          end  
        end  
      end  
 
  
 
Scene_Map update方法定义了遇敌 
# If encounter list isn't empty, and encounter count is 0     if $game_player.encounter_count == 0 and $game_map.encounter_list != []       # If event is running or encounter is not forbidden       unless $game_system.map_interpreter.running? or              $game_system.encounter_disabled         # Confirm troop         n = rand($game_map.encounter_list.size)         troop_id = $game_map.encounter_list[n]         # If troop is valid         if $data_troops[troop_id] != nil           # Set battle calling flag           $game_temp.battle_calling = true           $game_temp.battle_troop_id = troop_id           $game_temp.battle_can_escape = true           $game_temp.battle_can_lose = false           $game_temp.battle_proc = nil         end       end     end 
 
 # If encounter list isn't empty, and encounter count is 0  
    if $game_player.encounter_count == 0 and $game_map.encounter_list != []  
      # If event is running or encounter is not forbidden  
      unless $game_system.map_interpreter.running? or  
             $game_system.encounter_disabled  
        # Confirm troop  
        n = rand($game_map.encounter_list.size)  
        troop_id = $game_map.encounter_list[n]  
        # If troop is valid  
        if $data_troops[troop_id] != nil  
          # Set battle calling flag  
          $game_temp.battle_calling = true  
          $game_temp.battle_troop_id = troop_id  
          $game_temp.battle_can_escape = true  
          $game_temp.battle_can_lose = false  
          $game_temp.battle_proc = nil  
        end  
      end  
    end  
 
  
也就是当这个数值为0,并且设置了敌群,那么就随机一个敌群战斗。 
 
另外,每次地图改变,进入战斗都会重新刷新步数 
 
视频教程那么多,建议好好看看视频教学。很快就学会这些简单的了 
 
 
 
不明白你想问什么 
@encounter_count = rand(n) + rand(n) + 1 
生成遇敌计数,n是地图遇敌步数,默认是30,所以这个值肯定不可能是0 
角色每次移动这个值减少,直到等于0遇敌战斗(如果设置了敌队) 
$game_player.encounter_count和你说的@encounter_count是一回事。 
它是0就战斗,凭什么不让人家等于0。。 
 |