示例#1
0
        public static int calculateMissileSpeed(float ammoWeight, MissionWeapon rangedWeapon, int drawWeight)
        {
            int calculatedMissileSpeed = 10;

            if (rangedWeapon.CurrentUsageItem.ItemUsage.Equals("bow"))
            {
                float  powerstroke     = (25f * 0.0254f); //28f
                double potentialEnergy = 0.5f * (drawWeight * 4.448f) * powerstroke * 0.91f;
                //calculatedMissileSpeed = (int)Math.Floor(Math.Sqrt(((potentialEnergy * 2f) / ammoWeight) * 0.91f * ((ammoWeight * 3f) + 0.432f)));
                //calculatedMissileSpeed = (int)Math.Floor(Math.Sqrt((potentialEnergy * 2f) / (ammoWeight + (drawWeight * 0.00012f))));
                ammoWeight            += drawWeight * 0.00012f;
                calculatedMissileSpeed = (int)Math.Floor(Math.Sqrt((potentialEnergy * 2f) / (ammoWeight)));
            }
            else if (rangedWeapon.CurrentUsageItem.ItemUsage.Equals("long_bow"))
            {
                float  powerstroke     = (25f * 0.0254f); //30f
                double potentialEnergy = 0.5f * (drawWeight * 4.448f) * powerstroke * 0.89f;
                //calculatedMissileSpeed = (int)Math.Floor(Math.Sqrt(((potentialEnergy * 2f) / ammoWeight) * 0.89f * ((ammoWeight * 3.3f) + 0.33f) * (1f + (0.416f - (0.0026 * drawWeight)))));
                //calculatedMissileSpeed = (int)Math.Floor(Math.Sqrt((potentialEnergy * 2f) / (ammoWeight + (drawWeight * 0.00020f))));
                ammoWeight            += drawWeight * 0.00020f;
                calculatedMissileSpeed = (int)Math.Floor(Math.Sqrt((potentialEnergy * 2f) / (ammoWeight)));
            }
            else if (rangedWeapon.CurrentUsageItem.ItemUsage.Equals("crossbow") || rangedWeapon.CurrentUsageItem.ItemUsage.Equals("crossbow_fast"))
            {
                float  powerstroke     = (12f * 0.0254f); //4.5f
                double potentialEnergy = 0.5f * (drawWeight * 4.448f) * powerstroke * 0.91f;
                //calculatedMissileSpeed = (int)Math.Floor(Math.Sqrt(((potentialEnergy * 2f) / ammoWeight) * 0.45f));
                //calculatedMissileSpeed = (int)Math.Floor(Math.Sqrt((potentialEnergy * 2f) / (ammoWeight + (drawWeight * 0.0000588f))));
                ammoWeight            += drawWeight * 0.00027f;
                calculatedMissileSpeed = (int)Math.Floor(Math.Sqrt((potentialEnergy * 2f) / (ammoWeight)));
            }
            return(calculatedMissileSpeed);
        }
 public CreateMissile(
     int missileIndex,
     Agent agent,
     EquipmentIndex weaponIndex,
     MissionWeapon weapon,
     Vec3 position,
     Vec3 direction,
     float speed,
     Mat3 orientation,
     bool hasRigidBody,
     MissionObject missionObjectToIgnore,
     bool isPrimaryWeaponShot)
 {
     this.MissileIndex          = missileIndex;
     this.Agent                 = agent;
     this.WeaponIndex           = weaponIndex;
     this.Weapon                = weapon;
     this.Position              = position;
     this.Direction             = direction;
     this.Speed                 = speed;
     this.Orientation           = orientation;
     this.HasRigidBody          = hasRigidBody;
     this.MissionObjectToIgnore = missionObjectToIgnore;
     this.IsPrimaryWeaponShot   = isPrimaryWeaponShot;
 }
