设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 70|回复: 0

[转载发布] Battle Test v1.0

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    7959

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    29925
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    38778

    灌水之王

    发表于 3 天前 | 显示全部楼层 |阅读模式
    Introduction
    Provides various features to help with battle testing.

    Features

    • Run custom code at the start of each battle test.
    • Control the quantity of items given during battle test.
    • Set the starting HP/MP Rate of the party, as well as give a bonus/penalty to starting TP during battle test.
    • Allows for logging details of the battle to the console.
    • Allows for not closing the game after a battle test.
    How to use
    Save as APHO_BattleTest.js, add it via the plugin manager, adjust parameters as you see fit.
    Spoiler: Parameters Explanation
    Battle Test Initialise Code:
    Put custom code that you want to run before a battle test here. This will only apply to battle tests, and not test play.

    Override setupBattleTestItems:
    If enabled, allows you to set the quantity of items given during battle test. You can also set a different quantity for regular/key items/hidden items A/B.

    Exclude Item Prefix:
    Items whose names start with this are never given during battle test. Leave blank to not exclude anything.
    (For example, if you use items with names like '==POTIONS==' to divide your database for organisation, you can set this to '==' to ignore all such items)

    HP Rate, MP Rate:
    Starting HP/MP Rate of the party during a battle test. Must be a value between 0 to 1, where 1 is full HP/MP.

    TP Bonus:
    Grant a flat bonus to TP at the start of battle test. Can be negative to instead lose TP. Requires 'Preserve TP'.

    Detailed log:
    If set to true, details of the battle will be logged to the console. This works during test play as well. Set the value display and decimal rounding to whatever you prefer (if you do not want decimals to be rounded, set Decimals to -1), and set each parameter in the list to whether you want it logged or not.

    Close after battle test:
    By default, the game will close itself after a battle test.
    You may optionally choose to not close the game.
    This might be useful if you wish to review the logs at the end of battle.
    Note that doing so requires overriding BattleManager.updateBattleEnd whenever in a battle test.
    Script
    Spoiler: CODE
                    JavaScript:       
    1. //==========================================
    2. // APHO_BattleTest.js
    3. //==========================================
    4. /*:
    5. * @title Battle Test
    6. * @author Apho
    7. * @plugindesc v1.0 Provides various features to help with battle testing.
    8. *
    9. * @param BattleTestInitCode
    10. * @text Battle Test Initialise Code
    11. * @desc Code to run whenever a battle test starts. This runs after the default functions.
    12. * @type note
    13. * @default ""
    14. *
    15. * @param OverridesetupBattleTestItems
    16. * @text Override setupBattleTestItems?
    17. * @desc Override the default setupBattleTestItems function which gives the max number of all items?
    18. * @type boolean
    19. * @default false
    20. *
    21. * @param ExcludeItemPrefix
    22. * @parent OverridesetupBattleTestItems
    23. * @text Exclude Item Prefix
    24. * @desc Items whose names start with this are never given during battle test. Leave blank to not exclude anything.
    25. * @type string
    26. * @default
    27. *
    28. * @param RegularItemQty
    29. * @parent OverridesetupBattleTestItems
    30. * @text Regular Item Quantity
    31. * @desc Quantity of each regular item that will be given at the start of a battle test. This is an eval.
    32. * @type string
    33. * @default this.maxItems(item)
    34. *
    35. * @param KeyItemQty
    36. * @parent OverridesetupBattleTestItems
    37. * @text Key Item Quantity
    38. * @desc Quantity of each key item that will be given at the start of a battle test. This is an eval.
    39. * @type string
    40. * @default 0
    41. *
    42. * @param HiddenItemAQty
    43. * @parent OverridesetupBattleTestItems
    44. * @text Hidden Item A Quantity
    45. * @desc Quantity of each hidden item A that will be given at the start of a battle test. This is an eval.
    46. * @type string
    47. * @default 0
    48. *
    49. * @param HiddenItemBQty
    50. * @parent OverridesetupBattleTestItems
    51. * @text Hidden Item B Quantity
    52. * @desc Quantity of each hidden item B that will be given at the start of a battle test. This is an eval.
    53. * @type string
    54. * @default 0
    55. *
    56. * @param HpRate
    57. * @text HP Rate
    58. * @desc Starting HP rate of the party during battle test.
    59. * @type number
    60. * @decimals 10
    61. * @max 1
    62. * @min 0
    63. * @default 1
    64. *
    65. * @param MpRate
    66. * @text MP Rate
    67. * @desc Starting MP rate of the party during battle test.
    68. * @type number
    69. * @decimals 10
    70. * @max 1
    71. * @min 0
    72. * @default 1
    73. *
    74. * @param TpBonus
    75. * @text TP Bonus
    76. * @desc Grant a flat bonus (or penalty) to TP at the start of battle test. Requires 'Preserve TP'.
    77. * @type number
    78. * @min -999999
    79. * @default 0
    80. *
    81. * @param DetailedLog
    82. * @text Detailed Log
    83. * @desc Displays detailed information about the battle in the console.
    84. * @type boolean
    85. * @default true
    86. *
    87. * @param ValueDisplay
    88. * @parent DetailedLog
    89. * @text Value Display
    90. * @desc How should values in the log be displayed as?
    91. * @type select
    92. * @option Decimal
    93. * @value 0
    94. * @option Percentage
    95. * @value 1
    96. * @default 1
    97. *
    98. * @param Decimals
    99. * @parent DetailedLog
    100. * @text Decimals
    101. * @desc How many decimal places should values in the log be rounded to? Set to -1 for no rounding.
    102. * @type number
    103. * @min -1
    104. * @default -1
    105. *
    106. * @param EscapeRate
    107. * @parent DetailedLog
    108. * @text Escape Rate
    109. * @desc Show the current escape success rate. This is shown as a decimal, where 1.0 = 100%.
    110. * @type boolean
    111. * @default true
    112. *
    113. * @param PartyAvgHP
    114. * @parent DetailedLog
    115. * @text Party Average HP
    116. * @desc Show the average HP% of party members. Dead members count as having 0%.
    117. * @type boolean
    118. * @default true
    119. *
    120. * @param PartyAvgMP
    121. * @parent DetailedLog
    122. * @text Party Average MP
    123. * @desc Show the average MP% of party members. Members with 0 max MP count as having 0%.
    124. * @type boolean
    125. * @default true
    126. *
    127. * @param PartyAvgTP
    128. * @parent DetailedLog
    129. * @text Party Average TP
    130. * @desc Show the average TP% of party members.
    131. * @type boolean
    132. * @default true
    133. * @param TroopAvgHP
    134. * @parent DetailedLog
    135. * @text Troop Average HP
    136. * @desc Show the average HP% of enemy troop members. Dead members count as having 0%.
    137. * @type boolean
    138. * @default true
    139. *
    140. * @param TroopAvgMP
    141. * @parent DetailedLog
    142. * @text Troop Average MP
    143. * @desc Show the average MP% of enemy troop members. Members with 0 max MP count as having 0%.
    144. * @type boolean
    145. * @default true
    146. *
    147. * @param TroopAvgTP
    148. * @parent DetailedLog
    149. * @text Troop Average TP
    150. * @desc Show the average TP% of enemy troop members.
    151. * @type boolean
    152. * @default true
    153. *
    154. * @param CloseAfterBattleTest
    155. * @text Close after battle test
    156. * @desc Close the game after a battle test ends?
    157. * @type boolean
    158. * @default true
    159. *
    160. * @help
    161. * Battle Test Initialise Code:
    162. * Allows for running custom code upon starting a battle test.
    163. *
    164. * Override setupBattleTestItems:
    165. * Allows for overriding the default function that gives the max amount of items.
    166. * If enabled, you may exclude items, as well as specify the quantity based on
    167. * type. (regular item, key item, etc)
    168. * Evals may also be used. Use 'item' to refer to the item.
    169. *
    170. * HP Rate, MP Rate, TP Bonus:
    171. * Set the starting HP/MP Rate of the party during battle test.
    172. * HP/MP Rate must be a value from 0 to 1, where 1 is full HP/MP.
    173. * TP Bonus is a flat value added to starting TP. Can be negative.
    174. * Requires 'Preserve TP'.
    175. *
    176. * Detailed Log:
    177. * Allows for logging details of the battle to the console (F8).
    178. * Unlike the other features, this also works during regular test play battles.
    179. * This log will be updated at the end of each turn / battle.
    180. * You may have the values displayed either as a decimal (where 1.0 = 100%), or
    181. * as a percentage, as well as specify which values will be logged and number of
    182. * decimal places rounded to.
    183. *
    184. * Close after battle test:
    185. * By default, the game will close itself after a battle test.
    186. * You may optionally choose to not close the game.
    187. * This might be useful if you wish to review the logs at the end of battle.
    188. * Note that doing so requires overriding BattleManager.updateBattleEnd
    189. * whenever in a battle test.
    190. *
    191. * NOTES
    192. * - Since this plugin is purely for testing purposes, it can be removed or
    193. * disabled prior to deployment.
    194. * - If using YEP_BattleEngineCore.js, place this plugin above it in the Plugin
    195. * Manager.
    196. *
    197. * TERMS OF USE
    198. * - Edits allowed for personal use.
    199. * - Do not repost or claim as your own, even if edited.
    200. *
    201. * VERSION HISTORY
    202. * v1.0 - 2023/10/19 - Initial release.
    203. */
    204. (function(){
    205.     var parameters = PluginManager.parameters('APHO_BattleTest');
    206.     const GameParty_setupBattleTest = Game_Party.prototype.setupBattleTest;
    207.     Game_Party.prototype.setupBattleTest = function()
    208.     {
    209.         GameParty_setupBattleTest.call(this);
    210.         let HpRate = parseFloat(parameters['HpRate']);
    211.         let MpRate = parseFloat(parameters['MpRate']);
    212.         let TpBonus = parseInt(parameters['TpBonus']);
    213.         $gameParty.members().forEach(function(member) {
    214.             if(HpRate < 1)member.setHp(Math.round(member.mhp * HpRate));
    215.             if(MpRate < 1)member.setMp(Math.round(member.mmp * MpRate));
    216.             if(TpBonus != 0)member.gainTp(TpBonus);
    217.         });
    218.         eval(JSON.parse(parameters['BattleTestInitCode']));
    219.     };
    220.     const Game_Party_setupBattleTestItems = Game_Party.prototype.setupBattleTestItems;
    221.     Game_Party.prototype.setupBattleTestItems = function()
    222.     {
    223.         if(!parameters['OverridesetupBattleTestItems'])
    224.         {
    225.             Game_Party_setupBattleTestItems.call(this);
    226.         }
    227.         else
    228.         {
    229.             let ExcludeItemPrefix = parameters['ExcludeItemPrefix'];
    230.             let NeedsExclude = ExcludeItemPrefix && (ExcludeItemPrefix.length > 0);
    231.             $dataItems.forEach(function(item) {
    232.                 if (item && item.name.length > 0 && (!NeedsExclude || !item.name.startsWith(ExcludeItemPrefix)))
    233.                 {
    234.                     switch(item.itypeId)
    235.                     {
    236.                         case 1:
    237.                             this.gainItem(item, eval(parameters['RegularItemQty']));
    238.                             break;
    239.                         case 2:
    240.                             this.gainItem(item, eval(parameters['KeyItemQty']));
    241.                             break;
    242.                         case 3:
    243.                             this.gainItem(item, eval(parameters['HiddenItemAQty']));
    244.                             break;
    245.                         case 4:
    246.                             this.gainItem(item, eval(parameters['HiddenItemBQty']));
    247.                             break;
    248.                     }
    249.                 }
    250.             }, this);
    251.         }
    252.     }
    253.     //DETAILED LOGGING
    254.     var DetailedLog = JSON.parse(parameters['DetailedLog']);
    255.     if(DetailedLog)
    256.     {
    257.         //setting up functions and stuff
    258.         var ValueDisplay = parseInt(parameters['ValueDisplay']);
    259.         var Decimals = parseInt(parameters['Decimals']);
    260.         function round(n)
    261.         {
    262.             if(ValueDisplay == 0)
    263.             {
    264.                 if(Decimals == -1)
    265.                 {
    266.                     return n;
    267.                 }
    268.                 else
    269.                 {
    270.                     return n.toFixed(Decimals);
    271.                 }
    272.             }
    273.             else if(ValueDisplay == 1)
    274.             {
    275.                 n *= 100;
    276.                 if(Decimals == -1)
    277.                 {
    278.                     return n + "%";
    279.                 }
    280.                 else
    281.                 {
    282.                     return n.toFixed(Decimals) + "%";
    283.                 }
    284.             }
    285.         }
    286.         var NeedsEscapeRate = JSON.parse(parameters['EscapeRate']);
    287.         function EscapeRate()
    288.         {
    289.             if(NeedsEscapeRate)
    290.             {
    291.                 console.log("Escape Rate: " + round(BattleManager._escapeRatio));
    292.             }
    293.         }
    294.         var NeedsPartyAvgHP = JSON.parse(parameters['PartyAvgHP']);
    295.         function PartyAvgHP()
    296.         {
    297.             if(NeedsPartyAvgHP)
    298.             {
    299.                 let total = 0, average = 0;
    300.                 $gameParty.members().forEach(function(member){
    301.                     total += member.hpRate();
    302.                 });
    303.                 average = total / $gameParty.members().length
    304.                 console.log("Party HP: " + round(average));
    305.             }
    306.         }
    307.         var NeedsPartyAvgMP = JSON.parse(parameters['PartyAvgMP']);
    308.         function PartyAvgMP()
    309.         {
    310.             if(NeedsPartyAvgMP)
    311.             {
    312.                 let total = 0, average = 0;
    313.                 $gameParty.members().forEach(function(member){
    314.                     total += member.mpRate();
    315.                 });
    316.                 average = total / $gameParty.members().length
    317.                 console.log("Party MP: " + round(average));
    318.             }
    319.         }
    320.         var NeedsPartyAvgTP = JSON.parse(parameters['PartyAvgTP']);
    321.         function PartyAvgTP()
    322.         {
    323.             if(NeedsPartyAvgTP)
    324.             {
    325.                 let total = 0, average = 0;
    326.                 $gameParty.members().forEach(function(member){
    327.                     total += member.tpRate();
    328.                 });
    329.                 average = total / $gameParty.members().length
    330.                 console.log("Party TP: " + round(average));
    331.             }
    332.         }
    333.         var NeedsTroopAvgHP = JSON.parse(parameters['TroopAvgHP']);
    334.         function TroopAvgHP()
    335.         {
    336.             if(NeedsTroopAvgHP)
    337.             {
    338.                 let total = 0, average = 0;
    339.                 $gameTroop.members().forEach(function(member){
    340.                     total += member.hpRate();
    341.                 });
    342.                 average = total / $gameTroop.members().length
    343.                 console.log("Enemy Troop HP: " + round(average));
    344.             }
    345.         }
    346.         var NeedsTroopAvgMP = JSON.parse(parameters['TroopAvgMP']);
    347.         function TroopAvgMP()
    348.         {
    349.             if(NeedsTroopAvgMP)
    350.             {
    351.                 let total = 0, average = 0;
    352.                 $gameTroop.members().forEach(function(member){
    353.                     total += member.mpRate();
    354.                 });
    355.                 average = total / $gameTroop.members().length
    356.                 console.log("Enemy Troop MP: " + round(average));
    357.             }
    358.         }
    359.         var NeedsTroopAvgTP = JSON.parse(parameters['TroopAvgTP']);
    360.         function TroopAvgTP()
    361.         {
    362.             if(NeedsTroopAvgTP)
    363.             {
    364.                 let total = 0, average = 0;
    365.                 $gameTroop.members().forEach(function(member){
    366.                     total += member.tpRate();
    367.                 });
    368.                 average = total / $gameTroop.members().length
    369.                 console.log("Enemy Troop TP: " + round(average));
    370.             }
    371.         }
    372.         //actual logging
    373.         const BattleManager_startBattle = BattleManager.startBattle
    374.         BattleManager.startBattle = function()
    375.         {
    376.             BattleManager_startBattle.call(this);
    377.             console.log("==BATTLE START!==");
    378.             EscapeRate();
    379.             PartyAvgTP();
    380.             TroopAvgTP();
    381.         }
    382.         const BattleManager_endTurn = BattleManager.endTurn;
    383.         BattleManager.endTurn = function()
    384.         {
    385.             BattleManager_endTurn.call(this);
    386.             console.log("==TURN " + $gameTroop.turnCount() + " END==");
    387.             EscapeRate();
    388.             PartyAvgHP();
    389.             PartyAvgMP();
    390.             PartyAvgTP();
    391.             TroopAvgHP();
    392.             TroopAvgMP();
    393.             TroopAvgTP();
    394.         }
    395.         const BattleManager_processVictory = BattleManager.processVictory;
    396.         BattleManager.processVictory = function()
    397.         {
    398.             BattleManager_processVictory.call(this);
    399.             console.log("==VICTORY (TURN " + $gameTroop.turnCount() + ")==");
    400.             EscapeRate();
    401.             PartyAvgHP();
    402.             PartyAvgMP();
    403.             PartyAvgTP();
    404.             TroopAvgHP();
    405.             TroopAvgMP();
    406.             TroopAvgTP();
    407.         }
    408.         if(NeedsEscapeRate)
    409.         {
    410.             const BattleManager_processEscape = BattleManager.processEscape;
    411.             BattleManager.processEscape = function()
    412.             {
    413.                 let OriginalEscapeRate = round(BattleManager._escapeRatio);
    414.                 let EscapeSuccess = BattleManager_processEscape.call(this);
    415.                 if(EscapeSuccess)
    416.                 {
    417.                     console.log("==ESCAPED (TURN " + ($gameTroop.turnCount() + 1) + ")==");
    418.                     EscapeRate();
    419.                     PartyAvgHP();
    420.                     PartyAvgMP();
    421.                     PartyAvgTP();
    422.                     TroopAvgHP();
    423.                     TroopAvgMP();
    424.                     TroopAvgTP();
    425.                 }else
    426.                 {
    427.                     console.log("==ESCAPE FAILED==\nEscape Rate: " + OriginalEscapeRate + " → " + round(BattleManager._escapeRatio));
    428.                 }
    429.             }
    430.         }
    431.         const BattleManager_processAbort = BattleManager.processAbort;
    432.         BattleManager.processAbort = function()
    433.         {
    434.             BattleManager_processAbort.call(this);
    435.             console.log("==ABORTED (TURN " + $gameTroop.turnCount() + ")==");
    436.             EscapeRate();
    437.             PartyAvgHP();
    438.             PartyAvgMP();
    439.             PartyAvgTP();
    440.             TroopAvgHP();
    441.             TroopAvgMP();
    442.             TroopAvgTP();
    443.         }
    444.         const BattleManager_processDefeat = BattleManager.processDefeat;
    445.         BattleManager.processDefeat = function()
    446.         {
    447.             BattleManager_processDefeat.call(this);
    448.             console.log("==DEFEATED (TURN " + $gameTroop.turnCount() + ")==");
    449.             EscapeRate();
    450.             PartyAvgHP();
    451.             PartyAvgMP();
    452.             PartyAvgTP();
    453.             TroopAvgHP();
    454.             TroopAvgMP();
    455.             TroopAvgTP();
    456.         }
    457.     }
    458.     //Don't close the game after battleTest
    459.     var CloseAfterBattleTest = JSON.parse(parameters['CloseAfterBattleTest']);
    460.     if(!CloseAfterBattleTest)
    461.     {
    462.         const BattleManager_updateBattleEnd = BattleManager.updateBattleEnd;
    463.         BattleManager.updateBattleEnd = function()
    464.         {
    465.             if (!this.isBattleTest()) BattleManager_updateBattleEnd.call(this);
    466.         };
    467.     }
    468. })();
    复制代码


    Notes

    • Since this plugin is purely for testing purposes, it can be removed or disabled prior to deployment.
    • If using YEP_BattleEngineCore.js, place this plugin above it in the Plugin Manager.
    Terms of Use

    • Edits allowed for personal use.
    • Do not repost or claim as your own, even if edited.
    • Do not use for training AI models. This includes, but is not limited to, inputting the plugin contents or part thereof into AI models that train on user input.
    Version History
    v1.0 - 2023/10/19 - Initial release.

    Download Link
    GitHub

    Spoiler: SCREENSHOT




    本贴来自国际rpgmaker官方论坛作者:AphoticAmaranth处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/battle-test-v1-0.162160/

    本帖子中包含更多资源

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

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-1 03:41 , Processed in 0.090771 second(s), 57 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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