| 
 
| 赞 | 0 |  
| VIP | 1 |  
| 好人卡 | 0 |  
| 积分 | 1 |  
| 经验 | 3179 |  
| 最后登录 | 2013-10-25 |  
| 在线时间 | 140 小时 |  
 Lv1.梦旅人 
	梦石0 星屑66 在线时间140 小时注册时间2012-2-6帖子384 | 
| 
本帖最后由 杂兵天下 于 2012-2-18 10:39 编辑
x
加入我们,或者,欢迎回来。您需要 登录 才可以下载或查看,没有帐号?注册会员  
 这样大概可以了吧。。。复制代码class Game_BaseItem
  def stit(st)
    @class=RPG::Skill
    @item_id=st
  end
end
class Game_Action
  def evaluateforai(fault)#MAXBRAIN=100,MAXFAULT=100
    @value = 0
    evaluate_item_ai if valid?
    @value += fault * rand * 0.01 if @value > 0
    return @value
  end
  def evaluate_item_ai
    item_target_candidates.each do |target|
      value = evaluate_item_with_target_ai(target)
      if item.for_all?
        @value += value
      elsif value > @value
        @value = value
        @target_index = target.index
      end
    end
  end
  def evaluate_item_with_target_ai(target)
    target.result.clear
    target.make_damage_value_ai(subject, item)
    if item.for_opponent?
      solve=target.result.hp_damage.to_f / [target.hp, 1].max
    else
      recovery = [-target.result.hp_damage, target.mhp - target.hp].min
      solve=recovery.to_f / target.hp
    end
    sbef=solve
    #记录之前的solve
    solve=0 if ($data_enemies[subject.enemy_id].enemyblind>=100*rand) and (target.tgr<rand)
    #对于blind不为0的敌人说,被攻击度可能是很重要的。
    #不过被攻击度超过100(嘲讽)对于智能敌人是根本无用的。
    t=target
    u=subject
    m=item
    eval $data_enemies[subject.enemy_id].aievaline
    return solve
  end
  def skl=(skl)
    @item.stit(skl)
  end
end
class Game_Battler
  def make_damage_value_ai(user, item)
    value = item.damage.eval(user, self, $game_variables)
    value *= item_element_rate(user, item)
    value *= pdr if item.physical?
    value *= mdr if item.magical?
    value *= rec if item.damage.recover?
    value = apply_guard(value)
    @result.make_damage(value.to_i, item)
  end
end
class Scene_Battle
  alias ea execute_action
  def execute_action
    $game_troop.aipart
    ea
  end
end
module RPG
  class Enemy
    def enemybrain
      note.split(/[\r\n]+/).each { |line|
        case line
        when /<(?:BRAIN|brain):[ ](\d+)>/i
          return $1.to_i
        end
      }
      return 0
    end
    def enemyfault
      note.split(/[\r\n]+/).each { |line|
        case line
        when /<(?:FAULT|fault):[ ](\d+)>/i
          return $1.to_i
        end
      }
      return 100
    end
    def enemyblind
      note.split(/[\r\n]+/).each { |line|
        case line
        when /<(?:BLIND|blind):[ ](\d+)>/i
          return $1.to_i
        end
      }
      return 100
    end
    def aievaline
      note.split(/[\r\n]+/).each { |line|
        case line
        when "<aieval>"
          @aieval=true
          @aieva=""
        when "</aieval>"
          @aieval=false
          return @aieva
        else
          if @aieval==true
            @aieva+=line
            @aieva+="\n"
          end
        end
      }
      return ""
    end
  end
end
class Game_Enemy
  def make_actions
    super
    return if @actions.empty?
    action_list = enemy.actions.select {|a| action_valid?(a) }
    return if action_list.empty?
    rating_max = action_list.collect {|a| a.rating }.max
    rating_zero = rating_max - 3
    action_list.reject! {|a| a.rating <= rating_zero }
    @actions.each do |action|
      action.set_enemy_action(select_enemy_action(action_list, rating_zero))
    end
    @action_list=action_list
  end
  def aipart
    if $data_enemies[@enemy_id].enemybrain>=100*rand
      a=0
      b=0
      for k in @actions
        for i in @action_list
          j=i.skill_id#skill_id
          k.skl=j
          c=k.evaluateforai($data_enemies[@enemy_id].enemyfault)
          if c>a
            a=c
            b=j
          end
          b=j if (c==a and rand>0.5)
        end
      k.skl=b
      k.evaluateforai($data_enemies[@enemy_id].enemyfault)
      end
    end
  end
end
class Game_Troop < Game_Unit
  def aipart
    members.each {|member| member.aipart }
  end
end
不会出现突然行动一个特别的技能
 | 
 |