123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
-
- using CommonAI.Data;
- using CommonAI.Zone;
- using CommonAI.Zone.Formula;
- using CommonAI.Zone.Helper;
- using CommonLang;
- using XmdsCommon.Plugin;
- using XmdsCommonServer.Plugin;
- using XmdsCommonSkill.Plugin.Buffs;
- using XmdsCommonSkill.Plugin.Skills;
- namespace XmdsCommonSkill.Plugin.PassiveSkills.Monster
- {
- /// <summary>
- /// 【兰彻斯特(小恶魔)】10320403 重生:
- /// 受到致命伤害后不会立即死亡,立即获得一个护盾并进入重生阶段,
- /// 如果在10秒内护盾没有被打破,将获得重生,
- /// 恢复所有生命。这个效果在3分钟内只能生效一次
- /// (首次死亡后蜷缩自己,身上出现护盾,
- /// 10秒后如果护盾还在,则恢复生命。
- /// 如果护盾被打碎,则直接死亡。被动,有动作).
- /// </summary>
- public class Monster_10320403_Passive : XmdsPassiveSkillBase
- {
- /// <summary>
- ///ID.
- /// </summary>
- public static int ID = 10320403;
- /// <summary>
- /// BUFFID.
- /// </summary>
- public static int Buff_ID = ID;
- /// <summary>
- /// BUFF时间.
- /// </summary>
- public static int Buff_LTime = 20000;
- /// <summary>
- /// CD时间.
- /// </summary>
- public static int Buff_CDTime = 1000 * 60 * 3;
- /// <summary>
- /// 护盾承受的伤害.
- /// </summary>
- public static int Buff_Value_1 = 1000;
- /// <summary>
- /// 保护计时.
- /// </summary>
- public static int Proteced_Time = 10000;
- private int mUUID = 0;
- /// <summary>
- ///计时器.
- /// </summary>
- private TimeExpire<int> mBuffTimer = null;
- /// <summary>
- /// 是否开始计时.
- /// </summary>
- private bool mStartCountTime = false;
- /// <summary>
- /// 拥有者.
- /// </summary>
- private XmdsVirtual mOwner = null;
- private bool mHasDone = false;
- public override int SkillID
- {
- get { return ID; }
- }
- protected override void OnInit(GameSkill skillInfo, XmdsVirtual owner)
- {
- mOwner = owner;
- XmdsBuffPack pack = XmdsBuffFactory.GetInstance().GetXmdsBuffPack(Buff_ID);
- XmdsBuff_Shield_AbsorbDamage buff = (XmdsBuff_Shield_AbsorbDamage)pack.GetXmdsBuff(XmdsBuffProperties.XmdsBuffAbility.SHIELD_AbsorbDamage);
- buff.AbsorbDamageSum = Buff_Value_1;
- BuffTemplate bt = pack.mBuffTemplate;
- bt.IsHarmful = false;
- bt.LifeTimeMS = Buff_LTime;
-
- pack.BindTemplateAndDispose();
- owner.RegistSendBuff(bt);
- //设置CD时间.
- SetTimer(Buff_CDTime);
- //注册招架监听.
- mUUID = owner.RegistOnHitDamage(OnHandleOnHitDamage, skillInfo, true);
- }
- protected override void OnUpdate(int intervalMS, bool slowRefresh)
- {
- if (mBuffTimer != null && mStartCountTime == true)
- {
- if (mBuffTimer.Update(intervalMS))
- {
- mStartCountTime = false;
- mBuffTimer.Reset();
- //时间到,检查盾是否还在.
- CheckBuffState();
- }
- }
- base.OnUpdate(intervalMS, slowRefresh);
- }
- //招架触发回调.
- private float OnHandleOnHitDamage(float damage, XmdsVirtual hitter, XmdsVirtual attacker, AttackSource source,
- ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch)
- {
- if (mHasDone == false)
- {
- //触发技能.
- if (hitter.mUnit.CurrentHP - damage <= 0)
- {
- mHasDone = true;
- //假飘字.
- attacker.SendHPChangeMessage(hitter.mUnit.ID, (int)-damage);
- hitter.SendHPChangeMessage(hitter.mUnit.ID, (int)-damage);
- //本次伤害为0.
- damage = 0;
- //血量归1.
- hitter.mUnit.CurrentHP = 1;
- //启动计时器.
- if (mBuffTimer == null)
- {
- mBuffTimer = new TimeExpire<int>(Proteced_Time);
- }
- else
- {
- mBuffTimer.Reset(Proteced_Time);
- }
- mStartCountTime = true;
- hitter.mUnit.AddBuff(Buff_ID, hitter.mUnit);
- RestartTimer();
- }
- }
- return damage;
- }
- private void CheckBuffState()
- {
- if (mOwner != null)
- {
- //时间到,盾没破,满血回复.
- if (mOwner.mUnit.GetBuffByID(Buff_ID) != null)
- {
- mOwner.AddHP(mOwner.mUnit.MaxHP, mOwner.mUnit, false);
- mOwner.mUnit.removeBuff(Buff_ID);
- }
- }
- }
- protected override void OnDispose(XmdsVirtual owner)
- {
- owner.UnRegistOnHitDamage(mUUID);
- }
- }
- }
|