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

[转载发布] Damage Core v1.1

[复制链接]
累计送礼:
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
    Allows for more control over damage and stuff.

    Features

    • Play a sound effect when dealing 0 damage, or healing for 0 hp. Pitch variances may also be set for the sounds.
    • Introduces adaptive & piercing damage, as well as countermeasures to them.
    • Allows attacks to ignore guarding.
    • Allows for forcing min/max variance, or no variance.
    How to use
    Sound effects are defined in the plugin parameters.
    The following notetags are available:
    Skills, Items, Actors, Classes, Enemies, & States notetags:
    1. <adaptive>
    复制代码
    Calculates damage using higher of target's physical or magical damage rate.
    For Actors, Classes, Enemies, or States, causes all of user's attacks and skills to become adaptive.
    1. <adaptiveeval>
    复制代码
    1. //code
    复制代码
    1. </adaptiveeval>
    复制代码
    Evaluates code to determine if the attack should be adaptive.
    Must return either true (adaptive) or false (not adaptive).
    You may use 'a' for the attacker, 'b' for the defender, and 'item' for the skill/item Object.
    1. <piercing:x>
    复制代码
    ,
    1. <ppiercing:x>
    复制代码
    ,
    1. <mpiercing:x>
    复制代码
    Ignores a percentage of target's damage reduction. x must be a value between 0 and 1.
    'piercing' applies to both PDR and MDR, while 'ppiercing' and 'mpiercing' apply only to PDR and MDR respectively.
    For Actors, Classes, Enemies, or States, causes all of user's attacks and skills to have x piercing, overriding any skill or item notetags.
    Notetag priority from highest to lowest is as follows:
    States, Classes (for actors), Enemies/Actors

    EXAMPLE
    1. <piercing:0.4>
    复制代码
    If a physical skill with this notetag is used against a target with 80% Physical Damage Rate, the calculation is as follows:
    Original damage reduction = 100% - 80% = 20%
    0.4 / 40% of the damage reduction is ignored.
    Target still has 20% * (1 - 0.4) = 12% damage reduction.
    Final Physical Damage Rate = 100% - 12% = 88%
    1. <piercingeval>
    复制代码
    1. //code
    复制代码
    1. </piercingeval>
    复制代码
    Evaluates code to determine piercing. Must return a value between 0 and 1.
    You may also use
    1. <ppiercingeval>
    复制代码
    for physical piercing, or
    1. <mpiercingeval>
    复制代码
    for magical piercing.
    You may use 'a' for the attacker, 'b' for the defender, and 'item' for the skill/item Object.
    Values below 0 are treated as 0.

    EXAMPLE
    1. <mpiercingeval>
    复制代码
    1. (a.agi - b.agi) * 0.01
    复制代码
    1. </mpiercingeval>
    复制代码
    This would give 1% magical piercing per AGI the user has more than the target.
    If the target has more AGI, piercing will be 0.
    1. <nullguard>
    复制代码
    Bypasses guard. Damage will be calculated as though target was not guarding.
    For Actors, Classes, Enemies, or States, causes all of user's attacks and skills to bypass guard.

    Actors, Classes, Enemies, & States notetags:
    1. <piercingplus:x>
    复制代码
    ,
    1. <ppiercingplus:x>
    复制代码
    ,
    1. <mpiercingplus:x>
    复制代码
    Adds x bonus piercing amount to all of the user's attacks and skills.
    1. <piercingmult:x>
    复制代码
    ,
    1. <ppiercingmult:x>
    复制代码
    ,
    1. <mpiercingmult:x>
    复制代码
    Multiplies user's piercing effects by x.
    This is calculated after piercingplus.
    No effect if piercing is 0.
    1. <nulladaptive>
    复制代码
    Protects the user from adaptive effects.
    Damage will be calculated based on attacker's skill's default Hit Type.
    1. <nullpiercing>
    复制代码
    ,
    1. <nullppiercing>
    复制代码
    ,
    1. <nullmpiercing>
    复制代码
    Protects the user from piercing effects.
    Damage will be calculated as though attacker had no piercing.
    1. <forceminvariance>
    复制代码
    ,
    1. <forcemaxvariance>
    复制代码
    The user will always roll the min/max value for skills and items that have variance. If both these notetags are present, the ruling defined in the plugin parameters is applied.
    1. <forcenovariance>
    复制代码
    The user will not have any variance for all their skills and items.
    If the user has 'forceminvariance' and/or 'forcemaxvariance', the ruling defined in the plugin parameters is applied.

    Script
    Spoiler: code
                    JavaScript:       
    1. //==========================================
    2. // APHO_DamageCore.js
    3. //==========================================
    4. /*:
    5. * @title Damage Core
    6. * @author Apho
    7. * @plugindesc v1.1 Allows for more control over damage and stuff.
    8. *
    9. * @param NoDamageSound
    10. * @text No Damage Sound
    11. * @type file
    12. * @dir audio/se
    13. * @desc Sound Effect to play when dealing 0 damage.
    14. * @default Reflection
    15. *
    16. * @param NoDamageVolume
    17. * @parent NoDamageSound
    18. * @text Volume
    19. * @type number
    20. * @desc Volume of the 'no damage' sound.
    21. * @default 90
    22. *
    23. * @param NoDamagePitchMin
    24. * @parent NoDamageSound
    25. * @text Minimum pitch
    26. * @type number
    27. * @desc Minimum pitch of the 'no damage' sound.
    28. * @default 115
    29. *
    30. * @param NoDamagePitchMax
    31. * @parent NoDamageSound
    32. * @text Maximum pitch
    33. * @type number
    34. * @desc Maximum pitch of the 'no damage' sound.
    35. * @default 125
    36. * @param NoHealSound
    37. * @text No Heal Sound
    38. * @type file
    39. * @dir audio/se
    40. * @desc Sound Effect to play when healing for 0 HP.
    41. * @default Down2
    42. *
    43. * @param NoHealVolume
    44. * @parent NoHealSound
    45. * @text Volume
    46. * @type number
    47. * @desc Volume of the 'no heal' sound.
    48. * @default 90
    49. *
    50. * @param NoHealPitchMin
    51. * @parent NoHealSound
    52. * @text Minimum pitch
    53. * @type number
    54. * @desc Minimum pitch of the 'no heal' sound.
    55. * @default 75
    56. *
    57. * @param NoHealPitchMax
    58. * @parent NoHealSound
    59. * @text Maximum pitch
    60. * @type number
    61. * @desc Maximum pitch of the 'no Heal' sound.
    62. * @default 85
    63. *
    64. * @param NoHealSoundMenu
    65. * @parent NoHealSound
    66. * @text Menu Sound
    67. * @type boolean
    68. * @desc Play the sound effect when heal is used from the menu screen?
    69. * @default true
    70. *
    71. * @param ForceVarianceRuling
    72. * @text Force Variance Ruling
    73. * @type select
    74. * @option Cancel each other out (normal variance rates apply)
    75. * @value 0
    76. * @option Always force min
    77. * @value 1
    78. * @option Always force max
    79. * @value 2
    80. * @desc How should variance be handled if user has both 'forceminvariance' and 'forcemaxvariance'?
    81. * @default 0
    82. *
    83. * @param NoVarianceRuling
    84. * @parent ForceVarianceRuling
    85. * @text No Variance Ruling
    86. * @type select
    87. * @option Don't override
    88. * @value 0
    89. * @option Override both
    90. * @value 1
    91. * @option Override min only
    92. * @value 2
    93. * @option Override max only
    94. * @value 3
    95. * @desc Should 'forcenovariance' be allowed to override 'forceminvariance'/'forcemaxvariance'?
    96. * @default 1
    97. *
    98. * @help
    99. * Allows for more control over damage and stuff.
    100. * A sound effect can be played when an attack hits for 0 damage, or a heal heals
    101. * for 0 hp.
    102. * A min/max pitch may also be specified, which will be selected at random.
    103. * Also, the following notetags are available:
    104. * Skills, Items, Actors, Classes, Enemies, & States notetags:
    105. * <adaptive>
    106. * Calculates damage using higher of target's physical or magical damage rate.
    107. * For Actors, Classes, Enemies, or States, causes all of user's attacks and
    108. * skills to become adaptive.
    109. *
    110. * <adaptiveeval>
    111. * //code
    112. * </adaptiveeval>
    113. * Evaluates code to determine if the attack should be adaptive.
    114. * Must return either true (adaptive) or false (not adaptive).
    115. * You may use 'a' for the attacker, 'b' for the defender, and 'item' for the
    116. * skill/item Object.
    117. *
    118. * <piercing:x>, <ppiercing:x>, <mpiercing:x>
    119. * Ignores a percentage of target's damage reduction. x must be a value between
    120. * 0 and 1.
    121. * 'piercing' applies to both PDR and MDR, while 'ppiercing' and 'mpiercing'
    122. * apply only to PDR and MDR respectively.
    123. * For Actors, Classes, Enemies, or States, causes all of user's attacks and
    124. skills to have x piercing, overriding any skill or item notetags.
    125. * Notetag priority from highest to lowest is as follows:
    126. * States, Classes (for actors), Enemies/Actors
    127. *
    128. * EXAMPLE
    129. * <piercing:0.4>
    130. * If a physical skill with this notetag is used against a target with 80%
    131. * Physical Damage Rate, the calculation is as follows:
    132. * Original damage reduction = 100% - 80% = 20%
    133. * 0.4 / 40% of the damage reduction is ignored.
    134. * Target still has 20% * (1 - 0.4) = 12% damage reduction.
    135. * Final Physical Damage Rate = 100% - 12% = 88%
    136. *
    137. * <piercingeval>
    138. * //code
    139. * </piercingeval>
    140. * Evaluates code to determine piercing. Must return a value between 0 and 1.
    141. * You may also use <ppiercingeval> for physical piercing, or <mpiercingeval>
    142. * for magical piercing.
    143. * You may use 'a' for the attacker, 'b' for the defender, and 'item' for the
    144. * skill/item Object.
    145. * Values below 0 are treated as 0.
    146. *
    147. * EXAMPLE
    148. * <mpiercingeval>
    149. * (a.agi - b.agi) * 0.01
    150. * </mpiercingeval>
    151. * This would give 1% magical piercing per AGI the user has more than the target.
    152. * If the target has more AGI, piercing will be 0.
    153. *
    154. * <nullguard>
    155. * Bypasses guard. Damage will be calculated as though target was not guarding.
    156. * For Actors, Classes, Enemies, or States, causes all of user's attacks and
    157. * skills to bypass guard.
    158. *
    159. * Actors, Classes, Enemies, & States notetags:
    160. * <piercingplus:x>, <ppiercingplus:x>, <mpiercingplus:x>
    161. * Adds x bonus piercing amount to all of the user's attacks and skills.
    162. *
    163. * <piercingmult:x>, <ppiercingmult:x>, <mpiercingmult:x>
    164. * Multiplies user's piercing effects by x.
    165. * This is calculated after piercingplus.
    166. * No effect if piercing is 0.
    167. *
    168. * <nulladaptive>
    169. * Protects the user from adaptive effects.
    170. * Damage will be calculated based on attacker's skill's default Hit Type.
    171. *
    172. * <nullpiercing>, <nullppiercing>, <nullmpiercing>
    173. * Protects the user from piercing effects.
    174. * Damage will be calculated as though attacker had no piercing.
    175. *
    176. * <forceminvariance>, <forcemaxvariance>
    177. * The user will always roll the min/max value for skills and items that have
    178. * variance. If both these notetags are present, the ruling defined in the plugin
    179. * parameters is applied.
    180. *
    181. * <forcenovariance>
    182. * The user will not have any variance for all their skills and items.
    183. * If the user has 'forceminvariance' and/or 'forcemaxvariance', the ruling
    184. * defined in the plugin parameters is applied.
    185. *
    186. * TERMS OF USE
    187. * - Free for commercial and non-commercial use, as long as I get a free copy
    188. *   of the game.
    189. * - Edits allowed for personal use.
    190. * - Do not repost or claim as your own, even if edited.
    191. *
    192. * VERSION HISTORY
    193. * v1.1 - 2023/7/20 - Added adaptive eval and piercing eval notetags.
    194. * v1.0 - 2023/7/13 - Initial release.
    195. */
    196. (function(){
    197.     var parameters = PluginManager.parameters('APHO_DamageCore');
    198.     var Imported_YEP_DamageCore = $plugins.filter(function(p) { return p.name === 'YEP_DamageCore' && p.status === true; }).length > 0
    199.     CheckAdaptiveEval = function(notetag, a, b, item)
    200.     {
    201.         const AdaptiveEvalOpen = '<adaptiveeval>';
    202.         const AdaptiveEvalClose = '</adaptiveeval>';
    203.         let ReadAdaptiveEval = false;
    204.         let AdaptiveEvalInfo = "";
    205.         for (var n = 0; n < notetag.length; n++)
    206.         {
    207.             let NoteData = notetag.split(/[\r\n]+/);
    208.             let line = NoteData[n];
    209.             if (line && line.match(AdaptiveEvalOpen))
    210.             {
    211.                 ReadAdaptiveEval = true;
    212.             }
    213.             else if (line && line.match(AdaptiveEvalClose))
    214.             {
    215.                 ReadAdaptiveEval = false;
    216.             }
    217.             else if (ReadAdaptiveEval == true)
    218.             {
    219.                 AdaptiveEvalInfo += line + '\n';
    220.             }
    221.         }
    222.         return eval(AdaptiveEvalInfo)
    223.     };
    224.     CheckPiercingEval = function(notetag, a, b, item)
    225.     {
    226.         const PiercingEvalOpen = '<piercingeval>';
    227.         const PiercingEvalClose = '</piercingeval>';
    228.         let ReadPiercingEval = false;
    229.         let PiercingEvalInfo = "";
    230.         for (var n = 0; n < notetag.length; n++)
    231.         {
    232.             let NoteData = notetag.split(/[\r\n]+/);
    233.             let line = NoteData[n];
    234.             if (line && line.match(PiercingEvalOpen))
    235.             {
    236.                 ReadPiercingEval = true;
    237.             }
    238.             else if (line && line.match(PiercingEvalClose))
    239.             {
    240.                 ReadPiercingEval = false;
    241.             }
    242.             else if (ReadPiercingEval == true)
    243.             {
    244.                 PiercingEvalInfo += line + '\n';
    245.             }
    246.         }
    247.         return Math.max(0, eval(PiercingEvalInfo))
    248.     };
    249.     CheckPPiercingEval = function(notetag, a, b, item)
    250.     {
    251.         const PPiercingEvalOpen = '<ppiercingeval>';
    252.         const PPiercingEvalClose = '</ppiercingeval>';
    253.         let ReadPPiercingEval = false;
    254.         let PPiercingEvalInfo = "";
    255.         for (var n = 0; n < notetag.length; n++)
    256.         {
    257.             let NoteData = notetag.split(/[\r\n]+/);
    258.             let line = NoteData[n];
    259.             if (line && line.match(PPiercingEvalOpen))
    260.             {
    261.                 ReadPPiercingEval = true;
    262.             }
    263.             else if (line && line.match(PPiercingEvalClose))
    264.             {
    265.                 ReadPPiercingEval = false;
    266.             }
    267.             else if (ReadPPiercingEval == true)
    268.             {
    269.                 PPiercingEvalInfo += line + '\n';
    270.             }
    271.         }
    272.         return Math.max(0, eval(PPiercingEvalInfo))
    273.     };
    274.     CheckMPiercingEval = function(notetag, a, b, item)
    275.     {
    276.         const MPiercingEvalOpen = '<mpiercingeval>';
    277.         const MPiercingEvalClose = '</mpiercingeval>';
    278.         let ReadMPiercingEval = false;
    279.         let MPiercingEvalInfo = "";
    280.         for (var n = 0; n < notetag.length; n++)
    281.         {
    282.             let NoteData = notetag.split(/[\r\n]+/);
    283.             let line = NoteData[n];
    284.             if (line && line.match(MPiercingEvalOpen))
    285.             {
    286.                 ReadMPiercingEval = true;
    287.             }
    288.             else if (line && line.match(MPiercingEvalClose))
    289.             {
    290.                 ReadMPiercingEval = false;
    291.             }
    292.             else if (ReadMPiercingEval == true)
    293.             {
    294.                 MPiercingEvalInfo += line + '\n';
    295.             }
    296.         }
    297.         return Math.max(0, eval(MPiercingEvalInfo))
    298.     };
    299.     const Game_Action_makeDamageValue = Game_Action.prototype.makeDamageValue;
    300.     Game_Action.prototype.makeDamageValue = function(target, critical) {
    301.         var item = this.item();
    302.         let a = this.subject();
    303.         let adaptive;
    304.         if(item.meta.adaptiveeval) adaptive = CheckAdaptiveEval(item.note, a, target, item);
    305.         adaptive = item.meta.adaptive;
    306.         let piercing = parseFloat(item.meta.piercing) || 0;
    307.         if(item.meta.piercingeval) piercing = CheckPiercingEval(item.note, a, target, item);
    308.         let ppiercing = parseFloat(item.meta.ppiercing) || 0;
    309.         if(piercing) ppiercing = Math.max(piercing, ppiercing);
    310.         if(item.meta.ppiercingeval) ppiercing = CheckPPiercingEval(item.note, a, target, item);
    311.         let mpiercing = parseFloat(item.meta.mpiercing) || 0;
    312.         if(piercing) mpiercing = Math.max(piercing, mpiercing);
    313.         if(item.meta.mpiercingeval) mpiercing = CheckMPiercingEval(item.note, a, target, item);
    314.         let nullguard = item.meta.nullguard;
    315.         if(a.isEnemy())
    316.         {
    317.             if(a.enemy().meta.adaptiveeval) adaptive = CheckAdaptiveEval(a.enemy().note, a, target, item);
    318.             if(a.enemy().meta.adaptive) adaptive = true;
    319.             if(a.enemy().meta.ppiercing) ppiercing = parseFloat(a.enemy().meta.ppiercing);
    320.             if(a.enemy().meta.mpiercing) mpiercing = parseFloat(a.enemy().meta.mpiercing);
    321.             if(a.enemy().meta.piercing)
    322.             {
    323.                 ppiercing = parseFloat(a.enemy().meta.piercing);
    324.                 mpiercing = parseFloat(a.enemy().meta.piercing);
    325.             }
    326.             if(a.enemy().meta.ppiercingeval) ppiercing = CheckPPiercingEval(a.enemy().note, a, target, item);
    327.             if(a.enemy().meta.mpiercingeval) mpiercing = CheckMPiercingEval(a.enemy().note, a, target, item);
    328.             if(a.enemy().meta.piercingeval)
    329.             {
    330.                 ppiercing = CheckPiercingEval(a.enemy().note, a, target, item);
    331.                 mpiercing = CheckPiercingEval(a.enemy().note, a, target, item);
    332.             }
    333.             if(a.enemy().meta.ppiercingplus) ppiercing += parseFloat(a.enemy().meta.ppiercingplus);
    334.             if(a.enemy().meta.mpiercingplus) mpiercing += parseFloat(a.enemy().meta.mpiercingplus);
    335.             if(a.enemy().meta.piercingplus)
    336.             {
    337.                 ppiercing += parseFloat(a.enemy().meta.piercingplus);
    338.                 mpiercing += parseFloat(a.enemy().meta.piercingplus);
    339.             }
    340.             if(a.enemy().meta.ppiercingmult) ppiercing *= parseFloat(a.enemy().meta.ppiercingmult);
    341.             if(a.enemy().meta.mpiercingmult) mpiercing *= parseFloat(a.enemy().meta.mpiercingmult);
    342.             if(a.enemy().meta.piercingmult)
    343.             {
    344.                 ppiercing *= parseFloat(a.enemy().meta.piercingmult);
    345.                 mpiercing *= parseFloat(a.enemy().meta.piercingmult);
    346.             }
    347.             if(a.enemy().meta.nullguard) nullguard = true;
    348.         }else if(a.isActor())
    349.         {
    350.             if(a.actor().meta.adaptiveeval) adaptive = CheckAdaptiveEval(a.actor().note, a, target, item);
    351.             if($dataClasses[a._classId].meta.adaptiveeval) adaptive = CheckAdaptiveEval($dataClasses[a._classId].note, a, target, item);
    352.             if(a.actor().meta.adaptive || $dataClasses[a._classId].meta.adaptive) adaptive = true;
    353.             if(a.actor().meta.ppiercing) ppiercing = parseFloat(a.actor().meta.ppiercing);
    354.             if(a.actor().meta.mpiercing) mpiercing = parseFloat(a.actor().meta.mpiercing);
    355.             if(a.actor().meta.piercing)
    356.             {
    357.                 ppiercing = parseFloat(a.actor().meta.piercing);
    358.                 mpiercing = parseFloat(a.actor().meta.piercing);
    359.             }
    360.             if(a.actor().meta.ppiercingeval) ppiercing = CheckPPiercingEval(a.actor().note, a, target, item);
    361.             if(a.actor().meta.mpiercingeval) mpiercing = CheckMPiercingEval(a.actor().note, a, target, item);
    362.             if(a.actor().meta.piercingeval)
    363.             {
    364.                 ppiercing = CheckPiercingEval(a.actor().note, a, target, item);
    365.                 mpiercing = CheckPiercingEval(a.actor().note, a, target, item);
    366.             }
    367.             if($dataClasses[a._classId].meta.ppiercing) ppiercing = parseFloat($dataClasses[a._classId].meta.ppiercing);
    368.             if($dataClasses[a._classId].meta.mpiercing) mpiercing = parseFloat($dataClasses[a._classId].meta.mpiercing);
    369.             if($dataClasses[a._classId].meta.piercing)
    370.             {
    371.                 ppiercing = parseFloat($dataClasses[a._classId].meta.piercing);
    372.                 mpiercing = parseFloat($dataClasses[a._classId].meta.piercing);
    373.             }
    374.             if($dataClasses[a._classId].meta.ppiercingeval) ppiercing = CheckPPiercingEval($dataClasses[a._classId].note, a, target, item);
    375.             if($dataClasses[a._classId].meta.mpiercingeval) mpiercing = CheckMPiercingEval($dataClasses[a._classId].note, a, target, item);
    376.             if($dataClasses[a._classId].meta.piercingeval)
    377.             {
    378.                 ppiercing = CheckPiercingEval($dataClasses[a._classId].note, a, target, item);
    379.                 mpiercing = CheckPiercingEval($dataClasses[a._classId].note, a, target, item);
    380.             }
    381.             if(a.actor().meta.ppiercingplus) ppiercing += parseFloat(a.actor().meta.ppiercingplus);
    382.             if(a.actor().meta.mpiercingplus) mpiercing += parseFloat(a.actor().meta.mpiercingplus);
    383.             if(a.actor().meta.piercingplus)
    384.             {
    385.                 ppiercing += parseFloat(a.actor().meta.piercingplus);
    386.                 mpiercing += parseFloat(a.actor().meta.piercingplus);
    387.             }
    388.             if($dataClasses[a._classId].meta.ppiercingplus) ppiercing += parseFloat($dataClasses[a._classId].meta.ppiercingplus);
    389.             if($dataClasses[a._classId].meta.mpiercingplus) mpiercing += parseFloat($dataClasses[a._classId].meta.mpiercingplus);
    390.             if($dataClasses[a._classId].meta.piercingplus)
    391.             {
    392.                 ppiercing += parseFloat($dataClasses[a._classId].meta.piercingplus);
    393.                 mpiercing += parseFloat($dataClasses[a._classId].meta.piercingplus);
    394.             }
    395.             if(a.actor().meta.ppiercingmult) ppiercing *= parseFloat(a.actor().meta.ppiercingmult);
    396.             if(a.actor().meta.mpiercingmult) mpiercing *= parseFloat(a.actor().meta.mpiercingmult);
    397.             if(a.actor().meta.piercingmult)
    398.             {
    399.                 ppiercing *= parseFloat(a.actor().meta.piercingmult);
    400.                 mpiercing *= parseFloat(a.actor().meta.piercingmult);
    401.             }
    402.             if($dataClasses[a._classId].meta.ppiercingmult) ppiercing *= parseFloat($dataClasses[a._classId].meta.ppiercingmult);
    403.             if($dataClasses[a._classId].meta.mpiercingmult) mpiercing *= parseFloat($dataClasses[a._classId].meta.mpiercingmult);
    404.             if($dataClasses[a._classId].meta.piercingmult)
    405.             {
    406.                 ppiercing *= parseFloat($dataClasses[a._classId].meta.piercingmult);
    407.                 mpiercing *= parseFloat($dataClasses[a._classId].meta.piercingmult);
    408.             }
    409.             if(a.actor().meta.nullguard || $dataClasses[a._classId].meta.nullguard) nullguard = true;
    410.         }
    411.         for(var n = 0; n < a.states().length; n++)
    412.         {
    413.             if(a.states()[n].meta.adaptiveeval) adaptive = CheckAdaptiveEval(a.states()[n].note, a, target, item);
    414.             if(a.states()[n].meta.adaptive) adaptive = true;
    415.             if(a.states()[n].meta.piercing)
    416.             {
    417.                 ppiercing = parseFloat(a.states()[n].meta.piercing);
    418.                 mpiercing = parseFloat(a.states()[n].meta.piercing)
    419.             }
    420.             if(a.states()[n].meta.ppiercingeval) ppiercing = CheckPPiercingEval(a.states()[n].note, a, target, item);
    421.             if(a.states()[n].meta.mpiercingeval) mpiercing = CheckMPiercingEval(a.states()[n].note, a, target, item);
    422.             if(a.states()[n].meta.piercingeval)
    423.             {
    424.                 ppiercing = CheckPiercingEval(a.states()[n].note, a, target, item);
    425.                 mpiercing = CheckPiercingEval(a.states()[n].note, a, target, item);
    426.             }
    427.             if(a.states()[n].meta.ppiercingplus) ppiercing += parseFloat(a.states()[n].meta.ppiercingplus);
    428.             if(a.states()[n].meta.mpiercingplus) mpiercing += parseFloat(a.states()[n].meta.mpiercingplus);
    429.             if(a.states()[n].meta.piercingplus)
    430.             {
    431.                 ppiercing += parseFloat(a.states()[n].meta.piercingplus);
    432.                 mpiercing += parseFloat(a.states()[n].meta.piercingplus);
    433.             }
    434.             if(a.states()[n].meta.ppiercingmult) ppiercing *= parseFloat(a.states()[n].meta.ppiercingmult);
    435.             if(a.states()[n].meta.mpiercingmult) mpiercing *= parseFloat(a.states()[n].meta.mpiercingmult);
    436.             if(a.states()[n].meta.piercingmult)
    437.             {
    438.                 ppiercing *= parseFloat(a.states()[n].meta.piercingmult);
    439.                 mpiercing *= parseFloat(a.states()[n].meta.piercingmult);
    440.             }
    441.             if(a.states()[n].meta.nullguard) nullguard = true;
    442.         }
    443.         if(target.isEnemy())
    444.         {
    445.             if(target.enemy().meta.nulladaptive) adaptive = false;
    446.             if(target.enemy().meta.nullppiercing) ppiercing = 0;
    447.             if(target.enemy().meta.nullmpiercing) mpiercing = 0;
    448.             if(target.enemy().meta.nullpiercing)
    449.             {
    450.                 ppiercing = 0;
    451.                 mpiercing = 0;
    452.             }
    453.         }else if (target.isActor())
    454.         {
    455.             if(target.actor().meta.nulladaptive) adaptive = false;
    456.             if(target.actor().meta.nullppiercing) ppiercing = 0;
    457.             if(target.actor().meta.nullmpiercing) mpiercing = 0;
    458.             if(target.actor().meta.nullpiercing)
    459.             {
    460.                 ppiercing = 0;
    461.                 mpiercing = 0;
    462.             }
    463.         }
    464.         for(var n = 0; n < target.states().length; n++)
    465.         {
    466.             if(target.states()[n].meta.nulladaptive) adaptive = false;
    467.             if(target.states()[n].meta.nullppiercing) ppiercing = 0;
    468.             if(target.states()[n].meta.nullmpiercing) mpiercing = 0;
    469.             if(target.states()[n].meta.nullpiercing)
    470.             {
    471.                 ppiercing = 0;
    472.                 mpiercing = 0;
    473.             }
    474.         }
    475.         if(!adaptive && (!ppiercing || ppiercing <= 0) && (!mpiercing || mpiercing <= 0) && !nullguard)
    476.         {
    477.             value = Game_Action_makeDamageValue.call(this, target, critical);
    478.             return value;
    479.         }else
    480.         {
    481.             if(Imported_YEP_DamageCore)
    482.             {
    483.                 var baseDamage = this.evalDamageFormula(target);
    484.                 baseDamage = this.modifyBaseDamage(value, baseDamage, target);
    485.                 baseDamage *= this.calcElementRate(target);
    486.                 critical = this.modifyCritical(critical, baseDamage, target);
    487.                 target.result().critical = critical;
    488.                 var value = baseDamage;
    489.                 if(critical)
    490.                 {
    491.                     value = this.applyCriticalRate(value, baseDamage, target);
    492.                 }
    493.             }else
    494.             {
    495.                 var baseValue = this.evalDamageFormula(target);
    496.                 var value = baseValue * this.calcElementRate(target);
    497.             }
    498.             function CalcPhysDmg(value)
    499.             {
    500.                 if (ppiercing && target.pdr < 1)
    501.                 {
    502.                     let dr = (1 - target.pdr) * (1 - Math.min(ppiercing, 1));
    503.                     value *= 1 - dr;
    504.                 }else
    505.                 {
    506.                     value *= target.pdr;
    507.                 }
    508.                 if(Imported_YEP_DamageCore) value = Game_Action.prototype.applyFlatPhysical.call(this, value, baseDamage, target);
    509.                 return value;
    510.             }
    511.             function CalcMagDmg(value)
    512.             {
    513.                 if (mpiercing && target.mdr < 1)
    514.                 {
    515.                     let dr = (1 - target.mdr) * (1 - Math.min(mpiercing, 1));
    516.                     value *= 1 - dr;
    517.                 }else
    518.                 {
    519.                     value *= target.mdr;
    520.                 }
    521.                 if(Imported_YEP_DamageCore) value = Game_Action.prototype.applyFlatMagical.call(this, value, baseDamage, target);
    522.                 return value;
    523.             }
    524.             if (this.isPhysical() && !adaptive) {
    525.                 value = CalcPhysDmg(value);
    526.             }else if (this.isMagical( )&& !adaptive) {
    527.                 value = CalcMagDmg(value);
    528.             }
    529.             else if(adaptive)
    530.             {
    531.                 let pvalue = CalcPhysDmg(value);
    532.                 let mvalue = CalcMagDmg(value);
    533.                 value = Math.max(pvalue, mvalue);
    534.             }
    535.             if(Imported_YEP_DamageCore)
    536.             {
    537.                 if (baseDamage > 0) {
    538.                     value = this.applyFlatDamage(value, baseDamage, target);
    539.                 }
    540.                 if (baseDamage < 0) {
    541.                     value = this.applyFlatHeal(value, baseDamage, target);
    542.                 }
    543.                 if (critical) {
    544.                     value = this.applyFlatCritical(value, baseDamage, target);
    545.                 }
    546.             }else
    547.             {
    548.                 if (baseValue < 0) {
    549.                 value *= target.rec;
    550.                 }
    551.                 if (critical) {
    552.                     value = this.applyCritical(value, target);
    553.                 }
    554.             }
    555.             value = this.applyVariance(value, item.damage.variance);
    556.             if(!nullguard) value = this.applyGuard(value, target);
    557.             if(Imported_YEP_DamageCore) value = this.applyFlatGlobal(value, baseDamage, target);
    558.             value = Math.round(value);
    559.             if(Imported_YEP_DamageCore) value = this.applyMinimumDamage(value, baseDamage, target);
    560.             return value;
    561.         }
    562.     };
    563.     var ForceVarianceRuling = parseInt(parameters['ForceVarianceRuling']);
    564.     var NoVarianceRuling = parseInt(parameters['NoVarianceRuling']);
    565.     const Game_Action_applyVariance = Game_Action.prototype.applyVariance;
    566.     Game_Action.prototype.applyVariance = function(damage, variance)
    567.     {
    568.         let a = this.subject();
    569.         let forceminvariance = false;
    570.         let forcemaxvariance = false;
    571.         let forcenovariance = false;
    572.         let NeedsForceVariance = false;
    573.         if(a.isEnemy())
    574.         {
    575.             if(a.enemy().meta.forceminvariance) forceminvariance = true;
    576.             if(a.enemy().meta.forcemaxvariance) forcemaxvariance = true;
    577.             if(a.enemy().meta.forcenovariance) forcenovariance = true;
    578.         }else if(a.isActor())
    579.         {
    580.             if(a.actor().meta.forceminvariance || $dataClasses[a._classId].meta.forceminvariance) forceminvariance = true;
    581.             if(a.actor().meta.forcemaxvariance || $dataClasses[a._classId].meta.forcemaxvariance) forcemaxvariance = true;
    582.             if(a.actor().meta.forcenovariance || $dataClasses[a._classId].meta.forcenovariance) forcenovariance = true;
    583.         }
    584.         for(var n = 0; n < a.states().length; n++)
    585.         {
    586.             if(a.states()[n].meta.forceminvariance) forceminvariance = true;
    587.             if(a.states()[n].meta.forcemaxvariance) forcemaxvariance = true;
    588.             if(a.states()[n].meta.forcenovariance) forcenovariance = true;
    589.         }
    590.         if(forcenovariance)
    591.         {
    592.             switch(NoVarianceRuling)
    593.             {
    594.                 case 0:
    595.                 if(!forceminvariance && !forcemaxvariance) return damage;
    596.                     break;
    597.                 case 1:
    598.                     return damage;
    599.                     break;
    600.                 case 2:
    601.                     if(!forcemaxvariance)
    602.                     {
    603.                         return damage;
    604.                     }else if(forceminvariance)
    605.                     {
    606.                         forceminvariance = false;
    607.                     }
    608.                     break;
    609.                 case 3:
    610.                     if(!forceminvariance)
    611.                     {
    612.                         return damage;
    613.                     }else if(forcemaxvariance)
    614.                     {
    615.                         forcemaxvariance = false;
    616.                     }
    617.                     break;
    618.             }
    619.         }
    620.         if(ForceVarianceRuling == 0)
    621.         {
    622.             if(forceminvariance ^ forcemaxvariance) NeedsForceVariance = true;
    623.         }else
    624.         {
    625.             if(forceminvariance || forcemaxvariance) NeedsForceVariance = true;
    626.         }
    627.         if(NeedsForceVariance)
    628.         {
    629.             var amp = Math.floor(Math.max(Math.abs(damage) * variance / 100, 0));
    630.             var v;
    631.             if((ForceVarianceRuling == 0 && forceminvariance) ||
    632.             (ForceVarianceRuling == 1 && forceminvariance) ||
    633.             (ForceVarianceRuling == 2 && forceminvariance && !forceminvariance))
    634.             {
    635.                 v = amp * -1;
    636.             }
    637.             if((ForceVarianceRuling == 0 && forcemaxvariance) ||
    638.             (ForceVarianceRuling == 2 && forcemaxvariance) ||
    639.             (ForceVarianceRuling == 1 && forcemaxvariance && !forceminvariance))
    640.             {
    641.                 v = amp;
    642.             }
    643.             return damage >= 0 ? damage + v : damage - v;
    644.         }else
    645.         {
    646.             damage = Game_Action_applyVariance.call(this, damage, variance);
    647.             return damage;
    648.         }
    649.     }
    650.     var NoDamageSound = parameters['NoDamageSound'];
    651.     var NoDamageVolume = parseInt(parameters['NoDamageVolume']);
    652.     var NoDamagePitchMin = parseInt(parameters['NoDamagePitchMin']);
    653.     var NoDamagePitchRange = Math.max(parseInt(parameters['NoDamagePitchMax']) - NoDamagePitchMin, 0);
    654.     var NoHealSound = parameters['NoHealSound'];
    655.     var NoHealVolume = parseInt(parameters['NoHealVolume']);
    656.     var NoHealPitchMin = parseInt(parameters['NoHealPitchMin']);
    657.     var NoHealPitchRange = Math.max(parseInt(parameters['NoHealPitchMax']) - NoHealPitchMin, 0);
    658.     var NoHealSoundMenu = JSON.parse(parameters['NoHealSoundMenu']);
    659.     const Game_Action_apply = Game_Action.prototype.apply;
    660.     Game_Action.prototype.apply = function(target){
    661.         Game_Action_apply.call(this, target);
    662.         var result = target.result()
    663.         if(this.isHpEffect() && result.hpDamage == 0 && result.isHit())
    664.         {
    665.             if(this.isRecover())
    666.             {
    667.                 if(NoHealSound && ($gameParty.inBattle() || NoHealSoundMenu))
    668.                 {
    669.                     let Pitch = NoHealPitchMin + Math.randomInt(NoHealPitchRange + 1);
    670.                     AudioManager.playSe({name: NoHealSound, volume: NoHealVolume, pitch: Pitch, pan: 0});
    671.                 }
    672.             }else
    673.             {
    674.                 if(NoDamageSound && $gameParty.inBattle())
    675.                 {
    676.                     let Pitch = NoDamagePitchMin + Math.randomInt(NoDamagePitchRange + 1);
    677.                     AudioManager.playSe({name: NoDamageSound, volume: NoDamageVolume, pitch: Pitch, pan: 0});
    678.                 }
    679.             }
    680.         }
    681.     }
    682. })();
    复制代码


    Note
    This plugin, for the most part, works by overriding default functions when conditions are met. As such, I cannot guarantee full compatibility with plugins that also override the same default functions. In particular, this has limited compatibility with YEP_DamageCore, due to YEP_DamageCore overriding the makeDamgeValue function which this plugin is reliant on.

    If you wish to use the adaptive, piercing, and nullguard features of this plugin together with YEP_DamageCore, you can place this plugin below it. This plugin contains checks to attempt to replicate YEP_DamageCore's default damage flow if you have it loaded; however, it may not work as intended if you have changed YEP_DamageCore's default damage steps.

    Terms of use

    • Free for commercial and non-commercial use, as long as I get a free copy of the game.
    • 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.1 - 2023/7/20 - Added adaptive eval and piercing eval notetags.
    v1.0 - 2023/7/13 - Initial release.

    Download link
    GitHub


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

    本帖子中包含更多资源

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

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

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-8-1 04:52 , Processed in 0.093163 second(s), 53 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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