Warrior_110460.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. using CommonAI.Data;
  2. using CommonAI.Zone;
  3. using CommonAI.Zone.Formula;
  4. using CommonAI.Zone.Helper;
  5. using CommonAI.Zone.Instance;
  6. using CommonLang;
  7. using System;
  8. using XmdsCommon.Plugin;
  9. using XmdsCommonServer.Plugin;
  10. using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator;
  11. using XmdsCommonServer.XLS.Data;
  12. using XmdsCommonSkill.Plugin.Buffs;
  13. using XmdsCommonSkill.Plugin.Interface;
  14. using static XmdsCommonSkill.Plugin.Interface.ComSpellTemplate;
  15. namespace XmdsCommonSkill.Plugin.Skills.Warrior
  16. {
  17. /// <summary>
  18. /// 四技能4-6(buff期间受到伤害每5%血量减少(不算回血,仅计算受到伤害量)向周围范围产生血气冲击,造成伤害(生命值系数))
  19. /// </summary>
  20. public class Warrior_110460 : Warrior_110450
  21. {
  22. private static int ID = 110460;
  23. //气血冲击伤害
  24. protected XmdsSkillValue mValueSet4;
  25. private static int Buff_ID = (int)XmdsBuffBase.XmdsBuffList.HPReduce_Damage_4_6;
  26. //受伤统计
  27. private int mCurTotalDamage = 0;
  28. private long mPreReduceHPAddSpellTime = 0;
  29. private int mHPReduceTriggerSpell = 0;
  30. public override int SkillID { get { return ID; } }
  31. protected override void OnInit(GameSkill info, XmdsVirtual unit, ref SkillTemplate template)
  32. {
  33. base.OnInit(info, unit, ref template);
  34. // Buff3修改
  35. var pack = XmdsBuffFactory.GetInstance().GetXmdsBuffPack(Buff_ID);
  36. var buf = (XmdsBuff_Event_OnHitDamage)pack.GetXmdsBuff(XmdsBuffProperties.XmdsBuffAbility.Event_OnHitDamageEvent);
  37. buf.OnHitDamageEvent = OnUnitHit;
  38. pack.mBuffTemplate.LifeTimeMS = mValueSet6.GetValue(info.SkillLevel);
  39. var bt = pack.mBuffTemplate;
  40. pack.BindTemplateAndDispose();
  41. unit.RegistSendBuff(bt);
  42. unit.RegistLaunchSkillOver(OnLaunchSkillOver, info);
  43. unit.RegistCalThreatValue(OnHandleCalThreatValue, info, true);
  44. }
  45. protected override void OnSkillDataChange(GameSkill gs, XmdsVirtual unit)
  46. {
  47. base.OnSkillDataChange(gs, unit);
  48. var bt = unit.GetRegistBuff(Buff_ID);
  49. bt.LifeTimeMS = mValueSet6.GetValue(gs.SkillLevel);
  50. }
  51. private void OnHandleCalThreatValue(XmdsVirtual attacker, XmdsVirtual hitter, AttackSource source, GameSkill gs, ref XmdsVirtual.AtkResult result)
  52. {
  53. if(source == null || source.Attack == null)
  54. {
  55. return;
  56. }
  57. XmdsAttackProperties atkProp = source.Attack.Properties as XmdsAttackProperties;
  58. if(atkProp == null)
  59. {
  60. return;
  61. }
  62. if(atkProp.DamagePerID == 2)
  63. {
  64. result.breakShieldValue = mValueSet4.GetValue(gs.TalentSkillLevel3, 3);
  65. }
  66. }
  67. protected override bool OnSkillFinalDamageModifyEvent(BattleParams param)
  68. {
  69. //MMO-16584 - sub- MMO-16524, 修改成最大生命伤害系数
  70. if (param.AtkProp.DamagePerID != 1)
  71. {
  72. int hpValue = CUtils.CastInt(param.Attacker.mUnit.MaxHP * XmdsUnitProp.PER * mValueSet4.GetValue(param.GameSkill.TalentSkillLevel3, 2));
  73. param.HitDamge = XmdsDamageCalculator.GetDamage(hpValue, param.Attacker, param.Hitter, param.Source);
  74. return true;
  75. }
  76. else
  77. {
  78. return base.OnSkillFinalDamageModifyEvent(param);
  79. }
  80. }
  81. private int OnLaunchSkillOver(GameSkill info, XmdsCommonServer.Plugin.XmdsVirtual launcher, CommonAI.Zone.Instance.InstanceUnit.SkillState skill)
  82. {
  83. launcher.mUnit.AddBuff(Buff_ID, launcher.mUnit);
  84. this.mHPReduceTriggerSpell = Math.Max(1, CUtils.CastInt(launcher.MirrorProp.MaxHP * XmdsUnitProp.PER *
  85. mValueSet4.GetValue(info.TalentSkillLevel3, 1)));
  86. return 0;
  87. }
  88. public float OnUnitHit(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source,
  89. ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch)
  90. {
  91. mCurTotalDamage = mCurTotalDamage + (int)damage;
  92. //受到伤害大于 N ,创建法术
  93. if(mCurTotalDamage > this.mHPReduceTriggerSpell)
  94. {
  95. long lcurTime = CommonLang.CUtils.localTimeMS;
  96. //确保不密集触发
  97. if(lcurTime - mPreReduceHPAddSpellTime > 500 || lcurTime - mPreReduceHPAddSpellTime < 0)
  98. {
  99. mCurTotalDamage = 0;
  100. mPreReduceHPAddSpellTime = lcurTime;
  101. hitted.mUnit.Parent.unitLaunchSpell(XmdsSkillType.none, hitted.mUnit,
  102. ComSpellTemplate.Instance().GetSpellByID(XmdsSpellID.WARRIOR_4_6),
  103. hitted.mUnit.X, hitted.mUnit.Y, attacker.mUnit.ID);
  104. }
  105. }
  106. return damage;
  107. }
  108. protected override void OnInitConfig()
  109. {
  110. XmdsSkillData data = XmdsDataMgr.GetInstance().GetXmdsSkillData(ID);
  111. InitData(data, out mDamageReduce, XmdsSkillData.XmdsSkillDataKey.DmgRate);
  112. InitData(data, out mValueSet1, XmdsSkillData.XmdsSkillDataKey.ValueSet);
  113. InitData(data, out mValueSet2, XmdsSkillData.XmdsSkillDataKey.ValueSet2);
  114. InitData(data, out mValueSet3, XmdsSkillData.XmdsSkillDataKey.ValueSet3);
  115. InitData(data, out mValueSet4, XmdsSkillData.XmdsSkillDataKey.ValueSet4);
  116. // 扩展配置
  117. InitData(data, out mValueSet5, XmdsSkillData.XmdsSkillDataKey.ValueSet5);
  118. InitData(data, out mValueSet6, XmdsSkillData.XmdsSkillDataKey.ValueSet6);
  119. InitData(data, out mValueSet8, XmdsSkillData.XmdsSkillDataKey.ValueSet8);
  120. }
  121. }
  122. }