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); }
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); }
// 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); } }
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); }
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); }
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); }
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; } }
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); }
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; } }
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); }
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); }
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); }
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~ } } }
public ShotInfoArc(GenericShip ship1, GenericShip ship2, GenericArc arc, IShipWeapon weapon) : base(ship1, ship2) { Weapon = weapon ?? ship1.PrimaryWeapons.First(); Arc = arc; CheckRange(); }
public AttackDecision(GenericShip currentShip, GenericShip targetShip, IShipWeapon weapon) { CurrentShip = currentShip; TargetShip = targetShip; Weapon = weapon; CalculatePriority(); }
/// <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(); }
internal Ship(IMove moveImplementation, IRotation rotationImplemetation, IShipWeapon weapon, ShipModel model) { _model = model; _moveImpementation = moveImplementation; _rotationImplementation = rotationImplemetation; _weapon = weapon; _weapon.EquipWeapon(_model.BarrelPosition); _weapon.Activate(); }
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; } } }
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; } } }
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); } }
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; } }
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); }
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(); }
private static void CleanupCombatData() { AttackStep = CombatStep.None; Attacker = null; Defender = null; ChosenWeapon = null; ShotInfo = null; hitsCounter = 0; ExtraAttackFilter = null; IsAttackAlreadyCalled = false; }
public void PerformAttackWithWeapon(IShipWeapon weapon) { Tooltips.EndTooltip(); Combat.ChosenWeapon = weapon; Messages.ShowInfo("Attack with " + weapon.Name); Phases.FinishSubPhase(typeof(WeaponSelectionDecisionSubPhase)); CallBack(); }
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); }
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); } }
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); } }
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); }
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); }
public RotateNextEntry(IShipWeapon weapon) : base(406) { this.m_weapon = weapon; }
public BackpackEntry(Mobile from, IShipWeapon weapon) : base(2139) { this.m_weapon = weapon; this.m_from = from; }
public SetupEntry(Mobile from, IShipWeapon weapon) : base(97) { this.m_weapon = weapon; this.m_from = from; }
public void OnHit(Mobile from, IShipWeapon weapon, IEntity target, Point3D targetloc) { }
public RotatePreviousEntry(IShipWeapon weapon) : base(405) { this.m_weapon = weapon; }