Example #1
0
    private double[] SubEffectDamage(StateMachineInfo.FlyingEffect[] subEffects)
    {
        double[] damage = { 0, 0 };
        if (subEffects == null || subEffects.Length < 1)
        {
            return(damage);
        }

        for (int i = 0; i < subEffects.Length; i++)
        {
            var effect = ConfigManager.Get <FlyingEffectInfo>(subEffects[i].effect);
            if (!effect)
            {
                continue;
            }

            if (!effect.hitEffect.isEmpty)
            {
                double[] hitdamages = HitEffectDamage(effect.hitEffect);
                damage[0] += hitdamages[0];
                damage[1] += hitdamages[1];
            }

            for (int j = 0; j < effect.sections.Length; j++)
            {
                if (effect.sections[j].attackBox.isEmpty)
                {
                    continue;
                }

                var attack = AttackInfo.Get(effect.sections[j].attackBox.attackInfo);
                if (attack == null || attack.isIgnoreDamge)
                {
                    continue;
                }
                if (attack.execution)
                {
                    damage[1] += attack.damage;
                    continue;
                }
                damage[0] += attack.damage;
            }

            if (effect.subEffects != null && effect.subEffects.Length > 0)
            {
                double[] sub = SubEffectDamage(effect.subEffects);
                damage[0] += sub[0];
                damage[1] += sub[1];
            }
        }
        return(damage);
    }
Example #2
0
    private double[] HitEffectDamage(StateMachineInfo.FlyingEffect hitfEffect)
    {
        double[] damage = { 0, 0 };
        if (hitfEffect.isEmpty)
        {
            return(damage);
        }

        var hit = ConfigManager.Get <FlyingEffectInfo>(hitfEffect.effect);

        if (hit == null)
        {
            return(damage);
        }

        double[] hitdamage = HitEffectDamage(hit.hitEffect);
        damage[0] += hitdamage[0];
        damage[1] += hitdamage[1];

        for (int i = 0; i < hit.sections.Length; i++)
        {
            if (hit.sections[i].attackBox.isEmpty)
            {
                continue;
            }

            var attack = AttackInfo.Get(hit.sections[i].attackBox.attackInfo);
            if (attack == null || attack.isIgnoreDamge)
            {
                continue;
            }
            if (attack.execution)
            {
                damage[1] += attack.damage;
                continue;
            }
            damage[0] += attack.damage;
        }

        if (hit.subEffects != null && hit.subEffects.Length > 0)
        {
            double[] sub = SubEffectDamage(hit.subEffects);
            damage[0] += sub[0];
            damage[1] += sub[1];
        }
        return(damage);
    }
Example #3
0
    protected override void OnCollisionBegin(Collider_ other)
    {
        if (!enabled || m_creature == null)
        {
            return;
        }

        var c  = other as AttackCollider;
        var cc = c ? c.creature : null;

        if (!cc || cc.clearAttack || m_creature.SameCampWith(cc) || c.AttackedCount(this) > 1)
        {
            return;
        }

        if (!m_stateMachine)
        {
            m_stateMachine = m_creature.stateMachine;
        }

        var bullet = c.type == AttackColliderTypes.Bullet;
        var effect = c.type == AttackColliderTypes.Effect || c.type == AttackColliderTypes.Bullet;
        var ai     = bullet && (m_stateMachine.GetBool(StateMachineParam.weak) || cc.HawkEye) ? c.bulletAttackInfo : c.attackInfo;
        var a      = AttackInfo.Get(ai);

        if (!a || a.targetStates.Length < 1)
        {
            if (ai == 0)
            {
                c.OnRealHitTarget(this, a);
            }
            return;
        }

        if (!a.ignoreInvincible && m_creature.invincible)
        {
            return;                                                 // Invincible check
        }
        if (a.lockTarget && (m_stateMachine.passiveSource != cc || !m_stateMachine.GetBool(StateMachineParam.passiveCatchState)))
        {
            return;                                                                                                                         // Lock target check
        }
        a.fromBullet = bullet;
        a.fromEffect = effect;

        var mask    = m_stateMachine.GetInt(StateMachineParam.groupMask);
        var tss     = a.targetStates;
        var isCatch = cc.currentState.info.catchState != 0;

        for (int i = 0, count = tss.Length; i < count; ++i)
        {
            var ts = tss[i];
            if (mask.BitMask(ts.fromGroup))
            {
                var iid = (uint)c.creature.id << 16 | (uint)(a.ID & 0xFFFF);
                var ac  = m_attinfos.Get(iid);
                if (!m_creature.tough || isCatch)
                {
                    ac += 1;
                    m_attinfos.Set(iid, ac);
                }

                var ti = (byte)i;

                if (ac > a.comboLimit)
                {
                    if (isCatch)
                    {
                        cc.DispatchEvent(CreatureEvents.ATTACK_HIT_FAILED, Event_.Pop(m_creature));
                        break;
                    }
                    ti = byte.MaxValue;
                }

                OnHit(c, a, ti);
                c.OnRealHitTarget(this, a);

                break;
            }
        }
    }
