Esempio n. 1
0
        public static bool Prefix(AcidDamageEffect __instance, DamageAccumulation accum, IDamageReceiver recv, Vector3 damageOrigin, Vector3 impactForce, CastHit impactHit)
        {
            try
            {
                if (!Mod.Settings.Acid)
                {
                    return(true);
                }
                var currentArmor = recv.GetArmor().Value;
                var hasArmor     = currentArmor > 0;
                var totalDamage  = accum.Amount * accum.SourceMultiplier;
                var armorDamage  = 0f;
                if (hasArmor)
                {
                    armorDamage = Math.Min(totalDamage, currentArmor);
                }


                var healthDamage = totalDamage - armorDamage;
                //FileLog.Log($"({accum.Amount} * {accum.SourceMultiplier}) hit on {recv.GetDisplayName()}\ncurrentArmor {currentArmor}\ntotalDamage {totalDamage}\narmorDamage {armorDamage}\nhealthDamage {healthDamage}");
                var data = new DamageAccumulation.TargetData
                {
                    Target        = recv,
                    AmountApplied = totalDamage,
                    DamageResult  = new DamageResult
                    {
                        Source        = __instance.Source,
                        ArmorDamage   = armorDamage,
                        HealthDamage  = healthDamage,
                        ImpactForce   = impactForce,
                        ImpactHit     = impactHit,
                        DamageOrigin  = damageOrigin,
                        DamageTypeDef = __instance.AcidDamageEffectDef.DamageTypeDef
                    }
                };
                accum.AddGeneratedTarget(data);
            }
            catch (Exception e)
            {
                FileLog.Log(e.ToString());
            }

            return(false);
        }