예제 #1
0
        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);
                        }
                    }
                }
            }
        }
예제 #2
0
        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);
                        }
                    }
                }
            }
        }