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

Project1

 找回密码
 注册会员
搜索
查看: 3352|回复: 5

[原创发布] 自动战斗插件

[复制链接]

Lv2.观梦者

梦石
0
星屑
256
在线时间
214 小时
注册时间
2008-12-18
帖子
44
发表于 2021-8-30 16:21:44 | 显示全部楼层 |阅读模式

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

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

x
之前搞过一个MV版本的,现在简单的迁移并做了即时制战斗的适配。
没时间自己测试了,放出来大家测试吧。有BUG可以回帖反馈!

JAVASCRIPT 代码复制下载
  1. /*:
  2.  * @target MZ
  3.  * @plugindesc 自动战斗
  4.  * @author 魏玉龙
  5.  *
  6.  * @param enabled
  7.  * @text 自动战斗开关
  8.  * @type boolean
  9.  * @on 启用
  10.  * @off 禁用
  11.  * @default true
  12.  * @desc 是否开启自动战斗
  13.  *
  14.  * @param command
  15.  * @text 命令文字
  16.  * @type string
  17.  * @desc 命令显示文字
  18.  * @default 自动
  19.  *
  20.  * @param continous
  21.  * @text 连续自动战斗
  22.  * @type boolean
  23.  * @on 连续
  24.  * @off 不连续
  25.  * @desc 是否连续的自动战斗
  26.  * @default false
  27.  *
  28.  * @param skipMessage
  29.  * @text 跳过消息
  30.  * @type boolean
  31.  * @on 跳过
  32.  * @off 不跳过
  33.  * @desc 跳过战斗中的消息
  34.  * @default false
  35.  *
  36.  * @command set
  37.  * @text 自动战斗状态设置
  38.  * @desc 设置自动战斗的各种状态。
  39.  *
  40.  * @arg enabled
  41.  * @text 自动战斗开关
  42.  * @type boolean
  43.  * @on 启用
  44.  * @off 禁用
  45.  * @default true
  46.  * @desc 是否开启自动战斗
  47.  *
  48.  * @arg continous
  49.  * @text 连续自动战斗
  50.  * @type boolean
  51.  * @on 连续
  52.  * @off 不连续
  53.  * @desc 是否连续的自动战斗
  54.  * @default false
  55.  *
  56.  * @arg skipMessage
  57.  * @text 跳过消息
  58.  * @type boolean
  59.  * @on 跳过
  60.  * @off 不跳过
  61.  * @desc 跳过战斗中的消息
  62.  * @default false
  63.  *
  64.  * @help
  65.  * 此插件提供以下插件命令:
  66.  *
  67.  * AutoBattle enable
  68.  *   开启自动战斗
  69.  *
  70.  * AutoBattle disable
  71.  *   关闭自动战斗
  72.  *
  73.  * AutoBattle continous true/false
  74.  *   是否开启连续的自动战斗
  75.  *
  76.  * AutoBattle skipMessage true/false
  77.  *   是否跳过战斗中的消息
  78.  *
  79.  */
  80.  
  81. ;(() => {
  82.   const pluginName = document.currentScript.src.match(/.+\/(.+)\.js/)[1]
  83.   const parameters = PluginManager.parameters(pluginName)
  84.   let autoBattle = {
  85.     enabled: JSON.parse(parameters['enabled'] || true),
  86.     command: String(parameters['command' || 'auto']),
  87.     continous: JSON.parse(parameters['continous'] || false),
  88.     skipMessage: JSON.parse(parameters['skipMessage'] || false),
  89.   }
  90.  
  91.   const _Game_Temp_initialize = Game_Temp.prototype.initialize
  92.   Game_Temp.prototype.initialize = function () {
  93.     _Game_Temp_initialize.call(this)
  94.     this._continousAutoBattle = false
  95.   }
  96.  
  97.   const _Game_BattlerBase_isAutoBattle = Game_BattlerBase.prototype.isAutoBattle
  98.   Game_BattlerBase.prototype.isAutoBattle = function() {
  99.     if($gameTemp._continousAutoBattle){
  100.       return true
  101.     }else{
  102.       return _Game_BattlerBase_isAutoBattle.call(this)
  103.     }
  104.   }
  105.  
  106.   const _Scene_Battle_update = Scene_Battle.prototype.update
  107.   Scene_Battle.prototype.update = function () {
  108.     _Scene_Battle_update.call(this)
  109.     if ($gameTemp._continousAutoBattle && (Input.isTriggered('escape') || Input.isTriggered('cancel'))) {
  110.       SoundManager.playCancel()
  111.       $gameTemp._continousAutoBattle = false
  112.     }
  113.   }
  114.  
  115.   const _Scene_Battle_createAllWindows = Scene_Battle.prototype.createAllWindows
  116.   Scene_Battle.prototype.createAllWindows = function () {
  117.     if (!autoBattle.continous) {
  118.       $gameTemp._continousAutoBattle = false
  119.     }
  120.     _Scene_Battle_createAllWindows.call(this)
  121.   }
  122.  
  123.   const _Scene_Battle_createPartyCommandWindow = Scene_Battle.prototype.createPartyCommandWindow
  124.   Scene_Battle.prototype.createPartyCommandWindow = function () {
  125.     _Scene_Battle_createPartyCommandWindow.call(this)
  126.     if (autoBattle.enabled) {
  127.       this._partyCommandWindow.setHandler('auto', this.commandAutoBattle.bind(this))
  128.     }
  129.   }
  130.  
  131.   const _Scene_Battle_startPartyCommandSelection = Scene_Battle.prototype.startPartyCommandSelection
  132.   Scene_Battle.prototype.startPartyCommandSelection = function () {
  133.     if ($gameTemp._continousAutoBattle && !SceneManager.isSceneChanging()) {
  134.       this.commandAutoBattle.call(this)
  135.     } else {
  136.       _Scene_Battle_startPartyCommandSelection.call(this)
  137.     }
  138.   }
  139.   Scene_Battle.prototype.commandAutoBattle = function () {
  140.     $gameParty.battleMembers().forEach(function (member) {
  141.       if (member.canInput()) {
  142.         member.makeAutoBattleActions()
  143.         if (BattleManager.isTpb()) {
  144.           member.startTpbCasting()
  145.         }
  146.       }
  147.     })
  148.     $gameTemp._continousAutoBattle = true
  149.     this.endCommandSelection()
  150.     BattleManager.startTurn()
  151.   }
  152.   Scene_Battle.prototype.refreshAutobattlerStatusWindow = function () {
  153.     $gameParty.battleMembers().forEach(function (member) {
  154.       if (member.isAutoBattle()) {
  155.         this._statusWindow.drawItem(member.index)
  156.       }
  157.     })
  158.   }
  159.  
  160.   const _Window_Message_startPause = Window_Message.prototype.startPause
  161.   Window_Message.prototype.startPause = function () {
  162.     if ($gameParty.inBattle() && $gameTemp._continousAutoBattle && autoBattle.skipMessage) {
  163.       this.terminateMessage()
  164.     } else {
  165.       _Window_Message_startPause.call(this)
  166.     }
  167.   }
  168.  
  169.   const _Window_PartyCommand_makeCommandList = Window_PartyCommand.prototype.makeCommandList
  170.   Window_PartyCommand.prototype.makeCommandList = function () {
  171.     _Window_PartyCommand_makeCommandList.call(this)
  172.     if (autoBattle.enabled) {
  173.       this.addCommand(autoBattle.command, 'auto')
  174.     }
  175.   }
  176.  
  177.   PluginManager.registerCommand(pluginName, 'set', (args) => {
  178.     for (let [key, value] of Object.entries(args)) {
  179.       autoBattle[key] = value
  180.     }
  181.   })
  182. })()

Lv2.观梦者

梦石
0
星屑
691
在线时间
18 小时
注册时间
2020-8-2
帖子
38
发表于 2021-8-30 21:56:43 | 显示全部楼层
正想找,有时间测试一下
※MV封禁-暮还松填坑中.....
※RMMZ/MV素材分享搬运
www.rpgtuzi.com 素材搬运
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
160
在线时间
16 小时
注册时间
2021-7-4
帖子
39
发表于 2021-9-1 11:40:39 | 显示全部楼层
感谢分享
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
37
在线时间
8 小时
注册时间
2021-9-19
帖子
9
发表于 2021-9-23 06:31:03 | 显示全部楼层
有点复杂啊
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1188
在线时间
87 小时
注册时间
2022-2-5
帖子
194
发表于 2023-4-12 13:15:21 | 显示全部楼层
谢谢大佬~
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
17
在线时间
4 小时
注册时间
2023-5-8
帖子
4
发表于 2023-5-8 21:17:51 | 显示全部楼层
感谢大佬。。
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-3-29 22:43

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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