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 { /// /// 【兰彻斯特(小恶魔)】10320403 重生: /// 受到致命伤害后不会立即死亡,立即获得一个护盾并进入重生阶段, /// 如果在10秒内护盾没有被打破,将获得重生, /// 恢复所有生命。这个效果在3分钟内只能生效一次 /// (首次死亡后蜷缩自己,身上出现护盾, /// 10秒后如果护盾还在,则恢复生命。 /// 如果护盾被打碎,则直接死亡。被动,有动作). /// public class Monster_10320403_Passive : XmdsPassiveSkillBase { /// ///ID. /// public static int ID = 10320403; /// /// BUFFID. /// public static int Buff_ID = ID; /// /// BUFF时间. /// public static int Buff_LTime = 20000; /// /// CD时间. /// public static int Buff_CDTime = 1000 * 60 * 3; /// /// 护盾承受的伤害. /// public static int Buff_Value_1 = 1000; /// /// 保护计时. /// public static int Proteced_Time = 10000; private int mUUID = 0; /// ///计时器. /// private TimeExpire mBuffTimer = null; /// /// 是否开始计时. /// private bool mStartCountTime = false; /// /// 拥有者. /// 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(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); } } }