Monster_601011_Passive.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. using CommonAI.Data;
  2. using CommonAI.Zone;
  3. using CommonAI.Zone.Formula;
  4. using CommonLang;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using XmdsCommon.Plugin;
  10. using XmdsCommonServer.Plugin;
  11. using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator;
  12. using XmdsCommonServer.XLS.Data;
  13. using XmdsCommonSkill.Plugin.Buffs;
  14. using XmdsCommonSkill.Plugin.Skills;
  15. namespace XmdsCommonSkill.Plugin.PassiveSkills.Monster
  16. {
  17. /// <summary>
  18. /// 狂暴 生命值低于50时触发,赤虎妖伤害大幅上升,自身移动速度大幅下降 一个增加自身伤害同时降低自身速度的BUFF
  19. /// </summary>
  20. public class Monster_601011 : XmdsPassiveSkillBase
  21. {
  22. /// <summary>
  23. ///ID.
  24. /// </summary>
  25. public static int ID = 601011;
  26. /// <summary>
  27. /// BUFF时间. 姚晟:填一个很长的数值,90000秒这样
  28. /// </summary>
  29. public static int Buff_Time = 90000000;
  30. public static int Buff_ID = 601011;
  31. /// <summary>
  32. /// BUFF 攻击增加.
  33. /// </summary>
  34. public static XmdsSkillValue Buff_Value_1;
  35. /// <summary>
  36. /// BUFF 减速
  37. /// </summary>
  38. public static XmdsSkillValue Buff_Value_2;
  39. public static int Condition_1 = 5000;
  40. /// <summary>
  41. /// 是否使用.
  42. /// </summary>
  43. private bool HasDone = false;
  44. private int mUUID = 0;
  45. public override int SkillID
  46. {
  47. get { return ID; }
  48. }
  49. protected override void OnInit(GameSkill skillInfo, XmdsVirtual owner)
  50. {
  51. XmdsBuffPack pack = XmdsBuffFactory.GetInstance().GetXmdsBuffPack(Buff_ID);
  52. var bufflist = pack.GetXmdsBuffList();
  53. if (bufflist.Count >= 2)
  54. {
  55. //攻击增加.
  56. var propChange = (XmdsBuff_PropChange)bufflist[0];
  57. propChange.CurentChangeType = XmdsVirtual.UnitAttributeType.Attack;
  58. propChange.CurrentValue = this.GetTargetFormulaValue(skillInfo.SkillLevel, Buff_Value_1);
  59. propChange.IsPercent = true;
  60. //防御增加.
  61. var buff_speed = (XmdsBuff_MoveSpeedDown)bufflist[1];
  62. buff_speed.ChangePercent = -this.GetTargetFormulaValue(skillInfo.SkillLevel, Buff_Value_2);
  63. propChange.IsPercent = true;
  64. }
  65. BuffTemplate bt = pack.mBuffTemplate;
  66. bt.IsHarmful = false;
  67. bt.LifeTimeMS = Buff_Time;
  68. pack.BindTemplateAndDispose();
  69. owner.RegistSendBuff(bt);
  70. //注册招架监听.
  71. mUUID = owner.RegistOnHitDamage(OnHandleOnHitDamage, skillInfo, true);
  72. }
  73. private float OnHandleOnHitDamage(float damage, XmdsVirtual hitter, XmdsVirtual attacker, AttackSource source,
  74. ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch)
  75. {
  76. if (HasDone == false)
  77. {
  78. int v1 = CUtils.CastInt(hitter.mUnit.MaxHP * (Condition_1 * 1.0f / XmdsDamageCalculator.PERER));
  79. //小于指定血量.
  80. if (hitter.mUnit.CurrentHP - damage < v1)
  81. {
  82. HasDone = true;
  83. //触发技能效果.
  84. hitter.mUnit.AddBuff(Buff_ID, hitter.mUnit);
  85. CommonAI.Zone.LaunchSpell ls = new CommonAI.Zone.LaunchSpell();
  86. ls.SpellID = SkillID;
  87. //播放声音特效.
  88. //hitter.mUnit.Parent.unitLaunchSpell(hitter.mUnit, ls,
  89. // hitter.mUnit.X, hitter.mUnit.Y,
  90. // hitter.mUnit.ID);
  91. }
  92. }
  93. return damage;
  94. }
  95. protected override void OnDispose(XmdsVirtual owner)
  96. {
  97. owner.UnRegistOnHitDamage(mUUID);
  98. }
  99. protected override void OnInitSkillParam()
  100. {
  101. XmdsSkillData data = XmdsDataMgr.GetInstance().GetXmdsSkillData(ID);
  102. InitData(data, out Buff_Value_1, XmdsSkillData.XmdsSkillDataKey.ValueSet);
  103. InitData(data, out Buff_Value_2, XmdsSkillData.XmdsSkillDataKey.ValueSet2);
  104. }
  105. }
  106. }