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

Project1

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

[原创发布] 自动战斗(??),战斗行动指令自动输入

[复制链接]

Lv1.梦旅人

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
帖子
1316
跳转到指定楼层
1
发表于 2014-10-11 20:39:29 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x

可以用来制作一次性召唤兽等等
详见工程
自动战斗.zip (230.57 KB, 下载次数: 143)



晾晒脚本(才100多行我自豪我骄傲 233333333)
  1. class Game_Temp
  2.   attr_accessor :input_command, :input_skill
  3.   alias initialize_input_command initialize
  4.   def initialize
  5.     initialize_input_command
  6.     @input_command = []
  7.     @input_skill = []
  8.    
  9.     @input_command[1] = "防御"   # 1号角色会自动防御
  10.     @input_command[2] = "特技"   # 2号角色会自动防御
  11.     @input_command[7] = "特技"   # 3号角色会自动施放(默认)特技
  12.     @input_command[8] = "攻击"   # 4号角色会自动攻击
  13.    
  14.     @input_skill[1] = 57      #1号角色的默认技能十字斩
  15.     @input_skill[2] = 61      #2号角色的默认技能扫荡
  16.     @input_skill[7] = [*1..6] #7号角色的默认技能1到6号特技
  17.     @input_skill[8] = 7       #8号角色的默认技能火炎
  18.   end
  19. end
  20. class Scene_Battle
  21.   def input_command # 输入指令
  22.     for actor_index in 0...$game_party.actors.size
  23.       case $game_temp.input_command[$game_party.actors[actor_index].id]
  24.       when "防御"
  25.         # 设置行动
  26.         $game_party.actors[actor_index].current_action.kind = 0
  27.         $game_party.actors[actor_index].current_action.basic = 1
  28.       when "攻击"
  29.         # 设置行动
  30.         $game_party.actors[actor_index].current_action.kind = 0
  31.         $game_party.actors[actor_index].current_action.basic = 0
  32.         # 随机选择敌人
  33.         $game_party.actors[actor_index].current_action.target_index =
  34.         $game_troop.enemies.index($game_troop.random_target_enemy)
  35.       when "特技"
  36.         if $game_temp.input_skill[$game_party.actors[actor_index].id].is_a?(Numeric)
  37.           skill = $data_skills[$game_temp.input_skill[$game_party.actors[actor_index].id]]
  38.           # 魔法不足或者无效特技
  39.           if (skill.sp_cost > $game_party.actors[actor_index].sp) or ([2, 3].include?(skill.occasion) or skill.scope == 0)
  40.             # 气血较多自动攻击,较少自动防御
  41.             if 1.0 * $game_party.actors[actor_index].hp / $game_party.actors[actor_index].maxhp >= 0.3
  42.               # 设置行动
  43.               $game_party.actors[actor_index].current_action.kind = 0
  44.               $game_party.actors[actor_index].current_action.basic = 0
  45.               # 随机选择敌人
  46.               $game_party.actors[actor_index].current_action.target_index =
  47.               $game_troop.enemies.index($game_troop.random_target_enemy)
  48.             else
  49.               # 设置行动
  50.               $game_party.actors[actor_index].current_action.kind = 0
  51.               $game_party.actors[actor_index].current_action.basic = 1
  52.             end
  53.             next
  54.           end
  55.         elsif $game_temp.input_skill[$game_party.actors[actor_index].id].is_a?(Array)
  56.           skill_id = $game_temp.input_skill[$game_party.actors[actor_index].id]
  57.           # 随机特技
  58.           input_id = []
  59.           for id in skill_id
  60.             skill = $data_skills[id]
  61.             if (skill.sp_cost <= $game_party.actors[actor_index].sp) and ([0, 1].include?(skill.occasion) and skill.scope != 0)
  62.               input_id << id
  63.             end
  64.           end
  65.           # 指令
  66.           if input_id.size != 0
  67.             skill = $data_skills[input_id[rand(input_id.size)]]
  68.           else
  69.             # 气血较多自动攻击,较少自动防御
  70.             if 1.0 * $game_party.actors[actor_index].hp / $game_party.actors[actor_index].maxhp >= 0.3
  71.               # 设置行动
  72.               $game_party.actors[actor_index].current_action.kind = 0
  73.               $game_party.actors[actor_index].current_action.basic = 0
  74.               # 随机选择敌人
  75.               $game_party.actors[actor_index].current_action.target_index =
  76.               $game_troop.enemies.index($game_troop.random_target_enemy)
  77.             else
  78.               # 设置行动
  79.               $game_party.actors[actor_index].current_action.kind = 0
  80.               $game_party.actors[actor_index].current_action.basic = 1
  81.             end
  82.             next
  83.           end
  84.         end
  85.         # 设置行动
  86.         $game_party.actors[actor_index].current_action.kind = 1
  87.         $game_party.actors[actor_index].current_action.skill_id = skill.id
  88.         # 随机选择
  89.         case skill.scope
  90.         when 1
  91.           $game_party.actors[actor_index].current_action.target_index =
  92.           $game_troop.enemies.index($game_troop.random_target_enemy)
  93.         when 3
  94.           $game_party.actors[actor_index].current_action.target_index =
  95.           $game_party.actors.index($game_party.random_target_actor)
  96.         when 5
  97.           if $game_party.random_target_actor_hp0.nil?
  98.             next
  99.           end
  100.           $game_party.actors[actor_index].current_action.target_index =
  101.           $game_party.actors.index($game_party.random_target_actor_hp0)
  102.         end
  103.       end
  104.     end
  105.   end
  106.   #--------------------------------------------------------------------------
  107.   # ● 转到输入下一个角色的命令
  108.   #--------------------------------------------------------------------------
  109.   def phase3_next_actor
  110.     # 循环
  111.     begin
  112.       # 角色的明灭效果 OFF
  113.       if @active_battler != nil
  114.         @active_battler.blink = false
  115.       end
  116.       # 最后的角色的情况
  117.       if @actor_index == $game_party.actors.size-1
  118.         # 开始主回合
  119.         input_command
  120.         start_phase4
  121.         return
  122.       end
  123.       # 推进角色索引
  124.       @actor_index += 1
  125.       # =======================================================
  126.       while $game_temp.input_command[$game_party.actors[@actor_index].id] != nil
  127.         @actor_index += 1
  128.         if @actor_index == $game_party.actors.size - 1
  129.           # 开始主回合
  130.           input_command
  131.           start_phase4
  132.           return
  133.         end
  134.       end
  135.       # =======================================================
  136.       @active_battler = $game_party.actors[@actor_index]
  137.       @active_battler.blink = true
  138.     # 如果角色是在无法接受指令的状态就再试
  139.     end until @active_battler.inputable?
  140.     # 设置角色的命令窗口
  141.     phase3_setup_command_window
  142.   end
  143.   #--------------------------------------------------------------------------
  144.   # ● 转向前一个角色的命令输入
  145.   #--------------------------------------------------------------------------
  146.   def phase3_prior_actor
  147.     # 循环
  148.     begin
  149.       # 角色的明灭效果 OFF
  150.       if @active_battler != nil
  151.         @active_battler.blink = false
  152.       end
  153.       # 最初的角色的情况下
  154.       if @actor_index == 0
  155.         # 开始同伴指令回合
  156.         start_phase2
  157.         return
  158.       end
  159.       # 返回角色索引
  160.       @actor_index -= 1
  161.       # =======================================================
  162.       while $game_temp.input_command[$game_party.actors[@actor_index].id] != nil
  163.         @actor_index -= 1
  164.         if @actor_index <= 0
  165.           # 开始同伴指令回合
  166.           start_phase2
  167.           return
  168.         end
  169.       end
  170.       # =======================================================
  171.       @active_battler = $game_party.actors[@actor_index]
  172.       @active_battler.blink = true
  173.     # 如果角色是在无法接受指令的状态就再试
  174.     end until @active_battler.inputable?
  175.     # 设置角色的命令窗口
  176.     phase3_setup_command_window
  177.   end
  178. end
复制代码

Lv4.逐梦者

梦石
0
星屑
9275
在线时间
2504 小时
注册时间
2011-5-20
帖子
15389

开拓者

2
发表于 2014-10-11 21:32:54 | 只看该作者
一次性召唤兽?是召唤生物死了离队的那种吗···

点评

···感觉这个AI有点不科学···奶妈各种用治疗就算队友全部满血还是在用···还有阿尔西斯我这里测试不知道为什么不停防御不攻击···  发表于 2014-10-11 23:42
用技能或物品召唤出的同伴(更何况还不可控)自然不会长期在队伍中,所以我称为“一次性”。。  发表于 2014-10-11 23:30
···那这个一次性指的是什么···  发表于 2014-10-11 23:14
其实想要表达的是某同伴不可控制。。怎么离队都无所谓。。。  发表于 2014-10-11 23:11
我知道是这么召唤···我问的是是那种死掉就离队的召唤兽吗···  发表于 2014-10-11 23:04
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-29 15:15

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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