Project1

标题: 自动战斗插件 [打印本页]

作者: 魏玉龙    时间: 2018-9-13 23:14
标题: 自动战斗插件
本帖最后由 魏玉龙 于 2018-9-14 17:17 编辑

玩别人做的游戏时,刷野怪有点疲了,就随手写了个自动战斗插件!需要的尽管拿去!

JAVASCRIPT 代码复制下载
  1. /*:
  2.  * AutoBattle.js
  3.  * @plugindesc 自动战斗
  4.  * @author 魏玉龙
  5.  * @since 2018.09.12
  6.  * @version 1.0
  7.  *
  8.  * @param enabled
  9.  * @desc 开启自动战斗
  10.  * @default true
  11.  *
  12.  * @param command
  13.  * @desc 命令显示文字
  14.  * @default 自动
  15.  *
  16.  * @param continous
  17.  * @desc 是否连续的自动战斗
  18.  * @default false
  19.  *
  20.  * @param skipMessage
  21.  * @desc 跳过战斗中的消息
  22.  * @default false
  23.  *
  24.  * @help
  25.  * 此插件提供以下插件命令:
  26.  *
  27.  * AutoBattle enable
  28.  *   开启自动战斗
  29.  *
  30.  * AutoBattle disable
  31.  *   关闭自动战斗
  32.  *
  33.  * AutoBattle continous true/false
  34.  *   是否开启连续的自动战斗
  35.  *
  36.  * AutoBattle skipMessage true/false
  37.  *   是否跳过战斗中的消息
  38.  *
  39.  */
  40.  
  41. (function () {
  42.   var parameters = PluginManager.parameters('AutoBattle');
  43.   var autoBattle = {
  44.     enabled: JSON.parse(parameters['enabled'] || true),
  45.     command: String(parameters['command'] || '自动'),
  46.     continous: JSON.parse(parameters['continous'] || false),
  47.     skipMessage: JSON.parse(parameters['skipMessage'] || false)
  48.   };
  49.  
  50.   var Game_Temp_prototype_initialize = Game_Temp.prototype.initialize;
  51.   Game_Temp.prototype.initialize = function () {
  52.     Game_Temp_prototype_initialize.call(this);
  53.     this._continousAutoBattle = false;
  54.   };
  55.  
  56.   var Scene_Battle_prototype_update = Scene_Battle.prototype.update;
  57.   Scene_Battle.prototype.update = function () {
  58.     Scene_Battle_prototype_update.call(this);
  59.     if ($gameTemp._continousAutoBattle && (Input.isTriggered('escape') || Input.isTriggered('cancel'))) {
  60.       SoundManager.playCancel();
  61.       $gameTemp._continousAutoBattle = false;
  62.     }
  63.   }
  64.  
  65.   var Scene_Battle_prototype_createAllWindows = Scene_Battle.prototype.createAllWindows;
  66.   Scene_Battle.prototype.createAllWindows = function () {
  67.     if (!autoBattle.continous) {
  68.       $gameTemp._continousAutoBattle = false;
  69.     }
  70.     Scene_Battle_prototype_createAllWindows.call(this);
  71.   };
  72.  
  73.   var Scene_Battle_prototype_createPartyCommandWindow = Scene_Battle.prototype.createPartyCommandWindow;
  74.   Scene_Battle.prototype.createPartyCommandWindow = function () {
  75.     Scene_Battle_prototype_createPartyCommandWindow.call(this);
  76.     if (autoBattle.enabled) {
  77.       this._partyCommandWindow.setHandler('auto', this.commandAutoBattle.bind(this));
  78.     }
  79.   };
  80.  
  81.   var Scene_Battle_prototype_startPartyCommandSelection = Scene_Battle.prototype.startPartyCommandSelection;
  82.   Scene_Battle.prototype.startPartyCommandSelection = function () {
  83.     if ($gameTemp._continousAutoBattle && !SceneManager.isSceneChanging()) {
  84.       this.commandAutoBattle.call(this);
  85.     } else {
  86.       Scene_Battle_prototype_startPartyCommandSelection.call(this)
  87.     }
  88.   };
  89.   Scene_Battle.prototype.commandAutoBattle = function () {
  90.     $gameParty.battleMembers().forEach(function (member) {
  91.       if (member.canInput()) {
  92.         member.makeAutoBattleActions();
  93.       }
  94.     });
  95.     $gameTemp._continousAutoBattle = true;
  96.     this._partyCommandWindow.deactivate();
  97.     BattleManager.startTurn();
  98.   };
  99.   Scene_Battle.prototype.refreshAutobattlerStatusWindow = function () {
  100.     $gameParty.battleMembers().forEach(function (member) {
  101.       if (member.isAutoBattle()) {
  102.         this._statusWindow.drawItem(member.index)
  103.       }
  104.     });
  105.   };
  106.  
  107.   var Window_Message_prototype_startPause = Window_Message.prototype.startPause;
  108.   Window_Message.prototype.startPause = function () {
  109.     if ($gameParty.inBattle() && $gameTemp._continousAutoBattle && autoBattle.skipMessage) {
  110.       this.terminateMessage();
  111.     } else {
  112.       Window_Message_prototype_startPause.call(this);
  113.     }
  114.   }
  115.  
  116.   var Window_PartyCommand_prototype_makeCommandList = Window_PartyCommand.prototype.makeCommandList;
  117.   Window_PartyCommand.prototype.makeCommandList = function () {
  118.     Window_PartyCommand_prototype_makeCommandList.call(this);
  119.     if (autoBattle.enabled) {
  120.       this.addCommand(autoBattle.command, 'auto');
  121.     }
  122.   };
  123.  
  124.   var Game_Interpreter_prototype_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  125.   Game_Interpreter.prototype.pluginCommand = function (command, args) {
  126.     Game_Interpreter_prototype_pluginCommand.call(this, command, args);
  127.     if (command === "AutoBattle") {
  128.       switch (args) {
  129.         case 'enable':
  130.           autoBattle.enabled = true;
  131.           break
  132.         case 'disable':
  133.           autoBattle.enabled = false;
  134.           break
  135.         case 'continous':
  136.           autoBattle.continous = JSON.parse(args[1]);
  137.           break
  138.         case 'skipMessage':
  139.           autoBattle.continous = JSON.parse(args[1]);
  140.           break
  141.       }
  142.     }
  143.   };
  144. })();

