예제 #1
0
 public AmmoData(Single Speed, WeaponFlags Flags, Byte[] Unused, Int32 Value, Byte ClipRounds)
 {
     this.Speed      = Speed;
     this.Flags      = Flags;
     this.Unused     = Unused;
     this.Value      = Value;
     this.ClipRounds = ClipRounds;
 }
예제 #2
0
 public AmmoData(string Tag = null)
     : base(Tag)
 {
     Speed      = new Single();
     Flags      = new WeaponFlags();
     Unused     = new byte[3];
     Value      = new Int32();
     ClipRounds = new Byte();
 }
예제 #3
0
파일: Weap.cs 프로젝트: tstavrianos/patcher
 private void SetWeaponFlag(WeaponFlags value, bool set)
 {
     if (set)
     {
         Data.Flags |= value;
     }
     else
     {
         Data.Flags &= ~value;
     }
 }
 public WeaponUsageData(
     string weaponUsageDataId,
     WeaponClass weaponClass,
     WeaponFlags weaponFlags,
     string itemUsageFeatures,
     bool rotatedInHand             = false,
     bool useCenterOfMassAsHandBase = false)
 {
     this.WeaponUsageDataId         = weaponUsageDataId;
     this.WeaponClass               = weaponClass;
     this.WeaponFlags               = weaponFlags;
     this.ItemUsageFeatures         = itemUsageFeatures;
     this.RotatedInHand             = rotatedInHand;
     this.UseCenterOfMassAsHandBase = useCenterOfMassAsHandBase;
 }
예제 #5
0
 public WeaponDesign(
     CraftingTemplate template,
     string weaponName,
     WeaponDesignElement[] usedPieces)
 {
     this.Template             = template;
     this._usedPieces          = ((IEnumerable <WeaponDesignElement>)usedPieces).ToArray <WeaponDesignElement>();
     this.WeaponName           = weaponName;
     this._piecePivotDistances = new float[usedPieces.Length];
     this.CalculatePivotDistances();
     this.CraftedWeaponLength = this.CalculateWeaponLength();
     this.HolsterShiftAmount  = this.CalculateHolsterShiftAmount();
     foreach (WeaponDesignElement usedPiece in usedPieces)
     {
         this.WeaponFlags |= usedPiece.CraftingPiece.AdditionalWeaponFlags;
     }
 }
예제 #6
0
 public WeaponRecordData(System.IO.BinaryReader reader)
 {
     weight      = reader.ReadSingle();
     value       = reader.ReadInt32();
     type        = (WeaponType)reader.ReadInt16();
     maxHealth   = reader.ReadInt16();
     Speed       = reader.ReadSingle();
     reach       = reader.ReadSingle();
     enchantPts  = reader.ReadInt16();
     chopMin     = reader.ReadByte();
     chopMax     = reader.ReadByte();
     slashMin    = reader.ReadByte();
     slashMax    = reader.ReadByte();
     thrustMin   = reader.ReadByte();
     thrustMax   = reader.ReadByte();
     WeaponFlags = (WeaponFlags)reader.ReadInt32();
 }
 public void FillAsMissileBlow(
     ItemObject item,
     WeaponComponentData weaponComponentData,
     int missileIndex,
     sbyte weaponAttachBoneIndex,
     Vec3 startingPosition,
     Vec3 currentPosition,
     Vec3 velocity)
 {
     this._isMissile       = true;
     this.StartingPosition = startingPosition;
     this.CurrentPosition  = currentPosition;
     this.Velocity         = velocity;
     this.ItemFlags        = item.ItemFlags;
     this.WeaponFlags      = weaponComponentData.WeaponFlags;
     this.WeaponClass      = weaponComponentData.WeaponClass;
     this.BoneNoToAttach   = weaponAttachBoneIndex;
     this.AffectorWeaponSlotOrMissileIndex = missileIndex;
     this.Weight           = item.Weight;
     this._isMaterialMetal = weaponComponentData.PhysicsMaterial.Contains("metal");
 }
