private static void ApplyArrowArmorPen(ref AttackCollisionData collisionData, int inputArmor, bool multiplierHeadOrNeckShot)
            {
                var inflictedDamage = collisionData.InflictedDamage;

                inflictedDamage -= inputArmor;
                inflictedDamage  = Math.Max(inflictedDamage, BowDefaultDamageMin);

                if (multiplierHeadOrNeckShot)
                {
                    if (inputArmor >= BowHeadshotArmorThreshold)
                    {
                        inflictedDamage = Math.Min(inflictedDamage, BowDefaultDamageMax);
                    }
                }
                else
                {
                    if (inputArmor >= BowArmorThresholdLight)
                    {
                        inflictedDamage = Math.Min(inflictedDamage, BowArmorThresholdLightDamage);
                    }
                    if (inputArmor >= BowArmorThresholdMed)
                    {
                        inflictedDamage = Math.Min(inflictedDamage, BowArmorThresholdMedDamage);
                    }
                    if (inputArmor >= BowArmorThresholdHeavy)
                    {
                        inflictedDamage = Math.Min(inflictedDamage, BowArmorThresholdHeavyDamage);
                    }
                }


                collisionData.InflictedDamage = inflictedDamage;
            }
Exemple #2
0
        private static void MeleeHitCallbackPostfix(
            ref AttackCollisionData collisionData,
            Agent attacker,
            Agent victim,
            GameEntity realHitEntity,
            float momentumRemainingToComputeDamage,
            ref float inOutMomentumRemaining,
            ref MeleeCollisionReaction colReaction,
            CrushThroughState cts,
            Vec3 blowDir,
            Vec3 swingDir,
            bool crushedThroughWithoutAgentCollision
            )
        {
            var totalDamage = collisionData.InflictedDamage + collisionData.AbsorbedByArmor;

            if (totalDamage >= 1 && SliceLogic.ShouldSliceThrough(collisionData, attacker, victim))
            {
                var normalizedDamageInflicted = (float)collisionData.InflictedDamage / totalDamage;
                inOutMomentumRemaining =
                    momentumRemainingToComputeDamage *
                    normalizedDamageInflicted *
                    SubModule.Config.DamageRetainedPerCut;
            }
        }
            private static void ApplyBoltArmorPen(ref AttackCollisionData collisionData, int inputArmor, bool multiplierHeadOrNeckShot)
            {
                var inflictedDamage   = collisionData.InflictedDamage;
                var inputArmorReduced = (int)Math.Round(inputArmor * ArmorReductionMultiplier);

                inflictedDamage -= inputArmorReduced;
                inflictedDamage  = Math.Max(inflictedDamage, CrossbowDefaultDamageMin);

                if (multiplierHeadOrNeckShot)
                {
                    if (inputArmor >= CrossbowHeadshotArmorThreshold)
                    {
                        inflictedDamage = Math.Min(inflictedDamage, CrossbowDefaultDamageMax);
                    }
                }
                else
                {
                    if (inputArmor >= CrossbowArmorThresholdLight)
                    {
                        inflictedDamage = Math.Min(inflictedDamage, CrossbowArmorThresholdLightDamage);
                    }
                    if (inputArmor >= CrossbowArmorThresholdMed)
                    {
                        inflictedDamage = Math.Min(inflictedDamage, CrossbowArmorThresholdMedDamage);
                    }
                    if (inputArmor >= CrossbowArmorThresholdHeavy)
                    {
                        inflictedDamage = Math.Min(inflictedDamage, CrossbowArmorThresholdHeavyDamage);
                    }
                }


                collisionData.InflictedDamage = inflictedDamage;
            }
 public static void CalculateDamage(ref AttackInformation attackInformation, ref AttackCollisionData collisionData, WeaponComponentData weapon, ref int __result)
 {
     if ((attackInformation.IsVictimAgentMine || (attackInformation.IsVictimAgentMount && attackInformation.IsVictimAgentRiderAgentMine)) &&
         BannerlordCheatsSettings.Instance.Invincible)
     {
         __result = 0;
     }
 }
 public static void CalculateDamage(ref AttackInformation attackInformation, ref AttackCollisionData collisionData, WeaponComponentData weapon, ref int __result)
 {
     if ((attackInformation.AttackerFormation?.Team?.IsPlayerTeam ?? false) &&
         attackInformation.IsFriendlyFire &&
         BannerlordCheatsSettings.Instance.NoFriendlyFire)
     {
         __result = 0;
     }
 }
 public static void CalculateDamage(ref AttackInformation attackInformation, ref AttackCollisionData collisionData, WeaponComponentData weapon, ref int __result)
 {
     if ((attackInformation.AttackerFormation?.Team?.IsPlayerTeam ?? false) &&
         !attackInformation.IsFriendlyFire &&
         !BannerlordCheatsSettings.Instance.PartyOneHitKill)
     {
         __result *= BannerlordCheatsSettings.Instance.PartyDamageMultiplier;
     }
 }
