Project1

标题: 求一个主动技能关联被动技能的插件 [打印本页]

作者: 帝卡尔    时间: 2023-10-17 18:53
标题: 求一个主动技能关联被动技能的插件
请问有没有插件可以设置被动技能对主动技能有增幅?比如学习了被动技能a,那么与 a 有关联的主动技能 b 可以增幅30%的伤害。如果没学习被动技能a,那么 b 就只能发挥正常的伤害
作者: 2606358566    时间: 2023-10-18 04:53
我有一套,有偿的,你要不要?
作者: sundeshuo    时间: 2023-10-18 14:26
很久以前练习时写的,拿去用吧
  1. /*:
  2. * @target MZ
  3. * @author sun
  4. * @plugindesc 战斗效果拓展
  5. * @help
  6. *
  7. * @param Aoe Mode
  8. * @text 分裂效果模式
  9. * @type boolean
  10. * @default false
  11. * @desc 分裂效果是否对群体伤害生效
  12. *
  13. * @help
  14. * ======================================================
  15. * 将一些VS插件未制作常用效果编码,免去使用战斗插入制作的繁琐
  16. * ======================================================
  17. * 增加了一些方法方便在战斗插入中使用:
  18. * 判断是否是id为xx的技能
  19. * Item.isSkillId(xx);
  20. * Action.isSkillId(xx);
  21. * ======================================================
  22. * tag:
  23. *
  24. * 技能伤害 <Skill Damage ID: a%>
  25. * 可以用在装备、技能(当做被动)、状态;
  26. * ID替换为技能id,a替换为提升的值,a必须为整数;
  27. *
  28. * 分裂效果 <Physics Aoe: a%> <Magical Aoe: a%> <Certain Aoe: a%> <Heal Aoe: a%>
  29. * 可以用在装备、技能(当做被动)、状态;
  30. * 使物理、魔法、必中伤害、治疗效果附带分裂效果;
  31. * a替换为分裂伤害倍率,必须为整数;
  32. *
  33. * 治疗加成 <Heal Rate: a%>
  34. * 可以用在装备、技能(当做被动)、状态;
  35. * 增加使用者治疗效果的属性
  36. * a替换为分裂伤害倍率,必须为整数;
  37. * 若要将该属性显示在菜单上,可以使用:
  38. * Battler.showHealRate();
  39. */

  40. var Imported = Imported || {};
  41. Imported.sun_battleEffectExpand = true;

  42. var sunBattleEffectExpandParam = sunBattleEffectExpandParam || {};
  43. sunBattleEffectExpandParam.parameters = PluginManager.parameters('sun_BattleEffectExpandParam');
  44. sunBattleEffectExpandParam.aoeMode = (sunBattleEffectExpandParam.parameters['Aoe Mode'] === "true");

  45. var _sunBattleEffectInitialize = Scene_Battle.prototype.initialize;
  46. Scene_Battle.prototype.initialize = function () {
  47.     _sunBattleEffectInitialize.call(this)
  48.     for (let member of $gameParty.battleMembers()) {
  49.         member.updateBattleEffect();
  50.     }
  51.         for (let member of $gameTroop.members()) {
  52.         member._battleEffect = {};
  53.                 member._battleEffect._skillDamage = {};
  54.                 member._battleEffect._aoeDamage = {};
  55.     }
  56. };

  57. Game_Item.prototype.isSkillId = function (id) {
  58.     return this._itemId === id && this.isSkill();
  59. };

  60. Game_Action.prototype.isSkillId = function (id) {
  61.     return this._item.isSkill() && this._item.isSkillId(id);
  62. };

  63. Game_Battler.prototype.getEquipsTag = function (note) {
  64.     if (!this.isActor()) return;
  65.     const equips = this.equips().filter(item => item);
  66.     for (let equ of equips) {
  67.         note.push(equ.note);
  68.     }
  69.     return note;
  70. };

  71. Game_Battler.prototype.getSkillTag = function (note) {
  72.     if (!this.isActor()) return;
  73.     const skills = this.skills();
  74.     for (let skill of skills) {
  75.         note.push(skill.note);
  76.     }
  77.     return note;
  78. };

  79. Game_Battler.prototype.getStateTag = function () {
  80.     const states = this.states();
  81.     const note = [];
  82.     for (let state of states) {
  83.         note.push(state.note);
  84.     }
  85.     return note;
  86. };

  87. Game_Battler.prototype.updateBattleEffect = function () {
  88.     this._battleEffect = {};
  89.     let note = [];
  90.     note = this.getEquipsTag(note);
  91.     note = this.getSkillTag(note);
  92.     this.updateSkillDamage(note);
  93.     this.updateAoeDamage(note);
  94.     this.updateHealRate(note);
  95. };

  96. //技能伤害

  97. Game_Battler.prototype.updateSkillDamage = function (note) {
  98.     this._battleEffect._skillDamage = {};
  99.     this._battleEffect._skillDamage = { ...this.countSkillDamageTag(note) }
  100. };

  101. Game_Battler.prototype.countSkillDamageTag = function (note) {
  102.     const skillDamage = {};
  103.     for (let n of note) {
  104.         let tag = n.match(/<SKILL DAMAGE (\d+):[ ](\d+)[%%]>/ig) ? n.match(/<SKILL DAMAGE (\d+):[ ](\d+)[%%]>/ig) : [];
  105.         for (let sd of tag) {
  106.             if (sd.match(/<SKILL DAMAGE (\d+):[ ](\d+)[%%]>/i)) {
  107.                 let id = parseInt(RegExp.$1);
  108.                 let dam = parseInt(RegExp.$2) * 0.01;
  109.                 if (skillDamage[id] === undefined) skillDamage[id] = 0;
  110.                 skillDamage[id] += dam;
  111.             }
  112.         }
  113.     }
  114.     return skillDamage;
  115. };

  116. Game_Action.prototype.getSkillDamage = function () {
  117.     const user = this.subject();
  118.     const id = this._item._itemId;
  119.     let rate = user._battleEffect._skillDamage[id] ? user._battleEffect._skillDamage[id] : 0;
  120.     const skillDamage = user.countSkillDamageTag(user.getStateTag());
  121.     rate += skillDamage[id] ? skillDamage[id] : 0;
  122.     return rate;
  123. };

  124. Game_Action.prototype.applySkillDamage = function (value) {
  125.     const user = this.subject();
  126.     const id = this._item._itemId;
  127.     value *= 1 + this.getSkillDamage();
  128.     return value;
  129. };

  130. //分裂效果

  131. Game_Battler.prototype.updateAoeDamage = function (note) {
  132.     this._battleEffect._aoeDamage = {};
  133.     this._battleEffect._aoeDamage = { ...this.countAoeDamageTag(note) }
  134. };

  135. Game_Battler.prototype.countAoeDamageTag = function (note) {
  136.     const aoeDamage = {};
  137.     for (let n of note) {
  138.         let tag = n.match(/<(\w+) Aoe:[ ](\d+)[%%]>/ig) ? n.match(/<(\w+) Aoe:[ ](\d+)[%%]>/ig) : [];
  139.         for (let ad of tag) {
  140.             if (ad.match(/<(\w+) Aoe:[ ](\d+)[%%]>/i)) {
  141.                 let type = RegExp.$1;
  142.                 let dam = parseInt(RegExp.$2) * 0.01;
  143.                 if (aoeDamage[type] === undefined) aoeDamage[type] = 0;
  144.                 aoeDamage[type] += dam;
  145.             }
  146.         }
  147.     }
  148.     return aoeDamage;
  149. };

  150. Game_Action.prototype.getAoeDamage = function () {
  151.     const user = this.subject();
  152.     const id = this._item._itemId;
  153.     const aoeDamage = user.countAoeDamageTag(user.getStateTag());
  154.     let rate = 0;
  155.     if (this.isHpRecover()) {
  156.         rate = user._battleEffect._aoeDamage['Heal'] ? user._battleEffect._aoeDamage['Heal'] : 0;
  157.         rate += aoeDamage['Heal'] ? aoeDamage['Heal'] : 0;
  158.         return rate;
  159.         console.log(rate);
  160.     }
  161.     else if (this.isPhysical()) {
  162.         rate = user._battleEffect._aoeDamage['Physics'] ? user._battleEffect._aoeDamage['Physics'] : 0;
  163.         rate += aoeDamage['Physics'] ? aoeDamage['Physics'] : 0;
  164.         return rate;
  165.     }
  166.     else if (this.isMagical()) {
  167.         rate = user._battleEffect._aoeDamage['Magical'] ? user._battleEffect._aoeDamage['Magical'] : 0;
  168.         rate += aoeDamage['PMagical'] ? aoeDamage['Magical'] : 0;
  169.         return rate;
  170.     }
  171.     else if (this.isCertainHit()) {
  172.         rate = user._battleEffect._aoeDamage['Certain'] ? user._battleEffect._aoeDamage['Certain'] : 0;
  173.         rate += aoeDamage['Certain'] ? aoeDamage['Certain'] : 0;
  174.         return rate;
  175.     }
  176.     return 0;
  177. };

  178. Game_Action.prototype.applyAoeDamage = function (target, value) {
  179.     if (!sunBattleEffectExpandParam.aoeMode && !this.isForOne()) return;
  180.     const members = target.friendsUnit().aliveMembers();
  181.     const dam = Math.floor(value * (this.getAoeDamage()));
  182.     if (dam === 0) return;
  183.     for (let member of members) {
  184.         if (member !== target) {
  185.             member.gainHp(-dam);
  186.             member.startDamagePopup();
  187.             member.clearResult();
  188.             if (Imported.sun_battleDamageStat) this.subject().damStat(-dam, this.item().name)
  189.         }
  190.     }
  191. };

  192. //治疗加成

  193. Game_Battler.prototype.updateHealRate = function (note) {
  194.     this._battleEffect._healRate = this.countHealRateTag(note);
  195. };

  196. Game_Battler.prototype.countHealRateTag = function (note) {
  197.     let rate = 0;
  198.     for (let n of note) {
  199.         if (n.match(/<Heal Rate:[ ](\d+)[%%]>/i)) {
  200.             rate += parseInt(RegExp.$1) * 0.01;
  201.         }
  202.     }
  203.     return rate;
  204. };

  205. Game_Battler.prototype.showHealRate = function () {
  206.     const note = [];
  207.     note = this.getEquipsTag(note);
  208.     note = this.getSkillTag(note);
  209.     let rate = this.countHealRateTag(note);
  210.     rate += this.countHealRateTag(user.getStateTag());
  211.     return rate;
  212. }

  213. Game_Action.prototype.getHealRate = function () {
  214.     const user = this.subject();
  215.     const id = this._item._itemId;
  216.     let rate = user._battleEffect._healRate ? user._battleEffect._healRate : 0;
  217.     rate += user.countHealRateTag(user.getStateTag());
  218.     return rate;
  219. };

  220. Game_Action.prototype.applyHealRate = function (value) {
  221.     if (this.isRecover()) {
  222.         value *= 1 + this.getHealRate();
  223.     }
  224.     return value;
  225. };

  226. //执行效果

  227. var _sunExecuteDamage = Game_Action.prototype.executeDamage;
  228. Game_Action.prototype.executeDamage = function (target, value) {
  229.     value = this.applySkillDamage(value);
  230.     value = this.applyHealRate(value);
  231.     _sunExecuteDamage.call(this, target, value);
  232.     this.applyAoeDamage(target, value);
  233. };
复制代码





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