예제 #8
0
 public WeaponComponentData(ItemObject item, WeaponClass weaponClass = WeaponClass.Undefined, WeaponFlags weaponFlags = (WeaponFlags)0)
 {
     this.BodyArmor         = 0;
     this.PhysicsMaterial   = "";
     this.FlyingSoundCode   = "";
     this.PassbySoundCode   = "";
     this.ItemUsage         = (string)null;
     this.SwingSpeed        = 0;
     this.ThrustSpeed       = 0;
     this.MissileSpeed      = 0;
     this.WeaponLength      = 0;
     this.ThrustDamage      = 0;
     this.SwingDamage       = 0;
     this.AmmoOffset        = Vec3.Zero;
     this.Accuracy          = 0;
     this.StickingFrame     = MatrixFrame.Identity;
     this.TrailParticleName = "";
     this.WeaponClass       = weaponClass;
     this.WeaponFlags       = weaponFlags;
     this.Frame             = MatrixFrame.Identity;
     this.RotationSpeed     = Vec3.Zero;
 }
 public void FillAsMeleeBlow(
     ItemObject item,
     WeaponComponentData weaponComponentData,
     int affectorWeaponSlot,
     sbyte weaponAttachBoneIndex)
 {
     this._isMissile = false;
     if (weaponComponentData != null)
     {
         this.ItemFlags      = item.ItemFlags;
         this.WeaponFlags    = weaponComponentData.WeaponFlags;
         this.WeaponClass    = weaponComponentData.WeaponClass;
         this.BoneNoToAttach = weaponAttachBoneIndex;
         this.AffectorWeaponSlotOrMissileIndex = affectorWeaponSlot;
         this.Weight           = item.Weight;
         this._isMaterialMetal = weaponComponentData.PhysicsMaterial.Contains("metal");
     }
     else
     {
         this._isMaterialMetal = false;
         this.AffectorWeaponSlotOrMissileIndex = -1;
     }
 }
 public KillingBlow(
     Blow b,
     Vec3 ragdollImpulsePoint,
     Vec3 ragdollImpulseAmount,
     int deathAction,
     int weaponItemKind,
     Agent.KillInfo overrideKillInfo = Agent.KillInfo.Invalid)
 {
     this.RagdollImpulseLocalPoint = ragdollImpulsePoint;
     this.RagdollImpulseAmount     = ragdollImpulseAmount;
     this.DeathAction             = deathAction;
     this.OverrideKillInfo        = overrideKillInfo;
     this.DamageType              = b.DamageType;
     this.AttackType              = b.AttackType;
     this.OwnerId                 = b.OwnerId;
     this.BoneIndex               = b.BoneIndex;
     this.WeaponClass             = (int)b.WeaponRecord.WeaponClass;
     this.BlowPosition            = b.Position;
     this.WeaponRecordWeaponFlags = b.WeaponRecord.WeaponFlags;
     this.WeaponItemKind          = weaponItemKind;
     this.InflictedDamage         = b.InflictedDamage;
     this.IsMissile               = b.IsMissile;
     this.IsValid                 = true;
 }
예제 #11
0
 public void RemoveFlag(WeaponFlags flag)
 {
     wepFlags = wepFlags & (~flag);
 }
예제 #12
0
 public void AddFlag(WeaponFlags flag)
 {
     wepFlags = wepFlags | flag;
 }
