/// <summary>
        /// Suffer the specified caster, target and damage.
        /// 收到伤害的时候,没有返回值.
        /// </summary>
        /// <param name="caster">释放者</param>
        /// <param name="target">目标者</param>
        /// <param name="damage">伤害值</param>
        public void Suffer(ServerNPC caster, ServerNPC sufferer, SelfDescribed des, WarServerNpcMgr npcMgr)
        {
            //拿到算子
            InjuryOp sufOp = OperatorMgr.instance.getImplement <InjuryOp>(EffectOp.Injury);

            handled = new Dmg {
                dmgValue   = des.targetEnd.param1,
                dmgType    = (SkillTypeClass)des.targetEnd.param3,
                isCritical = des.targetEnd.param2 == 1,
                hitCls     = (HurtHitClass)Enum.ToObject(typeof(HurtHitClass), des.targetEnd.param4),
            };

            //TODO: find buff
            EffectConfigData[] help = null;
            suf = sufOp.toSuffer(ref handled, sufferer.data, caster.data, help);
            ///
            ///更多的事情发生了,比如护盾,吸血,反弹
            ///
            report(caster.UniqueID, sufferer.UniqueID, suf, npcMgr);

            ///
            /// --------- 最终结算 --------
            ///
            sufferer.data.rtData.curHp -= (int)handled.dmgValue;


            ///
            /// --------- 通知Trigger,OnKilled ----------
            ///
            toTriggerMsg(caster, sufferer, npcMgr);
        }
Exemple #2
0
        public Suf toSuffer(ref Dmg damage, NPCData suffer, NPCData from, EffectConfigData[] resis)
        {
                        #if DEBUG
            Utils.Assert(suffer == null, "NPCData suffer can't be null.");
            Utils.Assert(suffer == null, "NPCData attacker can't be null.");
                        #endif

            ///
            /// --------------- Suffer 获取Dot/Hot -------------
            ///

            bool forbid_die = damage.hitCls.check(HurtHitClass.Forbid_Die);
            if (forbid_die)
            {
                if (damage.dmgValue >= suffer.rtData.curHp)
                {
                    damage.dmgValue = suffer.rtData.curHp - 1;
                }
            }

            //TODO : 错误逻辑,仅仅是测试使用
            bool forbid_shield = damage.hitCls.check(HurtHitClass.Forbid_ProtectionShield);
            if (!forbid_shield)              //不无视护盾

            {
            }

            //要计算反弹吗?
            bool rebound = false;
            switch (damage.dmgType)
            {
            case SkillTypeClass.Rebound_Hol:
            case SkillTypeClass.Rebound_Mag:
            case SkillTypeClass.Rebound_Phy:
                rebound = false;
                break;

            case SkillTypeClass.Holly:
            case SkillTypeClass.Magical:
            case SkillTypeClass.Physical:
                rebound = true;
                break;
            }

            if (rebound)              //计算反弹

            {
            }


            ///
            /// ---- 计算吸血 ------
            ///

            Suf suf = new Suf()
            {
                sufValue   = damage,
                rebValue   = null,
                bdyValue   = null,
                protectVal = null,
                resDmgType = ResistanteClass.None,
            };
            return(suf);
        }
        void report(int CasterId, int SufferId, Suf suf, WarServerNpcMgr npcMgr)
        {
            //检测护盾
            if (suf.resDmgType.check(ResistanteClass.Protection))
            {
                if (suf.protectVal != null)
                {
                    //统计数据
                    SelfDescribed des = new SelfDescribed()
                    {
                        src    = CasterId,
                        target = SufferId,                         //SufferId 应该变为真实的护盾的NPC
                        act    = Verb.Punch,
                        srcEnd = null,
                    };

                    EndResult tarEnd = new EndResult();

                    Dmg protectDmg = suf.protectVal.Value;
                    tarEnd.param1 = (int)protectDmg.dmgValue;
                    tarEnd.param2 = protectDmg.isCritical ? 1 : 0;
                    tarEnd.param3 = (int)protectDmg.dmgType;
                    tarEnd.param4 = (int)HurtHitClass.None;

                    des.targetEnd = tarEnd;

                    WarTarAnimParam param = new WarTarAnimParam()
                    {
                        OP        = EffectOp.Injury,
                        OringinOP = EffectOp.Injury,
                        described = des,
                    };

                    npcMgr.SendMessageAsync(des.src, des.target, param);
                }
            }

            if (suf.resDmgType.check(ResistanteClass.Bloody) || suf.resDmgType.check(ResistanteClass.Rebound))
            {
                //反弹不为空
                if (suf.rebValue != null)
                {
                    //统计数据
                    SelfDescribed des = new SelfDescribed()
                    {
                        src    = SufferId,
                        target = CasterId,
                        act    = Verb.Punch,
                        srcEnd = null,
                    };

                    EndResult tarEnd = new EndResult();

                    Dmg rebDmg = suf.rebValue.Value;
                    tarEnd.param1 = (int)rebDmg.dmgValue;
                    tarEnd.param2 = rebDmg.isCritical ? 1 : 0;
                    tarEnd.param3 = (int)rebDmg.dmgType;
                    tarEnd.param4 = (int)HurtHitClass.None;

                    des.targetEnd = tarEnd;

                    WarTarAnimParam param = new WarTarAnimParam()
                    {
                        OP        = EffectOp.Injury,
                        OringinOP = EffectOp.Injury,
                        described = des,
                    };

                    npcMgr.SendMessageAsync(des.src, des.target, param);
                }

                //吸血不为空
                if (suf.bdyValue != null)
                {
                    //统计数据
                    SelfDescribed des = new SelfDescribed()
                    {
                        src    = SufferId,
                        target = CasterId,
                        act    = Verb.Recover,
                        srcEnd = null,
                    };

                    EndResult tarEnd = new EndResult();

                    Dmg bdyDmg = suf.bdyValue.Value;
                    tarEnd.param1 = (int)bdyDmg.dmgValue;
                    tarEnd.param2 = bdyDmg.isCritical ? 1 : 0;
                    tarEnd.param3 = (int)bdyDmg.dmgType;
                    tarEnd.param4 = (int)HurtHitClass.None;

                    des.targetEnd = tarEnd;

                    WarTarAnimParam param = new WarTarAnimParam()
                    {
                        OP        = EffectOp.Treat,
                        OringinOP = EffectOp.Treat,
                        described = des,
                    };

                    npcMgr.SendMessageAsync(des.src, des.target, param);
                }
            }
        }