public BuriedBody(int level, string who, Mobile digger) : base(0xe40) { string sCorpse = ContainerFunctions.GetOwner("Body"); if (who != "" && who != null) { sCorpse = "bones"; switch (Utility.RandomMinMax(0, 3)) { case 0: sCorpse = "bones"; break; case 1: sCorpse = "body"; break; case 2: sCorpse = "skeletal remains"; break; case 3: sCorpse = "skeletal bones"; break; } sCorpse = "The " + sCorpse + " of " + who; } Name = sCorpse; Movable = true; Weight = 5; GumpID = 9; ItemID = 3786 + Utility.Random(8); ContainerFunctions.FillTheContainer(level, this, digger); if (level > 4) { ContainerFunctions.FillTheContainer(level, this, digger); } if (level > 8) { ContainerFunctions.FillTheContainer(level, this, digger); } if (GetPlayerInfo.LuckyPlayer(digger.Luck)) { ContainerFunctions.FillTheContainer(level, this, digger); } int xTraCash = Utility.RandomMinMax((level * 300), (level * 500)); ContainerFunctions.AddGoldToContainer(xTraCash, this, 0, digger); if (Utility.RandomMinMax(0, 500) < (level)) { Item arty = ArtifactBuilder.CreateArtifact("random"); DropItem(arty); BaseContainer.DropItemFix(arty, digger, ItemID, GumpID); } TrapType = TrapType.None; TrapPower = 0; TrapLevel = 0; Locked = false; LockLevel = 0; MaxLockLevel = 0; RequiredSkill = 0; }
private void CreateArtifact(string artifactName, string path) { if (string.IsNullOrEmpty(artifactName) || artifactName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0) { throw new InvalidOperationException("Artifact Name cannot contain invalid file name characters: " + new string(Path.GetInvalidFileNameChars())); } if (StoredProcs.Releases_GetRelease(this.Context.ApplicationId, this.Context.ReleaseNumber) .Execute().ReleaseDeployables_Extended .Any(rd => rd.Deployable_Id == this.Context.DeployableId && rd.InclusionType_Code == Domains.DeployableInclusionTypes.Referenced)) { this.LogError( "An Artifact cannot be created for this Deployable because the Deployable is Referenced (as opposed to Included) by this Release. " + "To prevent this error, either include this Deployable in the Release or use a Predicate to prevent this action group from being executed."); return; } var fileOps = this.Context.Agent.GetService <IFileOperationsExecuter>(); var zipPath = fileOps.CombinePath(this.Context.TempDirectory, artifactName + ".zip"); this.LogDebug("Preparing directories..."); fileOps.DeleteFiles(new[] { zipPath }); this.ThrowIfCanceledOrTimeoutExpired(); var rootEntry = fileOps.GetDirectoryEntry( new GetDirectoryEntryCommand { Path = path, Recurse = false, IncludeRootPath = false } ).Entry; if ((rootEntry.Files == null || rootEntry.Files.Length == 0) && (rootEntry.SubDirectories == null || rootEntry.SubDirectories.Length == 0)) { this.LogWarning("There are no files to capture in this artifact."); } this.LogDebug("Zipping output..."); this.Context.Agent.GetService <IRemoteZip>().CreateZipFile(path, zipPath); var zipFileEntry = fileOps.GetFileEntry(zipPath); this.ThrowIfCanceledOrTimeoutExpired(); this.LogDebug("Transferring file to artifact library..."); var artifactId = new ArtifactIdentifier(this.Context.ApplicationId, this.Context.ReleaseNumber, this.Context.BuildNumber, this.Context.DeployableId, artifactName); ArtifactBuilder.ImportZip(artifactId, fileOps, zipFileEntry); this.LogDebug("Cleaning up..."); fileOps.DeleteFiles(new[] { zipPath }); this.LogInformation("Artfact captured from TFS."); }
public override void OnDoubleClick(Mobile from) { if (from.InRange(this.GetWorldLocation(), 2)) { from.SendSound(0x3D); from.PrivateOverheadMessage(MessageType.Regular, 1150, false, "You have pulled Vulcrum's Vault toward you.", from.NetState); LootChest MyChest = new LootChest(6); MyChest.Name = "Vulcrum's Vault"; MyChest.Hue = 0x4EA; if (from is PlayerMobile) { if (GetPlayerInfo.LuckyKiller(from.Luck)) { Item arty = ArtifactBuilder.CreateArtifact("random"); MyChest.DropItem(arty); } if (GetPlayerInfo.LuckyKiller(from.Luck) && !Server.Items.CharacterDatabase.GetSpecialsKilled(from, "Vulcrum")) { Server.Items.CharacterDatabase.SetSpecialsKilled(from, "Vulcrum", true); ManualOfItems lexicon = new ManualOfItems(); lexicon.Hue = 0x4EA; lexicon.Name = "Tome of Vulcrum Relics"; lexicon.m_Charges = 1; lexicon.m_Skill_1 = 0; lexicon.m_Skill_2 = 0; lexicon.m_Skill_3 = 0; lexicon.m_Skill_4 = 0; lexicon.m_Skill_5 = 0; lexicon.m_Value_1 = 0.0; lexicon.m_Value_2 = 0.0; lexicon.m_Value_3 = 0.0; lexicon.m_Value_4 = 0.0; lexicon.m_Value_5 = 0.0; lexicon.m_Slayer_1 = 19; lexicon.m_Slayer_2 = 0; lexicon.m_Owner = from; lexicon.m_Extra = "of Vulcrum of the Flame"; lexicon.m_FromWho = "Taken from Vulcrum"; lexicon.m_HowGiven = "Acquired by"; lexicon.m_Points = 200; lexicon.m_Hue = 0x4EA; MyChest.DropItem(lexicon); } } MyChest.MoveToWorld(from.Location, from.Map); LoggingFunctions.LogGenericQuest(from, "defeated Vulcrum of the Flame"); this.Delete(); } else { from.SendLocalizedMessage(502138); // That is too far away for you to use } }
public void Deserialize_ValidXml_TitleIsPreserved() { //Arrange var xml = new ArtifactBuilder().WithTitle("a"); SetupStream(xml.ToString()); //Act var result = target.Deserialize(inputMock.Object).Result; //Assert Assert.That(result.Title, Is.EqualTo("a")); }
public static void GiveArtifactTo(Mobile m) { //Item item = (Item)Activator.CreateInstance( Artifacts[Utility.Random(Artifacts.Length)] ); Item item = ArtifactBuilder.CreateArtifact("random"); if (m.AddToBackpack(item)) { m.SendMessage("As a reward for slaying the cursed creature, an artifact has been placed in your backpack."); } else { m.SendMessage("As your backpack is full, your reward for slaying cursed creature has been placed at your feet."); } }
public BuriedChest(int level, string who, Mobile digger) : base(0xe40) { if (who == "") { who = ContainerFunctions.GetOwner("Chest"); } else { string[] vAdj = new string[] { "Exotic", "Mysterious", "Marvelous", "Amazing", "Astonishing", "Mystical", "Astounding", "Magnificent", "Phenomenal", "Fantastic", "Incredible", "Extraordinary", "Fabulous", "Wondrous", "Glorious", "Lost", "Fabled", "Legendary", "Mythical", "Missing", "Ancestral", "Ornate", "Wonderful", "Sacred", "Unspeakable", "Unknown", "Forgotten" }; string sAdj = vAdj[Utility.RandomMinMax(0, (vAdj.Length - 1))]; who = "The " + sAdj + " Chest of " + who; } ContainerFunctions.BuildContainer(this, 0, Utility.RandomList(1, 2), 0, 0); Name = who; ContainerFunctions.FillTheContainer(level, this, digger); if (GetPlayerInfo.LuckyPlayer(digger.Luck)) { ContainerFunctions.FillTheContainer(level, this, digger); } if (level > 4) { ContainerFunctions.FillTheContainer(level, this, digger); } if (level > 8) { ContainerFunctions.FillTheContainer(level, this, digger); } ContainerFunctions.LockTheContainer(level, this, 1); int xTraCash = Utility.RandomMinMax((level * 300), (level * 500)); ContainerFunctions.AddGoldToContainer(xTraCash, this, 0, digger); if (Utility.RandomMinMax(0, 500) < (level)) { Item arty = ArtifactBuilder.CreateArtifact("random"); DropItem(arty); BaseContainer.DropItemFix(arty, digger, ItemID, GumpID); } }
public SunkenChest(int level, Mobile digger, int ancient) : base(0x455) { level = level + 4; if (level > 10) { level = 10; } ContainerFunctions.BuildContainer(this, 0, Utility.RandomList(1, 2), 0, 0); int xTraCash = Utility.RandomMinMax((level * 500), (level * 800)); ContainerFunctions.AddGoldToContainer(xTraCash, this, 0, digger); if (level > 0) { ContainerFunctions.FillTheContainer(level, this, digger); } if (level > 3) { ContainerFunctions.FillTheContainer(level, this, digger); } if (level > 7) { ContainerFunctions.FillTheContainer(level, this, digger); } if (GetPlayerInfo.LuckyPlayer(digger.Luck)) { ContainerFunctions.FillTheContainer(level, this, digger); } ContainerOwner = ContainerFunctions.GetOwner("Sunken"); ContainerDigger = digger.Name; Name = "sunken chest"; // = ARTIFACTS int artychance = GetPlayerInfo.LuckyPlayerArtifacts(digger.Luck) + 10; if (Utility.RandomMinMax(0, 100) < ((level * 10) + artychance)) { Item arty = ArtifactBuilder.CreateArtifact("random"); switch (Utility.RandomMinMax(1, 20)) { case 1: arty = ArtifactBuilder.CreateArtifact("driftwood"); break; case 2: arty = ArtifactBuilder.CreateArtifact("kelp"); break; case 3: arty = ArtifactBuilder.CreateArtifact("barnacle"); break; case 4: arty = ArtifactBuilder.CreateArtifact("neptune"); break; case 5: arty = ArtifactBuilder.CreateArtifact("bronzed"); break; } DropItem(arty); BaseContainer.DropItemFix(arty, digger, ItemID, GumpID); } int giveRelics = level; Item relic = Loot.RandomRelic(); while (giveRelics > 0) { relic = Loot.RandomRelic(); ContainerFunctions.RelicValueIncrease(level, relic); DropItem(relic); BaseContainer.DropItemFix(relic, digger, ItemID, GumpID); giveRelics = giveRelics - 1; } if (ancient > 0) { Name = "ancient sunken chest"; Hue = Utility.RandomList(0xB8E, 0xB8F, 0xB90, 0xB91, 0xB92, 0xB89, 0xB8B); Item net = new FabledFishingNet(); DropItem(net); BaseContainer.DropItemFix(net, digger, ItemID, GumpID); } else { Item net = new FishingNet(); if (Utility.RandomMinMax(1, 3) == 1) { net = new SpecialFishingNet(); } DropItem(net); BaseContainer.DropItemFix(net, digger, ItemID, GumpID); ItemID = Utility.RandomList(0x52E2, 0x52E3, 0x507E, 0x507F, 0x4910, 0x4911, 0x3332, 0x3333, 0x4FF4, 0x4FF5); Hue = 0; } }
public override void OnComponentUsed(AddonComponent ac, Mobile from) { if (from.Blessed) { from.SendMessage("You cannot drink from the pool while in this state."); } else if (!from.InRange(GetWorldLocation(), 3)) { from.SendMessage("You will have to get closer to drink from the magical pool!"); } else if (m_Uses > 0) { if (m_Pool == 1) // GAIN STATS { if (from.StatCap > (from.RawStatTotal)) { from.PlaySound(Utility.RandomList(0x30, 0x2D6)); int water = Utility.RandomMinMax(1, 3); int up = 1; int chance = Utility.RandomMinMax(1, 100); if (chance >= 98) { up = AvailPoints(from, 5); } else if (chance >= 87) { up = AvailPoints(from, 4); } else if (chance >= 75) { up = AvailPoints(from, 3); } else if (chance >= 50) { up = AvailPoints(from, 2); } if (water == 1) { from.RawInt = from.RawInt + up; from.SendMessage("You drink from the pool and you feel much smarter!"); } else if (water == 2) { from.RawStr = from.RawStr + up; from.SendMessage("You drink from the pool and you feel much stronger!"); } else { from.RawDex = from.RawDex + up; from.SendMessage("You drink from the pool and you feel much quicker!"); } this.m_Uses = 0; } else { from.PlaySound(Utility.RandomList(0x30, 0x2D6)); from.SendMessage("You drink from the pool and nothing happens!"); this.m_Uses = this.m_Uses - 1; } } else if (m_Pool == 2) // CURE { from.PlaySound(Utility.RandomList(0x30, 0x2D6)); if (from.Poisoned) { from.FixedParticles(0x373A, 10, 15, 5012, EffectLayer.Waist); from.CurePoison(from); from.SendMessage("You feel much better after drinking from the pool!"); this.m_Uses = this.m_Uses - 1; } else { from.PlaySound(Utility.RandomList(0x30, 0x2D6)); from.SendMessage("You drink from the pool and nothing happens!"); this.m_Uses = this.m_Uses - 1; } } else if (m_Pool == 3) // HEAL { from.PlaySound(Utility.RandomList(0x30, 0x2D6)); if (from.Hits < from.HitsMax) { if (from.Poisoned || MortalStrike.IsWounded(from)) { from.SendMessage("You drink from the pool and nothing happens!"); this.m_Uses = this.m_Uses - 1; } else { from.FixedParticles(0x373A, 10, 15, 5012, EffectLayer.Waist); int min = 50; int max = 75; if (m_Bonus > 8) { min = 125; max = 175; } else if (m_Bonus > 5) { min = 75; max = 125; } from.Heal(Utility.RandomMinMax(min, max)); from.SendMessage("You drink from the pool and your wounds magically heal!"); this.m_Uses = this.m_Uses - 1; } } else { from.PlaySound(Utility.RandomList(0x30, 0x2D6)); from.SendMessage("You drink from the pool and nothing happens!"); this.m_Uses = this.m_Uses - 1; } } else if (m_Pool == 4) // WATER ELEMENTAL { from.PlaySound(Utility.RandomList(0x30, 0x2D6)); try { Map map = this.Map; BaseCreature bc = (BaseCreature)Activator.CreateInstance(typeof(WaterElemental)); Point3D spawnLoc = this.Location; for (int i = 0; i < 10; i++) { int x = Location.X + Utility.Random(4); int y = Location.Y + Utility.Random(4); int z = Map.GetAverageZ(x, y); if (Map.CanSpawnMobile(new Point2D(x, y), this.Z)) { spawnLoc = new Point3D(x, y, this.Z); } else if (Map.CanSpawnMobile(new Point2D(x, y), z)) { spawnLoc = new Point3D(x, y, z); } } Timer.DelayCall(TimeSpan.FromSeconds(1), delegate() { bc.Home = Location; bc.RangeHome = 5; bc.FightMode = FightMode.Closest; bc.MoveToWorld(spawnLoc, map); bc.ForceReacquire(); }); } catch { } from.SendMessage("A water elemental emerges from the pool!"); this.m_Uses = this.m_Uses - 1; } else if (m_Pool == 5) // GOLD TO LEAD { from.PlaySound(Utility.RandomList(0x30, 0x2D6)); Container cont = from.Backpack; int nDull = 0; int m_gAmount = from.Backpack.GetAmount(typeof(Gold)); int m_cAmount = from.Backpack.GetAmount(typeof(DDCopper)); int m_sAmount = from.Backpack.GetAmount(typeof(DDSilver)); int m_xAmount = from.Backpack.GetAmount(typeof(DDXormite)); if (cont.ConsumeTotal(typeof(Gold), m_gAmount)) { from.AddToBackpack(new LeadCoin(m_gAmount)); nDull = 1; } if (cont.ConsumeTotal(typeof(DDCopper), m_cAmount)) { from.AddToBackpack(new LeadCoin(m_cAmount)); nDull = 1; } if (cont.ConsumeTotal(typeof(DDSilver), m_sAmount)) { from.AddToBackpack(new LeadCoin(m_sAmount)); nDull = 1; } if (cont.ConsumeTotal(typeof(DDXormite), m_xAmount)) { from.AddToBackpack(new LeadCoin(m_xAmount)); nDull = 1; } if (nDull > 0) { from.SendMessage("After drinking from the pool, you notice all of your coins has turned to lead!"); Effects.SendLocationParticles(EffectItem.Create(from.Location, from.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 5023); LoggingFunctions.LogGenericQuest(from, "had all of their coins turn to lead after drinking from a strange pool"); } else { from.PlaySound(Utility.RandomList(0x30, 0x2D6)); from.SendMessage("You drink from the pool and nothing happens!"); } this.m_Uses = this.m_Uses - 1; } else if (m_Pool == 6) // EQUIPPED ITEM DISAPPEARS { from.PlaySound(Utility.RandomList(0x30, 0x2D6)); this.m_Uses = this.m_Uses - 1; int mReturn = 0; Item ILost = HiddenTrap.GetMyItem(from); if (ILost != null) { ILost.Delete(); mReturn = 1; } if (mReturn != 1) { from.SendMessage("After drinking from the pool, you notice one of your equipped items disappears!"); Effects.SendLocationParticles(EffectItem.Create(from.Location, from.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 5023); LoggingFunctions.LogGenericQuest(from, "had an item vanish after drinking from a strange pool"); } } else if (m_Pool == 7) // LOSE A STAT POINT { from.PlaySound(Utility.RandomList(0x30, 0x2D6)); this.m_Uses = this.m_Uses - 1; int mCurse = 1; if (m_Bonus > 8) { if (from.RawStr > 10) { from.RawStr = from.RawStr - 1; from.SendMessage("You feel weaker after drinking from the pool!"); } else { from.SendMessage("You drink from the pool and nothing happens!"); mCurse = 0; } } else if (m_Bonus > 5) { if (from.RawDex > 10) { from.RawDex = from.RawDex - 1; from.SendMessage("You feel sluggish after drinking from the pool!"); } else { from.SendMessage("You drink from the pool and nothing happens!"); mCurse = 0; } } else { if (from.RawInt > 10) { from.RawInt = from.RawInt - 1; from.SendMessage("Your mind is foggy after drinking from the pool!"); } else { from.SendMessage("You drink from the pool and nothing happens!"); mCurse = 0; } } if (mCurse == 1) { from.FixedParticles(0x3779, 1, 15, 9905, 32, 2, EffectLayer.Head); from.FixedParticles(0x37B9, 1, 14, 9502, 32, 5, (EffectLayer)255); } } else if (m_Pool == 8) // TREASURE CHEST { from.PlaySound(0x364); from.SendMessage("You pull a mystical chest out from the pool!"); this.m_Uses = 0; LootChest MyChest = new LootChest(6); MyChest.ItemID = Utility.RandomList(0x2823, 0x2824, 0x4FE6, 0x4FE7, 0x281F, 0x2820); MyChest.Hue = Utility.RandomList(0x961, 0x962, 0x963, 0x964, 0x965, 0x966, 0x967, 0x968, 0x969, 0x96A, 0x96B, 0x96C, 0x96D, 0x96E, 0x96F, 0x970, 0x971, 0x972, 0x973, 0x974, 0x975, 0x976, 0x977, 0x978, 0x979, 0x97A, 0x97B, 0x97C, 0x97D, 0x97E, 0x4AA); Region reg = Region.Find(from.Location, from.Map); MyChest.Name = "mystical chest from " + Server.Misc.Worlds.GetRegionName(from.Map, from.Location); int xTraCash = Utility.RandomMinMax(5000, 8000); ContainerFunctions.AddGoldToContainer(xTraCash, MyChest, 0, from); int artychance = GetPlayerInfo.LuckyPlayerArtifacts(from.Luck) + 10; if (Utility.RandomMinMax(0, 100) < artychance) { Item arty = ArtifactBuilder.CreateArtifact("random"); MyChest.DropItem(arty); BaseContainer.DropItemFix(arty, from, MyChest.ItemID, MyChest.GumpID); } from.AddToBackpack(MyChest); LoggingFunctions.LogGenericQuest(from, "found a chest full of treasure in some strange pool"); } else if (m_Pool == 9) // COPPER SILVER TO GOLD { from.PlaySound(Utility.RandomList(0x30, 0x2D6)); Container cont = from.Backpack; int nShine = 0; int m_cAmount = from.Backpack.GetAmount(typeof(DDCopper)); int m_sAmount = from.Backpack.GetAmount(typeof(DDSilver)); int m_dAmount = from.Backpack.GetAmount(typeof(LeadCoin)); if (cont.ConsumeTotal(typeof(DDCopper), m_cAmount)) { from.AddToBackpack(new Gold(m_cAmount)); nShine = 1; } if (cont.ConsumeTotal(typeof(DDSilver), m_sAmount)) { from.AddToBackpack(new Gold(m_sAmount)); nShine = 1; } if (cont.ConsumeTotal(typeof(LeadCoin), m_dAmount)) { from.AddToBackpack(new Gold(m_dAmount)); nShine = 1; } if (nShine > 0) { from.SendMessage("After drinking from the pool, you notice your meager coins turn to gold!"); Effects.SendLocationParticles(EffectItem.Create(from.Location, from.Map, EffectItem.DefaultDuration), 0x3728, 10, 10, 5023); LoggingFunctions.LogGenericQuest(from, "had all of their meager coins turn to gold after drinking from a strange pool"); } else { from.SendMessage("You drink from the pool and nothing happens!"); } this.m_Uses = 0; } else // POISON { if (from.Poisoned) { from.SendMessage("You are too sick to drink from this pool!"); } else { Effects.SendLocationParticles(EffectItem.Create(from.Location, from.Map, EffectItem.DefaultDuration), 0x36B0, 1, 14, 63, 7, 9915, 0); from.PlaySound(Utility.RandomList(0x30, 0x2D6)); if (m_Bonus > 9) { from.ApplyPoison(from, Poison.Deadly); } else if (m_Bonus > 7) { from.ApplyPoison(from, Poison.Greater); } else if (m_Bonus > 4) { from.ApplyPoison(from, Poison.Regular); } else { from.ApplyPoison(from, Poison.Lesser); } from.SendMessage("You feel more sick after drinking from the pool!"); this.m_Uses = this.m_Uses - 1; } } } else { from.SendMessage("The magic from the pool seems to be drained!"); } }
public TreasureMapChest(Mobile owner, int level, bool temporary) : base(0xE40) { level = level + 4; if (level > 10) { level = 10; } m_Owner = owner; m_Level = level; m_DeleteTime = DateTime.UtcNow + TimeSpan.FromHours(3.0); m_Temporary = temporary; m_Guardians = new List <Mobile>(); m_Timer = new DeleteTimer(this, m_DeleteTime); m_Timer.Start(); Movable = false; Locked = true; if (level > 0) { ContainerFunctions.FillTheContainer(level, this, owner); } if (level > 3) { ContainerFunctions.FillTheContainer(level, this, owner); } if (level > 7) { ContainerFunctions.FillTheContainer(level, this, owner); } if (GetPlayerInfo.LuckyPlayer(owner.Luck)) { ContainerFunctions.FillTheContainer(level, this, owner); } ContainerFunctions.LockTheContainer(level, this, 1); int xTraCash = Utility.RandomMinMax((level * 700), (level * 1000)); ContainerFunctions.AddGoldToContainer(xTraCash, this, 0); string sChest = "grand treasure chest"; switch (level) { case 0: sChest = "meager treasure chest"; break; case 1: sChest = "simple treasure chest"; break; case 2: sChest = "good treasure chest"; break; case 3: sChest = "great treasure chest"; break; case 4: sChest = "excellent treasure chest"; break; case 5: sChest = "superb treasure chest"; break; } Name = ContainerFunctions.GetOwner("Treasure Chest"); Name = "the " + sChest + " of " + Name; // = SCROLL OF TRANCENDENCE if (level >= 4 && Utility.RandomDouble() > 0.9) { DropItem(ScrollofTranscendence.CreateRandom(level, level * 5)); } // = ARTIFACTS int artychance = GetPlayerInfo.LuckyPlayerArtifacts(owner.Luck); if (Utility.RandomMinMax(0, 100) < ((level * 17) + artychance)) { Item arty = ArtifactBuilder.CreateArtifact("random"); DropItem(arty); } // = SCROLL OF ALACRITY or POWERSCROLL if (level > 1) { if (Utility.RandomDouble() < (0.02 + (level / 200))) { SkillName WhatS = (SkillName)Utility.Random(SkillInfo.Table.Length); DropItem(PowerScroll.CreateRandomNoCraft(5, 5)); } else if (Utility.RandomDouble() < 0.075) { SkillName WhatS = (SkillName)Utility.Random(SkillInfo.Table.Length); DropItem(new ScrollofAlacrity(WhatS)); } } int giveRelics = level; Item relic = Loot.RandomRelic(); while (giveRelics > 0) { relic = Loot.RandomRelic(); ContainerFunctions.RelicValueIncrease(level, relic); DropItem(relic); giveRelics = giveRelics - 1; } }
public ParagonChest(string name, string title, int level, Mobile from) : base(Utility.RandomList(m_ItemIDs)) { int tMapLevel = level; level = level + 4; if (level > 7) { level = 7; } m_Name = name; if (title != "" && title != null) { m_Name = name + " " + title; } Hue = Utility.RandomList(m_Hues); if (level > 0) { ContainerFunctions.FillTheContainer(level, this, from); } if (level > 3) { ContainerFunctions.FillTheContainer(level, this, from); } if (level > 7) { ContainerFunctions.FillTheContainer(level, this, from); } ContainerFunctions.LockTheContainer(level, this, 1); int xTraCash = Utility.RandomMinMax((level * 600), (level * 900)); ContainerFunctions.AddGoldToContainer(xTraCash, this, 0, from); if (Utility.RandomMinMax(0, 100) < (level * 5)) { Item arty = ArtifactBuilder.CreateArtifact("random"); DropItem(arty); BaseContainer.DropItemFix(arty, from, ItemID, GumpID); } Map tMap = Map.Sosaria; switch (Utility.RandomMinMax(0, 4)) { case 0: tMap = Map.Sosaria; break; case 1: tMap = Map.Lodor; break; case 2: tMap = Map.SerpentIsland; break; case 3: tMap = Map.IslesDread; break; case 4: tMap = Map.SavagedEmpire; break; case 5: tMap = Map.Underworld; break; } Point3D loc = new Point3D(200, 200, 0); Item map = new TreasureMap(tMapLevel, tMap, loc, 200, 200); DropItem(map); BaseContainer.DropItemFix(map, from, ItemID, GumpID); int giveRelics = level; Item relic = Loot.RandomRelic(); while (giveRelics > 0) { relic = Loot.RandomRelic(); ContainerFunctions.RelicValueIncrease(level, relic); BaseContainer.DropItemFix(relic, from, ItemID, GumpID); DropItem(relic); giveRelics = giveRelics - 1; } }
public ParagonChest(string name, string title, int level, Mobile from) : base(Utility.RandomList(m_ItemIDs)) { int tMapLevel = level; level = level + 4; if (level > 7) { level = 7; } m_Name = name; if (title != "" && title != null) { m_Name = name + " " + title; } Hue = Utility.RandomList(m_Hues); if (level > 0) { ContainerFunctions.FillTheContainer(level, this, from); } if (level > 3) { ContainerFunctions.FillTheContainer(level, this, from); } if (level > 7) { ContainerFunctions.FillTheContainer(level, this, from); } ContainerFunctions.LockTheContainer(level, this, 1); int xTraCash = Utility.RandomMinMax((level * 600), (level * 900)); ContainerFunctions.AddGoldToContainer(xTraCash, this, 0); if (Utility.RandomMinMax(0, 100) < (level * 5)) { Item arty = ArtifactBuilder.CreateArtifact("random"); DropItem(arty); } Map tMap = Map.Trammel; switch (Utility.RandomMinMax(0, 4)) { case 0: tMap = Map.Trammel; break; case 1: tMap = Map.Felucca; break; case 2: tMap = Map.Malas; break; case 3: tMap = Map.Tokuno; break; case 4: tMap = Map.TerMur; break; case 5: tMap = Map.Ilshenar; break; } Point3D loc = new Point3D(200, 200, 0); DropItem(new TreasureMap(tMapLevel, tMap, loc, 200, 200)); int giveRelics = level; Item relic = Loot.RandomRelic(); while (giveRelics > 0) { relic = Loot.RandomRelic(); ContainerFunctions.RelicValueIncrease(level, relic); DropItem(relic); giveRelics = giveRelics - 1; } }
public override void OnDoubleClick(Mobile from) { if (from.InRange(this.GetWorldLocation(), 2)) { if (CharacterDatabase.GetBardsTaleQuest(from, "BardsTaleWin")) { from.PrivateOverheadMessage(MessageType.Regular, 1150, false, "You find nothing of interest.", from.NetState); from.SendMessage("A gate is open nearby. You better hurry or you will remain trapped here."); } else { CharacterDatabase.SetBardsTaleQuest(from, "BardsTaleWin"); from.SendSound(0x3D); from.PrivateOverheadMessage(MessageType.Regular, 1150, false, "You have pulled Mangar's Vault toward you.", from.NetState); from.SendMessage("A gate is open nearby. You better hurry or you will remain trapped here."); LootChest MyChest = new LootChest(6); MyChest.Name = "Mangar's Vault"; MyChest.Hue = 0x497; Item arty = ArtifactBuilder.CreateArtifact("random"); MyChest.DropItem(arty); int IamNecro = 0; int IamMage = 0; int IamBard = 0; if (from.Skills[SkillName.Necromancy].Base > 0) { IamNecro = (int)from.Skills[SkillName.Necromancy].Base; } if (from.Skills[SkillName.Magery].Base > 0) { IamMage = (int)from.Skills[SkillName.Magery].Base; } if (from.Skills[SkillName.Musicianship].Base > 0) { IamBard = (int)from.Skills[SkillName.Musicianship].Base; } if (!Server.Items.CharacterDatabase.GetSpecialsKilled(from, "Mangar")) { Server.Items.CharacterDatabase.SetSpecialsKilled(from, "Mangar"); ManualOfItems lexicon = new ManualOfItems(); lexicon.Hue = 0x497; lexicon.Name = "Tome of Mangar Relics"; lexicon.m_Charges = 1; lexicon.m_Skill_1 = 17; lexicon.m_Skill_2 = 31; lexicon.m_Skill_3 = 32; lexicon.m_Skill_4 = 33; lexicon.m_Skill_5 = 36; lexicon.m_Value_1 = 5.0; lexicon.m_Value_2 = 5.0; lexicon.m_Value_3 = 5.0; lexicon.m_Value_4 = 5.0; lexicon.m_Value_5 = 5.0; lexicon.m_Slayer_1 = 0; lexicon.m_Slayer_2 = 0; lexicon.m_Owner = from; lexicon.m_Extra = "of Mangar the Dark"; lexicon.m_FromWho = "Taken from Mangar"; lexicon.m_HowGiven = "Acquired by"; lexicon.m_Points = 250; lexicon.m_Hue = 0x497; MyChest.DropItem(lexicon); } if (IamBard > IamMage && IamBard > IamNecro && IamBard > 0) { MyChest.DropItem(new BardicFeatheredHat()); MySongbook newBook = new MySongbook(); newBook.Name = "Songs of Skara Brae"; newBook.Content = 0xFFFF; MyChest.DropItem(newBook); } else if (IamMage > IamBard && IamMage > IamNecro && IamMage > 0) { MyChest.DropItem(new MangarsRobe()); MySpellbook newBook = new MySpellbook(); newBook.Hue = 0x497; string book = newBook.Name; string[] eachWord = book.Split('\''); int nLine = 1; foreach (string eachWords in eachWord) { if (nLine != 1) { newBook.Name = "Mangar'" + eachWords; } else { nLine = 2; } } MyChest.DropItem(newBook); } else if (IamNecro > IamBard && IamNecro > IamMage && IamNecro > 0) { MyChest.DropItem(new MangarsNecroRobe()); MyNecromancerSpellbook newBook = new MyNecromancerSpellbook(); newBook.Hue = 0x497; string book = newBook.Name; string[] eachWord = book.Split('\''); int nLine = 1; foreach (string eachWords in eachWord) { if (nLine != 1) { newBook.Name = "Mangar'" + eachWords; } else { nLine = 2; } } MyChest.DropItem(newBook); } else if (IamMage > 0) { MyChest.DropItem(new MangarsRobe()); MySpellbook newBook = new MySpellbook(); newBook.Hue = 0x497; string book = newBook.Name; string[] eachWord = book.Split('\''); int nLine = 1; foreach (string eachWords in eachWord) { if (nLine != 1) { newBook.Name = "Mangar'" + eachWords; } else { nLine = 2; } } MyChest.DropItem(newBook); } else if (IamNecro > 0) { MyChest.DropItem(new MangarsNecroRobe()); MyNecromancerSpellbook newBook = new MyNecromancerSpellbook(); newBook.Hue = 0x497; string book = newBook.Name; string[] eachWord = book.Split('\''); int nLine = 1; foreach (string eachWords in eachWord) { if (nLine != 1) { newBook.Name = "Mangar'" + eachWords; } else { nLine = 2; } } MyChest.DropItem(newBook); } else if (IamBard > 0) { MyChest.DropItem(new BardicFeatheredHat()); MySongbook newBook = new MySongbook(); newBook.Name = "Songs of Skara Brae"; newBook.Content = 0xFFFF; MyChest.DropItem(newBook); } MyChest.MoveToWorld(from.Location, from.Map); LoggingFunctions.LogGenericQuest(from, "defeated Mangar and escaped Skara Brae"); } } else { from.SendLocalizedMessage(502138); // That is too far away for you to use } }
public override void Import(IBuildImporterContext context) { string zipFileName = null; string jenkinsBuildNumber = this.ResolveJenkinsBuildNumber(); if (string.IsNullOrEmpty(jenkinsBuildNumber)) { this.LogError("An error occurred attempting to resolve Jenkins build number \"{0}\". This can mean that " + "the special build type was not found, there are no builds for job \"{1}\", or that the job was not found or is disabled.", this.BuildNumber, this.JobName); return; } try { this.LogInformation("Importing {0} from {1}...", this.ArtifactName, this.JobName); var client = new JenkinsClient((JenkinsConfigurer)this.GetExtensionConfigurer(), this); zipFileName = Path.GetTempFileName(); this.LogDebug("Temp file: " + zipFileName); this.LogDebug("Downloading artifact..."); client.DownloadArtifact(this.JobName, jenkinsBuildNumber, zipFileName); this.LogInformation("Artifact downloaded."); using (var agent = Util.Agents.CreateLocalAgent()) { ArtifactBuilder.ImportZip( new ArtifactIdentifier( context.ApplicationId, context.ReleaseNumber, context.BuildNumber, context.DeployableId, this.ArtifactName), agent.GetService <IFileOperationsExecuter>(), new FileEntryInfo(Path.GetFileName(zipFileName), zipFileName) ); } } finally { try { if (zipFileName != null) { File.Delete(zipFileName); } } catch (Exception ex) { this.LogWarning("Error deleting temp file:" + ex.Message); } } this.LogDebug("Creating $JenkinsBuildNumber variable..."); DB.Variables_CreateOrUpdateVariableDefinition( Variable_Name: "JenkinsBuildNumber", Environment_Id: null, Server_Id: null, ApplicationGroup_Id: null, Application_Id: context.ApplicationId, Deployable_Id: null, Release_Number: context.ReleaseNumber, Build_Number: context.BuildNumber, Execution_Id: null, Promotion_Id: null, Value_Text: jenkinsBuildNumber, Sensitive_Indicator: false ); }
public override void Import(IBuildImporterContext context) { var configurer = (TfsConfigurer)this.GetExtensionConfigurer(); this.LogDebug("Searching for build {0} for team project {1} definition {2}...", this.TfsBuildNumber, this.TeamProject, this.BuildDefinition); var tfsBuild = configurer.GetBuildInfo(this.TeamProject, this.BuildDefinition, this.TfsBuildNumber, this.IncludeUnsuccessful); if (tfsBuild == null) { this.LogError("Query did not return any builds."); return; } this.LogInformation("TFS Build Number: {0}", tfsBuild.BuildNumber); if (string.IsNullOrWhiteSpace(tfsBuild.DropLocation)) { this.LogError("TFS configuration error: the selected build definition does not have a drop location specified."); return; } this.LogInformation("Drop location: {0}", tfsBuild.DropLocation); using (var agent = Util.Agents.CreateAgentFromId(configurer.ServerId)) { var fileOps = agent.GetService<IFileOperationsExecuter>(); this.LogDebug("Querying drop location..."); var directoryResult = Util.Files.GetDirectoryEntry( new GetDirectoryEntryCommand { Path = tfsBuild.DropLocation, Recurse = true, IncludeRootPath = true } ).Entry; var matches = Util.Files.Comparison.GetMatches(tfsBuild.DropLocation, directoryResult, new[] { "*" }) .Where(e => !IsSamePath(e.Path, tfsBuild.DropLocation)) .ToList(); if (!matches.Any()) { this.LogWarning("No files were found in the drop folder."); return; } this.LogDebug("Creating {0} artifact...", this.ArtifactName); var artifactId = new ArtifactIdentifier(context.ApplicationId, context.ReleaseNumber, context.BuildNumber, context.DeployableId, this.ArtifactName); using (var artifact = new ArtifactBuilder(artifactId)) { artifact.RootPath = tfsBuild.DropLocation; foreach (var match in matches) artifact.Add(match, fileOps); artifact.Commit(); } } this.LogDebug("Creating $TfsBuildNumber variable..."); StoredProcs.Variables_CreateOrUpdateVariableDefinition( Variable_Name: "TfsBuildNumber", Environment_Id: null, Server_Id: null, ApplicationGroup_Id: null, Application_Id: context.ApplicationId, Deployable_Id: null, Release_Number: context.ReleaseNumber, Build_Number: context.BuildNumber, Execution_Id: null, Value_Text: tfsBuild.BuildNumber, Sensitive_Indicator: YNIndicator.No ).Execute(); }
public override void Import(IBuildImporterContext context) { var configurer = (TfsConfigurer)this.GetExtensionConfigurer(); this.LogDebug($"Searching for build {this.TfsBuildNumber} for team project {this.TeamProject} definition {this.BuildDefinition}..."); var tfsBuild = configurer.GetBuildInfo(this.TeamProject, this.BuildDefinition, this.TfsBuildNumber, this.IncludeUnsuccessful); if (tfsBuild == null) { this.LogError("Query did not return any builds."); return; } this.LogInformation("TFS Build Number: " + tfsBuild.BuildNumber); if (string.IsNullOrWhiteSpace(tfsBuild.DropLocation)) { this.LogError("TFS configuration error: the selected build definition does not have a drop location specified."); return; } this.LogInformation("Drop location: " + tfsBuild.DropLocation); var agent = configurer.ServerId != null?BuildMasterAgent.Create((int)configurer.ServerId) : BuildMasterAgent.CreateLocalAgent(); using (agent) { var fileOps = agent.GetService <IFileOperationsExecuter>(); this.LogDebug("Querying drop location..."); var directoryResult = fileOps.GetDirectoryEntry( new GetDirectoryEntryCommand { Path = tfsBuild.DropLocation, Recurse = true, IncludeRootPath = true } ); var exception = directoryResult.Exceptions.FirstOrDefault(); if (exception != null) { throw exception; } var matches = Util.Files.Comparison.GetMatches(tfsBuild.DropLocation, directoryResult.Entry, new[] { "*" }) .Where(e => !IsSamePath(e.Path, tfsBuild.DropLocation)) .ToList(); if (!matches.Any()) { this.LogWarning("No files were found in the drop folder."); return; } this.LogDebug($"Creating {this.ArtifactName} artifact..."); var artifactId = new ArtifactIdentifier(context.ApplicationId, context.ReleaseNumber, context.BuildNumber, context.DeployableId, this.ArtifactName); using (var artifact = new ArtifactBuilder(artifactId)) { artifact.RootPath = tfsBuild.DropLocation; foreach (var match in matches) { artifact.Add(match, fileOps); } artifact.Commit(); } } if (this.CreateBuildNumberVariable) { this.LogDebug($"Setting $TfsBuildNumber build variable to {tfsBuild.BuildNumber}..."); DB.Variables_CreateOrUpdateVariableDefinition( Variable_Name: "TfsBuildNumber", Environment_Id: null, ServerRole_Id: null, Server_Id: null, ApplicationGroup_Id: null, Application_Id: context.ApplicationId, Deployable_Id: null, Release_Number: context.ReleaseNumber, Build_Number: context.BuildNumber, Execution_Id: null, Promotion_Id: null, Value_Text: tfsBuild.BuildNumber, Sensitive_Indicator: YNIndicator.No ); this.LogInformation("$TfsBuildNumber build variable set to: " + tfsBuild.BuildNumber); } }
/// <summary> /// Downloads and imports and artifact from Visual Studio Online. /// </summary> /// <param name="configurer">The configurer.</param> /// <param name="logger">The logger.</param> /// <param name="teamProject">The team project.</param> /// <param name="buildNumber">The build number.</param> /// <param name="artifactId">The artifact identifier.</param> public static string DownloadAndImport(TfsConfigurer configurer, ILogger logger, string teamProject, string buildNumber, string buildDefinitionName, ArtifactIdentifier artifactId) { if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (configurer == null) { throw new ArgumentNullException("A configurer must be configured or selected in order to import a VS online build."); } if (string.IsNullOrEmpty(configurer.BaseUrl)) { throw new InvalidOperationException("The base URL property of the TFS configurer must be set to import a VS online build."); } var api = new TfsRestApi(configurer.BaseUrl, teamProject) { UserName = string.IsNullOrEmpty(configurer.Domain) ? configurer.UserName : string.Format("{0}\\{1}", configurer.Domain, configurer.UserName), Password = configurer.Password }; logger.LogInformation($"Finding last successful build..."); var buildDefinitions = api.GetBuildDefinitions(); var buildDefinition = buildDefinitions.FirstOrDefault(b => b.name == buildDefinitionName); if (buildDefinition == null) { throw new InvalidOperationException($"The build definition {buildDefinitionName} could not be found."); } logger.LogInformation($"Finding {Util.CoalesceStr(buildNumber, "last successful")} build..."); var builds = api.GetBuilds( buildDefinition: buildDefinition.id, buildNumber: InedoLib.Util.NullIf(buildNumber, ""), resultFilter: "succeeded", statusFilter: "completed", top: 2 ); if (builds.Length == 0) { throw new InvalidOperationException($"Could not find build number {buildNumber}. Ensure there is a successful, completed build with this number."); } var build = builds.FirstOrDefault(); string tempFile = Path.GetTempFileName(); try { logger.LogInformation($"Downloading {artifactId.ArtifactName} artifact from VSO..."); logger.LogDebug("Downloading artifact file to: " + tempFile); api.DownloadArtifact(build.id, artifactId.ArtifactName, tempFile); logger.LogInformation("Artifact file downloaded from VSO, importing into BuildMaster artifact library..."); using (var stream = FileEx.Open(tempFile, FileMode.Open, FileAccess.Read, FileShare.Read)) { ArtifactBuilder.ImportZip(artifactId, stream); } logger.LogInformation($"{artifactId.ArtifactName} artifact imported."); return(build.buildNumber); } finally { if (tempFile != null) { FileEx.Delete(tempFile); } } }
public override void Import(IBuildImporterContext context) { var configurer = (NuGetConfigurer)this.GetExtensionConfigurer(); if (configurer.AlwaysClearNuGetCache) { this.LogDebug("Clearing NuGet cache..."); if (NuGetConfigurer.ClearCache()) { this.LogDebug("Cache cleared!"); } else { this.LogWarning("Error clearing cache; a file may be locked."); } } var nugetExe = configurer != null ? configurer.NuGetExe : null; if (string.IsNullOrEmpty(nugetExe)) { nugetExe = Path.Combine(Path.GetDirectoryName(typeof(NuGetBuildImporter).Assembly.Location), "nuget.exe"); } var packageSource = Util.CoalesceStr(this.PackageSource, configurer != null ? configurer.PackageSource : null); var args = "install \"" + this.PackageId + "\" -ExcludeVersion -NoCache"; if (!string.IsNullOrEmpty(this.PackageVersion)) { args += " -Version \"" + this.PackageVersion + "\""; } if (this.IncludePrerelease) { args += " -Prerelease"; } if (!string.IsNullOrEmpty(packageSource)) { args += " -Source \"" + packageSource + "\""; } var tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); try { Directory.CreateDirectory(tempPath); args += " -OutputDirectory \"" + tempPath + "\""; if (!string.IsNullOrWhiteSpace(this.AdditionalArguments)) { args += " " + this.AdditionalArguments; } this.LogDebug($"Executing {nugetExe} {args}"); this.LogInformation("Executing NuGet..."); using (var process = new LocalProcess(new RemoteProcessStartInfo { FileName = nugetExe, Arguments = args })) { process.OutputDataReceived += this.Process_OutputDataReceived; process.ErrorDataReceived += this.Process_ErrorDataReceived; process.Start(); process.WaitForExit(); if (process.ExitCode != 0) { this.LogError($"NuGet failed with exit code {process.ExitCode}."); return; } } this.LogInformation("NuGet indicated successful package install."); var packageRootPath = Path.Combine(tempPath, this.PackageId); var artifactName = this.PackageId; if (this.CaptureIdAndVersion || this.IncludeVersionInArtifactName) { try { var nupkgPath = Path.Combine(packageRootPath, this.PackageId + ".nupkg"); this.LogDebug($"Attempting to gather metadata from {nupkgPath}..."); var nuspec = NuGetPackage.ReadFromNupkgFile(nupkgPath); var packageId = nuspec.Id; var packageVersion = nuspec.Version.OriginalString; if (this.CaptureIdAndVersion) { this.LogDebug("Setting $ImportedPackageId = " + packageId); SetBuildVariable(context, "ImportedPackageId", packageId); this.LogDebug("Setting $ImportedPackageVersion = " + packageVersion); SetBuildVariable(context, "ImportedPackageVersion", packageVersion); } if (this.IncludeVersionInArtifactName) { artifactName = packageId + "." + packageVersion; } } catch (Exception ex) { this.LogError("Could not read package metadata: " + ex.ToString()); return; } } var rootCapturePath = Path.Combine(packageRootPath, (this.PackageArtifactRoot ?? string.Empty).Replace('/', '\\').TrimStart('/', '\\')); this.LogDebug($"Capturing files in {rootCapturePath}..."); var rootEntry = Util.Files.GetDirectoryEntry( new GetDirectoryEntryCommand { Path = rootCapturePath, IncludeRootPath = true, Recurse = true } ).Entry; using (var agent = BuildMasterAgent.CreateLocalAgent()) { var fileOps = agent.GetService <IFileOperationsExecuter>(); var matches = Util.Files.Comparison.GetMatches(rootCapturePath, rootEntry, new[] { "!\\" + this.PackageId + ".nupkg", "*" }); var artifactId = new ArtifactIdentifier(context.ApplicationId, context.ReleaseNumber, context.BuildNumber, context.DeployableId, artifactName); this.LogInformation($"Creating artifact {artifactName}..."); using (var artifact = new ArtifactBuilder(artifactId)) { artifact.RootPath = rootCapturePath; foreach (var match in matches) { artifact.Add(match, fileOps); } artifact.Commit(); } this.LogInformation("Artifact created."); } } finally { try { DirectoryEx.Delete(tempPath); } catch { } } }