예제 #13
0
        static bool Prefix(Mission __instance, ref bool __result, out int hitParticleIndex, ref AttackCollisionData collisionData,
                           Vec3 missileStartingPosition, Vec3 missilePosition, Vec3 missileAngularVelocity, Vec3 movementVelocity,
                           MatrixFrame attachGlobalFrame, MatrixFrame affectedShieldGlobalFrame, int numDamagedAgents, Agent attacker, Agent victim,
                           GameEntity hitEntity)
        {
            hitParticleIndex = -1;
            if (InvulnerableSettings.Instance.Enabled == false)
            {
                return(true);
            }
            if (victim == Agent.Main)
            {
                FieldInfo           missileField        = AccessTools.Field(typeof(Mission), "_missiles");
                var                 missiles            = (Dictionary <int, Mission.Missile>)missileField.GetValue(__instance);
                Mission.Missile     missile             = missiles[collisionData.AffectorWeaponSlotOrMissileIndex];
                MissionWeapon       weapon              = missile.Weapon;
                WeaponFlags         weaponFlags         = missile.Weapon.CurrentUsageItem.WeaponFlags;
                float               num                 = 1f;
                WeaponComponentData weaponComponentData = null;
                if (collisionData.AttackBlockedWithShield && weaponFlags.HasAnyFlag(WeaponFlags.CanPenetrateShield))
                {
                    return(true);    // Use original code
                }
                hitParticleIndex = -1;
                Mission.MissileCollisionReaction missileCollisionReaction = Mission.MissileCollisionReaction.BounceBack;
                bool            flag = !GameNetwork.IsSessionActive;
                bool            missileHasPhysics = collisionData.MissileHasPhysics;
                PhysicsMaterial fromIndex         = PhysicsMaterial.GetFromIndex(collisionData.PhysicsMaterialIndex);
                object          obj   = fromIndex.IsValid ? fromIndex.GetFlags() : PhysicsMaterialFlags.None;
                bool            flag2 = (weaponFlags & WeaponFlags.AmmoSticksWhenShot) > (WeaponFlags)0UL;
                object          obj2  = obj;
                bool            flag5 = false;
                if (collisionData.MissileGoneUnderWater)
                {
                    return(true);
                }
                else if (collisionData.AttackBlockedWithShield)
                {
                    return(true);
                }
                else
                {
                    // Friendly control
                    if (attacker != null && attacker.IsFriendOf(victim))
                    {
                        if (!missileHasPhysics)
                        {
                            if (flag)
                            {
                                if (attacker.Controller == Agent.ControllerType.AI)
                                {
                                    flag5 = true;
                                }
                            }
                            else if ((MultiplayerOptions.OptionType.FriendlyFireDamageRangedFriendPercent.GetIntValue(MultiplayerOptions.MultiplayerOptionsAccessMode.CurrentMapOptions) <= 0 && MultiplayerOptions.OptionType.FriendlyFireDamageRangedSelfPercent.GetIntValue(MultiplayerOptions.MultiplayerOptionsAccessMode.CurrentMapOptions) <= 0) || __instance.Mode == MissionMode.Duel)
                            {
                                flag5 = true;
                            }
                        }
                    }
                    else if (victim.IsHuman && !attacker.IsEnemyOf(victim))
                    {
                        flag5 = true;
                    }
                    else if (flag && attacker != null && attacker.Controller == Agent.ControllerType.AI && victim.RiderAgent != null && attacker.IsFriendOf(victim.RiderAgent))
                    {
                        flag5 = true;
                    }

                    if (flag5)
                    {
                        missileCollisionReaction = Mission.MissileCollisionReaction.BecomeInvisible;
                    }
                    else
                    {
                        // even weapons with multiple penetration can't penetrate me.
                        //bool flag6 = (weaponFlags & WeaponFlags.MultiplePenetration) > (WeaponFlags)0UL;
                        //if (flag6)
                        //{
                        //    return true;    // Use original code
                        //}

                        MethodInfo getAttackCollisionResultsMethod = typeof(Mission).GetMethod("GetAttackCollisionResults", BindingFlags.NonPublic | BindingFlags.Instance);
                        getAttackCollisionResultsMethod.Invoke(__instance, new object[] {
                            attacker, victim, null, num, collisionData, weapon, false, false, false, weaponComponentData
                        });
                        Blow blow = CreateMissileBlow(attacker, collisionData, weapon, missilePosition, missileStartingPosition);
                        blow.BlowFlag |= BlowFlags.ShrugOff;    // Any attack is so neglectable to our hero
                        if (victim.State == AgentState.Active)
                        {
                            MethodInfo registerBlowMethod = AccessTools.Method("Mission:RegisterBlow");
                            registerBlowMethod.Invoke(__instance, new object[] { attacker, victim, null, blow, collisionData, weapon });
                            //__instance.RegisterBlow(attacker, victim, null, blow, ref collisionData);
                        }
                    }
                }
                MatrixFrame attachLocalFrame;
                attachLocalFrame = attachGlobalFrame;


                // Any missile bounces back
                WeaponFlags weaponFlags2 = weaponFlags & WeaponFlags.AmmoBreakOnBounceBackMask;
                Vec3        zero         = Vec3.Zero;
                Vec3        zero2        = Vec3.Zero;
                if ((weaponFlags2 == WeaponFlags.AmmoCanBreakOnBounceBack &&
                     collisionData.MissileVelocity.Length >
                     ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.BreakableProjectileMinimumBreakSpeed)) ||
                    weaponFlags2 == WeaponFlags.AmmoBreaksOnBounceBack)
                {
                    if (collisionData.MissileTotalDamage > InvulnerableSettings.Instance.ArrowBreakingThres)
                    {
                        missileCollisionReaction = Mission.MissileCollisionReaction.BecomeInvisible;
                        Mission.Current.Scene.CreateBurstParticle(ParticleSystemManager.GetRuntimeIdByName("psys_game_broken_arrow"), attachLocalFrame);
                    }
                    else
                    {
                        hitParticleIndex = ParticleSystemManager.GetRuntimeIdByName("psys_game_broken_arrow");  // For some reason, setting this doesn't work
                    }
                }
                else
                {
                    missile.CalculateBounceBackVelocity(missileAngularVelocity, collisionData, out zero, out zero2);
                    Mission.Current.Scene.CreateBurstParticle(ParticleSystemManager.GetRuntimeIdByName("psys_game_missile_metal_coll"), attachLocalFrame);
                }
                __instance.HandleMissileCollisionReaction(collisionData.AffectorWeaponSlotOrMissileIndex, missileCollisionReaction, attachLocalFrame,
                                                          attacker, null, collisionData.AttackBlockedWithShield, collisionData.CollisionBoneIndex, null, zero, zero2, -1);
                foreach (MissionBehaviour missionBehaviour in __instance.MissionBehaviours)
                {
                    missionBehaviour.OnMissileHit(attacker, null, flag5);
                }

                __result = true;
                return(false);
            }
            return(true);
        }
예제 #14
0
 public abstract void DecideMissileWeaponFlags(
     Agent attackerAgent,
     MissionWeapon missileWeapon,
     ref WeaponFlags missileWeaponFlags);
예제 #15
0
 private void SetWeaponFlag(WeaponFlags value, bool set)
 {
     if (set)
         Data.Flags |= value;
     else
         Data.Flags &= ~value;
 }
