Example #1
0
 public abstract void CalculateCollisionStunMultipliers(
     Agent attackerAgent,
     Agent defenderAgent,
     bool isAlternativeAttack,
     CombatCollisionResult collisionResult,
     WeaponComponentData attackerWeapon,
     WeaponComponentData defenderWeapon,
     out float attackerStunMultiplier,
     out float defenderStunMultiplier);
 public static AttackCollisionData GetAttackCollisionDataForDebugPurpose(
     bool _attackBlockedWithShield,
     bool _correctSideShieldBlock,
     bool _isAlternativeAttack,
     bool _isColliderAgent,
     bool _collidedWithShieldOnBack,
     bool _isMissile,
     bool _isMissileBlockedWithWeapon,
     bool _missileHasPhysics,
     bool _entityExists,
     bool _thrustTipHit,
     bool _missileGoneUnderWater,
     CombatCollisionResult collisionResult,
     int affectorWeaponSlotOrMissileIndex,
     int StrikeType,
     int DamageType,
     sbyte CollisionBoneIndex,
     BoneBodyPartType VictimHitBodyPart,
     sbyte AttackBoneIndex,
     Agent.UsageDirection AttackDirection,
     int PhysicsMaterialIndex,
     CombatHitResultFlags CollisionHitResultFlags,
     float AttackProgress,
     float CollisionDistanceOnWeapon,
     float AttackerStunPeriod,
     float DefenderStunPeriod,
     float MissileTotalDamage,
     float MissileInitialSpeed,
     float ChargeVelocity,
     float FallSpeed,
     Vec3 WeaponRotUp,
     Vec3 _weaponBlowDir,
     Vec3 CollisionGlobalPosition,
     Vec3 MissileVelocity,
     Vec3 MissileStartingPosition,
     Vec3 VictimAgentCurVelocity,
     Vec3 GroundNormal)
 {
     return(new AttackCollisionData(_attackBlockedWithShield, _correctSideShieldBlock, _isAlternativeAttack, _isColliderAgent, _collidedWithShieldOnBack, _isMissile, _isMissileBlockedWithWeapon, _missileHasPhysics, _entityExists, _thrustTipHit, _missileGoneUnderWater, collisionResult, affectorWeaponSlotOrMissileIndex, StrikeType, DamageType, CollisionBoneIndex, VictimHitBodyPart, AttackBoneIndex, AttackDirection, PhysicsMaterialIndex, CollisionHitResultFlags, AttackProgress, CollisionDistanceOnWeapon, AttackerStunPeriod, DefenderStunPeriod, MissileTotalDamage, MissileInitialSpeed, ChargeVelocity, FallSpeed, WeaponRotUp, _weaponBlowDir, CollisionGlobalPosition, MissileVelocity, MissileStartingPosition, VictimAgentCurVelocity, GroundNormal));
 }
 private AttackCollisionData(
     bool attackBlockedWithShield,
     bool correctSideShieldBlock,
     bool isAlternativeAttack,
     bool isColliderAgent,
     bool collidedWithShieldOnBack,
     bool isMissile,
     bool missileBlockedWithWeapon,
     bool missileHasPhysics,
     bool entityExists,
     bool thrustTipHit,
     bool missileGoneUnderWater,
     CombatCollisionResult collisionResult,
     int affectorWeaponSlotOrMissileIndex,
     int StrikeType,
     int DamageType,
     sbyte CollisionBoneIndex,
     BoneBodyPartType VictimHitBodyPart,
     sbyte AttackBoneIndex,
     Agent.UsageDirection AttackDirection,
     int PhysicsMaterialIndex,
     CombatHitResultFlags CollisionHitResultFlags,
     float AttackProgress,
     float CollisionDistanceOnWeapon,
     float AttackerStunPeriod,
     float DefenderStunPeriod,
     float MissileTotalDamage,
     float MissileStartingBaseSpeed,
     float ChargeVelocity,
     float FallSpeed,
     Vec3 WeaponRotUp,
     Vec3 weaponBlowDir,
     Vec3 CollisionGlobalPosition,
     Vec3 MissileVelocity,
     Vec3 MissileStartingPosition,
     Vec3 VictimAgentCurVelocity,
     Vec3 GroundNormal)
 {
     this._attackBlockedWithShield  = attackBlockedWithShield;
     this._correctSideShieldBlock   = correctSideShieldBlock;
     this._isAlternativeAttack      = isAlternativeAttack;
     this._isColliderAgent          = isColliderAgent;
     this._collidedWithShieldOnBack = collidedWithShieldOnBack;
     this._isMissile = isMissile;
     this._missileBlockedWithWeapon        = missileBlockedWithWeapon;
     this._missileHasPhysics               = missileHasPhysics;
     this._entityExists                    = entityExists;
     this._thrustTipHit                    = thrustTipHit;
     this._missileGoneUnderWater           = missileGoneUnderWater;
     this._collisionResult                 = (int)collisionResult;
     this.AffectorWeaponSlotOrMissileIndex = affectorWeaponSlotOrMissileIndex;
     this.StrikeType                = StrikeType;
     this.DamageType                = DamageType;
     this.CollisionBoneIndex        = CollisionBoneIndex;
     this.VictimHitBodyPart         = VictimHitBodyPart;
     this.AttackBoneIndex           = AttackBoneIndex;
     this.AttackDirection           = AttackDirection;
     this.PhysicsMaterialIndex      = PhysicsMaterialIndex;
     this.CollisionHitResultFlags   = CollisionHitResultFlags;
     this.AttackProgress            = AttackProgress;
     this.CollisionDistanceOnWeapon = CollisionDistanceOnWeapon;
     this.AttackerStunPeriod        = AttackerStunPeriod;
     this.DefenderStunPeriod        = DefenderStunPeriod;
     this.MissileTotalDamage        = MissileTotalDamage;
     this.MissileStartingBaseSpeed  = MissileStartingBaseSpeed;
     this.ChargeVelocity            = ChargeVelocity;
     this.FallSpeed                   = FallSpeed;
     this.WeaponRotUp                 = WeaponRotUp;
     this._weaponBlowDir              = weaponBlowDir;
     this.CollisionGlobalPosition     = CollisionGlobalPosition;
     this.MissileVelocity             = MissileVelocity;
     this.MissileStartingPosition     = MissileStartingPosition;
     this.VictimAgentCurVelocity      = VictimAgentCurVelocity;
     this.CollisionGlobalNormal       = GroundNormal;
     this.BaseMagnitude               = 0.0f;
     this.MovementSpeedDamageModifier = 0.0f;
     this.AbsorbedByArmor             = 0;
     this.InflictedDamage             = 0;
     this.SelfInflictedDamage         = 0;
     this.IsShieldBroken              = false;
 }
        internal static bool GetDefendCollisionResultsAuxPrefix(Mission __instance, Agent attackerAgent, Agent defenderAgent,
                                                                CombatCollisionResult collisionResult, int weaponKind, int currentUsageIndex, bool isAlternativeAttack,
                                                                StrikeType strikeType, Agent.UsageDirection attackDirection, float currentAttackSpeed, float collisionDistanceOnWeapon,
                                                                float attackProgress, bool attackIsParried, ref float defenderStunPeriod, ref float attackerStunPeriod, ref bool crushedThrough,
                                                                ref bool chamber)
        {
            ItemObject          itemFromWeaponKind  = ItemObject.GetItemFromWeaponKind(weaponKind);
            WeaponComponentData weaponComponentData = (itemFromWeaponKind != null) ? itemFromWeaponKind.GetWeaponWithUsageIndex(currentUsageIndex) : null;
            EquipmentIndex      wieldedItemIndex    = defenderAgent.GetWieldedItemIndex(Agent.HandIndex.OffHand);

            if (wieldedItemIndex == EquipmentIndex.None)
            {
                wieldedItemIndex = defenderAgent.GetWieldedItemIndex(Agent.HandIndex.MainHand);
            }
            WeaponComponentData weaponComponentData2 = (wieldedItemIndex != EquipmentIndex.None) ? defenderAgent.Equipment[wieldedItemIndex].CurrentUsageItem : null;
            float num = 10f;

            attackerStunPeriod = ((strikeType == StrikeType.Thrust) ? ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.StunPeriodAttackerThrust) : ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.StunPeriodAttackerSwing));
            chamber            = false;
            float num2 = 0f;

            if (weaponComponentData != null)
            {
                float z    = attackerAgent.GetCurWeaponOffset().z;
                float num3 = weaponComponentData.GetRealWeaponLength() + z;
                num2 = MBMath.ClampFloat((0.2f + collisionDistanceOnWeapon) / num3, 0.1f, 0.98f);
                float exraLinearSpeed = MissionReversePatches.ComputeRelativeSpeedDiffOfAgents(attackerAgent, defenderAgent);
                float num4;
                if (strikeType == StrikeType.Thrust)
                {
                    num4 = CombatStatCalculator.CalculateBaseBlowMagnitudeForThrust((float)itemFromWeaponKind.PrimaryWeapon.ThrustSpeed / 11.7647057f * MissionReversePatches.SpeedGraphFunction(Mission.Current, attackProgress, strikeType, attackDirection), itemFromWeaponKind.Weight, exraLinearSpeed);
                }
                else
                {
                    num4 = CombatStatCalculator.CalculateBaseBlowMagnitudeForSwing((float)itemFromWeaponKind.PrimaryWeapon.SwingSpeed / 4.5454545f * MissionReversePatches.SpeedGraphFunction(Mission.Current, strikeType, attackDirection), weaponComponentData.GetRealWeaponLength(), itemFromWeaponKind.Weight, weaponComponentData.Inertia, weaponComponentData.CenterOfMass, num2, exraLinearSpeed);
                }
                if (strikeType == StrikeType.Thrust)
                {
                    num4 *= 0.8f;
                }
                else if (attackDirection == Agent.UsageDirection.AttackUp)
                {
                    num4 *= 1.25f;
                }
                num += num4;
            }
            float num5 = 1f;

            defenderStunPeriod = num * ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.StunMomentumTransferFactor);
            if (weaponComponentData2 != null)
            {
                if (weaponComponentData2.IsShield)
                {
                    float managedParameter = ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.StunDefendWeaponWeightOffsetShield);
                    num5 += managedParameter * weaponComponentData2.Item.Weight;
                }
                else
                {
                    num5 = 0.9f;
                    float managedParameter2 = ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.StunDefendWeaponWeightMultiplierWeaponWeight);
                    num5 += managedParameter2 * weaponComponentData2.Item.Weight;
                    ItemObject.ItemTypeEnum itemType = weaponComponentData2.Item.ItemType;
                    if (itemType == ItemObject.ItemTypeEnum.TwoHandedWeapon)
                    {
                        managedParameter2 = ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.StunDefendWeaponWeightBonusTwoHanded);
                    }
                    else if (itemType == ItemObject.ItemTypeEnum.Polearm)
                    {
                        num5 += ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.StunDefendWeaponWeightBonusPolearm);
                    }
                }
                if (collisionResult == CombatCollisionResult.Parried)
                {
                    attackerStunPeriod += 0.1f;
                    num5 += ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.StunDefendWeaponWeightBonusActiveBlocked);


                    if (GCOToolbox.GCOToolbox.MeleeBalance.GCOCheckHyperArmorConfiguration(defenderAgent))
                    {
                        GCOToolbox.GCOToolbox.MeleeBalance.CreateHyperArmorBuff(defenderAgent);
                    }
                }
                else if (collisionResult == CombatCollisionResult.Blocked)
                {
                    if (GCOToolbox.GCOToolbox.MeleeBalance.GCOCheckHyperArmorConfiguration(defenderAgent))
                    {
                        GCOToolbox.GCOToolbox.MeleeBalance.CreateHyperArmorBuff(defenderAgent);
                    }
                }
                else if (collisionResult == CombatCollisionResult.ChamberBlocked)
                {
                    attackerStunPeriod += 0.2f;
                    num5   += ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.StunDefendWeaponWeightBonusChamberBlocked);
                    chamber = true;
                }
            }
            if (!defenderAgent.GetIsLeftStance())
            {
                num5 += ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.StunDefendWeaponWeightBonusRightStance);
            }
            defenderStunPeriod /= num5;
            float managedParameter3 = ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.StunPeriodMax);

            attackerStunPeriod = Math.Min(attackerStunPeriod, managedParameter3);
            defenderStunPeriod = Math.Min(defenderStunPeriod, managedParameter3);
            crushedThrough     = (num > 38f && defenderStunPeriod > managedParameter3 - 0.03f && num2 > 0.5f);
            MissionGameModels.Current.AgentApplyDamageModel.CalculateEffects(attackerAgent, ref crushedThrough);
            if (chamber)
            {
                crushedThrough = false;
            }

            return(false);
        }