public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker) || (Contexts != null && Contexts.Any(c => c.Attacker == attacker))) { return; } ClearCurrentAbility(attacker); Map map = attacker.Map; if (map == null) { return; } BaseWeapon weapon = attacker.Weapon as BaseWeapon; if (weapon == null) { return; } if (!CheckMana(attacker, true)) { return; } attacker.FixedEffect(0x3728, 10, 15); attacker.PlaySound(0x2A1); System.Collections.Generic.List <Mobile> list = SpellHelper.AcquireIndirectTargets(attacker, attacker, attacker.Map, 1) .OfType <Mobile>() .Where(m => attacker.InRange(m, weapon.MaxRange) && m != defender).ToList(); int count = list.Count; if (count > 0) { double bushido = attacker.Skills.Bushido.Value; int bonus = 0; if (bushido > 0) { bonus = (int)Math.Min(100, ((list.Count * bushido) * (list.Count * bushido)) / 3600); } var context = new WhirlwindAttackContext(attacker, list, bonus); AddContext(context); attacker.RevealingAction(); foreach (Mobile m in list) { attacker.SendLocalizedMessage(1060161); // The whirling attack strikes a target! m.SendLocalizedMessage(1060162); // You are struck by the whirling attack and take damage! weapon.OnHit(attacker, m); } RemoveContext(context); } ColUtility.Free(list); weapon.ProcessingMultipleHits = false; }
private void AssignInstancedLoot(IEnumerable <Item> items) { if (m_Aggressors.Count == 0 || Items.Count == 0) { return; } if (m_InstancedItems == null) { m_InstancedItems = new Dictionary <Item, InstancedItemInfo>(); } List <Item> stackables = new List <Item>(); List <Item> unstackables = new List <Item>(); foreach (Item item in items) { if (!m_InstancedItems.ContainsKey(item) && item.LootType != LootType.Cursed) // Don't have cursed items take up someone's item spot..(?) { if (item.Stackable) { stackables.Add(item); } else { unstackables.Add(item); } } } List <Mobile> attackers = new List <Mobile>(m_Aggressors); for (int i = 1; i < attackers.Count - 1; i++) //randomize { int rand = Utility.Random(i + 1); Mobile temp = attackers[rand]; attackers[rand] = attackers[i]; attackers[i] = temp; } //stackables first, for the remaining stackables, have those be randomly added after for (int i = 0; i < stackables.Count; i++) { Item item = stackables[i]; if (item.Amount >= attackers.Count) { int amountPerAttacker = item.Amount / attackers.Count; int remainder = item.Amount % attackers.Count; for (int j = 0; j < (remainder == 0 ? attackers.Count - 1 : attackers.Count); j++) { Item splitItem = Mobile.LiftItemDupe(item, item.Amount - amountPerAttacker); //LiftItemDupe automagically adds it as a child item to the corpse if (!m_InstancedItems.ContainsKey(splitItem)) { m_InstancedItems.Add(splitItem, new InstancedItemInfo(splitItem, attackers[j])); } //What happens to the remaining portion? TEMP FOR NOW UNTIL OSI VERIFICATION: Treat as Single Item. } if (remainder == 0) { if (!m_InstancedItems.ContainsKey(item)) { m_InstancedItems.Add(item, new InstancedItemInfo(item, attackers[attackers.Count - 1])); } //Add in the original item (which has an equal amount as the others) to the instance for the last attacker, cause it wasn't added above. } else { unstackables.Add(item); } } else { //What happens in this case? TEMP FOR NOW UNTIL OSI VERIFICATION: Treat as Single Item. unstackables.Add(item); } } for (int i = 0; i < unstackables.Count; i++) { Mobile m = attackers[i % attackers.Count]; Item item = unstackables[i]; if (!m_InstancedItems.ContainsKey(item)) { m_InstancedItems.Add(item, new InstancedItemInfo(item, m)); } } ColUtility.Free(stackables); ColUtility.Free(unstackables); }
private void CombineCloth(Mobile m, CraftItem craftItem, ITool tool) { PlayCraftEffect(m); Timer.DelayCall(TimeSpan.FromSeconds(Delay), () => { if (m.Backpack == null) { m.SendGump(new CraftGump(m, this, tool, null)); } Container pack = m.Backpack; Dictionary <int, int> cloth = new Dictionary <int, int>(); List <Item> toConsume = new List <Item>(); object num = null; foreach (var item in pack.Items) { Type t = item.GetType(); if (t == typeof(UncutCloth) || t == typeof(Cloth) || t == typeof(CutUpCloth)) { if (!cloth.ContainsKey(item.Hue)) { toConsume.Add(item); cloth[item.Hue] = item.Amount; } else { toConsume.Add(item); cloth[item.Hue] += item.Amount; } } } if (cloth.Count == 0) { num = 1044253; // You don't have the components needed to make that. } else { foreach (var item in toConsume) { item.Delete(); } foreach (var kvp in cloth) { var c = new UncutCloth(kvp.Value); c.Hue = kvp.Key; DropItem(m, c, tool); } } if (tool != null) { tool.UsesRemaining--; if (tool.UsesRemaining <= 0 && !tool.Deleted) { tool.Delete(); m.SendLocalizedMessage(1044038); } else { m.SendGump(new CraftGump(m, this, tool, num)); } } ColUtility.Free(toConsume); cloth.Clear(); }); }
public Target[] AcquireTarget() { AmmoInfo ammo = AmmoInfo.GetAmmoInfo(AmmoType); int xOffset = 0; int yOffset = 0; int currentRange = 0; Point3D pnt = Location; Map map = Map; switch (GetFacing()) { case Direction.North: xOffset = 0; yOffset = -1; break; case Direction.South: xOffset = 0; yOffset = 1; break; case Direction.West: xOffset = -1; yOffset = 0; break; case Direction.East: xOffset = 1; yOffset = 0; break; } int xo = xOffset; int yo = yOffset; int lateralOffset = 1; while (currentRange++ <= Range) { xOffset = xo; yOffset = yo; if (LateralOffset > 1 && currentRange % LateralOffset == 0) { lateralOffset++; } TimeSpan delay = TimeSpan.FromSeconds(currentRange / 10.0); switch (AmmoType) { case AmmunitionType.Empty: break; case AmmunitionType.Cannonball: case AmmunitionType.FrostCannonball: case AmmunitionType.FlameCannonball: { Point3D newPoint = pnt; //List<IEntity> list = new List<IEntity>(); for (int i = -lateralOffset; i <= lateralOffset; i++) { if (xOffset == 0) { newPoint = new Point3D(pnt.X + (xOffset + i), pnt.Y + (yOffset * currentRange), pnt.Z); } else { newPoint = new Point3D(pnt.X + (xOffset * currentRange), pnt.Y + (yOffset + i), pnt.Z); } BaseGalleon g = FindValidBoatTarget(newPoint, map, ammo); if (g != null && g.DamageTaken < DamageLevel.Severely && g.Owner is PlayerMobile) { Target target = new Target(); target.Entity = g; target.Location = newPoint; target.Range = currentRange; return(new Target[] { target }); } } } break; case AmmunitionType.Grapeshot: { Point3D newPoint = pnt; List <Target> mobiles = new List <Target>(); for (int i = -lateralOffset; i <= lateralOffset; i++) { if (xOffset == 0) { newPoint = new Point3D(pnt.X + (xOffset + i), pnt.Y + (yOffset * currentRange), pnt.Z); } else { newPoint = new Point3D(pnt.X + (xOffset * currentRange), pnt.Y + (yOffset + i), pnt.Z); } foreach (Mobile m in GetTargets(newPoint, map)) { Target target = new Target(); target.Entity = m; target.Location = newPoint; target.Range = currentRange; mobiles.Add(target); } if (mobiles.Count > 0 && ammo.SingleTarget) { Target toHit = mobiles[Utility.Random(mobiles.Count)]; ColUtility.Free(mobiles); return(new Target[] { toHit }); } } if (mobiles.Count > 0) { return(mobiles.ToArray()); } } break; } } return(null); }
public override void OnResponse(RelayInfo info) { var id = info.ButtonID; if (id == 0) { ReleaseHidden(User); return; } var profile = UltimaStore.GetProfile(User); switch (id) { // Change Category case 100: case 101: case 102: case 103: case 104: case 105: { Search = false; var oldCat = profile.Category; profile.Category = (StoreCategory)id - 99; if (oldCat != profile.Category) { StoreList = UltimaStore.GetList(Category); Page = 0; } Refresh(); return; } // Promo Code case 106: { Refresh(); SendGump(new PromoCodeGump(User, this)); return; } // FAQ case 107: { if (!string.IsNullOrWhiteSpace(Configuration.Website)) { User.LaunchBrowser(Configuration.Website); } else { User.LaunchBrowser("https://uo.com/ultima-store/"); } Refresh(); return; } // Change Sort Method case 108: case 109: case 110: case 111: case 112: { var oldSort = profile.SortBy; profile.SortBy = (SortBy)id - 108; if (oldSort != profile.SortBy) { // re-orders the list if (oldSort == SortBy.Newest || oldSort == SortBy.Oldest) { ColUtility.Free(StoreList); StoreList = UltimaStore.GetList(Category); } UltimaStore.SortList(StoreList, profile.SortBy); Page = 0; } Refresh(); return; } // Cart View case 113: { if (profile != null) { profile.Category = StoreCategory.Cart; } Refresh(); return; } // Search case 114: { var searchTxt = info.GetTextEntry(0); if (searchTxt != null && !string.IsNullOrEmpty(searchTxt.Text)) { Search = true; SearchText = searchTxt.Text; } else { User.SendLocalizedMessage(1150315); // That text is unacceptable. } Refresh(); return; } // Buy case 115: { if (UltimaStore.CartCount(User) == 0) { if (profile != null) { profile.Category = StoreCategory.Cart; } Refresh(); return; } int total = UltimaStore.GetSubTotal(Cart); if (total <= UltimaStore.GetCurrency(User, true)) { SendGump(new ConfirmPurchaseGump(User)); } else { SendGump(new NoFundsGump(User)); } return; } // Next Page case 116: { ++Page; Refresh(); return; } // Previous Page case 117: { --Page; Refresh(); return; } } if (id < 2000) // Add To Cart { Refresh(); var entry = StoreList[id - 1000]; if (Cart == null || Cart.Count < 10) { SendGump(new ConfirmCartGump(User, this, entry)); return; } User.SendLocalizedMessage(1156745); // Your store cart is currently full. } else if (id < 3000) // Change Amount In Cart { Refresh(); var entry = UltimaStore.Entries[id - 2000]; SendGump(new ConfirmCartGump(User, this, entry, Cart != null && Cart.ContainsKey(entry) ? Cart[entry] : 0)); return; } else if (id < 4000) // Remove From Cart { var entry = UltimaStore.Entries[id - 3000]; if (profile != null) { profile.RemoveFromCart(entry); } Refresh(); return; } ReleaseHidden(User); }
public void HandlePlayerDeath(PlayerMobile victim) { VvVPlayerEntry ventry = GetPlayerEntry <VvVPlayerEntry>(victim); if (ventry != null && ventry.Active) { List <DamageEntry> list = victim.DamageEntries.OrderBy(d => - d.DamageGiven).ToList(); List <Mobile> handled = new List <Mobile>(); bool statloss = false; for (int i = 0; i < list.Count; i++) { Mobile dam = list[i].Damager; if (dam == victim || dam == null) { continue; } if (dam is BaseCreature && ((BaseCreature)dam).GetMaster() is PlayerMobile) { dam = ((BaseCreature)dam).GetMaster(); } bool isEnemy = IsEnemy(victim, dam); if (isEnemy) { VvVPlayerEntry kentry = GetPlayerEntry <VvVPlayerEntry>(dam); if (kentry != null && kentry.Active && !handled.Contains(dam)) { if (Battle.IsInActiveBattle(dam, victim)) { if (i == 0) { Battle.Update(ventry, kentry, UpdateType.Kill); } else { Battle.Update(ventry, kentry, UpdateType.Assist); } } handled.Add(dam); kentry.TotalKills++; if (EnhancedRules && kentry != null) { kentry.AwardSilver(victim); } } if (!handled.Contains(victim)) { ventry.TotalDeaths++; handled.Add(victim); } } if (!statloss && isEnemy) { statloss = true; } } if (statloss) { ApplySkillLoss(victim); } ColUtility.Free(list); ColUtility.Free(handled); } }
public ShadowguardInstance GetAvailableInstance(EncounterType type) { if (RandomInstances) { List <ShadowguardInstance> instances; if (type == EncounterType.Roof) { instances = new List <ShadowguardInstance>(); for (var index = 0; index < Instances.Count; index++) { var e = Instances[index]; if (e.IsRoof && !e.InUse) { instances.Add(e); } } } else { instances = new List <ShadowguardInstance>(); for (var index = 0; index < Instances.Count; index++) { var e = Instances[index]; if (!e.IsRoof && !e.InUse) { instances.Add(e); } } } ShadowguardInstance inst = null; if (instances.Count > 0) { inst = instances[Utility.Random(instances.Count)]; } ColUtility.Free(instances); return(inst); } if (type == EncounterType.Roof) { for (var index = 0; index < Instances.Count; index++) { var e = Instances[index]; if (e.IsRoof && !e.InUse) { return(e); } } return(null); } for (var index = 0; index < Instances.Count; index++) { var e = Instances[index]; if (!e.IsRoof && !e.InUse) { return(e); } } return(null); }
public override void ClearItems() { if (Armor != null) { List <Item> list = new List <Item>(Armor.Where(i => i != null && !i.Deleted)); foreach (Item armor in list) { armor.Delete(); } ColUtility.Free(list); ColUtility.Free(Armor); Armor = null; } if (DestroyedArmor != null) { List <Item> list = new List <Item>(DestroyedArmor.Where(i => i != null && !i.Deleted)); foreach (Item dest in list) { dest.Delete(); } ColUtility.Free(list); ColUtility.Free(DestroyedArmor); DestroyedArmor = null; } if (Spawn != null) { List <BaseCreature> list = new List <BaseCreature>(Spawn.Where(s => s != null && !s.Deleted)); foreach (BaseCreature spawn in list) { spawn.Delete(); } ColUtility.Free(list); ColUtility.Free(Spawn); Spawn = null; } if (Items != null) { List <Item> list = new List <Item>(Items.Where(i => i != null && !i.Deleted)); foreach (Item item in list) { item.Delete(); } ColUtility.Free(list); ColUtility.Free(Items); Items = null; } }
private void HandleResponse(Mobile from, string text) { int amount = Utility.ToInt32(text); if (amount <= 0) { from.SendLocalizedMessage(1073181); // That is not a valid donation quantity. return; } if (from.Backpack == null) { return; } if (m_Selected.Type == typeof(Gold)) { if (amount * m_Selected.Points < 1) { from.SendLocalizedMessage(1073167); // You do not have enough of that item to make a donation! from.SendGump(new CommunityCollectionGump((PlayerMobile)from, m_Collection, m_Location)); return; } Item[] items = from.Backpack.FindItemsByType(m_Selected.Type, true); Account acct = from.Account as Account; int goldcount = 0; int accountcount = acct == null ? 0 : acct.TotalGold; int amountRemaining = amount; foreach (Item item in items) { goldcount += item.Amount; } if (goldcount >= amountRemaining) { foreach (Item item in items) { if (item.Amount <= amountRemaining) { item.Delete(); amountRemaining -= item.Amount; } else { item.Amount -= amountRemaining; amountRemaining = 0; } if (amountRemaining == 0) { break; } } } else if (goldcount + accountcount >= amountRemaining) { foreach (Item item in items) { amountRemaining -= item.Amount; item.Delete(); } Banker.Withdraw(from, amountRemaining); } else { from.SendLocalizedMessage(1073182); // You do not have enough to make a donation of that magnitude! from.SendGump(new CommunityCollectionGump((PlayerMobile)from, m_Collection, m_Location)); return; } from.Backpack.ConsumeTotal(m_Selected.Type, amount, true, true); m_Collection.Donate((PlayerMobile)from, m_Selected, amount); } else { if (amount * m_Selected.Points < 1) { from.SendLocalizedMessage(1073167); // You do not have enough of that item to make a donation! from.SendGump(new CommunityCollectionGump((PlayerMobile)from, m_Collection, m_Location)); return; } List <Item> items = FindTypes((PlayerMobile)from, m_Selected); if (items.Count > 0) { // count items int count = 0; for (int i = 0; i < items.Count; i++) { Item item = GetActual(items[i]); if (item != null && !item.Deleted) { count += item.Amount; } } // check if (amount > count) { from.SendLocalizedMessage(1073182); // You do not have enough to make a donation of that magnitude! from.SendGump(new CommunityCollectionGump((PlayerMobile)from, m_Collection, m_Location)); return; } else if (amount * m_Selected.Points < 1) { from.SendLocalizedMessage(m_Selected.Type == typeof(Gold) ? 1073182 : 1073167); // You do not have enough of that item to make a donation! from.SendGump(new CommunityCollectionGump((PlayerMobile)from, m_Collection, m_Location)); return; } // donate int deleted = 0; for (int i = 0; i < items.Count && deleted < amount; i++) { Item item = GetActual(items[i]); if (item == null || item.Deleted) { continue; } if (item.Stackable && item.Amount + deleted > amount && !item.Deleted) { item.Amount -= amount - deleted; deleted += amount - deleted; } else if (!item.Deleted) { deleted += item.Amount; items[i].Delete(); } if (items[i] is CommodityDeed && !items[i].Deleted) { items[i].InvalidateProperties(); } } m_Collection.Donate((PlayerMobile)from, m_Selected, amount); } else { from.SendLocalizedMessage(1073182); // You do not have enough to make a donation of that magnitude! } ColUtility.Free(items); } }
public override void OnThink() { base.OnThink(); if (Combatant == null) { return; } if (_NextSpecial < DateTime.UtcNow) { _NextSpecial = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(45, 60)); switch (Utility.Random(Teleports ? 3 : 2)) { case 0: IPooledEnumerable eable = Map.GetMobilesInRange(Location, 10); foreach (Mobile m in eable) { if (m.Alive && m.AccessLevel == AccessLevel.Player && m is PlayerMobile && .75 > Utility.RandomDouble()) { DoDismount(m); } } eable.Free(); break; case 1: IPooledEnumerable eable2 = Map.GetMobilesInRange(Location, 10); List <Mobile> mobiles = new List <Mobile>(); foreach (Mobile m in eable2) { if (m.Alive && m.AccessLevel == AccessLevel.Player && m is PlayerMobile) { mobiles.Add(m); } } eable2.Free(); if (mobiles.Count > 0) { Mobile m = mobiles[Utility.Random(mobiles.Count)]; Point3D old2 = m.Location; Point3D p2 = _PlayerTeleList[Utility.Random(_PlayerTeleList.Length)]; m.MoveToWorld(p2, Map); m.ProcessDelta(); Effects.SendLocationParticles(EffectItem.Create(old2, Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 2023); Effects.SendLocationParticles(EffectItem.Create(p2, Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 5023); } ColUtility.Free(mobiles); break; case 2: int ran = -1; while (ran < 0 || ran > _TeleList.Length || ran == _LastTeleport) { ran = Utility.Random(_TeleList.Length); } _LastTeleport = ran; Point3D p = _TeleList[ran]; Point3D old = Location; MoveToWorld(p, Map); ProcessDelta(); Effects.SendLocationParticles(EffectItem.Create(old, Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 2023); Effects.SendLocationParticles(EffectItem.Create(p, Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 5023); break; } } else if (_NextBarrelThrow < DateTime.UtcNow && .25 > Utility.RandomDouble()) { _NextBarrelThrow = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(5, 10)); int barrel = CheckBarrel(); if (barrel >= 0) { IPooledEnumerable eable = Map.GetMobilesInRange(Location, 10); List <Mobile> mobiles = new List <Mobile>(); foreach (Mobile m in eable) { if (m.Alive && m.AccessLevel == AccessLevel.Player && m is PlayerMobile) { mobiles.Add(m); } } eable.Free(); if (mobiles.Count > 0) { Mobile m = mobiles[Utility.Random(mobiles.Count)]; DoHarmful(m); MovingParticles(m, barrel, 10, 0, false, true, 0, 0, 9502, 6014, 0x11D, EffectLayer.Waist, 0); Timer.DelayCall(TimeSpan.FromSeconds(1), () => { m.PlaySound(0x11D); AOS.Damage(m, this, Utility.RandomMinMax(70, 120), 100, 0, 0, 0, 0); }); } ColUtility.Free(mobiles); } } }
public void Target(IPoint3D p, Item item) { if (!Caster.CanSee(p)) { Caster.SendLocalizedMessage(500237); // Target can not be seen. } else if (SpellHelper.CheckTown(p, Caster) && (item != null || CheckSequence())) { if (item != null) { if (item is MaskOfKhalAnkur mask) { mask.Charges--; } if (item is PendantOfKhalAnkur pendant) { pendant.Charges--; } } SpellHelper.Turn(Caster, p); if (p is Item pItem) { p = pItem.GetWorldLocation(); } List <IDamageable> targets = new List <IDamageable>(); foreach (var target in AcquireIndirectTargets(p, 2)) { targets.Add(target); } int count = Math.Max(1, targets.Count); Effects.PlaySound(p, Caster.Map, 0x160); for (var index = 0; index < targets.Count; index++) { IDamageable id = targets[index]; Mobile m = id as Mobile; double damage = GetNewAosDamage(51, 1, 5, id is PlayerMobile, id); if (count > 2) { damage = (damage * 2) / count; } IDamageable source = Caster; IDamageable target = id; if (SpellHelper.CheckReflect(this, ref source, ref target)) { Timer.DelayCall(TimeSpan.FromSeconds(.5), () => { source.MovingParticles(target, item != null ? 0xA1ED : 0x36D4, 7, 0, false, true, 9501, 1, 0, 0x100); }); } if (m != null) { damage *= GetDamageScalar(m); } Caster.DoHarmful(id); SpellHelper.Damage(this, target, damage, 0, 100, 0, 0, 0); Caster.MovingParticles(id, item != null ? 0xA1ED : 0x36D4, 7, 0, false, true, 9501, 1, 0, 0x100); } ColUtility.Free(targets); } FinishSequence(); }
public void Deserialize(GenericReader reader) { int version = reader.ReadInt(); int count = reader.ReadInt(); for (int i = 0; i < count; i++) { ArenaStats stats = new ArenaStats(reader); if (stats.Owner != null) { SurvivalRankings.Add(stats); } } count = reader.ReadInt(); for (int i = 0; i < count; i++) { ArenaStats stats = new ArenaStats(reader); if (stats.Owner != null) { TeamRankings.Add(stats); } } count = reader.ReadInt(); for (int i = 0; i < count; i++) { Item blocker = reader.ReadItem(); if (blocker != null) { Blockers.Add(blocker); } } Stone = reader.ReadItem() as ArenaStone; Manager = reader.ReadMobile() as ArenaManager; Banner1 = reader.ReadItem() as ArenaExitBanner; Banner2 = reader.ReadItem() as ArenaExitBanner; count = reader.ReadInt(); for (int i = 0; i < count; i++) { ArenaDuel duel = new ArenaDuel(reader, this); DateTime dt = reader.ReadDeltaTime(); PendingDuels[duel] = dt; } count = reader.ReadInt(); for (int i = 0; i < count; i++) { BookedDuels.Add(new ArenaDuel(reader, this)); } if (reader.ReadInt() == 1) { CurrentDuel = new ArenaDuel(reader, this); } if (Stone != null) { Stone.Arena = this; } if (Manager != null) { Manager.Arena = this; } if (Banner1 != null) { Banner1.Arena = this; } if (Banner2 != null) { Banner2.Arena = this; } if (version == 0) { foreach (var blocker in Blockers) { blocker?.Delete(); } ColUtility.Free(Blockers); } }
public virtual void OnShipHit(object obj) { object[] list = (object[])obj; BaseBoat target = list[0] as BaseBoat; Point3D pnt = (Point3D)list[1]; AmmoInfo ammoInfo = AmmoInfo.GetAmmoInfo((AmmunitionType)list[2]); if (ammoInfo != null && target != null) { int damage = (Utility.RandomMinMax(ammoInfo.MinDamage, ammoInfo.MaxDamage)); damage /= 7; target.OnTakenDamage(Operator, damage); int z = target.ZSurface; if (target.TillerMan != null && target.TillerMan is IEntity) { z = ((IEntity)target.TillerMan).Z; } Direction d = Utility.GetDirection(this, pnt); int xOffset = 0; int yOffset = 0; Point3D hit = pnt; if (!ammoInfo.RequiresSurface) { switch (d) { default: case Direction.North: xOffset = Utility.RandomMinMax(-1, 1); yOffset = Utility.RandomMinMax(-2, 0); hit = new Point3D(pnt.X + xOffset, pnt.Y + yOffset, z); break; case Direction.South: xOffset = Utility.RandomMinMax(-1, 1); yOffset = Utility.RandomMinMax(0, 2); hit = new Point3D(pnt.X + xOffset, pnt.Y + yOffset, z); break; case Direction.East: xOffset = Utility.RandomMinMax(0, 2); yOffset = Utility.RandomMinMax(-1, 1); hit = new Point3D(pnt.X + xOffset, pnt.Y + yOffset, z); break; case Direction.West: xOffset = Utility.RandomMinMax(-2, 0); yOffset = Utility.RandomMinMax(-1, 1); hit = new Point3D(pnt.X + xOffset, pnt.Y + yOffset, z); break; } } Effects.SendLocationEffect(hit, target.Map, Utility.RandomBool() ? 14000 : 14013, 15, 10); Effects.PlaySound(hit, target.Map, 0x207); if (Operator != null && (!Operator.Deleted || CanFireUnmanned)) { Mobile victim = target.Owner; if (victim != null && target.Contains(victim) && Operator.CanBeHarmful(victim, false)) { Operator.DoHarmful(victim); } else { List <Mobile> candidates = new List <Mobile>(); SecurityLevel highest = SecurityLevel.Passenger; foreach (PlayerMobile mob in target.MobilesOnBoard.OfType <PlayerMobile>().Where(pm => Operator.CanBeHarmful(pm, false))) { if (target is BaseGalleon && ((BaseGalleon)target).GetSecurityLevel(mob) > highest) { candidates.Insert(0, mob); } else { candidates.Add(mob); } } if (candidates.Count > 0) { Operator.DoHarmful(candidates[0]); } else if (victim != null && Operator.IsHarmfulCriminal(victim)) { Operator.CriminalAction(false); } ColUtility.Free(candidates); } } } }
public static void CheckDrop(BaseCreature bc, Container c) { if (m_IngredientTable != null) { for (var index = 0; index < m_IngredientTable.Count; index++) { IngredientDropEntry entry = m_IngredientTable[index]; if (entry == null) { continue; } if (entry.Region != null) { string reg = entry.Region; if (reg == "TerMur" && c.Map != Map.TerMur) { continue; } if (reg == "Abyss" && (c.Map != Map.TerMur || c.X < 235 || c.X > 1155 || c.Y < 40 || c.Y > 1040)) { continue; } if (reg != "TerMur" && reg != "Abyss") { Region r = Server.Region.Find(c.Location, c.Map); if (r == null || !r.IsPartOf(entry.Region)) { continue; } } } if (bc.GetType() != entry.CreatureType && !bc.GetType().IsSubclassOf(entry.CreatureType)) { continue; } double toBeat = entry.Chance; List <Item> drops = new List <Item>(); if (bc is BaseVoidCreature creature) { toBeat *= creature.Stage + 1; } if (entry.DropMultiples) { for (var i = 0; i < entry.Ingredients.Length; i++) { Type type = entry.Ingredients[i]; if (toBeat >= Utility.RandomDouble()) { Item drop = Loot.Construct(type); if (drop != null) { drops.Add(drop); } } } } else if (toBeat >= Utility.RandomDouble()) { Item drop = Loot.Construct(entry.Ingredients); if (drop != null) { drops.Add(drop); } } for (var i = 0; i < drops.Count; i++) { Item item = drops[i]; c.DropItem(item); } ColUtility.Free(drops); } } }
public void CheckQueue() { if (Queue.Count == 0) { return; } bool message = false; List <Mobile> copy = new List <Mobile>(Queue.Keys); for (int i = 0; i < copy.Count; i++) { Mobile m = copy[i]; if (m.Map != Map.TerMur || m.NetState == null) { RemoveFromQueue(m); if (i == 0) { message = true; } continue; } for (var index = 0; index < Encounters.Count; index++) { ShadowguardEncounter inst = Encounters[index]; if (inst.PartyLeader == m) { if (i == 0) { message = true; } RemoveFromQueue(m); } } if (Queue.Count > 0) { message = true; Timer.DelayCall(TimeSpan.FromMinutes(2), mobile => { if (Queue.ContainsKey(m)) { EncounterType type = Queue[m]; ShadowguardInstance instance = GetAvailableInstance(type); if (instance != null && instance.TryBeginEncounter(m, true, type)) { RemoveFromQueue(m); } } }, m); } break; } ColUtility.Free(copy); if (message && Queue.Count > 0) { ColUtility.For(Queue.Keys, (i, mob) => { Party p = Party.Get(mob); if (p != null) { for (var index = 0; index < p.Members.Count; index++) { var info = p.Members[index]; info.Mobile.SendLocalizedMessage(1156190, i + 1 > 1 ? i.ToString() : "next"); } } //A Shadowguard encounter has opened. You are currently ~1_NUM~ in the //queue. If you are next, you may proceed to the entry stone to join. else { mob.SendLocalizedMessage(1156190, i + 1 > 1 ? i.ToString() : "next"); } }); } }
public override void Setup() { Armor = new List <Item>(); DestroyedArmor = new List <Item>(); Spawn = new List <BaseCreature>(); Items = new List <Item>(); int toSpawn = 1 + (PartySize() * 2); ColUtility.For(SpawnPoints, (i, p) => { ConvertOffset(ref p); var armor = new CursedSuitOfArmor(this); armor.MoveToWorld(p, Map.TerMur); Armor.Add(armor); if (i > 13) { armor.ItemID = 0x1512; } }); for (int i = 0; i < toSpawn; i++) { SpawnRandom(); } Item item = new Static(3633); Point3D pnt = new Point3D(-4, 2, 0); ConvertOffset(ref pnt); item.MoveToWorld(pnt, Map.TerMur); Items.Add(item); item = new Static(3633); pnt = new Point3D(-4, -4, 0); ConvertOffset(ref pnt); item.MoveToWorld(pnt, Map.TerMur); Items.Add(item); item = new Static(3633); pnt = new Point3D(2, -4, 0); ConvertOffset(ref pnt); item.MoveToWorld(pnt, Map.TerMur); Items.Add(item); item = new PurifyingFlames(); pnt = new Point3D(-4, 2, 8); ConvertOffset(ref pnt); item.MoveToWorld(pnt, Map.TerMur); Items.Add(item); item = new PurifyingFlames(); pnt = new Point3D(-4, -4, 8); ConvertOffset(ref pnt); item.MoveToWorld(pnt, Map.TerMur); Items.Add(item); item = new PurifyingFlames(); pnt = new Point3D(2, -4, 8); ConvertOffset(ref pnt); item.MoveToWorld(pnt, Map.TerMur); Items.Add(item); }
public override void Delete() { base.Delete(); EndTimer(); if (Encounters != null) { for (var index = 0; index < Encounters.Count; index++) { var e = Encounters[index]; e.Reset(); } ColUtility.Free(Encounters); Encounters = null; } if (Addons != null) { Addons.IterateReverse(addon => { addon.Delete(); }); ColUtility.Free(Addons); Addons = null; } if (Instances != null) { for (var index = 0; index < Instances.Count; index++) { var inst = Instances[index]; if (inst.Region != null) { inst.ClearRegion(); inst.Region.Unregister(); } } ColUtility.Free(Instances); Instances = null; } if (Queue != null) { Queue.Clear(); Queue = null; } if (Table != null) { Table.Clear(); Table = null; } Instance = null; }
private void OnTick() { if (m_NextBossEncounter == DateTime.MinValue || m_NextBossEncounter > DateTime.UtcNow) { return; } int good = GetArmyPower(Alignment.Good); int evil = GetArmyPower(Alignment.Evil); Alignment strongest = Alignment.Neutral; if (good == 0 && evil == 0) { m_NextBossEncounter = DateTime.UtcNow + EncounterCheckDuration; } else { if (good > evil) { strongest = Alignment.Good; } else if (good < evil) { strongest = Alignment.Evil; } else { strongest = 0.5 > Utility.RandomDouble() ? Alignment.Good : Alignment.Evil; } } List <Mobile> players = new List <Mobile>(); players.AddRange(m_GoodRegion.GetPlayers()); players.AddRange(m_EvilRegion.GetPlayers()); players.AddRange(m_StartRegion.GetPlayers()); foreach (Mobile m in players) { if (!m.Player) { continue; } WispOrb orb = GetWispOrb(m); m.PlaySound(0x66C); if (orb == null || orb.Alignment != strongest) { m.SendLocalizedMessage(strongest != Alignment.Neutral ? 1153334 : 1153333); // The Call to Arms has sounded, but your forces are not yet strong enough to heed it. // Your enemy forces are stronger, and they have been called to battle. } else if (orb != null && orb.Alignment == strongest) { m.SendLocalizedMessage(1153332); // The Call to Arms has sounded. The forces of your alignment are strong, and you have been called to battle! if (orb.Conscripted) { m.SendLocalizedMessage(1153337); // You will be teleported into the depths of the dungeon within 60 seconds to heed the Call to Arms, unless you release your conscripted creature or it dies. m_ToTransport.Add(m); } else { m.SendLocalizedMessage(1153338); // You have under 60 seconds to conscript a creature to answer the Call to Arms, or you will not be summoned for the battle. } } } if (strongest != Alignment.Neutral) { ColUtility.Free(players); m_SequenceAlignment = strongest; Timer.DelayCall(TimeSpan.FromSeconds(60), new TimerCallback(BeginSequence)); m_NextBossEncounter = DateTime.MinValue; m_Sequencing = true; } }
public override void AddGumpLayout() { base.AddGumpLayout(); var list = new List <TownCryerGreetingEntry>(TownCryerSystem.GreetingsEntries); list.Sort(); Entry = list[0]; if (Page >= 0 && Page < list.Count) { Entry = list[Page]; } int y = 150; if (Entry.Title != null) { if (Entry.Title.Number > 0) { AddHtmlLocalized(78, y, 700, 400, Entry.Title.Number, false, false); } else { AddHtml(78, y, 700, 400, Entry.Title.ToString(), false, false); } y += 40; } // For now, we're only supporting a cliloc (hard coded greetings per EA) or string (Custom) entries. Not both. // Html tags will needed to be added when creating the entry, this will not auto format it for you. if (Entry.Body1.Number > 0) { AddHtmlLocalized(78, y, 700, 400, Entry.Body1.Number, false, false); } else if (!String.IsNullOrEmpty(Entry.Body1.String)) { var str = Entry.Body1.String; if (!String.IsNullOrEmpty(Entry.Body2)) { if (!str.EndsWith("<br>")) { str += " "; } str += Entry.Body2; } if (!String.IsNullOrEmpty(Entry.Body3)) { if (!str.EndsWith("<br>")) { str += " "; } str += Entry.Body3; } AddHtml(78, y, 700, 400, str, false, false); } if (Entry.Expires != DateTime.MinValue) { AddHtmlLocalized(50, 550, 200, 20, 1060658, String.Format("{0}\t{1}", "Created", Entry.Created.ToShortDateString()), 0, false, false); AddHtmlLocalized(50, 570, 200, 20, 1060659, String.Format("{0}\t{1}", "Expires", Entry.Expires.ToShortDateString()), 0, false, false); } AddButton(350, 570, 0x605, 0x606, 1, GumpButtonType.Reply, 0); AddButton(380, 570, 0x609, 0x60A, 2, GumpButtonType.Reply, 0); AddButton(430, 570, 0x607, 0x608, 3, GumpButtonType.Reply, 0); AddButton(455, 570, 0x603, 0x604, 4, GumpButtonType.Reply, 0); AddHtml(395, 570, 35, 20, Center(String.Format("{0}/{1}", (Page + 1).ToString(), Pages.ToString())), false, false); AddButton(525, 625, 0x5FF, 0x600, 5, GumpButtonType.Reply, 0); AddHtmlLocalized(550, 625, 300, 20, 1158386, false, false); // Close and do not show this version again if (Entry.Link != null) { if (!string.IsNullOrEmpty(Entry.LinkText)) { AddHtml(50, 490, 745, 40, String.Format("<a href=\"{0}\">{1}</a>", Entry.Link, Entry.LinkText), false, false); } else { AddHtml(50, 490, 745, 40, String.Format("<a href=\"{0}\">{1}</a>", Entry.Link, Entry.Link), false, false); } } /*if (TownCryerSystem.HasCustomEntries()) * { * AddButton(40, 615, 0x603, 0x604, 6, GumpButtonType.Reply, 0); * AddHtmlLocalized(68, 615, 300, 20, 1060660, String.Format("{0}\t{1}", "Sort By", Sort.ToString()), 0, false, false); * }*/ if (User.AccessLevel >= AccessLevel.Administrator) { if (Entry.CanEdit) { AddButton(40, 601, 0x603, 0x604, 7, GumpButtonType.Reply, 0); AddHtml(68, 601, 300, 20, "Edit Greeting", false, false); } AddButton(40, 623, 0x603, 0x604, 8, GumpButtonType.Reply, 0); AddHtml(68, 623, 300, 20, "New Greeting", false, false); AddButton(40, 645, 0x603, 0x604, 9, GumpButtonType.Reply, 0); AddHtml(68, 645, 300, 20, "Entry Props", false, false); } ColUtility.Free(list); }
public override void OnDispose() { ColUtility.Free(StoreList); StoreList = null; }
public virtual void Fill() { Reset(); List <Item> contains = new List <Item>(Items); foreach (var i in contains) { i.Delete(); } ColUtility.Free(contains); for (int i = 0; i < Utility.RandomMinMax(6, 12); i++) { DropItem(Loot.RandomGem()); } DropItem(new Gold(Utility.RandomMinMax(800, 1100))); Item item = null; if (0.30 > Utility.RandomDouble()) { switch (Utility.Random(7)) { case 0: item = new Bandage(Utility.Random(10, 30)); break; case 1: item = new SmokeBomb(); item.Amount = Utility.Random(3, 6); break; case 2: item = new InvisibilityPotion(); item.Amount = Utility.Random(1, 3); break; case 3: item = new Lockpick(Utility.Random(1, 10)); break; case 4: item = new DreadHornMane(Utility.Random(1, 2)); break; case 5: item = new Corruption(Utility.Random(1, 2)); break; case 6: item = new Taint(Utility.Random(1, 2)); break; } DropItem(item); } if (0.25 > Utility.RandomDouble()) { DropItem(new CounterfeitPlatinum()); } if (0.2 > Utility.RandomDouble()) { switch (Utility.Random(3)) { case 0: item = new ZombiePainting(); break; case 1: item = new SkeletonPortrait(); break; case 2: item = new LichPainting(); break; } DropItem(item); } if (0.1 > Utility.RandomDouble()) { item = Loot.RandomArmorOrShieldOrWeaponOrJewelry(LootPackEntry.IsInTokuno(this), LootPackEntry.IsMondain(this), LootPackEntry.IsStygian(this)); if (item != null) { int min, max; TreasureMapChest.GetRandomItemStat(out min, out max, 1.0); RunicReforging.GenerateRandomItem(item, null, Utility.RandomMinMax(min, max), 0, ReforgedPrefix.None, ReforgedSuffix.Khaldun, Map); DropItem(item); } } }
public virtual void Fill() { Visible = false; Locked = true; TrapType = TrapType.MagicTrap; TrapPower = 100; List <Item> contains = new List <Item>(this.Items); foreach (var item in contains) { item.Delete(); } ColUtility.Free(contains); for (int i = 0; i < Utility.RandomMinMax(6, 12); i++) { DropItem(Loot.RandomGem()); } DropItem(new Gold(Utility.RandomMinMax(800, 1100))); if (0.1 > Utility.RandomDouble()) { DropItem(new StasisChamberPowerCore()); } if (0.1 > Utility.RandomDouble()) { DropItem(new CardOfSemidar((CardOfSemidar.CardType)Utility.RandomMinMax(0, 5))); } if (0.25 > Utility.RandomDouble()) { DropItem(new InoperativeAutomatonHead()); } if (0.1 > Utility.RandomDouble() && Server.Engines.Points.PointsSystem.TreasuresOfKotlCity.Enabled) { Item item = Loot.RandomArmorOrShieldOrWeaponOrJewelry(LootPackEntry.IsInTokuno(this), LootPackEntry.IsMondain(this), LootPackEntry.IsStygian(this)); if (item != null) { int min, max; TreasureMapChest.GetRandomItemStat(out min, out max, 1.0); RunicReforging.GenerateRandomItem(item, null, Utility.RandomMinMax(min, max), 0, ReforgedPrefix.None, ReforgedSuffix.Kotl, this.Map); DropItem(item); } } if (0.25 > Utility.RandomDouble()) { Item item; switch (Utility.Random(8)) { default: case 0: item = new JournalDrSpector1(); break; case 1: item = new JournalDrSpector2(); break; case 2: item = new JournalDrSpector3(); break; case 3: item = new JournalDrSpector4(); break; case 4: item = new HistoryOfTheGreatWok1(); break; case 5: item = new HistoryOfTheGreatWok2(); break; case 6: item = new HistoryOfTheGreatWok3(); break; case 7: item = new HistoryOfTheGreatWok4(); break; } DropItem(item); } }
public static void CheckDamage(Mobile attacker, Mobile defender, DamageType type, ref int damage) { if (defender is BaseCreature && (((BaseCreature)defender).Controlled || ((BaseCreature)defender).Summoned)) { CombatTrainingSpell spell = GetSpell <CombatTrainingSpell>(sp => sp.Target == defender); if (spell != null) { int storedDamage = damage; switch (spell.SpellType) { case TrainingType.Empowerment: break; case TrainingType.Berserk: if (InRageCooldown(defender)) { return; } if (spell.Phase > 1) { damage = damage - (int)((double)damage * spell.DamageMod); defender.FixedParticles(0x376A, 10, 30, 5052, 1261, 7, EffectLayer.LeftFoot, 0); } break; case TrainingType.ConsumeDamage: if (spell.Phase < 2) { defender.SendDamagePacket(attacker, damage); damage = 0; } break; case TrainingType.AsOne: if (((BaseCreature)defender).GetMaster() is PlayerMobile) { var pm = ((BaseCreature)defender).GetMaster() as PlayerMobile; var list = pm.AllFollowers.Where(m => (m == defender || m.InRange(defender.Location, 3)) && m.CanBeHarmful(attacker)).ToList(); if (list.Count > 0) { damage = damage / list.Count; foreach (var m in list.Where(mob => mob != defender)) { m.Damage(damage, attacker, true, false); } } ColUtility.Free(list); } return; } if (spell.Phase < 2) { if (spell.Phase != 1) { spell.Phase = 1; if (spell.SpellType != TrainingType.AsOne && (spell.SpellType != TrainingType.Berserk || !InRageCooldown(defender))) { Server.Timer.DelayCall(TimeSpan.FromSeconds(5), spell.EndPhase1); } } if (spell.DamageTaken == 0) { defender.FixedEffect(0x3779, 10, 30, 1743, 0); } spell.DamageTaken += storedDamage; } } } else if (attacker is BaseCreature && (((BaseCreature)attacker).Controlled || ((BaseCreature)attacker).Summoned)) { CombatTrainingSpell spell = GetSpell <CombatTrainingSpell>(sp => sp.Target == attacker); if (spell != null) { switch (spell.SpellType) { case TrainingType.Empowerment: if (spell.Phase > 1) { damage = damage + (int)((double)damage * spell.DamageMod); attacker.FixedParticles(0x376A, 10, 30, 5052, 1261, 7, EffectLayer.LeftFoot, 0); } break; case TrainingType.Berserk: case TrainingType.ConsumeDamage: case TrainingType.AsOne: break; } } } }
public void OnTarget(IPoint3D p) { if (SpellHelper.CheckTown(p, Caster) && CheckSequence()) { SpellHelper.Turn(Caster, p); SpellHelper.GetSurfaceTop(ref p); Map map = Caster.Map; if (map == null) { return; } Rectangle2D effectArea = new Rectangle2D(p.X - 3, p.Y - 3, 6, 6); Effects.PlaySound(p, map, 0x64F); for (int x = effectArea.X; x <= effectArea.X + effectArea.Width; x++) { for (int y = effectArea.Y; y <= effectArea.Y + effectArea.Height; y++) { if (x == effectArea.X && y == effectArea.Y || x >= effectArea.X + effectArea.Width - 1 && y >= effectArea.Y + effectArea.Height - 1 || y >= effectArea.Y + effectArea.Height - 1 && x == effectArea.X || y == effectArea.Y && x >= effectArea.X + effectArea.Width - 1) { continue; } IPoint3D pnt = new Point3D(x, y, p.Z); SpellHelper.GetSurfaceTop(ref pnt); Timer.DelayCall(TimeSpan.FromMilliseconds(Utility.RandomMinMax(100, 300)), point => { Effects.SendLocationEffect(point, map, 0x3779, 12, 11, 0x63, 0); }, new Point3D(pnt)); } } List <IDamageable> list = new List <IDamageable>(); foreach (var target in AcquireIndirectTargets(p, 2)) { list.Add(target); } int count = list.Count; for (var index = 0; index < list.Count; index++) { IDamageable id = list[index]; if (id.Deleted) { continue; } int damage = GetNewAosDamage(51, 1, 5, id is PlayerMobile, id); if (count > 2) { damage = (damage * 2) / count; } Caster.DoHarmful(id); SpellHelper.Damage(this, id, damage, 0, 0, 100, 0, 0); Effects.SendTargetParticles(id, 0x374A, 1, 15, 9502, 97, 3, (EffectLayer)255, 0); } ColUtility.Free(list); } FinishSequence(); }
public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker)) { return; } ClearCurrentAbility(attacker); Map map = attacker.Map; if (map == null) { return; } BaseWeapon weapon = attacker.Weapon as BaseWeapon; if (weapon == null) { return; } if (!CheckMana(attacker, true)) { return; } List <Mobile> targets = new List <Mobile>(); IPooledEnumerable eable = defender.GetMobilesInRange(5); foreach (Mobile m in eable) { if (m != defender && m != attacker && SpellHelper.ValidIndirectTarget(attacker, m)) { if (m == null || m.Deleted || m.Map != attacker.Map || !m.Alive || !attacker.CanSee(m) || !attacker.CanBeHarmful(m)) { continue; } if (!attacker.InRange(m, weapon.MaxRange) || !attacker.InLOS(m)) { continue; } targets.Add(m); } } eable.Free(); defender.BoltEffect(0); if (targets.Count > 0) { while (targets.Count > 2) { targets.Remove(targets[Utility.Random(targets.Count)]); } for (int i = 0; i < targets.Count; ++i) { Mobile m = targets[i]; m.BoltEffect(0); AOS.Damage(m, attacker, Utility.RandomMinMax(29, 40), 0, 0, 0, 0, 100); } } ColUtility.Free(targets); }