예제 #16
0
        public void Deserialize(ItemObject item, XmlNode node)
        {
            this.BodyArmor = node.Attributes["body_armor"] != null?int.Parse(node.Attributes["body_armor"].Value) : 0;

            this.PhysicsMaterial = node.Attributes["physics_material"]?.Value;
            this.FlyingSoundCode = node.Attributes["flying_sound_code"]?.Value;
            this.PassbySoundCode = node.Attributes["passby_sound_code"]?.Value;
            this.ItemUsage       = node.Attributes["item_usage"]?.Value;
            this.WeaponBalance   = node.Attributes["weapon_balance"] != null ? (float)int.Parse(node.Attributes["weapon_balance"].Value) * 0.01f : 0.0f;
            this.SwingSpeed      = node.Attributes["speed_rating"] != null?int.Parse(node.Attributes["speed_rating"].Value) : 0;

            this.ThrustSpeed = node.Attributes["thrust_speed"] != null?int.Parse(node.Attributes["thrust_speed"].Value) : 0;

            this.MissileSpeed = node.Attributes["missile_speed"] != null?int.Parse(node.Attributes["missile_speed"].Value) : 0;

            this.WeaponLength = node.Attributes["weapon_length"] != null?int.Parse(node.Attributes["weapon_length"].Value) : 0;

            this.ThrustDamage = node.Attributes["thrust_damage"] != null?int.Parse(node.Attributes["thrust_damage"].Value) : 0;

            this.SwingDamage = node.Attributes["swing_damage"] != null?int.Parse(node.Attributes["swing_damage"].Value) : 0;

            this.Accuracy = node.Attributes["accuracy"] != null?int.Parse(node.Attributes["accuracy"].Value) : 100;

            this.ThrustDamageType = node.Attributes["thrust_damage_type"] != null ? (DamageTypes)Enum.Parse(typeof(DamageTypes), node.Attributes["thrust_damage_type"].Value) : DamageTypes.Blunt;
            this.SwingDamageType  = node.Attributes["swing_damage_type"] != null ? (DamageTypes)Enum.Parse(typeof(DamageTypes), node.Attributes["swing_damage_type"].Value) : DamageTypes.Blunt;
            this.WeaponClass      = node.Attributes["weapon_class"] != null ? (WeaponClass)Enum.Parse(typeof(WeaponClass), node.Attributes["weapon_class"].Value) : WeaponClass.Undefined;
            this.AmmoClass        = node.Attributes["ammo_class"] != null ? (WeaponClass)Enum.Parse(typeof(WeaponClass), node.Attributes["ammo_class"].Value) : WeaponClass.Undefined;
            this.CenterOfMass     = (float)((double)this.WeaponLength * 0.5 * 0.00999999977648258);
            this.CenterOfMass3D   = node.Attributes["center_of_mass"] != null?Vec3.Parse(node.Attributes["center_of_mass"].Value) : Vec3.Zero;

            if (this.WeaponClass != WeaponClass.Bow && this.WeaponClass != WeaponClass.Crossbow && (this.WeaponClass != WeaponClass.SmallShield && this.WeaponClass != WeaponClass.LargeShield) && (this.WeaponClass != WeaponClass.Arrow && this.WeaponClass != WeaponClass.Bolt && (this.WeaponClass != WeaponClass.ThrowingKnife && this.WeaponClass != WeaponClass.ThrowingAxe)) && (this.WeaponClass != WeaponClass.Javelin && this.WeaponClass != WeaponClass.Stone))
            {
                int weaponClass = (int)this.WeaponClass;
            }
            XmlAttribute attribute1 = node.Attributes["ammo_limit"];
            XmlAttribute attribute2 = node.Attributes["stack_amount"];
            XmlAttribute attribute3 = node.Attributes["hit_points"];

            this.MaxDataValue = attribute1 == null ? (attribute2 == null ? (attribute3 == null ? (short)0 : short.Parse(attribute3.Value)) : short.Parse(attribute2.Value)) : short.Parse(attribute1.Value);
            Vec3    vec3       = new Vec3();
            Mat3    identity1  = Mat3.Identity;
            XmlNode attribute4 = (XmlNode)node.Attributes["sticking_position"];

            if (attribute4 != null)
            {
                string[] strArray = attribute4.Value.Split(',');
                if (strArray.Length == 3)
                {
                    float.TryParse(strArray[0], out vec3.x);
                    float.TryParse(strArray[1], out vec3.y);
                    float.TryParse(strArray[2], out vec3.z);
                }
            }
            XmlNode attribute5 = (XmlNode)node.Attributes["sticking_rotation"];

            if (attribute5 != null)
            {
                string[] strArray = attribute5.Value.Split(',');
                if (strArray.Length == 3)
                {
                    float result1;
                    float.TryParse(strArray[0], out result1);
                    float result2;
                    float.TryParse(strArray[1], out result2);
                    float result3;
                    float.TryParse(strArray[2], out result3);
                    identity1.RotateAboutSide(result1.ToRadians());
                    identity1.RotateAboutUp(result2.ToRadians());
                    identity1.RotateAboutForward(result3.ToRadians());
                }
            }
            vec3 = identity1.TransformToParent(vec3);
            this.StickingFrame = new MatrixFrame(identity1, vec3);
            Vec3    o          = new Vec3();
            Mat3    identity2  = Mat3.Identity;
            XmlNode attribute6 = (XmlNode)node.Attributes["position"];

            if (attribute6 != null)
            {
                string[] strArray = attribute6.Value.Split(',');
                if (strArray.Length == 3)
                {
                    float.TryParse(strArray[0], out o.x);
                    float.TryParse(strArray[1], out o.y);
                    float.TryParse(strArray[2], out o.z);
                }
            }
            XmlNode attribute7 = (XmlNode)node.Attributes["rotation"];

            if (attribute7 != null)
            {
                string[] strArray = attribute7.Value.Split(',');
                if (strArray.Length == 3)
                {
                    float result1;
                    float.TryParse(strArray[0], out result1);
                    float result2;
                    float.TryParse(strArray[1], out result2);
                    float result3;
                    float.TryParse(strArray[2], out result3);
                    identity2.RotateAboutUp(result3.ToRadians());
                    identity2.RotateAboutSide(result1.ToRadians());
                    identity2.RotateAboutForward(result2.ToRadians());
                }
            }
            this.Frame         = new MatrixFrame(identity2, o);
            this.RotationSpeed = node.Attributes["rotation_speed"] != null?Vec3.Parse(node.Attributes["rotation_speed"].Value) : Vec3.Zero;

            this.TrailParticleName = node.Attributes["trail_particle_name"]?.Value;
            foreach (XmlNode childNode in node.ChildNodes)
            {
                if (childNode.Name == "WeaponFlags")
                {
                    foreach (WeaponFlags weaponFlags in Enum.GetValues(typeof(WeaponFlags)))
                    {
                        if (childNode.Attributes[weaponFlags.ToString()] != null)
                        {
                            this.WeaponFlags |= weaponFlags;
                        }
                    }
                }
            }
            this.Inertia        = item.Weight * 0.05f;
            this.Handling       = this.ThrustSpeed;
            this.SweetSpotReach = 0.93f;
            this.SetDamageFactors(item.Weight);
        }