Example #4
0
    public double[] GetCurrentSkillDamge(int skillId, int level)
    {
        double[]        defaultDouble = new double[] { 0, 0 };
        WeaponAttribute attr          = ConfigManager.Get <WeaponAttribute>(moduleEquip.weapon.itemTypeId);

        if (!attr)
        {
            return(defaultDouble);
        }
        SkillToStateInfo states = m_currentSkillStates.Find(p => p.skillId == skillId && (p.elmentType == attr.elementType || p.elmentType == 0));

        if (!states || states.stateNames == null || states.stateNames.Length < 1)
        {
            return(defaultDouble);
        }

        double damage = 0;
        double spcail = 0;
        int    weapon = moduleEquip.weapon.GetPropItem().subType;

        for (int i = 0; i < states.stateNames.Length; i++)
        {
            int stateID = CreatureStateInfo.NameToID(states.stateNames[i]);
            var _state  = StateOverrideInfo.GetOverrideState(weapon, stateID, level);

            //int reliveID = CreatureStateInfo.NameToID(ReLiveState);
            //if (reliveID == stateID)
            //{
            //    reliveSkillId = states.skillId;
            //    if (_state.buffs.Length > 0)
            //    {
            //        defaultDouble[0] = (double)_state.buffs[0].duration / 1000;
            //        return defaultDouble;
            //    }
            //}

            for (int j = 0; j < _state.sections.Length; j++)
            {
                if (_state.sections[j].attackBox.isEmpty)
                {
                    continue;
                }

                var attack = AttackInfo.Get(_state.sections[j].attackBox.attackInfo);
                if (attack == null || attack.isIgnoreDamge)
                {
                    continue;
                }
                if (attack.execution)
                {
                    spcail += attack.damage;
                    continue;
                }
                damage += attack.damage;
            }

            int fly = _state.flyingEffects.Length;
            if (fly > 0)
            {
                for (int k = 0; k < fly; k++)
                {
                    var effect = ConfigManager.Get <FlyingEffectInfo>(_state.flyingEffects[k].effect);
                    if (effect == null)
                    {
                        continue;
                    }

                    //统计hiteffect的伤害,必须满足subeffect中不包含相同的effectid
                    if (!effect.hitEffect.isEmpty)
                    {
                        StateMachineInfo.FlyingEffect exist = StateMachineInfo.FlyingEffect.empty;
                        if (effect.subEffects != null && effect.subEffects.Length > 0)
                        {
                            exist = effect.subEffects.Find(p => p.effect == effect.hitEffect.effect);
                        }

                        if (exist.isEmpty)
                        {
                            double[] hit = HitEffectDamage(effect.hitEffect);
                            damage += hit[0];
                            spcail += hit[1];
                        }
                    }

                    if (effect.subEffects != null && effect.subEffects.Length > 0)
                    {
                        double[] sub = SubEffectDamage(effect.subEffects);
                        damage += sub[0];
                        spcail += sub[1];
                    }

                    for (int p = 0; p < effect.sections.Length; p++)
                    {
                        if (effect.sections[p].attackBox.isEmpty)
                        {
                            continue;
                        }

                        var attack = AttackInfo.Get(effect.sections[p].attackBox.attackInfo);
                        if (attack == null || attack.isIgnoreDamge)
                        {
                            continue;
                        }
                        if (attack.execution)
                        {
                            spcail += attack.damage;
                            continue;
                        }
                        damage += attack.damage;
                    }
                }
            }
        }
        double _d = UpSkillInfo.GetOverrideDamage(skillId, level) * (1 + modulePlayer.GetSkillDamageAddtion(skillId));

        defaultDouble[0] = damage * (1 + _d);
        defaultDouble[1] = spcail * (1 + _d);
        return(defaultDouble);
    }