Esempio n. 1
0
    //执行一次攻击,一般的攻击。proc-触发
    public void PerformAttack(BaseNPC target, bool useCastAttackOrb, bool prcoessProcs, bool skipCooldown, bool ignoreInvis = false, bool useProjectile = false, bool fakeAttack = false, bool neverMiss = false)
    {
        int hitChance = 0;

        if (neverMiss)
        {
            hitChance = 100;
        }
        if (!this.GetModifierState(Modifier_State.MODIFIER_STATE_INVULNERABLE))        //无敌状态
        {
            //Miss chance = 1 - [Π^n (1 - evasionn) x (1 - Min(sum of all sources of blind, 100%)) x (1 - uphill miss chance)]
            hitChance = (1 - EntityAttribute.CalcAndUpdateValue(target, EntityAttributeType.Evasion) / 100) * (1 - Math.Min(EntityAttribute.CalcAndUpdateValue(this, EntityAttributeType.MissRate), 100) / 100);
            if (hitChance < UnityEngine.Random.Range(0f, 1f))           //击中
            {
                //Damage = { [Main Damage × (1 +   Percentage Bonuses) + FlatBonuses] × Crit Multiplier - Blocked Damage } × Armor Multipliers × General Damage Multipliers
                int damage = (EntityAttribute.CalcAndUpdateValue(this, EntityAttributeType.AttackDamage) - EntityAttribute.CalcAndUpdateValue(target, EntityAttributeType.DamageBlock)) * EntityAttribute.CalcAndUpdateValue(this, EntityAttributeType.AttackOutgoModifier) / 100 * EntityAttribute.CalcAndUpdateValue(target, EntityAttributeType.AttackIncomeModifier) / 100;
                target.TakeDamage(DamageType.DAMAGE_TYPE_PHYSICAL, damage);
                this.TriggerModifierEvent(ModifierEventType.OnDealDamage);
                target.TriggerModifierEvent(ModifierEventType.OnTakeDamage);
            }
            else
            {
            }
        }

        // if(!fakeAttack)
        // {
        //  TriggerModifierEvent(ModifierEventType.OnAttack);
        // }
    }