示例#3
0
        protected override string OnGetLogFormat()
        {
            if (this.Agent == null)
            {
                return("Not equipping weapon because there is no agent to equip it to,");
            }
            object[] objArray = new object[8];
            objArray[0] = (object)"Equip weapon with name: ";
            MissionWeapon weapon = this.Weapon;
            TextObject    textObject;

            if (weapon.IsEmpty)
            {
                textObject = TextObject.Empty;
            }
            else
            {
                weapon     = this.Weapon;
                textObject = weapon.Item.Name;
            }
            objArray[1] = (object)textObject;
            objArray[2] = (object)" from SlotIndex: ";
            objArray[3] = (object)this.SlotIndex;
            objArray[4] = (object)" on agent: ";
            objArray[5] = (object)this.Agent.Name;
            objArray[6] = (object)" with index: ";
            objArray[7] = (object)this.Agent.Index;
            return(string.Concat(objArray));
        }
示例#4
0
        public static void ChangeWeaponSpeedsHandler(Agent agent, double speedMultiplier, bool requip = true)
        {
            // get currently wielded weapon(s) and index(es)
            MissionWeapon  equipped        = agent.WieldedWeapon;
            MissionWeapon  offhandEquipped = agent.WieldedOffhandWeapon;
            EquipmentIndex mainIndex       = EquipmentIndex.None;
            EquipmentIndex offIndex        = EquipmentIndex.None;

            if (equipped.CurrentUsageItem != null)
            {
                mainIndex = agent.GetWieldedItemIndex(Agent.HandIndex.MainHand);
            }
            if (offhandEquipped.CurrentUsageItem != null)
            {
                offIndex = agent.GetWieldedItemIndex(Agent.HandIndex.OffHand);
            }

            for (int i = 0; i < 4; i++)
            {
                MissionWeapon currentWeapon = agent.Equipment[i];

                ChangeWeaponSpeed(agent, i, speedMultiplier, currentWeapon);
                if (requip)
                {
                    RequipWeapon(agent, i, currentWeapon, mainIndex, offIndex);
                }
            }
        }
        public static void assignStoneMissileSpeed(MissionWeapon throwable, int index)
        {
            PropertyInfo property = typeof(WeaponComponentData).GetProperty("MissileSpeed");

            property.DeclaringType.GetProperty("MissileSpeed");
            throwable.CurrentUsageIndex = index;
            property.SetValue(throwable.CurrentUsageItem, 25, BindingFlags.NonPublic | BindingFlags.SetProperty, null, null, null);
            throwable.CurrentUsageIndex = 0;
        }
示例#6
0
 public AttachWeaponToSpawnedWeapon(
     MissionWeapon weapon,
     MissionObject missionObject,
     MatrixFrame attachLocalFrame)
 {
     this.Weapon           = weapon;
     this.MissionObject    = missionObject;
     this.AttachLocalFrame = attachLocalFrame;
 }
示例#7
0
 public static int assignStoneMissileSpeed(MissionWeapon throwable)
 {
     //PropertyInfo property = typeof(WeaponComponentData).GetProperty("MissileSpeed");
     //property.DeclaringType.GetProperty("MissileSpeed");
     //throwable.CurrentUsageIndex = index;
     //property.SetValue(throwable.CurrentUsageItem, 25, BindingFlags.NonPublic | BindingFlags.SetProperty, null, null, null);
     //throwable.CurrentUsageIndex = 0;
     return(25);
 }
        public static void DropBanner(this Agent agent)
        {
            MissionWeapon extraSlot = agent.Equipment[EquipmentIndex.ExtraWeaponSlot];

            if (!extraSlot.IsEmpty && extraSlot.CurrentUsageItem.Item.Type == ItemObject.ItemTypeEnum.Banner)
            {
                agent.DropItem(EquipmentIndex.ExtraWeaponSlot);
            }
        }