作者: q1456503215    时间: 2018-9-13 23:25
不会用                 
作者: 魏玉龙    时间: 2018-9-13 23:28
下载后扔到插件目录里,在插件管理器里启用就行了,这很难么?
作者: 347780682    时间: 2018-9-13 23:57
话说我想问下和游戏自带的自动战斗有什么不同吗
作者: 魏玉龙    时间: 2018-9-14 00:04
347780682 发表于 2018-9-13 23:57
话说我想问下和游戏自带的自动战斗有什么不同吗

效果类似梦幻西游那样的游戏挂自动刷经验
作者: 梦想家大魔王    时间: 2018-9-15 10:56
我以为可以自由设置自动战斗的AI,看代码是不能。
作者: walf_man    时间: 2018-9-17 16:26
不错的插件,看来mv生态日益强大啊
作者: yushao1999    时间: 2018-10-2 17:59
有没有跳过战斗动画的插件,就是和怪物战斗立马出结果的。
作者: 魏玉龙    时间: 2018-10-3 10:07
yushao1999 发表于 2018-10-2 17:59
有没有跳过战斗动画的插件,就是和怪物战斗立马出结果的。

嗯,我也有这个意思,自动战斗还是有点浪费时间了,想做一个直接结束战斗的调试插件!
但问题是,有些战斗里是有剧情对话和一些变量处理的,甚至可能有选项什么的!
直接pass掉有点不合适,还没想好怎么处理。
作者: gwb170269171    时间: 2018-12-8 01:15
能不能分享一下直接跳过战斗的插件啊,中间过程不用管的那种

作者: eterry11211    时间: 2019-7-23 17:22
好棒 谢谢大大
作者: lrf_2000    时间: 2020-4-5 23:53
收藏一下
作者: monvshuzi    时间: 2020-4-6 00:40
这是挂机战斗插件?谢谢楼主的分享,抱走试试看
作者: monvshuzi    时间: 2020-4-6 01:17
感谢,可以去试试挂机了
作者: 马铃薯条    时间: 2022-2-21 14:57
大佬你好,请问有mog的ABS战斗系统的自动战斗插件吗?
作者: w6363271    时间: 2022-2-21 15:13
这个好哦,可以挂机刷装备了
作者: 马铃薯条    时间: 2022-3-4 10:06
大佬能写个支持AABS的战斗插件吗?
作者: apple5740    时间: 2022-3-27 05:21
话说直接跳过战斗。。。不就是 物品+++ 经验值+++吗。。
作者: a337001949    时间: 2022-9-14 21:46
谢谢大佬分享




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1