Exemple #7
0
        private static void Prefix(ref AttackCollisionData collisionData, Agent attacker, Agent victim, GameEntity realHitEntity, float momentumRemainingToComputeDamage, ref float inOutMomentumRemaining, ref MeleeCollisionReaction colReaction, CrushThroughState cts, Vec3 blowDir, Vec3 swingDir, ref object hprd, bool crushedThroughWithoutAgentCollision)
        {
            bool flag = collisionData.VictimHitBodyPart == BoneBodyPartType.Head && collisionData.StrikeType == 0 && collisionData.DamageType == 0 && (attacker.AttackDirection == Agent.UsageDirection.AttackLeft || attacker.AttackDirection == Agent.UsageDirection.AttackRight);

            if (flag)
            {
                //DismembermentSubModule.AddPDV(victim, attacker);
                DismembermentSettings.Instance().GetDismembermentMissionBusiness().AddPDV(victim, attacker);
            }
        }
Exemple #8
0
 public override void OnHitByAttack(AttackCollisionData xAtColData, AttackPhase xAtPhase)
 {
     base.OnHitByAttack(xAtColData, xAtPhase);
     fFurthestAllowedDistance = 500f;
     AddHitEffect();
     if (Utils.GetTheGame().xNetworkInfo.enCurrentRole == NetworkHelperInterface.NetworkRole.Server)
     {
         SendClientInstruction(0);
     }
 }
Exemple #9
0
 public override void OnAttackHit(AttackCollisionData xAtColData, BaseStats xBaseStats)
 {
     if (!xAtColData.bShielded && Utils.GetTheGame().bEffectsOn)
     {
         IEffect kaktus = Utils.GetTheGame()._EffectMaster_AddEffect(new SortedAnimated(xAtColData.v2PointOfImpact, SortedAnimated.SortedAnimatedEffects._HitEffect_Pang1));
         kaktus.xRenderComponent.fVirtualHeight   += xOwner.xRenderComponent.fVirtualHeight;
         kaktus.xRenderComponent.xTransform        = xBaseStats.xOwner.xTransform;
         kaktus.xRenderComponent.v2OffsetRenderPos = new Vector2(0f, -10f);
     }
 }