示例#9
0
            private static ItemObject SelectValidItem(int index, Agent agent, bool hasBow, bool hasShield, bool isArcher, bool isHorseArcher)
            {
                ItemObject item;

                if (isArcher || isHorseArcher && !hasBow)
                {
                    // we must get a bow for the archers
                    hasBow = true;
                    var           bow = Rng.Next(0, 2) == 0;
                    MissionWeapon missionWeapon;

                    if (bow || isHorseArcher)
                    {
                        item = EquipmentItems.Select(x => x.Item).Where(x =>
                                                                        x.ItemType == ItemObject.ItemTypeEnum.Bow).GetRandomElement();
                        missionWeapon = new MissionWeapon(item, Hero.MainHero.ClanBanner);
                    }
                    else
                    {
                        item = EquipmentItems.Select(x => x.Item).Where(x =>
                                                                        x.ItemType == ItemObject.ItemTypeEnum.Crossbow).GetRandomElement();
                        missionWeapon = new MissionWeapon(item, Hero.MainHero.ClanBanner);
                    }

                    AddAmmo(agent, missionWeapon);
                }
                else
                {
                    // not an archer so get something else
                    item = EquipmentItems.Where(x =>
                                                x.Item.ItemType != ItemObject.ItemTypeEnum.Bow &&
                                                x.Item.ItemType != ItemObject.ItemTypeEnum.Crossbow)
                           .GetRandomElement().Item;
                }

                if (item.ItemType == ItemObject.ItemTypeEnum.Shield &&
                    hasShield)
                {
                    // we can't take a shield, make a subset for next filter
                    var selection = EquipmentItems.Select(x => x.Item).Where(x =>
                                                                             x.ItemType != ItemObject.ItemTypeEnum.Shield);
                    // we also can't take a bow now
                    if (hasBow || index > 2)
                    {
                        selection = selection.Where(x =>
                                                    x.ItemType != ItemObject.ItemTypeEnum.Bow &&
                                                    x.ItemType != ItemObject.ItemTypeEnum.Crossbow);
                    }

                    // pick from subset
                    item = selection.GetRandomElement();
                }

                return(item);
            }
        private void EquipAgentWithBanner(Agent agent)
        {
            if (((CharacterObject)agent.Character).IsArcher)
            {
                StripWeaponsFromArcher(agent);
            }

            MissionWeapon bannerWeapon = new MissionWeapon(MBObjectManager.Instance.GetObject <ItemObject>("campaign_banner_small"), agent.Origin.Banner);

            agent.EquipWeaponToExtraSlotAndWield(ref bannerWeapon);
        }
示例#11
0
        public static bool DropBanner(this Agent agent)
        {
            MissionWeapon extraSlot = agent.Equipment[EquipmentIndex.ExtraWeaponSlot];

            if (!extraSlot.IsEmpty && extraSlot.CurrentUsageItem.WeaponClass == WeaponClass.Banner)
            {
                agent.DropItem(EquipmentIndex.ExtraWeaponSlot);
                return(true);
            }
            return(false);
        }
 public AttachWeaponToWeaponInAgentEquipmentSlot(
     MissionWeapon weapon,
     Agent agent,
     EquipmentIndex slot,
     MatrixFrame attachLocalFrame)
 {
     this.Weapon           = weapon;
     this.Agent            = agent;
     this.SlotIndex        = slot;
     this.AttachLocalFrame = attachLocalFrame;
 }
示例#13
0
 public AttachWeaponToAgent(
     MissionWeapon weapon,
     Agent agent,
     sbyte boneIndex,
     MatrixFrame attachLocalFrame)
 {
     this.Weapon           = weapon;
     this.Agent            = agent;
     this.BoneIndex        = boneIndex;
     this.AttachLocalFrame = attachLocalFrame;
 }
        public static void assignThrowableMissileSpeed(MissionWeapon throwable, int index, int correctiveMissileSpeed)
        {
            float        ammoWeight = throwable.GetWeight() / throwable.Amount;
            int          calculatedThrowingSpeed = Utilities.calculateThrowableSpeed(ammoWeight);
            PropertyInfo property = typeof(WeaponComponentData).GetProperty("MissileSpeed");

            property.DeclaringType.GetProperty("MissileSpeed");
            throwable.CurrentUsageIndex = index;
            calculatedThrowingSpeed    += correctiveMissileSpeed;
            property.SetValue(throwable.CurrentUsageItem, calculatedThrowingSpeed, BindingFlags.NonPublic | BindingFlags.SetProperty, null, null, null);
            throwable.CurrentUsageIndex = 0;
        }
            static void Postfix(Agent shooterAgent, EquipmentIndex weaponIndex, Vec3 position, Vec3 velocity, Mat3 orientation, bool hasRigidBody, bool isPrimaryWeaponShot, int forcedMissileIndex, Mission __instance)
            {
                MissionWeapon missionWeapon = shooterAgent.Equipment[weaponIndex];

                WeaponStatsData[] wsd = missionWeapon.GetWeaponStatsData();
                if ((wsd[0].WeaponClass == (int)WeaponClass.Bow) || (wsd[0].WeaponClass == (int)WeaponClass.Crossbow))
                {
                    PropertyInfo property2 = typeof(WeaponComponentData).GetProperty("MissileSpeed");
                    property2.DeclaringType.GetProperty("MissileSpeed");
                    property2.SetValue(shooterAgent.Equipment[weaponIndex].CurrentUsageItem, _oldMissileSpeed, BindingFlags.NonPublic | BindingFlags.SetProperty, null, null, null);
                }
            }
