Ejemplo n.º 1
0
        private static bool TryToDeclareTarget(GenericShip attacker, GenericShip targetShip)
        {
            Selection.AnotherShip = targetShip;

            IShipWeapon chosenWeapon = null;
            Dictionary <IShipWeapon, int> availableWeapons = new Dictionary <IShipWeapon, int>();

            foreach (IShipWeapon weapon in attacker.GetAllWeapons())
            {
                if (Rules.TargetIsLegalForShot.IsLegal(attacker, targetShip, weapon, isSilent: true))
                {
                    availableWeapons.Add(weapon, CalculatePriority(attacker, targetShip, weapon));
                }
            }

            if (availableWeapons.Count > 0)
            {
                chosenWeapon = availableWeapons.OrderByDescending(n => n.Value).Select(n => n.Key).ToList().First();
            }

            if (chosenWeapon != null)
            {
                Combat.ChosenWeapon = chosenWeapon;
                Combat.ShotInfo     = new ShotInfo(attacker, Selection.AnotherShip, Combat.ChosenWeapon);
                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        private bool SnapShotAttackFilter(GenericShip defender, IShipWeapon weapon, bool isSilent)
        {
            bool result = true;

            if (defender != snapShotTarget)
            {
                if (!isSilent)
                {
                    Messages.ShowErrorToHuman(
                        string.Format("Snap Shot's target must be {0}", snapShotTarget.PilotInfo.PilotName));
                }
                result = false;
            }
            else if (!(weapon.GetType() == HostUpgrade.GetType()))
            {
                if (!isSilent)
                {
                    Messages.ShowErrorToHuman(
                        string.Format("This attack must be Snap Shot attack"));
                }
                result = false;
            }

            return(result);
        }
Ejemplo n.º 3
0
    // CHECK AVAILABLE WEAPONS TO ATTACK THIS TARGET

    private static void SelectWeapon()
    {
        List <IShipWeapon> weapons = GetAvailbleAttackTypes(Selection.ThisShip, Selection.AnotherShip);

        if (weapons.Count > 1)
        {
            Phases.StartTemporarySubPhaseOld(
                "Choose a weapon for this attack.",
                typeof(WeaponSelectionDecisionSubPhase),
                delegate { TryPerformAttack(isSilent: false); }
                );
        }
        else if (weapons.Count == 1)
        {
            Combat.ChosenWeapon = weapons.First();
            Messages.ShowInfo("Attacking with " + Combat.ChosenWeapon.Name);

            Combat.ShotInfo = new ShotInfo(Selection.ThisShip, Selection.AnotherShip, Combat.ChosenWeapon);

            TryPerformAttack(isSilent: false);
        }
        else
        {
            // Messages.ShowError("Error: No weapon to use");
            TryPerformAttack(isSilent: false);
        }
    }
Ejemplo n.º 4
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (from == null || m_projectile == null || from.Map == null)
                {
                    return;
                }

                IShipWeapon weapon = null;

                if (targeted is IShipWeapon)
                {
                    // load the cannon
                    weapon = (IShipWeapon)targeted;
                }
                else if (targeted is ShipComponent)
                {
                    weapon = ((ShipComponent)targeted).Addon as IShipWeapon;
                }

                if (weapon == null || weapon.Map == null)
                {
                    from.SendMessage("Invalid target");
                    return;
                }

                // load the cannon
                weapon.LoadWeapon(from, m_projectile);
            }
Ejemplo n.º 5
0
        private bool IsBullsEyePrimary(GenericShip defender, IShipWeapon weapon, bool isSilent)
        {
            bool result = false;

            if (weapon.WeaponType == WeaponTypes.PrimaryWeapon && HostShip.SectorsInfo.IsShipInSector(defender, ArcType.Bullseye))
            {
                result = true;
            }
            else
            {
                if (weapon.WeaponType != WeaponTypes.PrimaryWeapon)
                {
                    if (!isSilent)
                    {
                        Messages.ShowError("This attack must be performed with the primary weapon");
                    }
                }
                else
                {
                    if (!isSilent)
                    {
                        Messages.ShowError("This attack must be performed against a target in the ship's Bullseye arc");
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 6
0
        private bool IsAllowedAttack(GenericShip defender, IShipWeapon weapon, bool isSilent)
        {
            if (defender != Defender)
            {
                if (!isSilent)
                {
                    Messages.ShowError("Your attack must be against the same ship");
                }
                return(false);
            }

            if (weapon == AlreadyUsedCannon)
            {
                if (!isSilent)
                {
                    Messages.ShowError("You must use a cannon you have not attacked with this round");
                }
                return(false);
            }

            if (weapon.WeaponType != WeaponTypes.Cannon)
            {
                if (!isSilent)
                {
                    Messages.ShowError("Your attack must use a cannon");
                }
                return(false);
            }

            return(true);
        }
Ejemplo n.º 7
0
 private void AllowRange0Primaries(IShipWeapon weapon, ref int minRange, ref int maxRange, GenericShip target)
 {
     if (weapon.WeaponType == WeaponTypes.PrimaryWeapon && (weapon.HostShip == HostShip || target == HostShip))
     {
         minRange = 0;
     }
 }
Ejemplo n.º 8
0
        private bool HasTurret()
        {
            // TODOREVERT

            bool result = false;

            /*if (HostShip.PrimaryWeapon.CanShootOutsideArc)
             * {
             *  result = true;
             * }
             * else
             * {*/
            foreach (GenericUpgrade upgrade in HostShip.UpgradeBar.GetUpgradesOnlyFaceup())
            {
                IShipWeapon weapon = upgrade as IShipWeapon;
                if (weapon != null)
                {
                    /*if (weapon.CanShootOutsideArc)
                     * {
                     *  result = true;
                     *  break;
                     * }*/
                }
            }
            //}

            return(result);
        }
Ejemplo n.º 9
0
        private void CheckAbility(GenericShip ship)
        {
            if (!ActionsHolder.HasTargetLockOn(HostShip, Combat.Defender))
            {
                return;
            }

            if (HostShip.IsCannotAttackSecondTime)
            {
                return;
            }

            var availableCannons = HostShip.UpgradeBar
                                   .GetInstalledUpgrades(UpgradeType.Cannon)
                                   .Where(c => c != Combat.ShotInfo.Weapon);

            if (availableCannons.Any())
            {
                Defender          = Combat.Defender;
                AlreadyUsedCannon = Combat.ShotInfo.Weapon.WeaponType == WeaponTypes.Cannon ? Combat.ShotInfo.Weapon : null;
                HostShip.OnCombatCheckExtraAttack += RegisterSecondAttackTrigger;
            }
            else
            {
                Defender          = null;
                AlreadyUsedCannon = null;
            }
        }
Ejemplo n.º 10
0
        private bool IsAllowedAttack(GenericShip defender, IShipWeapon weapon, bool isSilent)
        {
            if (HostShip.State.Force < 2)
            {
                if (!isSilent)
                {
                    Messages.ShowError("Your must have at least 2 Force tokens to perform this attack");
                }
                return(false);
            }

            if (weapon.WeaponType != WeaponTypes.PrimaryWeapon)
            {
                if (!isSilent)
                {
                    Messages.ShowError("Your bonus attack must be a primary weapon attack");
                }
                return(false);
            }

            if (!FirstAttackMissed && defender == OriginalDefender)
            {
                if (!isSilent)
                {
                    Messages.ShowError("Your bonus attack must be against a different target");
                }
                return(false);
            }

            return(true);
        }
Ejemplo n.º 11
0
        private bool IsClusterMissilesShotToNeighbour(GenericShip defender, IShipWeapon weapon, bool isSilent)
        {
            bool   result           = false;
            string TargetingFailure = "The attack can be performed";

            if (weapon == HostUpgrade)
            {
                if (defender.ShipId != OriginalDefender.ShipId)
                {
                    if (TargetsInRange.Contains(defender))
                    {
                        result = true;
                    }
                    else
                    {
                        TargetingFailure = "The attack cannot be performed. The new target is further than range 1 from the original target";
                    }
                }
                else
                {
                    TargetingFailure = "The attack cannot be performed. You cannot attack the original target of Cluster Missiles with the second attack";
                }
            }
            else
            {
                TargetingFailure = "The attack cannot be performed: Weapon " + HostUpgrade.UpgradeInfo.Name + " is not equipped";
            }

            if (result == false && !isSilent)
            {
                Messages.ShowErrorToHuman(TargetingFailure);
            }

            return(result);
        }
Ejemplo n.º 12
0
        private bool HasTurret()
        {
            bool result = false;

            if (HostShip.PrimaryWeapon.CanShootOutsideArc)
            {
                result = true;
            }
            else
            {
                foreach (GenericUpgrade upgrade in HostShip.UpgradeBar.GetUpgradesOnlyFaceup())
                {
                    IShipWeapon weapon = upgrade as IShipWeapon;
                    if (weapon != null)
                    {
                        if (weapon.CanShootOutsideArc)
                        {
                            result = true;
                            break;
                        }
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 13
0
        public override void GetProperties(ObjectPropertyList list)
        {
            base.GetProperties(list);

            IShipWeapon weapon = Addon as IShipWeapon;

            if (weapon == null)
            {
                return;
            }

            if (weapon.Projectile == null || weapon.Projectile.Deleted)
            {
                //list.Add(1061169, "empty"); // range ~1_val~
                list.Add(1042975); // It's empty
            }
            else
            {
                list.Add(500767);                                       // Reloaded
                list.Add(1060658, "Type\t{0}", weapon.Projectile.Name); // ~1_val~: ~2_val~

                ISiegeProjectile projectile = weapon.Projectile as ISiegeProjectile;
                if (projectile != null)
                {
                    list.Add(1061169, projectile.Range.ToString()); // range ~1_val~
                }
            }
        }
Ejemplo n.º 14
0
        public ShotInfoArc(GenericShip ship1, GenericShip ship2, GenericArc arc, IShipWeapon weapon) : base(ship1, ship2)
        {
            Weapon = weapon ?? ship1.PrimaryWeapons.First();

            Arc = arc;

            CheckRange();
        }
Ejemplo n.º 15
0
        public AttackDecision(GenericShip currentShip, GenericShip targetShip, IShipWeapon weapon)
        {
            CurrentShip = currentShip;
            TargetShip  = targetShip;
            Weapon      = weapon;

            CalculatePriority();
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Creates a new ShotInfo from ship1 (attacker) to ship2 (defender)
        /// </summary>
        /// <param name="ship1">The attacker.</param>
        /// <param name="ship2">The defender.</param>
        /// <param name="weapon">The weapon. If null, ship1's primary weapon will be used.</param>
        public ShotInfo(GenericShip ship1, GenericShip ship2, IShipWeapon weapon) : base(ship1, ship2)
        {
            Weapon = weapon ?? ship1.PrimaryWeapons.First();

            ShotAvailableFromArcs = new List <GenericArc>();

            CheckRange();
            CheckFailed();
        }
Ejemplo n.º 17
0
 internal Ship(IMove moveImplementation, IRotation rotationImplemetation, IShipWeapon weapon, ShipModel model)
 {
     _model                  = model;
     _moveImpementation      = moveImplementation;
     _rotationImplementation = rotationImplemetation;
     _weapon                 = weapon;
     _weapon.EquipWeapon(_model.BarrelPosition);
     _weapon.Activate();
 }
Ejemplo n.º 18
0
 private void SetRangeToOne(GenericShip thisShip, GenericShip anotherShip, IShipWeapon chosenWeapon, ref int range)
 {
     if (thisShip.ShipId == HostShip.ShipId)
     {
         if ((range <= 3) && (chosenWeapon.GetType() == typeof(PrimaryWeaponClass)))
         {
             range = 1;
         }
     }
 }
Ejemplo n.º 19
0
 private void SetRangeToOne(GenericShip thisShip, GenericShip anotherShip, IShipWeapon chosenWeapon, ref int range)
 {
     if (thisShip.ShipId == HostShip.ShipId)
     {
         if ((range <= 3) && (Combat.ChosenWeapon.WeaponType == WeaponTypes.PrimaryWeapon))
         {
             range = 1;
         }
     }
 }
Ejemplo n.º 20
0
        public void RemoveWeapon(IShipWeapon weapon)
        {
            ShipWeaponGroup group = WeaponGroups.Find((WeaponGroup) => WeaponGroup.num == weapon.GetDefaultOperation());

            group.shipWeapons.Remove(weapon);
            if (group.shipWeapons.Count == 0)
            {
                WeaponGroups.Remove(group);
            }
        }
Ejemplo n.º 21
0
        private void CheckDoubleEdgeAbility()
        {
            if (!IsAbilityUsed && !HostShip.IsCannotAttackSecondTime && HasAlternativeWeapon() && WeaponIsTurretOrMissile())
            {
                IsAbilityUsed     = true;
                AlreadyUsedWeapon = Combat.ChosenWeapon;

                // Trigger must be registered just before it's resolution
                HostShip.OnCombatCheckExtraAttack += RegisterDoubleEdgeAbility;
            }
        }
Ejemplo n.º 22
0
    public static ShotInfo GetFiringRangeAndShow(GenericShip thisShip, GenericShip anotherShip)
    {
        IShipWeapon outOfArcWeapon = (IShipWeapon)thisShip.UpgradeBar.GetUpgradesOnlyFaceup().FirstOrDefault(n => n is IShipWeapon && (n as IShipWeapon).CanShootOutsideArc == true);

        IShipWeapon checkedWeapon = outOfArcWeapon ?? thisShip.PrimaryWeapon;

        ShotInfo shotInfo = new ShotInfo(thisShip, anotherShip, checkedWeapon);

        MovementTemplates.ShowFiringArcRange(shotInfo);
        return(shotInfo);
    }
Ejemplo n.º 23
0
        public void PerformAttackWithWeapon(IShipWeapon weapon)
        {
            Tooltips.EndTooltip();
            Messages.ShowInfo("Attacking with " + weapon.Name);

            Combat.ChosenWeapon = weapon;
            Combat.ShotInfo     = new ShotInfo(Selection.ThisShip, Selection.AnotherShip, Combat.ChosenWeapon);

            Phases.FinishSubPhase(typeof(WeaponSelectionDecisionSubPhase));
            CallBack();
        }
Ejemplo n.º 24
0
 private static void CleanupCombatData()
 {
     AttackStep            = CombatStep.None;
     Attacker              = null;
     Defender              = null;
     ChosenWeapon          = null;
     ShotInfo              = null;
     hitsCounter           = 0;
     ExtraAttackFilter     = null;
     IsAttackAlreadyCalled = false;
 }
Ejemplo n.º 25
0
        public void PerformAttackWithWeapon(IShipWeapon weapon)
        {
            Tooltips.EndTooltip();

            Combat.ChosenWeapon = weapon;

            Messages.ShowInfo("Attack with " + weapon.Name);

            Phases.FinishSubPhase(typeof(WeaponSelectionDecisionSubPhase));
            CallBack();
        }
Ejemplo n.º 26
0
        public override bool IsWeaponHaveRangeBonus(IShipWeapon weapon)
        {
            List <WeaponTypes> rangeEffectedWeaponTypes = new List <WeaponTypes>()
            {
                WeaponTypes.Cannon,
                WeaponTypes.PrimaryWeapon,
                WeaponTypes.Turret
            };

            return(rangeEffectedWeaponTypes.Contains(weapon.WeaponType) && !weapon.WeaponInfo.NoRangeBonus);
        }
Ejemplo n.º 27
0
 private bool IsPrimaryWeaponShot(GenericShip ship, IShipWeapon weapon, bool isSilent)
 {
     if (weapon is PrimaryWeaponClass && ship == theShipAttacked)
     {
         return(true);
     }
     else
     {
         Messages.ShowError("Bossk bonus attack must be performed with a primary weapon and be the same target.");
         return(false);
     }
 }
Ejemplo n.º 28
0
        public void CallUpdateWeaponRange(IShipWeapon weapon, ref int minRange, ref int maxRange, GenericShip target = null)
        {
            if (OnUpdateWeaponRange != null)
            {
                OnUpdateWeaponRange(weapon, ref minRange, ref maxRange, target);
            }

            if (OnUpdateWeaponRangeGlobal != null)
            {
                OnUpdateWeaponRangeGlobal(weapon, ref minRange, ref maxRange, target);
            }
        }
Ejemplo n.º 29
0
        private bool CounterAttackFilter(GenericShip targetShip, IShipWeapon weapon)
        {
            bool result = true;

            if (targetShip != shipToPunish)
            {
                Messages.ShowErrorToHuman(string.Format("{0} can attack only {1}", HostShip.PilotName, shipToPunish.PilotName));
                result = false;
            }

            return(result);
        }
Ejemplo n.º 30
0
        private bool CanAttackTargetWithPrimaryWeapon(GenericShip targetShip)
        {
            //AI tries to check non-turret weapon first
            IShipWeapon weapon = HostShip.PrimaryWeapons.FirstOrDefault(w => !w.WeaponInfo.ArcRestrictions.Contains(ArcType.SingleTurret));

            if (weapon == null)
            {
                weapon = HostShip.PrimaryWeapons.First();
            }
            ShotInfo primaryShot = new ShotInfo(HostShip, targetShip, weapon);

            return(primaryShot.IsShotAvailable);
        }
Ejemplo n.º 31
0
 public RotateNextEntry(IShipWeapon weapon)
     : base(406)
 {
     this.m_weapon = weapon;
 }
Ejemplo n.º 32
0
 public BackpackEntry(Mobile from, IShipWeapon weapon)
     : base(2139)
 {
     this.m_weapon = weapon;
     this.m_from = from;
 }
Ejemplo n.º 33
0
 public SetupEntry(Mobile from, IShipWeapon weapon)
     : base(97)
 {
     this.m_weapon = weapon;
     this.m_from = from;
 }
Ejemplo n.º 34
0
        public void OnHit(Mobile from, IShipWeapon weapon, IEntity target, Point3D targetloc)
        {

        }
Ejemplo n.º 35
0
 public RotatePreviousEntry(IShipWeapon weapon)
     : base(405)
 {
     this.m_weapon = weapon;
 }