Exemple #10
0
 public static void CalculateDamage(ref AttackInformation attackInformation, ref AttackCollisionData collisionData, WeaponComponentData weapon, ref int __result)
 {
     if ((attackInformation.AttackerAgentCharacter?.IsPlayerCharacter ?? false) &&
         !attackInformation.IsFriendlyFire &&
         attackInformation.IsVictimAgentHuman &&
         BannerlordCheatsSettings.Instance.OneHitKill)
     {
         __result = attackInformation.VictimAgentCharacter.HitPoints;
     }
 }
        public static void CalculateDamage(ref AttackInformation attackInformation, ref AttackCollisionData collisionData, WeaponComponentData weapon, ref int __result)
        {
            if ((attackInformation.IsVictimAgentMine || (attackInformation.IsVictimAgentMount && attackInformation.IsVictimAgentRiderAgentMine)) &&
                !BannerlordCheatsSettings.Instance.Invincible)
            {
                var factor = BannerlordCheatsSettings.Instance.DamageTakenPercentage / 100f;

                var newValue = (int)Math.Round(factor * __result);

                __result = newValue;
            }
        }
        public static void CalculateDamage(ref AttackInformation attackInformation, ref AttackCollisionData collisionData, WeaponComponentData weapon, ref int __result)
        {
            if ((attackInformation.VictimFormation?.Team?.IsPlayerTeam ?? false) &&
                !BannerlordCheatsSettings.Instance.PartyInvincible)
            {
                var factor = BannerlordCheatsSettings.Instance.PartyDamageTakenPercentage / 100f;

                var newValue = (int)Math.Round(factor * __result);

                __result = newValue;
            }
        }
Exemple #13
0
 public override void OnHitByAttack(AttackCollisionData xAtColData, AttackPhase xAtPhase)
 {
     if ((!(xAtPhase.xStats.sAttackHandle != "Bomb") || CAS.DifficultySetting >= 3) && iCounter >= 30)
     {
         if (iCounter < iExplodeAt - 5)
         {
             iCounter = iExplodeAt - 5;
         }
         _ = iTimesHit;
         _ = iTimesToHitBeforeDestroy;
     }
 }
Exemple #14
0
 private static void ComputeBlowMagnitudeFromHorseChargePostfix(
     ref AttackCollisionData acd,
     Vec3 attackerAgentMovementDirection,
     Vec3 attackerAgentVelocity,
     float agentMountChargeDamageProperty,
     Vec3 victimAgentVelocity,
     Vec3 victimAgentPosition,
     ref float baseMagnitude,
     ref float specialMagnitude
     )
 {
     specialMagnitude *= SubModule.Config.ChargeDamageMultiplier;
 }
Exemple #15
0
 static void Postfix(ref AttackCollisionData collisionData, Agent attacker, Agent victim,
                     GameEntity realHitEntity, ref float inOutMomentumRemaining,
                     ref MeleeCollisionReaction colReaction, CrushThroughState crushThroughState, Vec3 blowDir, Vec3 swingDir,
                     ref object hitParticleResultData, bool crushedThroughWithoutAgentCollision)
 {
     if (InvulnerableSettings.Instance.Enabled == false)
     {
         return;
     }
     if (victim == Agent.Main)
     {
         // DecideWeaponCollisionReaction
         colReaction = MeleeCollisionReaction.Bounced;
     }
 }
Exemple #16
0
        static bool Prefix(ref AttackCollisionData acd,
                           ItemObject weaponItem,
                           bool isVictimAgentNull,
                           float momentumRemaining,
                           float missileTotalDamage,
                           out float baseMagnitude,
                           out float specialMagnitude,
                           Vec3 victimVel)
        {
            double num1 = (isVictimAgentNull ? (double)acd.MissileVelocity.Length : (double)(victimVel - acd.MissileVelocity).Length) / (double)acd.MissileStartingBaseSpeed;
            float  num2 = (float)(num1 * num1);

            baseMagnitude    = num2 * missileTotalDamage * momentumRemaining * Vars.dict["MissileFactor"];
            specialMagnitude = baseMagnitude;
            return(false);
        }
Exemple #17
0
 private static void DecideWeaponCollisionReactionPostfix(
     Mission __instance,
     Blow registeredBlow,
     ref AttackCollisionData collisionData,
     Agent attacker,
     Agent defender,
     bool isFatalHit,
     bool isShruggedOff,
     ref MeleeCollisionReaction colReaction
     )
 {
     if (SliceLogic.ShouldSliceThrough(collisionData, attacker, defender))
     {
         colReaction = MeleeCollisionReaction.SlicedThrough;
     }
 }
        internal static void CheckForProjectileFlinch(ref Blow b, ref Blow blow, AttackCollisionData collisionData, Agent victim)
        {
            if (victim != null && b.IsMissile())
            {
                if (collisionData.VictimHitBodyPart != BoneBodyPartType.Head && collisionData.VictimHitBodyPart != BoneBodyPartType.Neck)
                {
                    var projStunThresholdMultiplier = Config.ConfigSettings.ProjectileStunPercentageThreshold / 100;

                    if (b.InflictedDamage < (victim.HealthLimit * projStunThresholdMultiplier))
                    {
                        b.BlowFlag    |= BlowFlags.ShrugOff;
                        blow.BlowFlag |= BlowFlags.ShrugOff;
                    }
                }
            }
        }