示例#16
0
        public static int assignThrowableMissileSpeed(MissionWeapon throwable, int correctiveMissileSpeed, int effectiveSkill)
        {
            float ammoWeight = throwable.GetWeight() / throwable.Amount;
            int   calculatedThrowingSpeed = calculateThrowableSpeed(ammoWeight, effectiveSkill);

            //PropertyInfo property = typeof(WeaponComponentData).GetProperty("MissileSpeed");
            //property.DeclaringType.GetProperty("MissileSpeed");
            //throwable.CurrentUsageIndex = index;
            calculatedThrowingSpeed += correctiveMissileSpeed;
            return(calculatedThrowingSpeed);
            //property.SetValue(throwable.CurrentUsageItem, calculatedThrowingSpeed, BindingFlags.NonPublic | BindingFlags.SetProperty, null, null, null);
            //throwable.CurrentUsageIndex = 0;
        }
示例#17
0
        public void OnMainAgentWieldedItemChange()
        {
            if (!_fireSwordEnabled || DropLock)
            {
                return;
            }
            MissionWeapon wieldedWeapon = Agent.Main.WieldedWeapon;

            if (wieldedWeapon.Weapons.IsEmpty())
            {
                SetFireSwordEnable(false);
            }
        }
示例#18
0
 public static void SwitchShieldBanner(this Agent agent, Banner banner)
 {
     for (int i = 0; i < (int)EquipmentIndex.NumAllWeaponSlots; i++)
     {
         MissionWeapon paintedShield = new MissionWeapon(MBObjectManager.Instance.GetObject <ItemObject>(CampaignBannerID), null, banner);
         if (!agent.Equipment[i].IsEmpty && (agent.Equipment[i].Item.PrimaryWeapon.WeaponClass == WeaponClass.SmallShield || agent.Equipment[i].Item.PrimaryWeapon.WeaponClass == WeaponClass.LargeShield))
         {
             string shieldId = agent.Equipment[i].Item.StringId;
             agent.RemoveEquippedWeapon((EquipmentIndex)i);
             paintedShield = new MissionWeapon(MBObjectManager.Instance.GetObject <ItemObject>(shieldId), null, banner);
             agent.EquipWeaponWithNewEntity((EquipmentIndex)i, ref paintedShield);
         }
     }
 }
示例#19
0
        private static short CalculateRemainingAmmo(Agent agent)
        {
            MissionWeapon weaponFromSlot0 = agent.Equipment[EquipmentIndex.Weapon0];
            short         ammoFromSlot0   = weaponFromSlot0.Equals(MissionWeapon.Invalid) || weaponFromSlot0.IsShield() ? (short)0 : weaponFromSlot0.Amount;
            MissionWeapon weaponFromSlot1 = agent.Equipment[EquipmentIndex.Weapon1];
            short         ammoFromSlot1   = weaponFromSlot1.Equals(MissionWeapon.Invalid) || weaponFromSlot1.IsShield() ? (short)0 : weaponFromSlot1.Amount;
            MissionWeapon weaponFromSlot2 = agent.Equipment[EquipmentIndex.Weapon2];
            short         ammoFromSlot2   = weaponFromSlot2.Equals(MissionWeapon.Invalid) || weaponFromSlot2.IsShield() ? (short)0 : weaponFromSlot2.Amount;
            MissionWeapon weaponFromSlot3 = agent.Equipment[EquipmentIndex.Weapon3];
            short         ammoFromSlot3   = weaponFromSlot3.Equals(MissionWeapon.Invalid) || weaponFromSlot3.IsShield() ? (short)0 : weaponFromSlot3.Amount;
            MissionWeapon weaponFromSlot4 = agent.Equipment[EquipmentIndex.Weapon4];
            short         ammoFromSlot4   = weaponFromSlot4.Equals(MissionWeapon.Invalid) || weaponFromSlot4.IsShield() ? (short)0 : weaponFromSlot4.Amount;

            return((short)(ammoFromSlot0 + ammoFromSlot1 + ammoFromSlot2 + ammoFromSlot3 + ammoFromSlot4));
        }
