private void AppendDamage(CharacterInfo sender, CharacterInfo receiver, ImpactInfo impactInfo, int parentDamage)
        {
            if (sender == null || receiver == null || impactInfo == null)
            {
                return;
            }
            int       skillLevel = 0;
            bool      isCritical = false;
            bool      isOrdinary = false;
            SkillInfo skillInfo  = sender.GetSkillStateInfo().GetSkillInfoById(impactInfo.m_SkillId);

            if (null != skillInfo)
            {
                skillLevel = skillInfo.SkillLevel;
                if (skillInfo.Category == SkillCategory.kAttack)
                {
                    isOrdinary = true;
                }
            }
            ElementDamageType element_type = (ElementDamageType)impactInfo.ConfigData.ElementType;

            if (ElementDamageType.DC_None == element_type)
            {
                element_type = sender.GetEquipmentStateInfo().WeaponDamageType;
            }
            int appendDamage = (int)(impactInfo.ConfigData.DamageRate * parentDamage + impactInfo.ConfigData.DamageValue);

            if (appendDamage <= 0)
            {
                return;
            }
            int curDamage = DamageCalculator.CalcImpactDamage(sender, receiver,
                                                              (SkillDamageType)impactInfo.ConfigData.DamageType,
                                                              element_type,
                                                              0,
                                                              appendDamage,
                                                              out isCritical);
            List <ImpactInfo> impactInfos = receiver.GetSkillStateInfo().GetAllImpact();

            for (int i = 0; i < impactInfos.Count; i++)
            {
                IImpactLogic logic = ImpactLogicManager.Instance.GetImpactLogic(impactInfos[i].ConfigData.ImpactLogicId);
                if (null != logic)
                {
                    curDamage = logic.RefixHpDamage(receiver, impactInfos[i].m_ImpactId, curDamage, sender.GetId(), ref isCritical, receiver.GetId());
                }
            }

            /*
             * foreach (ImpactInfo ii in receiver.GetSkillStateInfo().GetAllImpact()) {
             * IImpactLogic logic = ImpactLogicManager.Instance.GetImpactLogic(ii.ConfigData.ImpactLogicId);
             * if (null != logic) {
             *  curDamage = logic.RefixHpDamage(receiver, ii.m_ImpactId, curDamage, sender.GetId(), ref isCritical, receiver.GetId());
             * }
             * }*/
            OnCharacterDamage(sender, receiver, curDamage, isCritical, isOrdinary);
        }
Example #2
0
        protected void ApplyDamageImpl(CharacterInfo sender, CharacterInfo obj, ImpactInfo impactInfo, out int damage, bool is_ignore_passive_check = false)
        {
            damage = 0;
            int  skillLevel = 0;
            bool isCritical = false;
            bool isOrdinary = false;

            if (null != sender)
            {
                SkillInfo skillInfo = sender.GetSkillStateInfo().GetSkillInfoById(impactInfo.m_SkillId);
                if (null != skillInfo)
                {
                    skillLevel = skillInfo.SkillLevel;
                    if (skillInfo.Category == SkillCategory.kAttack)
                    {
                        isOrdinary = true;
                    }
                }
                float old_critical = 0;
                bool  is_adjusted  = AdjustCritical(sender, out old_critical);
                int   curDamage    = DamageCalculator.CalcImpactDamage(
                    sender,
                    obj,
                    (SkillDamageType)impactInfo.ConfigData.DamageType,
                    ElementDamageType.DC_None == (ElementDamageType)impactInfo.ConfigData.ElementType ? sender.GetEquipmentStateInfo().WeaponDamageType : (ElementDamageType)impactInfo.ConfigData.ElementType,
                    impactInfo.ConfigData.DamageRate + skillLevel * impactInfo.ConfigData.LevelRate,
                    impactInfo.ConfigData.DamageValue,
                    out isCritical);
                if (is_adjusted)
                {
                    //LogSystem.Error("----critical: reset critical to {0}", old_critical);
                    sender.GetActualProperty().SetCritical(Operate_Type.OT_Absolute, old_critical);
                }
                curDamage = TalentAdjustDamage(sender, obj, curDamage);
                List <ImpactInfo> targetImpactInfos = obj.GetSkillStateInfo().GetAllImpact();
                for (int i = 0; i < targetImpactInfos.Count; i++)
                {
                    if (is_ignore_passive_check && targetImpactInfos[i].m_ImpactType == (int)ImpactType.PASSIVE)
                    {
                        continue;
                    }
                    IImpactLogic logic = ImpactLogicManager.Instance.GetImpactLogic(obj.GetSkillStateInfo().GetAllImpact()[i].ConfigData.ImpactLogicId);
                    if (null != logic)
                    {
                        curDamage = logic.RefixHpDamage(obj, targetImpactInfos[i].m_ImpactId, curDamage, sender.GetId(), ref isCritical, obj.GetId());
                    }
                }

                /*
                 * foreach (ImpactInfo ii in obj.GetSkillStateInfo().GetAllImpact()) {
                 * if (is_ignore_passive_check && ii.m_ImpactType == (int)ImpactType.PASSIVE) {
                 *  continue;
                 * }
                 * IImpactLogic logic = ImpactLogicManager.Instance.GetImpactLogic(ii.ConfigData.ImpactLogicId);
                 * if (null != logic) {
                 *  curDamage = logic.RefixHpDamage(obj, ii.m_ImpactId, curDamage, sender.GetId(), ref isCritical, obj.GetId());
                 * }
                 * }*/
                if (!is_ignore_passive_check)
                {
                    List <ImpactInfo> senderImpactInfos = sender.GetSkillStateInfo().GetAllImpact();
                    for (int i = 0; i < senderImpactInfos.Count; i++)
                    {
                        if (senderImpactInfos[i].m_ImpactType == (int)ImpactType.PASSIVE)
                        {
                            IImpactLogic logic = ImpactLogicManager.Instance.GetImpactLogic(senderImpactInfos[i].ConfigData.ImpactLogicId);
                            if (null != logic)
                            {
                                curDamage = logic.RefixHpDamage(obj, senderImpactInfos[i].m_ImpactId, curDamage, sender.GetId(), ref isCritical, sender.GetId());
                            }
                        }
                    }

                    /*
                     * foreach (ImpactInfo passive_impact in sender.GetSkillStateInfo().GetAllImpact()) {
                     * if (passive_impact.m_ImpactType == (int)ImpactType.PASSIVE) {
                     *  IImpactLogic logic = ImpactLogicManager.Instance.GetImpactLogic(passive_impact.ConfigData.ImpactLogicId);
                     *  if (null != logic) {
                     *    curDamage = logic.RefixHpDamage(obj, passive_impact.m_ImpactId, curDamage, sender.GetId(), ref isCritical, sender.GetId());
                     *  }
                     * }
                     * }*/
                }
                damage = curDamage;
                OnCharacterDamage(sender, obj, curDamage, isCritical, isOrdinary);
            }
        }