Exemple #19
0
 public static void CalculateDamage(ref AttackInformation attackInformation, ref AttackCollisionData collisionData, WeaponComponentData weapon, ref float __result)
 {
     try
     {
         if (attackInformation.AttackerAgentCharacter.IsPlayer() &&
             !attackInformation.IsFriendlyFire &&
             BannerlordCheatsSettings.Instance?.OneHitKill == true)
         {
             __result = 10000;
         }
     }
     catch (Exception e)
     {
         SubModule.LogError(e, typeof(OneHitKill));
     }
 }
 public static void CalculateDamage(ref AttackInformation attackInformation, ref AttackCollisionData collisionData, WeaponComponentData weapon, ref float __result)
 {
     try
     {
         if (attackInformation.AttackerAgentOrigin.TryGetParty(out var party) &&
             party.IsPlayerParty() &&
             attackInformation.IsFriendlyFire &&
             BannerlordCheatsSettings.Instance?.NoFriendlyFire == true)
         {
             __result = 0;
         }
     }
     catch (Exception e)
     {
         SubModule.LogError(e, typeof(NoFriendlyFire));
     }
 }
Exemple #21
0
 public static void Postfix(ref AttackCollisionData acd,
                            Vec3 attackerAgentMovementDirection,
                            Vec3 attackerAgentVelocity,
                            float agentMountChargeDamageProperty,
                            Vec3 victimAgentVelocity,
                            Vec3 victimAgentPosition,
                            ref float baseMagnitude,
                            ref float specialMagnitude)
 {
     if (attackerAgentVelocity.Length > NonZero && victimAgentVelocity.Length > NonZero)
     {
         if (Vec3.DotProduct(attackerAgentVelocity, victimAgentVelocity) /
             (attackerAgentVelocity.Length * victimAgentVelocity.Length) > 0.5)
         {
             specialMagnitude *= SubModule.Settings.Battle_WarStomp_WarStompDamageMultiplier;
         }
     }
 }
 public static void CalculateDamage(ref AttackInformation attackInformation, ref AttackCollisionData collisionData, WeaponComponentData weapon, ref float __result)
 {
     try
     {
         if (attackInformation.AttackerAgentOrigin.TryGetParty(out var party) &&
             party.IsPlayerParty() &&
             !attackInformation.AttackerAgentCharacter.IsPlayer() &&
             !attackInformation.IsFriendlyFire &&
             BannerlordCheatsSettings.Instance?.PartyDamageMultiplier > 1f)
         {
             __result *= BannerlordCheatsSettings.Instance.PartyDamageMultiplier;
         }
     }
     catch (Exception e)
     {
         SubModule.LogError(e, typeof(PartyDamageMultiplier));
     }
 }
Exemple #23
0
        public static void CalculateDamage(ref AttackInformation attackInformation, ref AttackCollisionData collisionData, WeaponComponentData weapon, ref float __result)
        {
            try
            {
                if (attackInformation.AttackerAgentOrigin.IsOnPlayerEnemySide() &&
                    BannerlordCheatsSettings.Instance?.EnemyDamagePercentage < 100f)
                {
                    var factor = BannerlordCheatsSettings.Instance.EnemyDamagePercentage / 100f;

                    var newValue = (int)Math.Round(factor * __result);

                    __result = newValue;
                }
            }
            catch (Exception e)
            {
                SubModule.LogError(e, typeof(EnemyDamagePercentage));
            }
        }
        public static void CalculateDamage(ref AttackInformation attackInformation, ref AttackCollisionData collisionData, WeaponComponentData weapon, ref float __result)
        {
            try
            {
                if (attackInformation.VictimAgentCharacter.IsPlayer() &&
                    BannerlordCheatsSettings.Instance?.DamageTakenPercentage < 100f)
                {
                    var factor = BannerlordCheatsSettings.Instance.DamageTakenPercentage / 100f;

                    var newValue = (int)Math.Round(factor * __result);

                    __result = newValue;
                }
            }
            catch (Exception e)
            {
                SubModule.LogError(e, typeof(DamageTakenPercentage));
            }
        }