示例#20
0
        private bool IsAgentBannerBearer(Agent agent)
        {
            MissionPeer missionPeer         = agent?.MissionPeer ?? agent?.OwningAgentMissionPeer;
            Formation   controlledFormation = missionPeer?.ControlledFormation;

            if (controlledFormation != null)
            {
                MissionWeapon missionWeapon = agent.Equipment[EquipmentIndex.Weapon4];
                if (!missionWeapon.IsEmpty && missionWeapon.Item.ItemType == ItemObject.ItemTypeEnum.Banner && new Banner(controlledFormation.BannerCode, missionPeer.Team.Color, missionPeer.Team.Color2).Serialize() == missionWeapon.Banner.Serialize())
                {
                    return(true);
                }
            }
            return(false);
        }
示例#21
0
 private static void AddAmmo(Agent agent, MissionWeapon missionWeapon)
 {
     if (missionWeapon.PrimaryItem.ItemType == ItemObject.ItemTypeEnum.Bow)
     {
         Mod.Log("Adding arrows");
         var ammo = new MissionWeapon(Arrows.GetRandomElement(), Hero.MainHero.ClanBanner);
         Traverse.Create(agent.Equipment).Field <MissionWeapon[]>("_weaponSlots").Value[3] = ammo;
     }
     else
     {
         Mod.Log("Adding bolts");
         var ammo = new MissionWeapon(Bolts.GetRandomElement(), Hero.MainHero.ClanBanner);
         Traverse.Create(agent.Equipment).Field <MissionWeapon[]>("_weaponSlots").Value[3] = ammo;
     }
 }
示例#22
0
        public static void RequipWeapon(Agent agent, int index, MissionWeapon weapon, EquipmentIndex mainIndex, EquipmentIndex offIndex)
        {
            // reset weapon to set new speed
            agent.EquipWeaponWithNewEntity((EquipmentIndex)index, ref weapon);

            // if weapon was currently equipped, re-equip it
            if (mainIndex != EquipmentIndex.None && index == (int)mainIndex)
            {
                agent.TryToWieldWeaponInSlot(mainIndex, Agent.WeaponWieldActionType.Instant, true);
            }
            if (offIndex != EquipmentIndex.None && index == (int)offIndex)
            {
                agent.TryToWieldWeaponInSlot(offIndex, Agent.WeaponWieldActionType.Instant, true);
            }
        }
