コード例 #1
0
    void DamageEntity(EntityBase targetEntity)
    {
        if (targetEntity.m_health_current <= 0)
        {
            return;
        }

        // Separamos por partes cada efecto posible del arma

        // Calculo de daño directo.
        if (m_weaponReferenced.baseEffect_normal > 0)
        {
            float dmgDone = m_inheritedStrenght * m_entityUser.GetDamageMultiplier() * m_weaponReferenced.baseEffect_normal * m_weaponReferenced.weapon_effectivenessMultiplier;
            if (Random.Range(1, 101) < m_entityUser.GetCriticalChance())
            {
                dmgDone *= m_weaponReferenced.GetCritDamage() + m_entityUser.GetCriticialDamageMultiplier();
                targetEntity.DealDamage(dmgDone, WeaponData.DamageType.critical);
            }
            else
            {
                targetEntity.DealDamage(dmgDone, WeaponData.DamageType.normal);
            }
        }


        // Calculo de daño de fuego.
        if (m_weaponReferenced.baseEffect_photon > 0)
        {
            m_lastEntityDamaged.DealFireDamage(m_inheritedStrenght * m_entityUser.GetDamageMultiplier() * m_weaponReferenced.baseEffect_photon * m_weaponReferenced.weapon_effectivenessMultiplier);
        }

        // Calculo de robo de energia.
        if (m_weaponReferenced.baseEffect_energySteal > 0)
        {
            if (m_entityUser != null)
            {
                m_entityUser.HealWithEnergySteal(m_inheritedStrenght * m_weaponReferenced.baseEffect_energySteal * m_weaponReferenced.weapon_effectivenessMultiplier);
            }
        }
        // Calculo de daño nuclear.
        if (m_weaponReferenced.baseEffect_nuclear > 0)
        {
            m_lastEntityDamaged.DealNuclearDamage(m_inheritedStrenght * m_weaponReferenced.baseEffect_nuclear * m_weaponReferenced.weapon_effectivenessMultiplier * m_entityUser.GetDamageMultiplier());
        }
    }