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

Project1

 找回密码
 注册会员
搜索
查看: 4456|回复: 7
打印 上一主题 下一主题

[交流讨论] 大家们来看看这个伤害公式扩展脚本,看看能脑洞出些什么

[复制链接]

Lv2.观梦者

梦石
0
星屑
637
在线时间
164 小时
注册时间
2012-4-18
帖子
264
跳转到指定楼层
1
发表于 2016-2-15 16:15:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
如题,从某个RPGMV插件分享站拔了个伤害公式扩展的插件,机翻了一下说明什么的,发觉挺好用,我之前设想的几种技能也许都能够实现,本着好东西要分享的心态,把这个插件发出来,大家看看,脑洞打开,看看能脑洞些什么出来。插件如下:
  1. /*:
  2. -------------------------------------------------------------------------
  3. @title Formula Effects
  4. @author Hime --> HimeWorks (http://himeworks.com)
  5. @date Feb 11, 2015
  6. @version 1.0
  7. @filename HIME_FormulaEffects.js
  8. @url http://himeworks.com/2016/02/formula-effects-mv/

  9. If you enjoy my work, consider supporting me on Patreon!

  10. * https://www.patreon.com/himeworks

  11. If you have any questions or concerns, you can contact me at any of
  12. the following sites:

  13. * Main Website: http://himeworks.com
  14. * Facebook: https://www.facebook.com/himeworkscom/
  15. * Twitter: https://twitter.com/HimeWorks
  16. * Youtube: https://www.youtube.com/c/HimeWorks
  17. * Tumblr: http://himeworks.tumblr.com/

  18. -------------------------------------------------------------------------------
  19. @plugindesc v1.0 - Allows you to execute any formula as an effect
  20. @help
  21. -------------------------------------------------------------------------------
  22. == Description ==

  23. All items and skills in RPG Maker come with additional "effects".
  24. RPGMV为所有物品技能提供了额外的效果。
  25. Effects include gaining HP, learning a skill, gaining a buff in a parameter,
  26. or running a common event.
  27. 效果包括获得生命值,学习技能,获得状态,运行公共事件。
  28. However, what if you would like a skill to do something that isn't provided
  29. by default?
  30. 但是,如果你想让一个技能做一些非默认的事情,你会怎样?
  31. You could use the damage formula, but what if you would like to create conditions on those effects?
  32. 你可以使用伤害公式,但如果你想获得更多效果呢?
  33. You could include those conditions in the formula as well,
  34. but the problem here is you may end up with a very complex damage formula.
  35. 你可以在公式中包括这些条件,但问题是你可能最终会有一个非常复杂的伤害公式
  36. Instead of using the damage formula for everything, you can create custom effects that support formulas.
  37. 你可以创建自定义效果,支持公式,而不是完全依靠伤害公式
  38. If you already knew how to write the formula,
  39. then you can just move it from the damage formula into this formula effect.
  40. 如果你已经知道怎么写公式,那么你就可以把它从损伤公式中移到这个公式中
  41. Because a formula effect is just another effect, it supports other plugins
  42. that work with effects, such as Conditional Effects, which allows you to
  43. determine whether an effect should be executed based on a condition.
  44. 因为一个公式效应只是另一个效果,它支持其他插件的工作效果,如条件效应,
  45. 这让你决定是否应该根据一个条件执行效果
  46. == Terms of Use ==

  47. - Free for use in non-commercial projects with credits
  48. - Contact me for commercial use

  49. == Change Log ==

  50. Feb 11, 2015 -  initial release

  51. == Usage ==

  52. To create a formula effect, note-tag items or skills with
  53. 道具栏,技能栏备注中写下,
  54.   <formula effect>
  55.     FORMULA
  56.   </formula effect>
  57.   
  58. Where the FORMULA will be evaluated during skill execution and the behavior
  59. is determined by what you write in the formula.
  60. 把“FORMULA”替换成你要执行的公式。
  61. The following formula variables are available
  62. 可以使用以下变量

  63.   a - attacker                                //攻击者
  64.   b - target                                //被击者
  65.   i - current item or skill        //当前正在发动使用的技能或道具
  66.   v - game variables                //游戏变量
  67.   s - game switches                        //游戏开关
  68.   t - game troop                        //游戏敌群
  69.   p - game party                        //游戏队伍
  70.   
  71. So for example, if you wanted to reduce the target's HP by 100, you could
  72. use the formula
  73. 例:对方扣100点血
  74.   b.gainHp(-100);

  75. You can access the result of the action on the target using
  76. 你可以访问目标使用的操作的结果
  77.   var r = b.result()
  78.   
  79. With this, you can then check how much HP damage or MP damage was dealt
  80. 有了这个你可以检查已经造成多少生命伤害和法力伤害
  81.   r.hpDamage
  82.   r.mpDamage
  83.   
  84. And then use this in your effect calculations.
  85. 然后在你的效果计算中使用这个
  86. Anything that is defined in the code can be used as an effect.
  87. 任何在代码中定义的事都可以作为一个技能/物品效果。
  88. -------------------------------------------------------------------------------
  89. */
  90. var Imported = Imported || {} ;
  91. var TH = TH || {};
  92. Imported.FormulaEffects = 1;
  93. TH.FormulaEffects = TH.FormulaEffects || {};

  94. (function ($) {

  95.   $.Code = "TH_FORMULA_EFFECT";
  96.   $.Regex = /<formula[-_ ]effect:\s*(\w+)\s*\/>/img
  97.   $.ExtRegex = /<formula[-_ ]effect>([\s\S]*?)<\/formula[-_ ]effect>/img

  98.   $.loadEffects = function(obj) {
  99.     if (obj.thFormulaEffectsLoaded) {
  100.       return;
  101.     }
  102.     obj.thFormulaEffectsLoaded = true;
  103.     var res;
  104.     while (res = $.ExtRegex.exec(obj.note)) {
  105.       var formula = res[1];
  106.       var eff = {
  107.         code: $.Code,
  108.         dataId: 0,
  109.         value1: formula,
  110.         value2: 0
  111.       };
  112.       obj.effects.push(eff);
  113.     }
  114.   };
  115.   
  116.   var TH_GameAction_applyItemEffect = Game_Action.prototype.applyItemEffect;
  117.   Game_Action.prototype.applyItemEffect = function(target, effect) {
  118.     if (effect.code === $.Code) {
  119.       this.itemEffectFormulaEffect(target, effect);
  120.     }
  121.     else {
  122.       TH_GameAction_applyItemEffect.call(this, target, effect);
  123.     }
  124.   };
  125.   
  126.   /* Apply custom formula effect to user or target */
  127.   Game_Action.prototype.itemEffectFormulaEffect = function(target, effect) {
  128.     var formula = effect.value1;
  129.     var a = this.subject();
  130.     var b = target;
  131.     var i = this.item();
  132.     var v = $gameVariables;
  133.     var s = $gameSwitches;   
  134.     var p = $gameParty;
  135.     var t = $gameTroop;
  136.     eval(formula);
  137.     this.makeSuccess(target);
  138.   };

  139.   var TH_DataManager_onLoad = DataManager.onLoad;  
  140.   DataManager.onLoad = function(object) {
  141.     TH_DataManager_onLoad.call(this, object);
  142.     if (object[1] && object[1].effects !== undefined) {
  143.       for (var i = 1, len = object.length; i < len; i++) {        
  144.         $.loadEffects(object[i])
  145.       };
  146.     };
  147.   };
  148. })(TH.FormulaEffects);
