public HarvestVein( double veinChance, double chanceToFallback, HarvestResource primaryResource, HarvestResource fallbackResource ) { VeinChance = veinChance; ChanceToFallback = chanceToFallback; PrimaryResource = primaryResource; FallbackResource = fallbackResource; }
public HarvestVein(double veinChance, double chanceToFallback, HarvestResource primaryResource, HarvestResource fallbackResource) { VeinChance = veinChance; ChanceToFallback = chanceToFallback; PrimaryResource = primaryResource; FallbackResource = fallbackResource; }
public void DoMining() { if (Map == null || Map == Map.Internal) { return; } // We may not mine while we are fighting if (Combatant != null) { return; } HarvestSystem system = Mining.System; HarvestDefinition def = Mining.System.OreAndStone; // Our target is the land tile under us Map map = Map; Point3D loc = Location; int x = 0, y = 0; GetMiningOffset(Direction, ref x, ref y); loc.X += x; loc.Y += y; int tileId = map.Tiles.GetLandTile(loc.X, loc.Y).ID & 0x3FFF; if (!def.Validate(tileId)) { return; } HarvestBank bank = def.GetBank(map, loc.X, loc.Y); if (bank == null || bank.Current < def.ConsumedPerHarvest) { return; } HarvestVein vein = bank.Vein; if (vein == null) { return; } HarvestResource primary = vein.PrimaryResource; HarvestResource fallback = def.Resources[0]; HarvestResource resource = system.MutateResource(this, null, def, map, loc, vein, primary, fallback); double skillBase = Skills[def.Skill].Base; Type type = null; if (skillBase >= resource.ReqSkill && CheckSkill(def.Skill, resource.MinSkill, resource.MaxSkill)) { type = system.GetResourceType(this, null, def, map, loc, resource); if (type != null) { type = system.MutateType(type, this, null, def, map, loc, resource); } if (type != null) { Item item = system.Construct(type, this, null); if (item == null) { type = null; } else { if (item.Stackable) { int amount = def.ConsumedPerHarvest; int feluccaAmount = def.ConsumedPerFeluccaHarvest; bool inFelucca = (map == Map.Felucca); if (inFelucca) { item.Amount = feluccaAmount; } else { item.Amount = amount; } } bank.Consume(item.Amount, this); item.MoveToWorld(loc, map); system.DoHarvestingEffect(this, null, def, map, loc); system.DoHarvestingSound(this, null, def, null); // Mine for gems BonusHarvestResource bonus = def.GetBonusResource(); if (bonus != null && bonus.Type != null && skillBase >= bonus.ReqSkill) { Item bonusItem = system.Construct(bonus.Type, this, null); bonusItem.MoveToWorld(loc, map); } } } } }
private HerbGathering() { HarvestResource[] res; HarvestVein[] veins; #region HerbGathering HarvestDefinition herbs = new HarvestDefinition(); // Resource banks are every 4x3 tiles herbs.BankWidth = 1; herbs.BankHeight = 1; // Every bank holds from 20 to 45 logs herbs.MinTotal = 2; herbs.MaxTotal = 8; // A resource bank will respawn its content every 20 to 30 minutes herbs.MinRespawn = TimeSpan.FromMinutes(30.0); herbs.MaxRespawn = TimeSpan.FromMinutes(60.0); // Skill checking is done on the Camping skill herbs.Skill = SkillName.Camping; // Set the list of harvestable tiles herbs.Tiles = m_PlantTiles; // Players must be within 2 tiles to harvest herbs.MaxRange = 2; // Ten logs per harvest action herbs.ConsumedPerHarvest = 2; herbs.ConsumedPerFeluccaHarvest = 2; // The chopping effect herbs.EffectActions = new int[] { 13 }; herbs.EffectSounds = new int[] { 0x13E }; herbs.EffectCounts = (Core.AOS ? new int[] { 1 } : new int[] { 1, 2, 2, 2, 3 }); herbs.EffectDelay = TimeSpan.FromSeconds(1.6); herbs.EffectSoundDelay = TimeSpan.FromSeconds(0.9); herbs.NoResourcesMessage = "There's not enough herbs left to harvest."; // There's not enough wood here to harvest. herbs.FailMessage = "You fail to find any usable herbs."; // You hack at the tree for a while, but fail to produce any useable wood. herbs.OutOfRangeMessage = 500446; // That is too far away. herbs.PackFullMessage = "You can't place any more herbs in your pack."; // You can't place any wood into your backpack! herbs.ToolBrokeMessage = "You broke your sickle."; // You broke your axe. var common = "You find some common herbs."; res = new HarvestResource[] { new HarvestResource(00.0, 00.0, 100.0, common, typeof(BlackPearl)), new HarvestResource(00.0, 00.0, 100.0, common, typeof(Bloodmoss)), new HarvestResource(00.0, 00.0, 100.0, common, typeof(Garlic)), new HarvestResource(00.0, 00.0, 100.0, common, typeof(Ginseng)), new HarvestResource(00.0, 00.0, 100.0, common, typeof(MandrakeRoot)), new HarvestResource(00.0, 00.0, 100.0, common, typeof(Nightshade)), new HarvestResource(00.0, 00.0, 100.0, common, typeof(SpidersSilk)), new HarvestResource(00.0, 00.0, 100.0, common, typeof(SulfurousAsh)), new HarvestResource(99.9, 60.0, 140.0, "You find some batwings.", typeof(BatWing)), new HarvestResource(99.9, 60.0, 140.0, "You find some eyes of newt.", typeof(EyeOfNewt)), }; veins = new HarvestVein[] { new HarvestVein(10.0, 0.0, res[0], null), new HarvestVein(10.0, 0.5, res[1], res[0]), new HarvestVein(10.0, 0.5, res[2], res[0]), new HarvestVein(10.0, 0.5, res[3], res[0]), new HarvestVein(10.0, 0.5, res[4], res[0]), new HarvestVein(10.0, 0.5, res[5], res[0]), new HarvestVein(10.0, 0.5, res[6], res[0]), new HarvestVein(10.0, 0.5, res[7], res[0]), new HarvestVein(10.0, 0.5, res[8], res[0]), new HarvestVein(10.0, 0.5, res[9], res[0]), }; herbs.BonusResources = new BonusHarvestResource[] { new BonusHarvestResource(0, 83.9, null, null), //Nothing //new BonusHarvestResource( 100, 10.0, 1072548, typeof( CommonSeeds ) ), new BonusHarvestResource(100, 03.0, 1072550, typeof(Seed)), //new BonusHarvestResource( 100, 02.0, 1072547, typeof( UnCommonSeeds ) ), new BonusHarvestResource(100, 01.0, 1072549, typeof(ParasiticPlant)), //new BonusHarvestResource( 100, 00.1, 1072551, typeof( ExoticSeeds ) ) }; herbs.Resources = res; herbs.Veins = veins; herbs.RaceBonus = false; herbs.RandomizeVeins = false; m_Definition = herbs; Definitions.Add(herbs); #endregion }
public bool DoDisposeOre(int x, int y, int z, Map map, Mobile from) { if (!IsMiningTile(x, y, map)) { this.Say("I can not mine here"); return(false); } HarvestBank bank = Mining.System.OreAndStone.GetBank(map, x, y); if (bank == null) { this.Say("I can not mine here"); return(false); } if (bank.Current <= 0) { return(false); } HarvestVein vein = bank.DefaultVein; if (vein == null) { this.Say("I can not mine here"); return(false); } HarvestDefinition def = Mining.System.OreAndStone; HarvestResource res = vein.PrimaryResource; BaseOre ore = Mining.System.Construct(res.Types[0], null) as BaseOre; if (ore == null) { return(false); } if (ore.Resource > CraftResource.Iron) { double minskill = 0.0; double minskill2 = 0.0; double maxskill = 0.0; double skillbase = this.Skills.Mining.Base; if (this.Skills.Mining.Base < 100.0) { this.Say("skill = {0}", Convert.ToString(skillbase)); } switch (ore.Resource) { case CraftResource.Iron: { minskill = 00.0; minskill2 = 00.0; maxskill = 100.0; } break; case CraftResource.DullCopper: { minskill = 60.0; minskill2 = 25.0; maxskill = 100.0; } break; case CraftResource.ShadowIron: { minskill = 65.0; minskill2 = 30.0; maxskill = 100.0; } break; case CraftResource.Copper: { minskill = 70.0; minskill2 = 35.0; maxskill = 100.0; } break; case CraftResource.Gold: { minskill = 75.0; minskill2 = 40.0; maxskill = 100.0; } break; case CraftResource.Agapite: { minskill = 80.0; minskill2 = 45.0; maxskill = 100.0; } break; case CraftResource.Verite: { minskill = 85.0; minskill2 = 50.0; maxskill = 100.0; } break; case CraftResource.Valorite: { minskill = 90.0; minskill2 = 55.0; maxskill = 100.0; } break; case CraftResource.Silver: { minskill = 100.0; minskill2 = 60.0; maxskill = 100.0; } break; //case CraftResource.Jade: { minskill = 105.0; minskill2 = 105.0; maxskill = 120.0; } break; //case CraftResource.Moonstone: { minskill = 110.0; minskill2 = 105.0; maxskill = 120.0; } break; // case CraftResource.Sunstone: { minskill = 110.0; minskill2 = 105.0; maxskill = 120.0; } break; } if (Utility.RandomDouble() <= 0.01 || skillbase < minskill) { ore = new IronOre(); minskill = 00.0; minskill2 = 00.0; maxskill = 100.0; } if (!(from.CheckSkill(SkillName.Mining, minskill2, maxskill))) { ore.Delete(); return(false); } } ore.Amount = (map == Map.Felucca ? 2 : 1); if (from != null) { from.AddToBackpack(ore); } else { ore.Delete(); } bank.Consume(ore.Amount, this); this.Hue = ore.Hue; return(true); }
public virtual Item ReapResource(int hue, Mobile from, int amount) { Item resourceItem = null; HarvestResource resource = null; if (amount > 0) { // changes to check for all defined resources not just matching hue when chopping (TC) /* * if( PhaseResources.ContainsKey(hue)) * { * resource = PhaseResources[hue]; * } * else if (PhaseResources.ContainsKey(0)) * { * resource = PhaseResources[0]; * } */ // get resources HarvestResource fallbackResource = null; if (PhaseResources.Count == 1) { // seriously... apart from Linq, no way to get ONE value from a dictionary? foreach (HarvestResource val in PhaseResources.Values) { fallbackResource = val; } } else if (PhaseResources.Count > 1) { // sort through resources - fallbackResource is the easiest to chop int lowestKey = -1; double lowestReqSkill = -1; foreach (int key in PhaseResources.Keys) { if (PhaseResources[key].ReqSkill < lowestReqSkill || lowestReqSkill == -1) { lowestKey = key; lowestReqSkill = PhaseResources[key].ReqSkill; } } fallbackResource = PhaseResources[lowestKey]; // check skill req for fallbackResource if (from.Skills[HarvestSkill].Value < fallbackResource.ReqSkill) { fallbackResource = null; } // get a random resource other than fallbackResource List <HarvestResource> mainResources = new List <HarvestResource>(); foreach (int key in PhaseResources.Keys) { if (key == lowestKey) { continue; } mainResources.Add(PhaseResources[key]); } // Console.Writeline("phaseresource count ="+ PhaseResource.Count); if (mainResources.Count > 1) { resource = mainResources[Utility.RandomMinMax(1, PhaseResources.Count - 7)]; } else { resource = mainResources[0]; } // check skill req for main resource if (from.Skills[HarvestSkill].Value < resource.ReqSkill) { resource = null; } } // check for main resource if (resource != null) { // from CheckSkill(lumberjacking, resource.MinSkill, resource.MaxSkill); double minSkill = resource.MinSkill; double maxSkill = resource.MaxSkill; double value = from.Skills[HarvestSkill].Value; double chance; if (value < minSkill || from.Skills.Cap == 0) { chance = 0; // Too difficult } else if (value >= maxSkill) { chance = 1; // No challenge } else { chance = (value - minSkill) / (maxSkill - minSkill); } if (chance < Utility.RandomDouble()) { resource = null; // unlucky - reset resource } } // skillcheck passed in LumberHarvest.cs - give fallback resource if (resource == null && fallbackResource != null) { resource = fallbackResource; } if (resource != null) { try { Type type = resource.Types[Utility.Random(resource.Types.Length)]; Item item = Activator.CreateInstance(type) as Item; if (item != null) { item.Amount = amount; resourceItem = item; } } catch { Console.WriteLine("exception caught when trying to create bonus resource"); } } else { from.SendMessage("You won't be able to chop any useable wood out of this type of trees quite yet."); } } return(resourceItem); }
public void DoMining() { if (Map == null || Map == Map.Internal) { return; } // We may not mine while we are fighting if (Combatant != null) { return; } if (this.Backpack.TotalWeight >= this.Backpack.MaxWeight) { Emote(String.Format("My backpack is full and cannot hold anymore!", Name)); if (m_MiningTimer != null && m_MiningTimer.Running) { m_MiningTimer.Stop(); Emote(String.Format("{0} stops mining", Name)); } } HarvestSystem system = Mining.System; HarvestDefinition def = Mining.System.OreAndStone; // Our target is the land tile under us Map map = this.Map; Point3D loc = this.Location; int x = 0, y = 0; GetMiningOffset(this.Direction, ref x, ref y); loc.X += x; loc.Y += y; int tileId = map.Tiles.GetLandTile(loc.X, loc.Y).ID & (0x3FFF | 0x4000); foreach (StaticTile staticTile in this.GetStaticTilesInRange(map, 0)) { if ((staticTile.ID >= 1339 && staticTile.ID >= 1359) || (staticTile.ID >= 1361 && staticTile.ID >= 1363) || staticTile.ID == 1386) { tileId = staticTile.ID; } } if (!def.Validate(tileId) && !def.ValidateSpecial(tileId)) { return; } HarvestBank bank = def.GetBank(map, loc.X, loc.Y); bool available = (bank != null && bank.Current >= def.ConsumedPerHarvest); if (!available) { Emote(String.Format("There is no metal here to mine")); return; } if (bank == null || bank.Current < def.ConsumedPerHarvest) { return; } HarvestVein vein = bank.Vein; if (vein == null) { return; } HarvestResource primary = vein.PrimaryResource; HarvestResource fallback = def.Resources[0]; HarvestResource resource = system.MutateResource(this, null, def, map, loc, vein, primary, fallback); double skillBase = this.Skills[def.Skill].Base; Type type = null; if (skillBase >= resource.ReqSkill && this.CheckSkill(def.Skill, resource.MinSkill, resource.MaxSkill)) { type = system.GetResourceType(this, null, def, map, loc, resource); if (type != null) { type = system.MutateType(type, this, null, def, map, loc, resource); } if (type != null) { Item item = system.Construct(type, this, null); if (item == null) { type = null; } else { if (item.Stackable) { int amount = def.ConsumedPerHarvest; int feluccaAmount = def.ConsumedPerFeluccaHarvest; bool inFelucca = (map == Map.Felucca); if (inFelucca) { item.Amount = feluccaAmount; } else { item.Amount = amount; } } bank.Consume(item.Amount, this); Container pack = this.Backpack; if (pack == null) { return; } this.Hue = item.Hue; pack.DropItem(item); if (item.ItemID == 6583) { item.Delete(); } else { Smelt(item); } // item.MoveToWorld(loc, map); system.DoHarvestingEffect(this, null, def, map, loc); system.DoHarvestingSound(this, null, def, null); // Mine for gems BonusHarvestResource bonus = def.GetBonusResource(); if (bonus != null && bonus.Type != null && skillBase >= bonus.ReqSkill) { Item bonusItem = system.Construct(bonus.Type, this, null); //item.MoveToWorld(loc, map); //pack.DropItem( bonusItem ); pack.TryDropItem(this, bonusItem, false); } } } } }
public HarvestVein(double veinChance, HarvestResource resource) { VeinChance = veinChance; Resource = resource; }