查看: 8598|回复: 5

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

[复制链接]
梦石
0
星屑
296
在线时间
217 小时
注册时间
2008-12-18
回帖
30
发表于 2021-8-30 16:21:44 | 显示全部楼层 |阅读模式

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

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

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

  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.   const pluginName = document.currentScript.src.match(/.+\/(.+)\.js/)[1]
  82.   const parameters = PluginManager.parameters(pluginName)
  83.   let autoBattle = {
  84.     enabled: JSON.parse(parameters['enabled'] || true),
  85.     command: String(parameters['command' || 'auto']),
  86.     continous: JSON.parse(parameters['continous'] || false),
  87.     skipMessage: JSON.parse(parameters['skipMessage'] || false),
  88.   }

  89.   const _Game_Temp_initialize = Game_Temp.prototype.initialize
  90.   Game_Temp.prototype.initialize = function () {
  91.     _Game_Temp_initialize.call(this)
  92.     this._continousAutoBattle = false
  93.   }

  94.   const _Game_BattlerBase_isAutoBattle = Game_BattlerBase.prototype.isAutoBattle
  95.   Game_BattlerBase.prototype.isAutoBattle = function() {
  96.     if($gameTemp._continousAutoBattle){
  97.       return true
  98.     }else{
  99.       return _Game_BattlerBase_isAutoBattle.call(this)
  100.     }
  101.   }

  102.   const _Scene_Battle_update = Scene_Battle.prototype.update
  103.   Scene_Battle.prototype.update = function () {
  104.     _Scene_Battle_update.call(this)
  105.     if ($gameTemp._continousAutoBattle && (Input.isTriggered('escape') || Input.isTriggered('cancel'))) {
  106.       SoundManager.playCancel()
  107.       $gameTemp._continousAutoBattle = false
  108.     }
  109.   }

  110.   const _Scene_Battle_createAllWindows = Scene_Battle.prototype.createAllWindows
  111.   Scene_Battle.prototype.createAllWindows = function () {
  112.     if (!autoBattle.continous) {
  113.       $gameTemp._continousAutoBattle = false
  114.     }
  115.     _Scene_Battle_createAllWindows.call(this)
  116.   }

  117.   const _Scene_Battle_createPartyCommandWindow = Scene_Battle.prototype.createPartyCommandWindow
  118.   Scene_Battle.prototype.createPartyCommandWindow = function () {
  119.     _Scene_Battle_createPartyCommandWindow.call(this)
  120.     if (autoBattle.enabled) {
  121.       this._partyCommandWindow.setHandler('auto', this.commandAutoBattle.bind(this))
  122.     }
  123.   }

  124.   const _Scene_Battle_startPartyCommandSelection = Scene_Battle.prototype.startPartyCommandSelection
  125.   Scene_Battle.prototype.startPartyCommandSelection = function () {
  126.     if ($gameTemp._continousAutoBattle && !SceneManager.isSceneChanging()) {
  127.       this.commandAutoBattle.call(this)
  128.     } else {
  129.       _Scene_Battle_startPartyCommandSelection.call(this)
  130.     }
  131.   }
  132.   Scene_Battle.prototype.commandAutoBattle = function () {
  133.     $gameParty.battleMembers().forEach(function (member) {
  134.       if (member.canInput()) {
  135.         member.makeAutoBattleActions()
  136.         if (BattleManager.isTpb()) {
  137.           member.startTpbCasting()
  138.         }
  139.       }
  140.     })
  141.     $gameTemp._continousAutoBattle = true
  142.     this.endCommandSelection()
  143.     BattleManager.startTurn()
  144.   }
  145.   Scene_Battle.prototype.refreshAutobattlerStatusWindow = function () {
  146.     $gameParty.battleMembers().forEach(function (member) {
  147.       if (member.isAutoBattle()) {
  148.         this._statusWindow.drawItem(member.index)
  149.       }
  150.     })
  151.   }

  152.   const _Window_Message_startPause = Window_Message.prototype.startPause
  153.   Window_Message.prototype.startPause = function () {
  154.     if ($gameParty.inBattle() && $gameTemp._continousAutoBattle && autoBattle.skipMessage) {
  155.       this.terminateMessage()
  156.     } else {
  157.       _Window_Message_startPause.call(this)
  158.     }
  159.   }

  160.   const _Window_PartyCommand_makeCommandList = Window_PartyCommand.prototype.makeCommandList
  161.   Window_PartyCommand.prototype.makeCommandList = function () {
  162.     _Window_PartyCommand_makeCommandList.call(this)
  163.     if (autoBattle.enabled) {
  164.       this.addCommand(autoBattle.command, 'auto')
  165.     }
  166.   }

  167.   PluginManager.registerCommand(pluginName, 'set', (args) => {
  168.     for (let [key, value] of Object.entries(args)) {
  169.       autoBattle[key] = value
  170.     }
  171.   })
  172. })()
复制代码
梦石
0
星屑
698
在线时间
18 小时
注册时间
2020-8-2
回帖
27
发表于 2021-8-30 21:56:43 | 显示全部楼层
正想找,有时间测试一下
※MV封禁-暮还松填坑中.....
※RMMZ/MV素材分享搬运
www.rpgtuzi.com 素材搬运
回复

使用道具 举报

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

使用道具 举报

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

使用道具 举报

梦石
0
星屑
1217
在线时间
89 小时
注册时间
2022-2-5
回帖
190
发表于 2023-4-12 13:15:21 | 显示全部楼层
谢谢大佬~
回复

使用道具 举报

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

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部