예제 #17
0
        internal static bool MissileHitCallbackPrefix(ref bool __result, ref Mission __instance, out int hitParticleIndex, ref AttackCollisionData collisionData, int missileIndex, Vec3 missileStartingPosition, Vec3 missilePosition, Vec3 missileAngularVelocity, Vec3 movementVelocity, MatrixFrame attachGlobalFrame, MatrixFrame affectedShieldGlobalFrame, int numDamagedAgents, Agent attacker, Agent victim, GameEntity hitEntity)
        {
            var _missiles = MissionAccessTools.Get_missiles(ref __instance);

            Mission.Missile missile = _missiles[missileIndex];

            bool isHorseArcher = GCOToolbox.GCOToolbox.ProjectileBalance.CheckForHorseArcher(victim);
            bool makesRear     = GCOToolbox.GCOToolbox.ProjectileBalance.ApplyHorseCrippleLogic(victim, collisionData.VictimHitBodyPart);

            WeaponFlags         weaponFlags1      = missile.Weapon.CurrentUsageItem.WeaponFlags;
            float               momentumRemaining = 1f;
            WeaponComponentData shieldOnBack      = (WeaponComponentData)null;

            if (collisionData.AttackBlockedWithShield && weaponFlags1.HasAnyFlag <WeaponFlags>(WeaponFlags.CanPenetrateShield))
            {
                GetAttackCollisionResultsPrefix(ref __instance, isHorseArcher, missile, attacker, victim, hitEntity, momentumRemaining, ref collisionData, false, false, out shieldOnBack);
                EquipmentIndex wieldedItemIndex = victim.GetWieldedItemIndex(Agent.HandIndex.OffHand);
                if ((double)collisionData.InflictedDamage > (double)ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.ShieldPenetrationOffset) + (double)ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.ShieldPenetrationFactor) * (double)victim.Equipment[wieldedItemIndex].GetShieldArmorForCurrentUsage())
                {
                    AttackCollisionData.UpdateDataForShieldPenetration(ref collisionData);
                    momentumRemaining *= (float)(0.400000005960464 + (double)MBRandom.RandomFloat * 0.200000002980232);
                }
            }
            hitParticleIndex = -1;
            bool            flag1             = !GameNetwork.IsSessionActive;
            bool            missileHasPhysics = collisionData.MissileHasPhysics;
            PhysicsMaterial fromIndex         = PhysicsMaterial.GetFromIndex(collisionData.PhysicsMaterialIndex);
            int             num1  = fromIndex.IsValid ? (int)fromIndex.GetFlags() : 0;
            bool            flag2 = (weaponFlags1 & WeaponFlags.AmmoSticksWhenShot) > (WeaponFlags)0;
            bool            flag3 = (num1 & 1) == 0;
            bool            flag4 = (uint)(num1 & 8) > 0U;
            MissionObject   attachedMissionObject = (MissionObject)null;

            if (victim == null && (NativeObject)hitEntity != (NativeObject)null)
            {
                GameEntity gameEntity = hitEntity;
                do
                {
                    attachedMissionObject = gameEntity.GetFirstScriptOfType <MissionObject>();
                    gameEntity            = gameEntity.Parent;
                }while (attachedMissionObject == null && (NativeObject)gameEntity != (NativeObject)null);
                hitEntity = attachedMissionObject?.GameEntity;
            }
            Mission.MissileCollisionReaction collisionReaction1 = !flag4 ? (!weaponFlags1.HasAnyFlag <WeaponFlags>(WeaponFlags.Burning) ? (!flag3 || !flag2 ? Mission.MissileCollisionReaction.BounceBack : Mission.MissileCollisionReaction.Stick) : Mission.MissileCollisionReaction.BecomeInvisible) : Mission.MissileCollisionReaction.PassThrough;
            bool isCanceled = false;

            Mission.MissileCollisionReaction collisionReaction2;
            if (collisionData.MissileGoneUnderWater)
            {
                collisionReaction2 = Mission.MissileCollisionReaction.BecomeInvisible;
                hitParticleIndex   = 0;
            }
            else if (victim == null)
            {
                if ((NativeObject)hitEntity != (NativeObject)null)
                {
                    GetAttackCollisionResultsPrefix(ref __instance, isHorseArcher, missile, attacker, victim, hitEntity, momentumRemaining, ref collisionData, false, false, out shieldOnBack);
                    Blow missileBlow = __instance.CreateMissileBlow(attacker, ref collisionData, missile, missilePosition, missileStartingPosition);
                    __instance.RegisterBlow(attacker, (Agent)null, hitEntity, missileBlow, ref collisionData);
                }
                collisionReaction2 = collisionReaction1;
                hitParticleIndex   = 0;
            }
            else if (collisionData.AttackBlockedWithShield)
            {
                GetAttackCollisionResultsPrefix(ref __instance, isHorseArcher, missile, attacker, victim, hitEntity, momentumRemaining, ref collisionData, false, false, out shieldOnBack);
                collisionReaction2 = collisionData.IsShieldBroken ? Mission.MissileCollisionReaction.BecomeInvisible : collisionReaction1;
                hitParticleIndex   = 0;
            }
            else
            {
                if (attacker != null && attacker.IsFriendOf(victim))
                {
                    if (!missileHasPhysics)
                    {
                        if (flag1)
                        {
                            if (attacker.Controller == Agent.ControllerType.AI)
                            {
                                isCanceled = true;
                            }
                        }
                        else if (MultiplayerOptions.OptionType.FriendlyFireDamageRangedFriendPercent.GetIntValue(MultiplayerOptions.MultiplayerOptionsAccessMode.CurrentMapOptions) <= 0 && MultiplayerOptions.OptionType.FriendlyFireDamageRangedSelfPercent.GetIntValue(MultiplayerOptions.MultiplayerOptionsAccessMode.CurrentMapOptions) <= 0 || __instance.Mode == MissionMode.Duel)
                        {
                            isCanceled = true;
                        }
                    }
                }
                else if (victim.IsHuman && !attacker.IsEnemyOf(victim))
                {
                    isCanceled = true;
                }
                else if (flag1 && attacker != null && (attacker.Controller == Agent.ControllerType.AI && victim.RiderAgent != null) && attacker.IsFriendOf(victim.RiderAgent))
                {
                    isCanceled = true;
                }
                if (isCanceled)
                {
                    if (flag1 && attacker == Agent.Main && attacker.IsFriendOf(victim))
                    {
                        InformationManager.DisplayMessage(new InformationMessage(GameTexts.FindText("ui_you_hit_a_friendly_troop", (string)null).ToString(), Color.ConvertStringToColor("#D65252FF")));
                    }
                    collisionReaction2 = Mission.MissileCollisionReaction.BecomeInvisible;
                }
                else
                {
                    bool flag5 = (weaponFlags1 & WeaponFlags.MultiplePenetration) > (WeaponFlags)0;
                    GetAttackCollisionResultsPrefix(ref __instance, isHorseArcher, missile, attacker, victim, (GameEntity)null, momentumRemaining, ref collisionData, false, false, out shieldOnBack);
                    Blow missileBlow = __instance.CreateMissileBlow(attacker, ref collisionData, missile, missilePosition, missileStartingPosition);
                    if (makesRear)
                    {
                        missileBlow.BlowFlag = BlowFlags.MakesRear;
                    }

                    if (!collisionData.CollidedWithShieldOnBack & flag5 && numDamagedAgents > 0)
                    {
                        missileBlow.InflictedDamage     /= numDamagedAgents;
                        missileBlow.SelfInflictedDamage /= numDamagedAgents;
                    }
                    float managedParameter1 = ManagedParameters.Instance.GetManagedParameter(missileBlow.DamageType != DamageTypes.Cut ? (missileBlow.DamageType != DamageTypes.Pierce ? ManagedParametersEnum.DamageInterruptAttackThresholdBlunt : ManagedParametersEnum.DamageInterruptAttackThresholdPierce) : ManagedParametersEnum.DamageInterruptAttackThresholdCut);
                    if ((double)collisionData.InflictedDamage <= (double)managedParameter1)
                    {
                        missileBlow.BlowFlag |= BlowFlags.ShrugOff;
                    }
                    if (victim.State == AgentState.Active)
                    {
                        __instance.RegisterBlow(attacker, victim, (GameEntity)null, missileBlow, ref collisionData);
                    }
                    hitParticleIndex = ParticleSystemManager.GetRuntimeIdByName("psys_game_blood_sword_enter");
                    if (flag5 && numDamagedAgents < 3)
                    {
                        collisionReaction2 = Mission.MissileCollisionReaction.PassThrough;
                    }
                    else
                    {
                        collisionReaction2 = collisionReaction1;
                        if (collisionReaction1 == Mission.MissileCollisionReaction.Stick && !collisionData.CollidedWithShieldOnBack)
                        {
                            bool flag6 = __instance.CombatType == Mission.MissionCombatType.Combat;
                            if (flag6)
                            {
                                bool flag7 = victim.IsHuman && collisionData.VictimHitBodyPart == BoneBodyPartType.Head;
                                flag6 = victim.State != AgentState.Active || !flag7;
                            }
                            if (flag6)
                            {
                                float managedParameter2 = ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.MissileMinimumDamageToStick);
                                float num2 = 2f * managedParameter2;
                                if (!GameNetwork.IsClientOrReplay && (double)missileBlow.InflictedDamage < (double)managedParameter2 && (double)missileBlow.AbsorbedByArmor > (double)num2)
                                {
                                    collisionReaction2 = Mission.MissileCollisionReaction.BounceBack;
                                }
                            }
                            else
                            {
                                collisionReaction2 = Mission.MissileCollisionReaction.BecomeInvisible;
                            }
                        }
                    }
                }
            }
            if (collisionData.CollidedWithShieldOnBack && shieldOnBack != null && (victim != null && victim.IsMainAgent))
            {
                InformationManager.DisplayMessage(new InformationMessage(GameTexts.FindText("ui_hit_shield_on_back", (string)null).ToString(), Color.ConvertStringToColor("#FFFFFFFF")));
            }
            MatrixFrame attachLocalFrame;

            if (!collisionData.MissileHasPhysics && !collisionData.MissileGoneUnderWater)
            {
                bool shouldMissilePenetrate = collisionReaction2 == Mission.MissileCollisionReaction.Stick;
                attachLocalFrame = __instance.CalculateAttachedLocalFrame(ref attachGlobalFrame, collisionData, missile.Weapon.CurrentUsageItem, victim, hitEntity, movementVelocity, missileAngularVelocity, affectedShieldGlobalFrame, shouldMissilePenetrate);
            }
            else
            {
                attachLocalFrame      = attachGlobalFrame;
                attachedMissionObject = (MissionObject)null;
            }
            Vec3 velocity        = Vec3.Zero;
            Vec3 angularVelocity = Vec3.Zero;

            if (collisionReaction2 == Mission.MissileCollisionReaction.BounceBack)
            {
                WeaponFlags weaponFlags2 = weaponFlags1 & WeaponFlags.AmmoBreakOnBounceBackMask;
                if (weaponFlags2 == WeaponFlags.AmmoCanBreakOnBounceBack && (double)collisionData.MissileVelocity.Length > (double)ManagedParameters.Instance.GetManagedParameter(ManagedParametersEnum.BreakableProjectileMinimumBreakSpeed) || weaponFlags2 == WeaponFlags.AmmoBreaksOnBounceBack)
                {
                    collisionReaction2 = Mission.MissileCollisionReaction.BecomeInvisible;
                    hitParticleIndex   = ParticleSystemManager.GetRuntimeIdByName("psys_game_broken_arrow");
                }
                else
                {
                    missile.CalculateBounceBackVelocity(missileAngularVelocity, collisionData, out velocity, out angularVelocity);
                }
            }
            __instance.HandleMissileCollisionReaction(missileIndex, collisionReaction2, attachLocalFrame, attacker, victim, collisionData.AttackBlockedWithShield, collisionData.CollisionBoneIndex, attachedMissionObject, velocity, angularVelocity, -1);
            foreach (MissionBehaviour missionBehaviour in __instance.MissionBehaviours)
            {
                missionBehaviour.OnMissileHit(attacker, victim, isCanceled);
            }
            __result = collisionReaction2 != Mission.MissileCollisionReaction.PassThrough;

            return(false);
        }