Exemple #25
0
        /// <summary>
        /// Applies multipliers according to configuration file.
        /// </summary>
        /// <param name="tickDamage"></param>
        /// <param name="b"></param>
        /// <param name="collisionData"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        public static double ApplyMultipliers(this double tickDamage, Blow b, AttackCollisionData collisionData, Config config)
        {
            if (b.DamageType == DamageTypes.Cut)
            {
                tickDamage *= 1 + config.CutMultiplier;
            }
            if (b.DamageType == DamageTypes.Blunt)
            {
                tickDamage *= 1 + config.BluntMultiplier;
            }
            if (b.DamageType == DamageTypes.Pierce)
            {
                tickDamage *= 1 + config.PierceMultiplier;
            }
            if (b.DamageType == DamageTypes.Invalid)
            {
                tickDamage *= 1 + config.InvalidMultiplier;
            }

            if (collisionData.VictimHitBodyPart == BoneBodyPartType.Neck)
            {
                tickDamage *= 1 + config.BodyMultipliers.Neck.Mult;
            }
            if (collisionData.VictimHitBodyPart == BoneBodyPartType.Head)
            {
                tickDamage *= 1 + config.BodyMultipliers.Head.Mult;
            }
            if (collisionData.VictimHitBodyPart == BoneBodyPartType.BipedalArmLeft || collisionData.VictimHitBodyPart == BoneBodyPartType.BipedalArmRight)
            {
                tickDamage *= 1 + config.BodyMultipliers.Arms.Mult;
            }
            if (collisionData.VictimHitBodyPart == BoneBodyPartType.BipedalLegs)
            {
                tickDamage *= 1 + config.BodyMultipliers.Legs.Mult;
            }
            if (collisionData.VictimHitBodyPart == BoneBodyPartType.ShoulderLeft || collisionData.VictimHitBodyPart == BoneBodyPartType.ShoulderRight)
            {
                tickDamage *= 1 + config.BodyMultipliers.Shoulders.Mult;
            }

            return(tickDamage);
        }
Exemple #26
0
        internal static bool ShouldSliceThrough(AttackCollisionData collisionData, Agent attacker, Agent victim)
        {
            if (!DoPreflightSliceThroughChecksPass(attacker, victim))
            {
                return(false);
            }
            var weaponClass = attacker.WieldedWeapon.Weapons?.FirstOrDefault()?.WeaponClass ?? WeaponClass.Undefined;

            if (WeaponClassSliceMetadata.ContainsKey(weaponClass))
            {
                var weaponSliceMetadatum = WeaponClassSliceMetadata[weaponClass];
                var isSliceDirection     = weaponSliceMetadatum.SliceDirections.Contains(collisionData.AttackDirection);
                if (isSliceDirection)
                {
                    var totalDamage = collisionData.InflictedDamage + collisionData.AbsorbedByArmor;
                    var normalizedDamageInflicted = (float)collisionData.InflictedDamage / totalDamage;
                    return(normalizedDamageInflicted >= SubModule.Config.PercentageOfInflictedDamageRequiredToCutThroughArmor);
                }
            }
            return(false);
        }
 internal static void MeleeHitCallbackPostfix(ref Mission __instance, ref AttackCollisionData collisionData, Agent attacker, Agent victim, GameEntity realHitEntity, float momentumRemainingToComputeDamage, ref float inOutMomentumRemaining, ref MeleeCollisionReaction colReaction, CrushThroughState cts, Vec3 blowDir, Vec3 swingDir, bool crushedThroughWithoutAgentCollision)
 {
     if (!Config.CompatibilitySettings.XorbarexCleaveExists)
     {
         if (GCOToolbox.GCOToolbox.MeleeBalance.CheckApplyCleave(__instance, attacker, victim, colReaction))
         {
             if (attacker.HasMount)
             {
                 inOutMomentumRemaining = momentumRemainingToComputeDamage * 0.25f;
             }
             else if (GCOToolbox.GCOToolbox.MeleeBalance.IsDefenderAFriendlyInShieldFormation(attacker, victim))
             {
                 inOutMomentumRemaining = momentumRemainingToComputeDamage * (Config.ConfigSettings.AdditionalCleaveForTroopsInShieldWallMomentumLoss * 0.01f);
             }
             else
             {
                 inOutMomentumRemaining = momentumRemainingToComputeDamage * 0.5f;
             }
         }
     }
 }
