Monster_10320403_Passive.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. 
  2. using CommonAI.Data;
  3. using CommonAI.Zone;
  4. using CommonAI.Zone.Formula;
  5. using CommonAI.Zone.Helper;
  6. using CommonLang;
  7. using XmdsCommon.Plugin;
  8. using XmdsCommonServer.Plugin;
  9. using XmdsCommonSkill.Plugin.Buffs;
  10. using XmdsCommonSkill.Plugin.Skills;
  11. namespace XmdsCommonSkill.Plugin.PassiveSkills.Monster
  12. {
  13. /// <summary>
  14. /// 【兰彻斯特(小恶魔)】10320403 重生:
  15. /// 受到致命伤害后不会立即死亡,立即获得一个护盾并进入重生阶段,
  16. /// 如果在10秒内护盾没有被打破,将获得重生,
  17. /// 恢复所有生命。这个效果在3分钟内只能生效一次
  18. /// (首次死亡后蜷缩自己,身上出现护盾,
  19. /// 10秒后如果护盾还在,则恢复生命。
  20. /// 如果护盾被打碎,则直接死亡。被动,有动作).
  21. /// </summary>
  22. public class Monster_10320403_Passive : XmdsPassiveSkillBase
  23. {
  24. /// <summary>
  25. ///ID.
  26. /// </summary>
  27. public static int ID = 10320403;
  28. /// <summary>
  29. /// BUFFID.
  30. /// </summary>
  31. public static int Buff_ID = ID;
  32. /// <summary>
  33. /// BUFF时间.
  34. /// </summary>
  35. public static int Buff_LTime = 20000;
  36. /// <summary>
  37. /// CD时间.
  38. /// </summary>
  39. public static int Buff_CDTime = 1000 * 60 * 3;
  40. /// <summary>
  41. /// 护盾承受的伤害.
  42. /// </summary>
  43. public static int Buff_Value_1 = 1000;
  44. /// <summary>
  45. /// 保护计时.
  46. /// </summary>
  47. public static int Proteced_Time = 10000;
  48. private int mUUID = 0;
  49. /// <summary>
  50. ///计时器.
  51. /// </summary>
  52. private TimeExpire<int> mBuffTimer = null;
  53. /// <summary>
  54. /// 是否开始计时.
  55. /// </summary>
  56. private bool mStartCountTime = false;
  57. /// <summary>
  58. /// 拥有者.
  59. /// </summary>
  60. private XmdsVirtual mOwner = null;
  61. private bool mHasDone = false;
  62. public override int SkillID
  63. {
  64. get { return ID; }
  65. }
  66. protected override void OnInit(GameSkill skillInfo, XmdsVirtual owner)
  67. {
  68. mOwner = owner;
  69. XmdsBuffPack pack = XmdsBuffFactory.GetInstance().GetXmdsBuffPack(Buff_ID);
  70. XmdsBuff_Shield_AbsorbDamage buff = (XmdsBuff_Shield_AbsorbDamage)pack.GetXmdsBuff(XmdsBuffProperties.XmdsBuffAbility.SHIELD_AbsorbDamage);
  71. buff.AbsorbDamageSum = Buff_Value_1;
  72. BuffTemplate bt = pack.mBuffTemplate;
  73. bt.IsHarmful = false;
  74. bt.LifeTimeMS = Buff_LTime;
  75. pack.BindTemplateAndDispose();
  76. owner.RegistSendBuff(bt);
  77. //设置CD时间.
  78. SetTimer(Buff_CDTime);
  79. //注册招架监听.
  80. mUUID = owner.RegistOnHitDamage(OnHandleOnHitDamage, skillInfo, true);
  81. }
  82. protected override void OnUpdate(int intervalMS, bool slowRefresh)
  83. {
  84. if (mBuffTimer != null && mStartCountTime == true)
  85. {
  86. if (mBuffTimer.Update(intervalMS))
  87. {
  88. mStartCountTime = false;
  89. mBuffTimer.Reset();
  90. //时间到,检查盾是否还在.
  91. CheckBuffState();
  92. }
  93. }
  94. base.OnUpdate(intervalMS, slowRefresh);
  95. }
  96. //招架触发回调.
  97. private float OnHandleOnHitDamage(float damage, XmdsVirtual hitter, XmdsVirtual attacker, AttackSource source,
  98. ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch)
  99. {
  100. if (mHasDone == false)
  101. {
  102. //触发技能.
  103. if (hitter.mUnit.CurrentHP - damage <= 0)
  104. {
  105. mHasDone = true;
  106. //假飘字.
  107. attacker.SendHPChangeMessage(hitter.mUnit.ID, (int)-damage);
  108. hitter.SendHPChangeMessage(hitter.mUnit.ID, (int)-damage);
  109. //本次伤害为0.
  110. damage = 0;
  111. //血量归1.
  112. hitter.mUnit.CurrentHP = 1;
  113. //启动计时器.
  114. if (mBuffTimer == null)
  115. {
  116. mBuffTimer = new TimeExpire<int>(Proteced_Time);
  117. }
  118. else
  119. {
  120. mBuffTimer.Reset(Proteced_Time);
  121. }
  122. mStartCountTime = true;
  123. hitter.mUnit.AddBuff(Buff_ID, hitter.mUnit);
  124. RestartTimer();
  125. }
  126. }
  127. return damage;
  128. }
  129. private void CheckBuffState()
  130. {
  131. if (mOwner != null)
  132. {
  133. //时间到,盾没破,满血回复.
  134. if (mOwner.mUnit.GetBuffByID(Buff_ID) != null)
  135. {
  136. mOwner.AddHP(mOwner.mUnit.MaxHP, mOwner.mUnit, false);
  137. mOwner.mUnit.removeBuff(Buff_ID);
  138. }
  139. }
  140. }
  141. protected override void OnDispose(XmdsVirtual owner)
  142. {
  143. owner.UnRegistOnHitDamage(mUUID);
  144. }
  145. }
  146. }