Warrior_110500.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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.XLS.Data;
  11. using XmdsCommonSkill.Plugin.Buffs;
  12. namespace XmdsCommonSkill.Plugin.Skills.Warrior
  13. {
  14. /// <summary>
  15. /// 五技能 :基类
  16. /// 至少聚气0.5秒,最多2秒(点击开始聚气,再按一次图标),期间获得20%免伤,降低20%移动速度,
  17. /// 不可释放其他技能。聚气完后旋转挥击巨剑,自身形成烈焰风暴环绕,周身产生烟尘,
  18. /// 对周围敌人每0.5秒造成一次n%攻击力伤害,聚气时间越长伤害越高(正比提升),持续5秒。整个期间,免疫眩晕(转换成最大减速50%)
  19. /// </summary>
  20. public class Warrior_110500 : XmdsSkillBase
  21. {
  22. private static readonly int ID = 110500;
  23. protected static readonly int Buff_ID_1 = (int)XmdsBuffBase.XmdsBuffList. LAUNCH_BUF_ZS_5; // 剑刃风暴,免控buf
  24. protected static readonly int Buff_ID_2 = (int)XmdsBuffBase.XmdsBuffList.TRY_LAUNCH_BUF_ZS_5; // 聚气buf
  25. public override int SkillID { get { return ID; } }
  26. protected static readonly int DAMAGE_SPELL_TIME = 5000; //剑刃风暴时间,和编辑器挂钩,这里标记一个变量
  27. //聚气减伤,减速buff,时间编辑器固定不能修改
  28. protected XmdsSkillValue mJuQiValue;
  29. //剑刃风暴,免疫控制,转换成减速
  30. protected XmdsSkillValue mValueSet5;
  31. //蓄力五段伤害,5段时间。策划确定写死
  32. protected XmdsSkillValue mValueSet6;
  33. //每次触发段造成伤害,增加怒气值
  34. protected XmdsSkillValue mValueSet8;
  35. //伤害倍数.
  36. protected XmdsSkillValue mValueSet1;
  37. //根据时间,控制每一段造成伤害加怒气的唯一性
  38. protected bool[] mIsHit = { false, false, false, false, false};
  39. protected long launchTime = 0; //
  40. protected long damageStartTime = 0; // 伤害开始时间
  41. //聚气伤害加成
  42. protected int mReadyDamageAddition = 0;
  43. protected bool mAutoLaunch = true;
  44. protected override void OnSkillDamagePerEvent(BattleParams param)
  45. {
  46. param.SkillDamageAdd = mValueSet1.GetValue(param.GameSkill.SkillLevel);
  47. param.SkillDamagePer = CUtils.CastInt(mValueSet1.GetValueExt(param.GameSkill.SkillLevel) * XmdsUnitProp.PER * this.mReadyDamageAddition);
  48. }
  49. protected override void OnInit(GameSkill info, XmdsVirtual unit, ref SkillTemplate template)
  50. {
  51. // 释放剑刃风暴获得buff
  52. var pack1 = XmdsBuffFactory.GetInstance().GetXmdsBuffPack(Buff_ID_1);
  53. var buff = (XmdsBuff_IgnorCtrlToSpeedDown)pack1.GetXmdsBuff(XmdsBuffProperties.XmdsBuffAbility.IgnorCtrl_To_SpeedDown);
  54. buff.speedChange = -mValueSet5.GetValue(info.SkillLevel); //减速万分之N
  55. var bt1 = pack1.mBuffTemplate;
  56. bt1.IsHarmful = true;
  57. bt1.LifeTimeMS = DAMAGE_SPELL_TIME; //时间由spell确定,所以写死
  58. pack1.BindTemplateAndDispose();
  59. unit.RegistSendBuff(bt1);
  60. // 聚气buff
  61. var pack2 = XmdsBuffFactory.GetInstance().GetXmdsBuffPack(Buff_ID_2);
  62. var buff2 = (XmdsBuff_SpeedChg_DamageRemit)pack2.GetXmdsBuff(XmdsBuffProperties.XmdsBuffAbility.SpeedChg_DamageRemit);
  63. buff2.speedChange = -mJuQiValue.GetValue(info.SkillLevel, 1); //减速万分之N
  64. buff2.damageRemit = mJuQiValue.GetValue(info.SkillLevel, 2); //减伤万分之N
  65. var bt2 = pack2.mBuffTemplate;
  66. bt2.IsHarmful = true;
  67. bt2.LifeTimeMS = 2000; //时间由动作确定,所以写死
  68. pack2.BindTemplateAndDispose();
  69. unit.RegistSendBuff(bt2);
  70. unit.RegistLaunchSkillOver(OnLaunchSkillOver, info);
  71. unit.RegistTrySendSpellEvent(OnTrySendSpell, info);
  72. unit.RegistOnHitOther(OnHandleHitOther, info);
  73. }
  74. protected override void OnSkillDataChange(GameSkill gs, XmdsVirtual unit)
  75. {
  76. base.OnSkillDataChange(gs, unit);
  77. var buff = unit.GetRegisBuffVirtual(Buff_ID_2) as XmdsBuff_SpeedChg_DamageRemit;
  78. buff.speedChange = -mJuQiValue.GetValue(gs.SkillLevel, 1); //减速万分之N
  79. buff.damageRemit = mJuQiValue.GetValue(gs.SkillLevel, 2); //减伤万分之N
  80. }
  81. private float OnHandleHitOther(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source,
  82. ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch)
  83. {
  84. //int timeIndex = Math.Min((int)((CommonLang.CUtils.localTimeMS - damageStartTime) / 1000), mIsHit.Length);
  85. int timeIndex = (int)((CommonLang.CUtils.localTimeMS - damageStartTime) / 1000);
  86. if (timeIndex < 0 || timeIndex >= mIsHit.Length)
  87. {
  88. if(timeIndex > 7)
  89. {
  90. log.Error("Warrior_110500获取时间索引异常:" + attacker.mUnit.PlayerUUID + ", " + timeIndex + ", " + attacker.mUnit.Parent.GetSceneID());
  91. }
  92. return damage;
  93. }
  94. if(!mIsHit[timeIndex])
  95. {
  96. mIsHit[timeIndex] = true;
  97. attacker.Talent__Add(mValueSet8.GetValue(skill.SkillLevel));
  98. }
  99. return damage;
  100. }
  101. private void OnTrySendSpell(GameSkill skill, XmdsVirtual launcher, LaunchSpell launch, ref SpellTemplate spell, ref JSGCreateSpellData createData, ref float startX, ref float startY)
  102. {
  103. //System.Console.WriteLine("OnTrySendSpell: " + spell.ID + ", " + CommonLang.CUtils.localTimeMS);
  104. damageStartTime = CommonLang.CUtils.localTimeMS;
  105. }
  106. private int OnLaunchSkillOver(GameSkill info, XmdsCommonServer.Plugin.XmdsVirtual attacker, CommonAI.Zone.Instance.InstanceUnit.SkillState state)
  107. {
  108. if(state.ActionIndex == 0)
  109. {
  110. this.launchTime = CommonLang.CUtils.localTimeMS;
  111. this.mReadyDamageAddition = mValueSet6.GetValue(1, 5);
  112. this.mAutoLaunch = true;
  113. for(int i = 0; i < mIsHit.Length; i++)
  114. {
  115. this.mIsHit[i] = false;
  116. }
  117. }
  118. else if(state.ActionIndex == 2) //手动释放剑刃风暴
  119. {
  120. this.mAutoLaunch = false;
  121. attacker.mUnit.removeBuff(Buff_ID_2);
  122. long curTime = CommonLang.CUtils.localTimeMS;
  123. long readyTime = (curTime - this.launchTime);
  124. if (readyTime <= 500)
  125. {
  126. this.mReadyDamageAddition = mValueSet6.GetValue(1, 1);
  127. }
  128. else if(readyTime <= 1000)
  129. {
  130. this.mReadyDamageAddition = mValueSet6.GetValue(1, 2);
  131. }
  132. else if(readyTime <= 1500)
  133. {
  134. this.mReadyDamageAddition = mValueSet6.GetValue(1, 3);
  135. }
  136. else if (readyTime < 2000)
  137. {
  138. this.mReadyDamageAddition = mValueSet6.GetValue(1, 4);
  139. }
  140. this.launchTime = curTime;
  141. }
  142. return 0;
  143. }
  144. protected override void OnInitConfig()
  145. {
  146. XmdsSkillData data = XmdsDataMgr.GetInstance().GetXmdsSkillData(ID);
  147. InitData(data, out mJuQiValue, XmdsSkillData.XmdsSkillDataKey.DmgRate);
  148. InitData(data, out mValueSet1, XmdsSkillData.XmdsSkillDataKey.ValueSet);
  149. //扩展配置
  150. InitData(data, out mValueSet5, XmdsSkillData.XmdsSkillDataKey.ValueSet5);
  151. InitData(data, out mValueSet6, XmdsSkillData.XmdsSkillDataKey.ValueSet6);
  152. InitData(data, out mValueSet8, XmdsSkillData.XmdsSkillDataKey.ValueSet8);
  153. }
  154. }
  155. }