Exemple #28
0
 public static void DecideAgentKnockedByBlow(
     ref Agent attacker,
     ref Agent victim,
     ref AttackCollisionData collisionData,
     ref WeaponComponentData attackerWeapon,
     ref bool isInitialBlowShrugOff,
     ref Blow blow)
 {
     try
     {
         if (attacker.IsPlayer() &&
             BannerlordCheatsSettings.Instance?.AlwaysKnockDown == true)
         {
             blow.BlowFlag &= ~BlowFlags.ShrugOff;
             blow.BlowFlag |= BlowFlags.KnockDown;
         }
     }
     catch (Exception e)
     {
         SubModule.LogError(e, typeof(AlwaysKnockDown));
     }
 }
            internal static void ApplyProjectileArmorResistance(float finputArmor, ref AttackCollisionData collisionData, Mission.Missile missile, bool isHorseArcher)
            {
                int  inputArmor = (int)finputArmor;
                bool multiplierHeadOrNeckShot = collisionData.VictimHitBodyPart == BoneBodyPartType.Head || collisionData.VictimHitBodyPart == BoneBodyPartType.Neck;

                var type = missile.Weapon.CurrentUsageItem.WeaponClass;

                switch (type)
                {
                case WeaponClass.Arrow:
                    ApplyArrowArmorPen(ref collisionData, inputArmor, multiplierHeadOrNeckShot);
                    break;

                case WeaponClass.Bolt:
                    ApplyBoltArmorPen(ref collisionData, inputArmor, multiplierHeadOrNeckShot);
                    break;

                case WeaponClass.ThrowingAxe:
                    ApplyThrowableArmorPen(ref collisionData, inputArmor, multiplierHeadOrNeckShot);
                    break;

                case WeaponClass.ThrowingKnife:
                    ApplyThrowableArmorPen(ref collisionData, inputArmor, multiplierHeadOrNeckShot);
                    break;

                case WeaponClass.Javelin:
                    ApplyThrowableArmorPen(ref collisionData, inputArmor, multiplierHeadOrNeckShot);
                    break;

                default:
                    break;
                }

                if (isHorseArcher)
                {
                    collisionData.InflictedDamage *= 2;
                }
            }
 public static void DecideWeaponCollisionReaction(
     ref Blow registeredBlow,
     ref AttackCollisionData collisionData,
     ref Agent attacker,
     ref Agent defender,
     ref MissionWeapon attackerWeapon,
     ref bool isFatalHit,
     ref bool isShruggedOff,
     ref MeleeCollisionReaction colReaction)
 {
     try
     {
         if (attacker.IsPlayer() &&
             BannerlordCheatsSettings.Instance?.SliceThroughEveryone == true)
         {
             colReaction = MeleeCollisionReaction.SlicedThrough;
         }
     }
     catch (Exception e)
     {
         SubModule.LogError(e, typeof(SliceThroughEveryoneWeapon));
     }
 }