示例#23
0
        public static void UnequipAllAndEquipStones(this Agent agent)
        {
            for (int i = 0; i < (int)EquipmentIndex.NumAllWeaponSlots - 1; i++)
            {
                if (!agent.Equipment[i].IsEmpty)
                {
                    agent.RemoveEquippedWeapon((EquipmentIndex)i);
                }
            }

            MissionWeapon rockWeapon = new MissionWeapon(MBObjectManager.Instance.GetObject <ItemObject>(ThrowingStonesID), null, null);

            agent.EquipWeaponWithNewEntity(EquipmentIndex.Weapon0, ref rockWeapon);
            agent.WieldNextWeapon(Agent.HandIndex.MainHand);
        }
 public SpawnWeaponWithNewEntity(
     MissionWeapon weapon,
     Mission.WeaponSpawnFlags weaponSpawnFlags,
     int forcedIndex,
     MatrixFrame frame,
     MissionObject parentMissionObject,
     bool isVisible,
     bool hasLifeTime)
 {
     this.Weapon              = weapon;
     this.WeaponSpawnFlags    = weaponSpawnFlags;
     this.ForcedIndex         = forcedIndex;
     this.Frame               = frame;
     this.ParentMissionObject = parentMissionObject;
     this.IsVisible           = isVisible;
     this.HasLifeTime         = hasLifeTime;
 }
        private void SwapEquipment(Agent agent, int loadout)
        {
            MWAXConfig      config          = new MWAXConfig();
            CharacterObject characterObject = Game.Current.ObjectManager.GetObject <CharacterObject>("weapon_practice_stage_" + config.MWAXWeaponStage() + "_" + this._settlement.MapFaction.Culture.StringId) ?? Game.Current.ObjectManager.GetObject <CharacterObject>("weapon_practice_stage_1_empire");

            for (int i = 0; i < 4; i++)
            {
                EquipmentElement equipmentFromSlot = characterObject.BattleEquipments.ToList <Equipment>()[loadout].GetEquipmentFromSlot((EquipmentIndex)i);
                agent.RemoveEquippedWeapon((EquipmentIndex)i);
                if (equipmentFromSlot.Item != null)
                {
                    MissionWeapon missionWeapon = new MissionWeapon(equipmentFromSlot.Item, agent.Origin?.Banner);
                    agent.EquipWeaponWithNewEntity((EquipmentIndex)i, ref missionWeapon);
                }
            }

            agent.WieldInitialWeapons();
        }
            static bool Prefix(Agent shooterAgent, EquipmentIndex weaponIndex, Vec3 position, ref Vec3 velocity, Mat3 orientation, bool hasRigidBody, bool isPrimaryWeaponShot, int forcedMissileIndex, Mission __instance)
            {
                MissionWeapon missionWeapon = shooterAgent.Equipment[weaponIndex];

                WeaponStatsData[] wsd = missionWeapon.GetWeaponStatsData();

                if ((wsd[0].WeaponClass == (int)WeaponClass.Bow) || (wsd[0].WeaponClass == (int)WeaponClass.Crossbow))
                {
                    if (missionWeapon.ItemModifier != null)
                    {
                        FieldInfo field = typeof(ItemModifier).GetField("_missileSpeed", BindingFlags.NonPublic | BindingFlags.Instance);
                        field.DeclaringType.GetField("_missileSpeed");
                        int missileSpeedModifier = (int)field.GetValue(missionWeapon.ItemModifier);

                        _oldMissileSpeed = missionWeapon.GetModifiedMissileSpeedForUsage(0) - missileSpeedModifier;
                    }
                    else
                    {
                        _oldMissileSpeed = missionWeapon.GetModifiedMissileSpeedForUsage(0);
                    }
                    float ammoWeight = missionWeapon.AmmoWeapon.GetWeight();

                    int calculatedMissileSpeed = Utilities.calculateMissileSpeed(ammoWeight, missionWeapon, missionWeapon.GetModifiedMissileSpeedForUsage(0));

                    Vec3 shooterAgentVelocity = new Vec3(shooterAgent.Velocity, -1);
                    Vec3 myVelocity           = new Vec3(velocity, -1);

                    myVelocity.Normalize();

                    float shooterAgentSpeed = Vec3.DotProduct(shooterAgentVelocity, myVelocity);

                    Vec3 modifierVec = shooterAgentVelocity + myVelocity;

                    velocity.x = myVelocity.x * (calculatedMissileSpeed + shooterAgentSpeed);
                    velocity.y = myVelocity.y * (calculatedMissileSpeed + shooterAgentSpeed);
                    velocity.z = myVelocity.z * (calculatedMissileSpeed + shooterAgentSpeed);

                    PropertyInfo property2 = typeof(WeaponComponentData).GetProperty("MissileSpeed");
                    property2.DeclaringType.GetProperty("MissileSpeed");
                    property2.SetValue(shooterAgent.Equipment[weaponIndex].CurrentUsageItem, calculatedMissileSpeed, BindingFlags.NonPublic | BindingFlags.SetProperty, null, null, null);
                }
                return(true);
            }