예제 #18
0
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.WeaponWeaponFlags           = ((WeaponFlags)(binaryReader.ReadInt32()));
     this.FieldOldStringId            = binaryReader.ReadStringID();
     this.SecondaryTriggerMode        = ((SecondaryTriggerModeEnum)(binaryReader.ReadInt16()));
     this.MaximumAlternateShotsLoaded = binaryReader.ReadInt16();
     this.TurnOnTime                  = binaryReader.ReadSingle();
     this.ReadyTime                   = binaryReader.ReadSingle();
     this.ReadyEffect                 = binaryReader.ReadTagReference();
     this.ReadyDamageEffect           = binaryReader.ReadTagReference();
     this.HeatRecoveryThreshold       = binaryReader.ReadSingle();
     this.OverheatedThreshold         = binaryReader.ReadSingle();
     this.HeatDetonationThreshold     = binaryReader.ReadSingle();
     this.HeatDetonationFraction      = binaryReader.ReadSingle();
     this.HeatLossPerSecond           = binaryReader.ReadSingle();
     this.HeatIllumination            = binaryReader.ReadSingle();
     this.OverheatedHeatLossPerSecond = binaryReader.ReadSingle();
     this.Overheated                  = binaryReader.ReadTagReference();
     this.OverheatedDamageEffect      = binaryReader.ReadTagReference();
     this.Detonation                  = binaryReader.ReadTagReference();
     this.DetonationDamageEffect0     = binaryReader.ReadTagReference();
     this.PlayerMeleeDamage           = binaryReader.ReadTagReference();
     this.PlayerMeleeResponse         = binaryReader.ReadTagReference();
     pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.MeleeAimAssist.ReadFields(binaryReader)));
     pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.MeleeDamageParameters.ReadFields(binaryReader)));
     this.MeleeDamageReportingType = ((MeleeDamageReportingTypeEnum)(binaryReader.ReadByte()));
     this.fieldpad3               = binaryReader.ReadBytes(1);
     this.MagnificationLevels     = binaryReader.ReadInt16();
     this.MagnificationRange      = binaryReader.ReadRange();
     pointerQueue                 = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.WeaponAimAssist.ReadFields(binaryReader)));
     this.MovementPenalized       = ((MovementPenalizedEnum)(binaryReader.ReadInt16()));
     this.fieldpad4               = binaryReader.ReadBytes(2);
     this.ForwardMovementPenalty  = binaryReader.ReadSingle();
     this.SidewaysMovementPenalty = binaryReader.ReadSingle();
     this.AIScariness             = binaryReader.ReadSingle();
     this.WeaponPoweronTime       = binaryReader.ReadSingle();
     this.WeaponPoweroffTime      = binaryReader.ReadSingle();
     this.WeaponPoweronEffect     = binaryReader.ReadTagReference();
     this.WeaponPoweroffEffect    = binaryReader.ReadTagReference();
     this.AgeHeatRecoveryPenalty  = binaryReader.ReadSingle();
     this.AgeRateOfFirePenalty    = binaryReader.ReadSingle();
     this.AgeMisfireStart         = binaryReader.ReadSingle();
     this.AgeMisfireChance        = binaryReader.ReadSingle();
     this.PickupSound             = binaryReader.ReadTagReference();
     this.ZoominSound             = binaryReader.ReadTagReference();
     this.ZoomoutSound            = binaryReader.ReadTagReference();
     this.ActiveCamoDing          = binaryReader.ReadSingle();
     this.ActiveCamoRegrowthRate  = binaryReader.ReadSingle();
     this.HandleNode              = binaryReader.ReadStringID();
     this.WeaponClass             = binaryReader.ReadStringID();
     this.WeaponName              = binaryReader.ReadStringID();
     this.MultiplayerWeaponType   = ((MultiplayerWeaponTypeEnum)(binaryReader.ReadInt16()));
     this.WeaponType              = ((WeaponTypeEnum)(binaryReader.ReadInt16()));
     pointerQueue                 = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.Tracking.ReadFields(binaryReader)));
     pointerQueue                 = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.PlayerInterface.ReadFields(binaryReader)));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(8));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(92));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(64));
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(236));
     this.fieldpad5 = binaryReader.ReadBytes(8);
     this.MaxMovementAcceleration = binaryReader.ReadSingle();
     this.MaxMovementVelocity     = binaryReader.ReadSingle();
     this.MaxTurningAcceleration  = binaryReader.ReadSingle();
     this.MaxTurningVelocity      = binaryReader.ReadSingle();
     this.DeployedVehicle         = binaryReader.ReadTagReference();
     this.AgeEffect  = binaryReader.ReadTagReference();
     this.AgedWeapon = binaryReader.ReadTagReference();
     this.FirstPersonWeaponOffset = binaryReader.ReadVector3();
     this.FirstPersonScopeSize    = binaryReader.ReadVector2();
     return(pointerQueue);
 }