private static void Shoot(PlayerMobile from, Mobile target, INinjaWeapon weapon) { if (from != target && CanUseWeapon(from, weapon) && from.CanBeHarmful(target)) { if (weapon.WeaponMinRange == 0 || !from.InRange(target, weapon.WeaponMinRange)) { from.NinjaWepCooldown = true; from.Direction = from.GetDirectionTo(target); from.RevealingAction(); weapon.AttackAnimation(from, target); ConsumeUse(weapon); if (CombatCheck(from, target)) { Timer.DelayCall(TimeSpan.FromSeconds(1.0), new TimerStateCallback<object[]>(OnHit), new object[] { from, target, weapon }); } Timer.DelayCall(TimeSpan.FromSeconds(2.5), new TimerStateCallback<PlayerMobile>(ResetUsing), from); } else { from.SendLocalizedMessage(1063303); // Your target is too close! } } }
public static void AttemptShoot(PlayerMobile from, INinjaWeapon weapon) { if (CanUseWeapon(from, weapon)) { from.BeginTarget(weapon.WeaponMaxRange, false, TargetFlags.Harmful, new TargetStateCallback<INinjaWeapon>(OnTarget), weapon); } }
private static void Unload(Mobile from, INinjaWeapon weapon) { if (weapon.UsesRemaining > 0) { INinjaAmmo ammo = Activator.CreateInstance(weapon.AmmoType, new object[] { weapon.UsesRemaining }) as INinjaAmmo; ammo.Poison = weapon.Poison; ammo.PoisonCharges = weapon.PoisonCharges; from.AddToBackpack((Item)ammo); weapon.UsesRemaining = 0; weapon.PoisonCharges = 0; weapon.Poison = null; } }
private static void Unload(Mobile from, INinjaWeapon weapon) { if (weapon.UsesRemaining > 0) { var ammo = weapon.AmmoType.CreateInstance <Item>(weapon.UsesRemaining); if (ammo is INinjaAmmo ninaAmmo) { ninaAmmo.Poison = weapon.Poison; ninaAmmo.PoisonCharges = weapon.PoisonCharges; } from.AddToBackpack(ammo); weapon.UsesRemaining = 0; weapon.PoisonCharges = 0; weapon.Poison = null; } }
public void DoRangedAttack() { Mobile c = m_Mobile.Combatant; if (c == null) { return; } List <INinjaWeapon> list = new List <INinjaWeapon>(); int d = (int)m_Mobile.GetDistanceToSqrt(c.Location); foreach (Item item in m_Mobile.Items) { if (item is INinjaWeapon && ((INinjaWeapon)item).UsesRemaining > 0 && d >= ((INinjaWeapon)item).WeaponMinRange && d <= ((INinjaWeapon)item).WeaponMaxRange) { list.Add(item as INinjaWeapon); } } if (m_Mobile.Backpack != null) { foreach (Item item in m_Mobile.Backpack.Items) { if (item is INinjaWeapon && ((INinjaWeapon)item).UsesRemaining > 0 && d >= ((INinjaWeapon)item).WeaponMinRange && d <= ((INinjaWeapon)item).WeaponMaxRange) { list.Add(item as INinjaWeapon); } } } if (list.Count > 0) { INinjaWeapon toUse = list[Utility.Random(list.Count)]; if (toUse != null) { NinjaWeapon.Shoot(m_Mobile, c, toUse); } } m_NextRanged = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(30, 120)); }
private static void OnTarget(Mobile from, object targeted, INinjaWeapon weapon) { PlayerMobile player = from as PlayerMobile; if (WeaponIsValid(weapon, from)) { if (targeted is Mobile) { Shoot(player, (Mobile)targeted, weapon); } else if (targeted.GetType() == weapon.AmmoType) { Reload(player, weapon, (INinjaAmmo)targeted); } else { player.SendLocalizedMessage(weapon.WrongAmmoMessage); } } }
public UnloadEntry(INinjaWeapon wep, int entry) : base(entry, 0) { this.weapon = wep; this.Enabled = (this.weapon.UsesRemaining > 0); }
public LoadEntry(INinjaWeapon wep, int entry) : base(entry, 0) { this.weapon = wep; }
private static bool WeaponIsValid(INinjaWeapon weapon, Mobile from) { Item item = weapon as Item; if (!item.Deleted && item.RootParent == from) { return true; } return false; }
public UnloadEntry(INinjaWeapon belt) : base(6223, 0) { weapon = belt; Enabled = (weapon.UsesRemaining > 0); }
private static void ConsumeUse(INinjaWeapon weapon) { if (weapon.UsesRemaining > 0) { weapon.UsesRemaining--; if (weapon.UsesRemaining < 1) { weapon.PoisonCharges = 0; weapon.Poison = null; } } }
private static bool WeaponIsValid(INinjaWeapon weapon, Mobile from) => weapon is Item item && !item.Deleted && item.RootParent == from;
private static bool WeaponIsValid(INinjaWeapon weapon, Mobile from) { Item item = weapon as Item; return(!item.Deleted && item.RootParent == from); }
public LoadEntry(INinjaWeapon wep) : base(6222, 0) { weapon = wep; }
public UnloadEntry(INinjaWeapon wep, int entry) : base(entry, 0) { weapon = wep; Enabled = (weapon.UsesRemaining > 0); }
private static bool CanUseWeapon(PlayerMobile from, INinjaWeapon weapon) { if (WeaponIsValid(weapon, from)) { if (weapon.UsesRemaining > 0) { if (!from.NinjaWepCooldown) { if (BasePotion.HasFreeHand(from)) { return true; } else { from.SendLocalizedMessage(weapon.NoFreeHandMessage); } } else { from.SendLocalizedMessage(weapon.RecentlyUsedMessage); } } else { from.SendLocalizedMessage(weapon.EmptyWeaponMessage); } } return false; }
private static void Reload(PlayerMobile from, INinjaWeapon weapon, INinjaAmmo ammo) { if (weapon.UsesRemaining < MaxUses) { int need = Math.Min((MaxUses - weapon.UsesRemaining), ammo.UsesRemaining); if (need > 0) { if (weapon.Poison != null && (ammo.Poison == null || weapon.Poison.Level > ammo.Poison.Level)) { from.SendLocalizedMessage(1070767); // Loaded projectile is stronger, unload it first } else { if (weapon.UsesRemaining > 0) { if ((weapon.Poison == null && ammo.Poison != null) || ((weapon.Poison != null && ammo.Poison != null) && weapon.Poison.Level != ammo.Poison.Level)) { Unload(from, weapon); need = Math.Min(MaxUses, ammo.UsesRemaining); } } int poisonneeded = Math.Min((MaxUses - weapon.PoisonCharges), ammo.PoisonCharges); weapon.UsesRemaining += need; weapon.PoisonCharges += poisonneeded; if (weapon.PoisonCharges > 0) { weapon.Poison = ammo.Poison; } ammo.PoisonCharges -= poisonneeded; ammo.UsesRemaining -= need; if (ammo.UsesRemaining < 1) { ((Item)ammo).Delete(); } else if (ammo.PoisonCharges < 1) { ammo.Poison = null; } } }// "else" here would mean they targeted "ammo" with 0 uses. undefined behavior. } else { from.SendLocalizedMessage(weapon.FullWeaponMessage); } }
public LoadEntry(INinjaWeapon wep, int entry) : base(entry, 0) { weapon = wep; }