示例#27
0
        public override void OnAgentShootMissile(Agent shooterAgent, EquipmentIndex weaponIndex, Vec3 position, Vec3 velocity, Mat3 orientation, bool hasRigidBody, int forcedMissileIndex)
        {
            if (!_fireArrowEnabled)
            {
                return;
            }

            bool          allowed = false;
            MissionWeapon weapon  = shooterAgent.Equipment[weaponIndex];

            switch (weapon.CurrentUsageItem.WeaponClass)
            {
            case WeaponClass.Arrow:
            case WeaponClass.Bolt:
            case WeaponClass.Bow:
            case WeaponClass.Crossbow:
                allowed = true;
                break;

            case WeaponClass.ThrowingAxe:
            case WeaponClass.ThrowingKnife:
            case WeaponClass.Javelin:
                allowed = FireLordConfig.AllowFireThrownWeapon;
                break;
            }
            if (allowed)
            {
                foreach (Mission.Missile missile in Mission.Current.Missiles)
                {
                    if (!_missileParticles.ContainsKey(missile))
                    {
                        MatrixFrame    localFrame = new MatrixFrame(Mat3.Identity, new Vec3(0, 0, 0));
                        ParticleSystem particle   = ParticleSystem.CreateParticleSystemAttachedToEntity(
                            "psys_game_burning_agent", missile.Entity, ref localFrame);
                        Light light = Light.CreatePointLight(FireLordConfig.FireArrowLightRadius);
                        light.Intensity  = FireLordConfig.FireArrowLightIntensity;
                        light.LightColor = FireLordConfig.FireArrowLightColor;
                        missile.Entity.AddLight(light);
                        _missileParticles.Add(missile, particle);
                    }
                }
            }
        }
示例#28
0
 public bool IsAgentEligibleForAmmoSupply(Agent agent)
 {
     if (agent.IsAIControlled && this._sideList.Contains(agent.Team.Side))
     {
         for (EquipmentIndex index = EquipmentIndex.WeaponItemBeginSlot; index < EquipmentIndex.NumAllWeaponSlots; ++index)
         {
             MissionWeapon missionWeapon = agent.Equipment[index];
             if (!missionWeapon.IsEmpty)
             {
                 missionWeapon = agent.Equipment[index];
                 if (missionWeapon.IsAnyAmmo())
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
示例#29
0
        public override bool Check(MissionPeer peer)
        {
            Formation controlledFormation = peer?.ControlledFormation;

            if (controlledFormation != null && MultiplayerOptions.OptionType.NumberOfBotsPerFormation.GetIntValue() > 0)
            {
                foreach (IFormationUnit allUnit in controlledFormation.arrangement.GetAllUnits())
                {
                    if (allUnit is Agent agent2 && agent2.IsActive())
                    {
                        MissionWeapon missionWeapon = agent2.Equipment[EquipmentIndex.Weapon4];
                        if (!missionWeapon.IsEmpty && missionWeapon.Item.ItemType == ItemObject.ItemTypeEnum.Banner && new Banner(controlledFormation.BannerCode, peer.Team.Color, peer.Team.Color2).Serialize() == missionWeapon.Banner.Serialize())
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
            static void Postfix(Agent __instance)
            {
                int i = 0;

                for (EquipmentIndex equipmentIndex = EquipmentIndex.WeaponItemBeginSlot; equipmentIndex < EquipmentIndex.NumAllWeaponSlots; equipmentIndex++)
                {
                    if (__instance.Equipment != null && !__instance.Equipment[equipmentIndex].IsEmpty)
                    {
                        WeaponStatsData[] wsd = __instance.Equipment[equipmentIndex].GetWeaponStatsData();
                        if ((wsd[0].WeaponClass == (int)WeaponClass.Bow) || (wsd[0].WeaponClass == (int)WeaponClass.Crossbow))
                        {
                            MissionWeapon missionWeapon = __instance.Equipment[equipmentIndex];

                            PropertyInfo property = typeof(WeaponComponentData).GetProperty("MissileSpeed");
                            property.DeclaringType.GetProperty("MissileSpeed");
                            property.SetValue(missionWeapon.CurrentUsageItem, _oldMissileSpeeds.ToArray()[i], BindingFlags.NonPublic | BindingFlags.SetProperty, null, null, null);
                            i++;
                        }
                    }
                }
                _oldMissileSpeeds.Clear();
            }