复制代码
我想来脑洞几个:
1·斩杀:可以写检查剩余生命值比例,低于25%,就造成大量的伤害。
2·散失:烧蓝,烧点多少蓝就根据比例掉血。
3·奇美拉射击:检查目标中毒状态的剩余回合数(这个= =可能不好获取啊……),取消掉中毒,一次性造成剩余回合数X每一跳伤害。
4·以攻击力或防御力较高的值来造成伤害= =
5·伏击:只能在自身处于潜行状态下才能使用,否则不能使用或者不能造成伤害。

暂时就脑洞这么多,我先研究下具体公式能不能写出来再说,看到的小伙伴们,脑洞起来。

Lv4.逐梦者

梦石
0
星屑
5732
在线时间
1556 小时
注册时间
2011-6-14
帖子
520
2
发表于 2016-2-15 17:35:15 | 只看该作者
楼主 求点例子
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
723
在线时间
530 小时
注册时间
2010-6-9
帖子
840
3
发表于 2016-2-15 18:59:46 | 只看该作者
真心求教如何写条件,如IF的格式
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
637
在线时间
164 小时
注册时间
2012-4-18
帖子
264
4
 楼主| 发表于 2016-2-15 19:06:46 | 只看该作者
我目前还在研究,弄好的就一个斩杀:
<formula effect>
  if (b.hp < b.mhp * 0.25){ a.atk * 10 * b.hjl };
  else { a.atk * 4 * b.hjl }
</formula effect>
hjl是我自己在底层脚本上加的一个系统变量,具体最用是用防御和等级生成一个护甲减免比率,然后1-这个比例。你用的时候自行替换成你自己的伤害公式即可。

点评

鉴于我自己恢复的冲突= =我还是放上斩杀的原始伤害公式吧= = (b.hp > b.mhp * 0.25) ? 100 : 400 100替换成正常的伤害公式,400替换成生命值低于25%时的伤害公式   发表于 2016-2-16 09:16
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
637
在线时间
164 小时
注册时间
2012-4-18
帖子
264
5
 楼主| 发表于 2016-2-16 09:11:24 | 只看该作者
反馈几个冲突= =
已知这个插件和MOG的战斗系统冲突,包括MOG_BossHp,MOG_EnemyHp,表现为血条显示BUG,血条变为红色且不会往下掉。
另外这个插件和YEP的战斗核心冲突,包括YEP_BattleEngineCore,表现为怪打不死= =

点评

那可惜了,你说的插件我也有再用  发表于 2016-2-16 10:41
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
676
在线时间
224 小时
注册时间
2006-12-7
帖子
839
6
发表于 2016-2-16 10:41:41 | 只看该作者
这个和yanfly那个相比有哪些新功能?
想做合击还没研究用哪个插件
基本就是要判定是否某个队友在队 然后属性要读多人的

点评

合击不清楚= =不过看翻译出来的说明应该是可以的,只不过要研究下才行。  发表于 2016-2-16 15:24
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
440
在线时间
679 小时
注册时间
2014-3-15
帖子
292

开拓者

7
发表于 2016-2-17 17:03:31 | 只看该作者
我觉得这个与Yanfly的damagecore功能差不多
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
637
在线时间
164 小时
注册时间
2012-4-18
帖子
264
8
 楼主| 发表于 2016-2-18 10:24:01 | 只看该作者
嗯嗯,是差不多,而且YEP的还有额外的功能,比这个强大,但是还是会有BUG,怪会打不死= =不知道为什么,难道是写法错误了= =

点评

说明一下,是被含有这个以及YEP同类插件注释的技能命中之后,怪物就会变成不死且不掉血= =没有使用含注释的技能则无此BUG  发表于 2016-2-18 10:26
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-10 09:26

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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