Consume() public méthode

public Consume ( int amount, Mobile from ) : void
amount int
from Mobile
Résultat void
Exemple #1
0
        public override Item Construct(Type type, Mobile from, Item tool, HarvestDefinition def, HarvestBank bank, HarvestResource resource)
        {
            if (UseLumberjackingCaptcha)
            {
                Item item = base.Construct(type, from, tool, def, bank, resource);

                if (item == null)
                {
                    return(null);
                }

                Server.Mobiles.PlayerMobile pm = from as Server.Mobiles.PlayerMobile;

                if (pm != null && !pm.HarvestLockedout)
                {
                    pm.TempStashedHarvestDef = def;
                    pm.TempStashedHarvest    = item;

                    item.Amount = bank.Current;
                    bank.Consume(bank.Current, from);
                    HarvestSystem.WearTool(from, tool, def);
                }

                return(null);
            }

            else
            {
                return(base.Construct(type, from, tool, def, bank, resource));
            }
        }
        public virtual void FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked)
        {
            from.EndAction(locked);

            if (!CheckHarvest(from, tool))
            {
                return;
            }

            int     tileID;
            Map     map;
            Point3D loc;

            if (!GetHarvestDetails(from, tool, toHarvest, out tileID, out map, out loc))
            {
                OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }
            else if (!def.Validate(tileID) && !def.ValidateSpecial(tileID))
            {
                OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }

            if (!CheckRange(from, tool, def, map, loc, true))
            {
                return;
            }
            else if (!CheckResources(from, tool, def, map, loc, true))
            {
                return;
            }
            else if (!CheckHarvest(from, tool, def, toHarvest))
            {
                return;
            }

            if (SpecialHarvest(from, tool, def, map, loc))
            {
                return;
            }

            HarvestBank bank = def.GetBank(map, loc.X, loc.Y);

            if (bank == null)
            {
                return;
            }

            HarvestVein vein = bank.Vein;

            if (vein != null)
            {
                vein = MutateVein(from, tool, def, bank, toHarvest, vein);
            }

            if (vein == null)
            {
                return;
            }

            HarvestResource primary  = vein.PrimaryResource;
            HarvestResource fallback = vein.FallbackResource;
            HarvestResource resource = MutateResource(from, tool, def, map, loc, vein, primary, fallback);

            double skillBase = from.Skills[def.Skill].Base;

            Type type = null;

            if (CheckHarvestSkill(map, loc, from, resource, def))
            {
                type = GetResourceType(from, tool, def, map, loc, resource);

                if (type != null)
                {
                    type = MutateType(type, from, tool, def, map, loc, resource);
                }

                if (type != null)
                {
                    Item item = Construct(type, from, tool);

                    if (item == null)
                    {
                        type = null;
                    }
                    else
                    {
                        int amount        = def.ConsumedPerHarvest;
                        int feluccaAmount = def.ConsumedPerFeluccaHarvest;
                        //The whole harvest system is kludgy and I'm sure this is just adding to it.
                        if (item.Stackable)
                        {
                            int racialAmount        = (int)Math.Ceiling(amount * 1.1);
                            int feluccaRacialAmount = (int)Math.Ceiling(feluccaAmount * 1.1);

                            bool eligableForRacialBonus = (def.RaceBonus && from.Race == Race.Human);
                            bool inFelucca = map == Map.Felucca && !Siege.SiegeShard;

                            if (eligableForRacialBonus && inFelucca && bank.Current >= feluccaRacialAmount && 0.1 > Utility.RandomDouble())
                            {
                                item.Amount = feluccaRacialAmount;
                            }
                            else if (inFelucca && bank.Current >= feluccaAmount)
                            {
                                item.Amount = feluccaAmount;
                            }
                            else if (eligableForRacialBonus && bank.Current >= racialAmount && 0.1 > Utility.RandomDouble())
                            {
                                item.Amount = racialAmount;
                            }
                            else
                            {
                                item.Amount = amount;
                            }

                            // Void Pool Rewards
                            item.Amount += WoodsmansTalisman.CheckHarvest(from, type, this);
                        }

                        bank.Consume(amount, from);
                        EventSink.InvokeResourceHarvestSuccess(new ResourceHarvestSuccessEventArgs(from, tool, item, this));

                        if (Give(from, item, def.PlaceAtFeetIfFull))
                        {
                            SendSuccessTo(from, item, resource);
                        }
                        else
                        {
                            SendPackFullTo(from, item, def, resource);
                            item.Delete();
                        }

                        BonusHarvestResource bonus = def.GetBonusResource();

                        if (bonus != null && bonus.Type != null && skillBase >= bonus.ReqSkill)
                        {
                            if (bonus.RequiredMap == null || bonus.RequiredMap == from.Map)
                            {
                                Item bonusItem = Construct(bonus.Type, from, tool);

                                if (Give(from, bonusItem, true))                                        //Bonuses always allow placing at feet, even if pack is full irregrdless of def
                                {
                                    bonus.SendSuccessTo(from);
                                }
                                else
                                {
                                    bonusItem.Delete();
                                }
                            }
                        }
                    }

                    #region High Seas
                    OnToolUsed(from, tool, item != null);
                    #endregion
                }

                // Siege rules will take into account axes and polearms used for lumberjacking
                if (tool is IUsesRemaining && (tool is BaseHarvestTool || tool is Pickaxe || tool is SturdyPickaxe || tool is GargoylesPickaxe || Siege.SiegeShard))
                {
                    IUsesRemaining toolWithUses = (IUsesRemaining)tool;

                    toolWithUses.ShowUsesRemaining = true;

                    if (toolWithUses.UsesRemaining > 0)
                    {
                        --toolWithUses.UsesRemaining;
                    }

                    if (toolWithUses.UsesRemaining < 1)
                    {
                        tool.Delete();
                        def.SendMessageTo(from, def.ToolBrokeMessage);
                    }
                }
            }

            if (type == null)
            {
                def.SendMessageTo(from, def.FailMessage);
            }

            OnHarvestFinished(from, tool, def, vein, bank, resource, toHarvest);
        }
Exemple #3
0
        public virtual void FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked)
        {
            from.EndAction(locked);

            if (!CheckHarvest(from, tool))
            {
                return;
            }

            int     tileID;
            Map     map;
            Point3D loc;

            if (!GetHarvestDetails(from, tool, toHarvest, out tileID, out map, out loc))
            {
                OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }
            else if (!def.Validate(tileID))
            {
                OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }

            if (!CheckRange(from, tool, def, map, loc, true))
            {
                return;
            }
            else if (!CheckResources(from, tool, def, map, loc, true))
            {
                return;
            }
            else if (!CheckHarvest(from, tool, def, toHarvest))
            {
                return;
            }

            if (SpecialHarvest(from, tool, def, map, loc))
            {
                return;
            }

            HarvestBank bank = def.GetBank(map, loc.X, loc.Y);

            if (bank == null)
            {
                return;
            }

            HarvestVein vein = bank.Vein;

            if (vein != null)
            {
                vein = MutateVein(from, tool, def, bank, toHarvest, vein);
            }

            if (vein == null)
            {
                return;
            }

            HarvestResource primary  = vein.PrimaryResource;
            HarvestResource fallback = vein.FallbackResource;
            HarvestResource resource = MutateResource(from, tool, def, map, loc, vein, primary, fallback);

            double skillBase  = from.Skills[def.Skill].Base;
            double skillValue = from.Skills[def.Skill].Value;

            Type type = null;

            if (skillBase >= resource.ReqSkill && from.CheckSkill(def.Skill, resource.MinSkill, resource.MaxSkill))
            {
                type = GetResourceType(from, tool, def, map, loc, resource);

                if (type != null)
                {
                    type = MutateType(type, from, tool, def, map, loc, resource);
                }

                if (type != null)
                {
                    Item item = Construct(type, from);

                    if (item == null)
                    {
                        type = null;
                    }
                    else
                    {
                        //The whole harvest system is kludgy and I'm sure this is just adding to it.
                        if (item.Stackable)
                        {
                            int amount        = def.ConsumedPerHarvest;
                            int feluccaAmount = def.ConsumedPerFeluccaHarvest;

                            int racialAmount        = (int)Math.Ceiling(amount * 1.1);
                            int feluccaRacialAmount = (int)Math.Ceiling(feluccaAmount * 1.1);

                            bool eligableForRacialBonus = (def.RaceBonus && from.Race == Race.Human);
                            bool inFelucca = (map == Map.Felucca);

                            if (eligableForRacialBonus && inFelucca && bank.Current >= feluccaRacialAmount)
                            {
                                item.Amount = feluccaRacialAmount;
                            }
                            else if (inFelucca && bank.Current >= feluccaAmount)
                            {
                                item.Amount = feluccaAmount;
                            }
                            else if (eligableForRacialBonus && bank.Current >= racialAmount)
                            {
                                item.Amount = racialAmount;
                            }
                            else
                            {
                                item.Amount = amount;
                            }
                        }

                        if (bank.Current <= 3 && item is IronOre)
                        {
                            bank.Consume(item.Amount, from);
                            item.Delete();
                            Item items;
                            if (Utility.Random(100) > 50)
                            {
                                items = new SmallIronOre();
                            }
                            else
                            {
                                items = new SmallestIronOre();
                            }

                            if (Give(from, items, def.PlaceAtFeetIfFull))
                            {
                                SendSuccessTo(from, items, resource);
                            }
                            else
                            {
                                SendPackFullTo(from, items, def, resource);
                                items.Delete();
                            }
                        }
                        else
                        {
                            bank.Consume(item.Amount, from);

                            if (Give(from, item, def.PlaceAtFeetIfFull))
                            {
                                SendSuccessTo(from, item, resource);
                            }
                            else
                            {
                                SendPackFullTo(from, item, def, resource);
                                item.Delete();
                            }
                        }

                        BonusHarvestResource bonus = def.GetBonusResource();

                        if (bonus != null && bonus.Type != null && skillBase >= bonus.ReqSkill)
                        {
                            Item bonusItem = Construct(bonus.Type, from);

                            if (Give(from, bonusItem, true))                                    //Bonuses always allow placing at feet, even if pack is full irregrdless of def
                            {
                                bonus.SendSuccessTo(from);
                            }
                            else
                            {
                                item.Delete();
                            }
                        }

                        if (tool is IUsesRemaining)
                        {
                            IUsesRemaining toolWithUses = (IUsesRemaining)tool;

                            toolWithUses.ShowUsesRemaining = true;

                            if (toolWithUses.UsesRemaining > 0)
                            {
                                if (!((tool.LootType == LootType.Newbied) && (tool is BaseAxe)))
                                {
                                    --toolWithUses.UsesRemaining;
                                }
                            }

                            if (toolWithUses.UsesRemaining < 1)
                            {
                                tool.Delete();
                                def.SendMessageTo(from, def.ToolBrokeMessage);
                            }
                        }
                    }
                }
            }

            if (type == null)
            {
                def.SendMessageTo(from, def.FailMessage);
            }

            OnHarvestFinished(from, tool, def, vein, bank, resource, toHarvest);
        }
        public virtual void FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked)
        {
            from.EndAction(locked);

            if (!CheckHarvest(from, tool))
            {
                return;
            }

            int     tileID;
            Map     map;
            Point3D loc;

            if (!GetHarvestDetails(from, tool, toHarvest, out tileID, out map, out loc))
            {
                OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }
            else if (!def.Validate(tileID))
            {
                OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }

            if (!CheckRange(from, tool, def, map, loc, true))
            {
                return;
            }
            else if (!CheckResources(from, tool, def, map, loc, true))
            {
                return;
            }
            else if (!CheckHarvest(from, tool, def, toHarvest))
            {
                return;
            }

            if (SpecialHarvest(from, tool, def, map, loc))
            {
                return;
            }

            HarvestBank bank = def.GetBank(map, loc.X, loc.Y);

            if (bank == null)
            {
                return;
            }

            HarvestVein vein = bank.Vein;

            if (vein != null)
            {
                vein = MutateVein(from, tool, def, bank, toHarvest, vein);
            }

            if (vein == null)
            {
                return;
            }

            HarvestResource primary  = vein.PrimaryResource;
            HarvestResource fallback = vein.FallbackResource;
            HarvestResource resource = MutateResource(from, tool, def, map, loc, vein, primary, fallback);

            double skillBase  = from.Skills[def.Skill].Base;
            double skillValue = from.Skills[def.Skill].Value;

            Type type = null;

            if (skillBase >= resource.ReqSkill && from.CheckSkill(def.Skill, resource.MinSkill, resource.MaxSkill))
            {
                type = GetResourceType(from, tool, def, map, loc, resource);

                if (type != null)
                {
                    type = MutateType(type, from, tool, def, map, loc, resource);
                }

                if (type != null)
                {
                    Item item = Construct(type, from);

                    if (item == null)
                    {
                        type = null;
                    }
                    else
                    {
                        if (item.Stackable)
                        {
                            if (map == Map.Felucca && bank.Current >= def.ConsumedPerFeluccaHarvest)
                            {
                                item.Amount = def.ConsumedPerFeluccaHarvest;
                            }
                            else
                            {
                                item.Amount = def.ConsumedPerHarvest;
                            }
                        }

                        bank.Consume(def, item.Amount);

                        if (Give(from, item, def.PlaceAtFeetIfFull))
                        {
                            SendSuccessTo(from, item, resource);
                        }
                        else
                        {
                            SendPackFullTo(from, item, def, resource);
                            item.Delete();
                        }

                        if (tool is IUsesRemaining)
                        {
                            IUsesRemaining toolWithUses = (IUsesRemaining)tool;

                            toolWithUses.ShowUsesRemaining = true;

                            if (toolWithUses.UsesRemaining > 0)
                            {
                                --toolWithUses.UsesRemaining;
                            }

                            if (toolWithUses.UsesRemaining < 1)
                            {
                                tool.Delete();
                                def.SendMessageTo(from, def.ToolBrokeMessage);
                            }
                        }
                    }
                }
            }

            if (type == null)
            {
                def.SendMessageTo(from, def.FailMessage);
            }

            OnHarvestFinished(from, tool, def, vein, bank, resource, toHarvest);
        }
Exemple #5
0
        public override void FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked)
        {
            //Lava fishing needs to have its own set of rules.
            if (IsLavaHarvest(tool, toHarvest))
            {
                from.EndAction(locked);

                if (!CheckHarvest(from, tool))
                {
                    return;
                }

                int     tileID;
                Map     map;
                Point3D loc;

                if (!GetHarvestDetails(from, tool, toHarvest, out tileID, out map, out loc))
                {
                    OnBadHarvestTarget(from, tool, toHarvest);
                    return;
                }
                else if (!def.Validate(tileID) && !def.ValidateSpecial(tileID))
                {
                    OnBadHarvestTarget(from, tool, toHarvest);
                    return;
                }

                if (!CheckRange(from, tool, def, map, loc, true))
                {
                    return;
                }
                else if (!CheckResources(from, tool, def, map, loc, true))
                {
                    return;
                }
                else if (!CheckHarvest(from, tool, def, toHarvest))
                {
                    return;
                }

                HarvestBank bank = def.GetBank(map, loc.X, loc.Y);

                if (bank == null)
                {
                    return;
                }

                HarvestVein vein = bank.Vein;

                if (vein == null)
                {
                    return;
                }

                Type type = null;

                HarvestResource resource = MutateResource(from, tool, def, map, loc, vein, vein.PrimaryResource, vein.FallbackResource);

                if (from.CheckSkill(def.Skill, resource.MinSkill, resource.MaxSkill))
                {
                    //Special eye candy item
                    type = GetSpecialLavaItem(from, tool, map, loc, toHarvest);

                    //Special fish
                    if (type == null)
                    {
                        type = FishInfo.GetSpecialItem(from, tool, loc, IsLavaHarvest(tool, tileID));
                    }

                    if (type != null)
                    {
                        Item item = Construct(type, from, tool);

                        if (item == null)
                        {
                            type = null;
                        }
                        else
                        {
                            if (from.AccessLevel == AccessLevel.Player)
                            {
                                bank.Consume(Convert.ToInt32(map != null && map.Rules == MapRules.FeluccaRules ? Math.Ceiling(item.Amount / 2.0) : item.Amount), from);
                            }

                            if (Give(from, item, true))
                            {
                                SendSuccessTo(from, item, null);
                            }
                            else
                            {
                                SendPackFullTo(from, item, def, null);
                                item.Delete();
                            }
                        }
                    }
                }

                if (type == null)
                {
                    def.SendMessageTo(from, def.FailMessage);

                    double skill = from.Skills[SkillName.Fishing].Value / 50;

                    if (0.5 / skill > Utility.RandomDouble())
                    {
                        OnToolUsed(from, tool, false);
                    }
                }
                else
                {
                    OnToolUsed(from, tool, true);
                }

                OnHarvestFinished(from, tool, def, vein, bank, null, null);
            }
            else
            {
                base.FinishHarvesting(from, tool, def, toHarvest, locked);
            }
        }
        public virtual void FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked)
        {
            from.EndAction(locked);
            from.RevealingAction();

            if (!CheckHarvest(from, tool))
            {
                return;
            }

            int     tileID;
            Map     map;
            Point3D loc;

            if (!GetHarvestDetails(from, tool, toHarvest, out tileID, out map, out loc))
            {
                OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }

            else if (!def.Validate(tileID))
            {
                OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }

            if (!CheckRange(from, tool, def, map, loc, true))
            {
                return;
            }

            else if (!CheckResources(from, tool, def, map, loc, true))
            {
                return;
            }

            else if (!CheckHarvest(from, tool, def, toHarvest))
            {
                return;
            }

            if (SpecialHarvest(from, tool, def, map, loc))
            {
                return;
            }

            HarvestBank bank = def.GetBank(map, loc.X, loc.Y);

            if (bank == null)
            {
                return;
            }

            HarvestVein vein = bank.Vein;

            if (vein != null)
            {
                vein = MutateVein(from, tool, def, bank, toHarvest, vein);
            }

            if (vein == null)
            {
                return;
            }

            HarvestResource primary  = vein.PrimaryResource;
            HarvestResource fallback = vein.FallbackResource;
            HarvestResource resource = MutateResource(from, tool, def, map, loc, vein, primary, fallback);

            double skillBase  = from.Skills[def.Skill].Base;
            double skillValue = from.Skills[def.Skill].Value;

            Type type = null;

            if (skillBase >= resource.ReqSkill && from.CheckSkill(def.Skill, resource.MinSkill, resource.MaxSkill, 1.0))
            {
                type = GetResourceType(from, tool, def, map, loc, resource);

                if (type != null)
                {
                    type = MutateType(type, from, tool, def, map, loc, resource);
                }

                if (type != null)
                {
                    Item item = Construct(type, from, tool, def, bank, resource);

                    if (item == null)
                    {
                        type = null;
                    }

                    else
                    {
                        BaseShip ownerShip = BaseShip.FindShipAt(from.Location, from.Map);

                        if (item is MessageInABottle)
                        {
                        }

                        else if (item is RawFish || item is RawLargeFish)
                        {
                            if (ownerShip != null)
                            {
                                if (ownerShip.IsOwner(from) || ownerShip.IsCoOwner(from) || ownerShip.IsFriend(from))
                                {
                                    //ownerShip.fishCaught++;
                                }
                            }
                        }

                        if (item.Stackable)
                        {
                            int amount        = def.ConsumedPerHarvest;
                            int feluccaAmount = def.ConsumedPerFeluccaHarvest;

                            int racialAmount        = (int)Math.Ceiling(amount * 1.1);
                            int feluccaRacialAmount = (int)Math.Ceiling(feluccaAmount * 1.1);

                            bool eligableForRacialBonus = (def.RaceBonus && from.Race == Race.Human);
                            bool inFelucca = (map == Map.Felucca);

                            if (eligableForRacialBonus && inFelucca && bank.Current >= feluccaRacialAmount && 0.1 > Utility.RandomDouble())
                            {
                                item.Amount = feluccaRacialAmount;
                            }

                            else if (inFelucca && bank.Current >= feluccaAmount)
                            {
                                item.Amount = feluccaAmount;
                            }

                            else if (eligableForRacialBonus && bank.Current >= racialAmount && 0.1 > Utility.RandomDouble())
                            {
                                item.Amount = racialAmount;
                            }

                            else
                            {
                                item.Amount = amount;
                            }
                        }

                        bank.Consume(item.Amount, from);

                        if (Give(from, item, def.PlaceAtFeetIfFull))
                        {
                            SendSuccessTo(from, item, resource);
                        }

                        else
                        {
                            SendPackFullTo(from, item, def, resource);
                            item.Delete();
                        }

                        BonusHarvestResource bonus = def.GetBonusResource();

                        if (bonus != null && bonus.Type != null && skillBase >= bonus.ReqSkill)
                        {
                            Item bonusItem = Construct(bonus.Type, from, tool, def, bank, resource);

                            if (Give(from, bonusItem, true))
                            {
                                bonus.SendSuccessTo(from);
                            }

                            else
                            {
                                item.Delete();
                            }
                        }

                        WearTool(from, tool, def);
                    }
                }

                //TEST: CHECK THIS

                /*
                 * if (type == null)
                 * {
                 *  if ((def.Skill != SkillName.Mining && def.Skill != SkillName.Lumberjacking) || !Mining.UseMiningCaptcha)
                 *  {
                 *      def.SendMessageTo(from, def.FailMessage);
                 *
                 *      FailHarvest(from, def);
                 *  }
                 * }
                 */
            }

            else
            {
                def.SendMessageTo(from, def.FailMessage);

                FailHarvest(from, def);
            }

            OnHarvestFinished(from, tool, def, vein, bank, resource, toHarvest);
        }
Exemple #7
0
        public override void OnHarvestFinished(Mobile from, Item tool, HarvestDefinition def, HarvestVein vein, HarvestBank bank, HarvestResource resource, object harvested)
        {
            if (tool is GargoylesPickaxe && def == m_OreAndStone && 0.1 > Utility.RandomDouble())
            {
                HarvestResource res = vein.PrimaryResource;

                if (res == resource && res.Types.Length >= 3)
                {
                    try
                    {
                        Map map = from.Map;

                        if (map == null)
                        {
                            return;
                        }

                        BaseCreature spawned = Activator.CreateInstance(res.Types[2], new object[] { 25 }) as BaseCreature;

                        if (spawned != null)
                        {
                            int offset = Utility.Random(8) * 2;

                            for (int i = 0; i < m_Offsets.Length; i += 2)
                            {
                                int x = from.X + m_Offsets[(offset + i) % m_Offsets.Length];
                                int y = from.Y + m_Offsets[(offset + i + 1) % m_Offsets.Length];

                                if (map.CanSpawnMobile(x, y, from.Z))
                                {
                                    spawned.OnBeforeSpawn(new Point3D(x, y, from.Z), map);
                                    spawned.MoveToWorld(new Point3D(x, y, from.Z), map);
                                    spawned.Combatant = from;
                                    return;
                                }
                                else
                                {
                                    int z = map.GetAverageZ(x, y);

                                    if (map.CanSpawnMobile(x, y, z))
                                    {
                                        spawned.OnBeforeSpawn(new Point3D(x, y, z), map);
                                        spawned.MoveToWorld(new Point3D(x, y, z), map);
                                        spawned.Combatant = from;
                                        return;
                                    }
                                }
                            }
                            spawned.OnBeforeSpawn(from.Location, from.Map);
                            spawned.MoveToWorld(from.Location, from.Map);
                            spawned.Combatant = from;
                        }
                    }
                    catch
                    {
                    }
                }
            }

            if (bank != null && bank.Vein != null && bank.Vein.PrimaryResource != null)
            {
                int    bankAmount = bank.Current;
                double skillReq   = bank.Vein.PrimaryResource.ReqSkill;

                if (skillReq >= 99.0 && bankAmount <= 13)
                {
                    bank.Consume(def, bankAmount, from);
                }
                else if (skillReq >= 98.0 && bankAmount <= 12)
                {
                    bank.Consume(def, bankAmount, from);
                }
                else if (skillReq >= 97.0 && bankAmount <= 10)
                {
                    bank.Consume(def, bankAmount, from);
                }
                else if (skillReq >= 90.0 && bankAmount <= 8)
                {
                    bank.Consume(def, bankAmount, from);
                }
                else if (skillReq >= 75.0 && bankAmount <= 6)
                {
                    bank.Consume(def, bankAmount, from);
                }
                else if (skillReq >= 65.0 && bankAmount <= 4)
                {
                    bank.Consume(def, bankAmount, from);
                }
            }
        }
/* End Captcha Mod */



        public virtual void FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked)
        {
            from.EndAction(locked);

            if (!this.CheckHarvest(from, tool))
            {
                return;
            }

            int     tileID;
            Map     map;
            Point3D loc;

            if (!this.GetHarvestDetails(from, tool, toHarvest, out tileID, out map, out loc))
            {
                this.OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }
            else if (!def.Validate(tileID))
            {
                this.OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }

            if (!this.CheckRange(from, tool, def, map, loc, true))
            {
                return;
            }
            else if (!this.CheckResources(from, tool, def, map, loc, true))
            {
                return;
            }
            else if (!this.CheckHarvest(from, tool, def, toHarvest))
            {
                return;
            }

            if (this.SpecialHarvest(from, tool, def, map, loc))
            {
                return;
            }

            HarvestBank bank = def.GetBank(map, loc.X, loc.Y);

            if (bank == null)
            {
                return;
            }

            HarvestVein vein = bank.Vein;

            if (vein != null)
            {
                vein = this.MutateVein(from, tool, def, bank, toHarvest, vein);
            }

            if (vein == null)
            {
                return;
            }

            HarvestResource primary  = vein.PrimaryResource;
            HarvestResource fallback = vein.FallbackResource;
            HarvestResource resource = this.MutateResource(from, tool, def, map, loc, vein, primary, fallback);

            double skillBase  = from.Skills[def.Skill].Base;
            double skillValue = from.Skills[def.Skill].Value;

            Type type = null;

            //daat99 OWLTR start - daat99 harvesting
            type = GetResourceType(from, tool, def, map, loc, resource);
            bool daatHarvesting = false;

            if (daat99.OWLTROptionsManager.IsEnabled(daat99.OWLTROptionsManager.OPTIONS_ENUM.DAAT99_MINING) && (type.IsSubclassOf(typeof(BaseOre)) || type.IsSubclassOf(typeof(BaseGranite))))
            {
                daatHarvesting = true;
            }
            else if (daat99.OWLTROptionsManager.IsEnabled(daat99.OWLTROptionsManager.OPTIONS_ENUM.DAAT99_LUMBERJACKING) && type.IsSubclassOf(typeof(BaseLog)))
            {
                daatHarvesting = true;
            }
            if (daatHarvesting || (skillBase >= resource.ReqSkill && from.CheckSkill(def.Skill, resource.MinSkill, resource.MaxSkill)))
            {
                if (type != null)                      //añadido 18/03/2018
                {
                    type = GetResourceType(from, tool, def, map, loc, resource);
                }

                if (type != null)
                {
                    type = MutateType(type, from, tool, def, map, loc, resource);
                }
                if (daatHarvesting)
                {
                    type = ResourceHelper.GetDaat99HarvestedType(type, bank.Vein.IsProspected, skillValue);
                    from.CheckSkill(def.Skill, 0.0, from.Skills[def.Skill].Cap + (vein.IsProspected?10.0:0.0));
                }
                //daat99 OWLTR end - daat99 harvesting

                if (type != null)
                {
                    Item item = this.Construct(type, from);

                    if (item == null)
                    {
                        type = null;
                    }
                    else
                    {
                        //The whole harvest system is kludgy and I'm sure this is just adding to it.
                        if (item.Stackable)
                        {
                            int amount        = def.ConsumedPerHarvest;
                            int feluccaAmount = def.ConsumedPerFeluccaHarvest;

                            int racialAmount        = (int)Math.Ceiling(amount * 1.1);
                            int feluccaRacialAmount = (int)Math.Ceiling(feluccaAmount * 1.1);

                            bool eligableForRacialBonus = (def.RaceBonus && from.Race == Race.Human);
                            bool inFelucca = (map == Map.Felucca);

                            if (eligableForRacialBonus && inFelucca && bank.Current >= feluccaRacialAmount && 0.1 > Utility.RandomDouble())
                            {
                                item.Amount = feluccaRacialAmount;
                            }
                            else if (inFelucca && bank.Current >= feluccaAmount)
                            {
                                item.Amount = feluccaAmount;
                            }
                            else if (eligableForRacialBonus && bank.Current >= racialAmount && 0.1 > Utility.RandomDouble())
                            {
                                item.Amount = racialAmount;
                            }
                            else
                            {
                                item.Amount = amount;
                            }
                        }

                        bank.Consume(item.Amount, from);
                        //daat99 OWLTR start - custom harvesting
                        CraftResource craftResourceFromType = CraftResources.GetFromType(type);
                        string        s_Type   = "UNKNOWN";
                        int           i_Tokens = 1;
                        if (craftResourceFromType != CraftResource.None)
                        {
                            s_Type   = CraftResources.GetInfo(craftResourceFromType).Name;
                            i_Tokens = CraftResources.GetIndex(craftResourceFromType) + 1;
                        }
                        if (craftResourceFromType != CraftResource.None && daat99.OWLTROptionsManager.IsEnabled(daat99.OWLTROptionsManager.OPTIONS_ENUM.DAAT99_MINING) && def.Skill == SkillName.Mining && (type.IsSubclassOf(typeof(Server.Items.BaseOre)) || type.IsSubclassOf(typeof(Server.Items.BaseGranite))))
                        {
                            if (type.IsSubclassOf(typeof(Server.Items.BaseOre)))
                            {
                                if (Give(from, item, def.PlaceAtFeetIfFull))
                                {
                                    from.SendMessage("You dig some {0} ore and placed it in your backpack.", s_Type);
                                }
                                else
                                {
                                    from.SendMessage("Your backpack is full, so the ore you mined is lost.");
                                    item.Delete();
                                }
                            }
                            else
                            {
                                if (Give(from, item, def.PlaceAtFeetIfFull))
                                {
                                    from.SendMessage("You carefully extract some workable stone from the ore vein.");
                                }
                                else
                                {
                                    from.SendMessage("Your backpack is full, so the ore you mined is lost.");
                                    item.Delete();
                                }
                            }
                        }
                        else if (craftResourceFromType != CraftResource.None && OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.DAAT99_LUMBERJACKING) && def.Skill == SkillName.Lumberjacking)
                        {
                            if (Give(from, item, def.PlaceAtFeetIfFull))
                            {
                                from.SendMessage("You placed some {0} logs in your backpack.", s_Type);
                            }
                            else
                            {
                                from.SendMessage("You can't place any wood into your backpack!");
                                item.Delete();
                            }
                        }
                        else
                        {
                            //daat99 OWLTR end - custom harvesting

                            if (Give(from, item, def.PlaceAtFeetIfFull))
                            {
                                SendSuccessTo(from, item, resource);
                            }
                            else
                            {
                                SendPackFullTo(from, item, def, resource);
                                item.Delete();
                            }
                            //daat99 OWLTR start - custom harvesting
                        }
                        if (from.Map == Map.Felucca)
                        {
                            i_Tokens = (int)(i_Tokens * 1.5);
                        }
                        if (OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.HARVEST_GIVE_TOKENS))
                        {
                            TokenSystem.GiveTokensToPlayer(from as Server.Mobiles.PlayerMobile, i_Tokens);
                        }
                        //daat99 OWLTR end - custom harvesting



                        BonusHarvestResource bonus = def.GetBonusResource();

                        if (bonus != null && bonus.Type != null && skillBase >= bonus.ReqSkill)
                        {
                            Item bonusItem = this.Construct(bonus.Type, from);

                            if (this.Give(from, bonusItem, true))   //Bonuses always allow placing at feet, even if pack is full irregrdless of def
                            {
                                bonus.SendSuccessTo(from);
                            }
                            else
                            {
                                item.Delete();
                            }
                        }

                        if (tool is IUsesRemaining)
                        {
                            IUsesRemaining toolWithUses = (IUsesRemaining)tool;

                            toolWithUses.ShowUsesRemaining = true;

                            if (toolWithUses.UsesRemaining > 0)
                            {
                                --toolWithUses.UsesRemaining;
                            }

                            if (toolWithUses.UsesRemaining < 1)
                            {
                                tool.Delete();
                                def.SendMessageTo(from, def.ToolBrokeMessage);
                            }
                        }
                    }
                }
            }
        }
        public virtual async void FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, object toHarvest,
                                                   object locked)
        {
            from.EndAction(locked);

            if (!CheckHarvest(from, tool))
            {
                return;
            }

            int     tileID;
            Map     map;
            Point3D loc;

            if (!GetHarvestDetails(from, tool, toHarvest, out tileID, out map, out loc))
            {
                OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }
            else if (!def.Validate(tileID))
            {
                OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }

            if (!CheckRange(from, tool, def, map, loc, true))
            {
                return;
            }
            else if (!CheckResources(from, tool, def, map, loc, true))
            {
                return;
            }
            else if (!CheckHarvest(from, tool, def, toHarvest))
            {
                return;
            }

            HarvestBank bank = def.GetBank(map, loc.X, loc.Y);

            if (bank == null)
            {
                return;
            }

            Type type = null;

            var consumeAmount = GetConsumeAmount(from, def);

            bank.Consume(consumeAmount, from);

            if (from.ShilCheckSkill(def.Skill))
            {
                var         chanceForColored = 0;
                var         harvestAmount    = consumeAmount;
                HarvestVein vein;

                if (def.Resources.Length > 0)
                {
                    chanceForColored = GetChanceForColored(from, tool, def);
                }

                from.FireHook(h => h.OnToolHarvestBonus(from, ref harvestAmount));

                if (chanceForColored > 0 && Utility.Random(1, 100) <= chanceForColored)
                {
                    harvestAmount = def.ModifyHarvestAmount(from, tool, harvestAmount);

                    vein = def.GetColoredVein(from, tool, ref harvestAmount);
                    if (vein == null)
                    {
                        var veinName = def.Skill == SkillName.Lumberjacking ? "logs" : "ores";
                        def.SendMessageTo(from, $"You fail to find any colored {veinName}.");
                        return;
                    }
                }
                else
                {
                    vein = def.DefaultVein;
                    from.FireHook(h => h.OnHarvestAmount(from, ref harvestAmount));
                }

                var resource = vein.Resource;

                type = GetResourceType(from, tool, def, map, loc, resource);

                if (type != null)
                {
                    type = MutateType(type, from, tool, def, map, loc, resource);
                }

                if (type != null)
                {
                    Item item = Construct(type, from);

                    if (item == null)
                    {
                        type = null;
                    }
                    else
                    {
                        if (item.Stackable)
                        {
                            item.Amount = harvestAmount;
                        }

                        if (Give(from, item, def.PlaceAtFeetIfFull))
                        {
                            SendSuccessTo(from, item, resource);
                        }
                        else
                        {
                            SendPackFullTo(from, item, def, resource);
                            item.Delete();
                        }
                    }
                }
            }

            if (type == null)
            {
                def.SendMessageTo(from, def.FailMessage);
            }

            await Timer.Pause(1000);

            if (type != null)
            {
                def.BonusEffect(from, tool);
            }

            OnHarvestFinished(from, tool, def, bank, toHarvest);
        }
Exemple #10
0
        public virtual void FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked)
        {
            from.EndAction(locked);

            if (!CheckHarvest(from, tool))
            {
                return;
            }

            int     tileID;
            Map     map;
            Point3D loc;

            if (tool.Parent != from && !(tool is FishingNet))
            {
                from.SendMessage("Vous devez avoir l'objet en main pour l'utiliser."); // That must be in your pack for you to use it.
                return;
            }
            else if (!GetHarvestDetails(from, tool, toHarvest, out tileID, out map, out loc))
            {
                OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }
            else if (!def.Validate(tileID))
            {
                OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }

            if (!CheckRange(from, tool, def, map, loc, true))
            {
                return;
            }
            else if (!CheckResources(from, tool, def, map, loc, true, tileID))
            {
                return;
            }
            else if (!CheckHarvest(from, tool, def, toHarvest))
            {
                return;
            }

            if (SpecialHarvest(from, tool, def, map, loc))
            {
                return;
            }

            HarvestBank bank = def.GetBank(from, map, loc.X, loc.Y, tool, tileID);

            if (bank == null)
            {
                def.SendMessageTo(from, def.FailMessage);
                return;
            }

            HarvestVein vein = bank.Vein;

            //if ( vein != null )
            //    vein = MutateVein( from, tool, def, bank, toHarvest, vein );

            if (vein == null)
            {
                def.SendMessageTo(from, def.FailMessage);
                return;
            }

            HarvestResource primary  = vein.PrimaryResource;
            HarvestResource fallback = vein.FallbackResource;
            HarvestResource resource = MutateResource(from, tool, def, map, loc, vein, primary, fallback);

            double skillBase  = from.Skills[def.Skill].Base;
            double skillValue = from.Skills[def.Skill].Value;

            Type type = null;

            from.CheckSkill(def.Skill, -20, 120);

            if (skillBase >= resource.ReqSkill && from.CheckSkill(def.Skill, resource.MinSkill - 25, resource.MaxSkill + 25))
            {
                type = GetResourceType(from, tool, def, map, loc, resource);

                if (type != null)
                {
                    type = MutateType(type, from, tool, def, map, loc, resource);
                }

                if (type != null)
                {
                    Item item = Construct(type, from);

                    if (item == null)
                    {
                        type = null;
                    }
                    else
                    {
                        /*if (def.Skill == SkillName.Peche && 0.015 > Utility.RandomDouble())
                         * {
                         *  if (tool is LargeFishingPole)
                         *      item = Loot.RandomMidTreasureMap();
                         *  else if (tool is StrongFishingPole)
                         *      item = Loot.RandomMidTreasureMap();
                         *  else if (tool is LargeStrongFishingPole)
                         *      item = Loot.RandomHighTreasureMap();
                         *  else if (tool is FishingNet)
                         *      item = Loot.RandomLowTreasureMap();
                         *  else if (tool is Harpoon)
                         *      item = Loot.RandomLowTreasureMap();
                         *  else
                         *      item = Loot.RandomLowTreasureMap();
                         *
                         *  if (item.Amount != 1)
                         *      item.Amount = 1;
                         *
                         *  type = item.GetType();
                         * }*/

                        if (item.Stackable /*&& !(item is BaseTreasureMapPart)*/)
                        {
                            int consumed = Utility.RandomMinMax(def.MinConsumedPerHarvest, def.MaxConsumedPerHarvest);
                            consumed += (int)(from.Skills[def.Skill].Value / 25);

                            if (from is PlayerMobile)
                            {
                                PlayerMobile tmob = (PlayerMobile)from;
                                Random       rand = new Random();

                                //TOCHECK HARVESTING

                                /*
                                 * if (def.Skill == SkillName.Foresterie)
                                 * {
                                 *  if (tmob.GetAptitudeValue(Aptitude.Forestier) * 5 > rand.Next(0, 100))
                                 *      consumed += tmob.GetAptitudeValue(Aptitude.Forestier) / 3;
                                 * }
                                 * else if (def.Skill == SkillName.Excavation)
                                 * {
                                 *  if (tmob.GetAptitudeValue(Aptitude.Mineur) * 5 > rand.Next(0, 100))
                                 *      consumed += tmob.GetAptitudeValue(Aptitude.Mineur) / 3;
                                 * }
                                 */
                            }

                            consumed += Utility.RandomMinMax(-1, 1);

                            if (consumed > 10)
                            {
                                consumed = 10;
                            }

                            if (consumed < 1 /*|| (def.Skill == SkillName.Fishing && (tool is Harpoon || tool is LargeStrongFishingPole || tool is LargeFishingPole || tool is StrongFishingPole || tool is FishingPole))*/)
                            {
                                consumed = 1;
                            }

                            if (bank.Current < consumed)
                            {
                                consumed = bank.Current;
                            }

                            if (bank.Current >= consumed)
                            {
                                item.Amount = consumed;
                            }
                        }

                        //if (!(item is BaseTreasureMapPart))
                        bank.Consume(def, item.Amount, loc);

                        if (Give(from, item, def.PlaceAtFeetIfFull, loc))
                        {
                            SendSuccessTo(from, item, resource);
                        }
                        else
                        {
                            SendPackFullTo(from, item, def, resource);
                            item.Delete();
                        }

                        if (tool is IUsesRemaining)
                        {
                            IUsesRemaining toolWithUses = (IUsesRemaining)tool;

                            toolWithUses.ShowUsesRemaining = true;

                            if (toolWithUses.UsesRemaining > 0)
                            {
                                --toolWithUses.UsesRemaining;
                            }

                            if (toolWithUses.UsesRemaining < 1)
                            {
                                tool.Delete();
                                def.SendMessageTo(from, def.ToolBrokeMessage);
                            }
                        }
                    }
                }
            }

            if (type == null)
            {
                def.SendMessageTo(from, def.FailMessage);
            }

            OnHarvestFinished(from, tool, def, vein, bank, resource, toHarvest);
        }
Exemple #11
0
		public override void OnHarvestFinished( Mobile from, Item tool, HarvestDefinition def, HarvestVein vein, HarvestBank bank, HarvestResource resource, object harvested )
		{
			if ( tool is GargoylesPickaxe && def == m_OreAndStone && 0.1 > Utility.RandomDouble() )
			{
				HarvestResource res = vein.PrimaryResource;

				if ( res == resource && res.Types.Length >= 3 )
				{
					try
					{
						Map map = from.Map;

						if ( map == null )
							return;

						BaseCreature spawned = Activator.CreateInstance( res.Types[2], new object[]{ 25 } ) as BaseCreature;

						if ( spawned != null )
						{
							int offset = Utility.Random( 8 ) * 2;

							for ( int i = 0; i < m_Offsets.Length; i += 2 )
							{
								int x = from.X + m_Offsets[(offset + i) % m_Offsets.Length];
								int y = from.Y + m_Offsets[(offset + i + 1) % m_Offsets.Length];

								if ( map.CanSpawnMobile( x, y, from.Z ) )
								{
                                    spawned.OnBeforeSpawn(new Point3D(x, y, from.Z), map);
									spawned.MoveToWorld( new Point3D( x, y, from.Z ), map );
									spawned.Combatant = from;
									return;
								}
								else
								{
									int z = map.GetAverageZ( x, y );

									if ( map.CanSpawnMobile( x, y, z ) )
									{
                                        spawned.OnBeforeSpawn(new Point3D(x, y, z), map);
										spawned.MoveToWorld( new Point3D( x, y, z ), map );
										spawned.Combatant = from;
										return;
									}
								}
							}
                            spawned.OnBeforeSpawn(from.Location, from.Map);
							spawned.MoveToWorld( from.Location, from.Map );
							spawned.Combatant = from;
						}
					}
					catch
					{
					}
				}
			}

            if (bank != null && bank.Vein != null && bank.Vein.PrimaryResource != null)
            {
                int bankAmount = bank.Current;
                double skillReq = bank.Vein.PrimaryResource.ReqSkill;

                if (skillReq >= 99.0 && bankAmount <= 13)
                    bank.Consume(def, bankAmount, from);
                else if (skillReq >= 98.0 && bankAmount <= 12)
                    bank.Consume(def, bankAmount, from);
                else if (skillReq >= 97.0 && bankAmount <= 10)
                    bank.Consume(def, bankAmount, from);
                else if (skillReq >= 90.0 && bankAmount <= 8)
                    bank.Consume(def, bankAmount, from);
                else if (skillReq >= 75.0 && bankAmount <= 6)
                    bank.Consume(def, bankAmount, from);
                else if (skillReq >= 65.0 && bankAmount <= 4)
                    bank.Consume(def, bankAmount, from);
            }
		}
Exemple #12
0
        public virtual void FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked)
        {
            from.EndAction(locked);

            if (!CheckHarvest(from, tool))
            {
                return;
            }

            int     tileID;
            Map     map;
            Point3D loc;

            if (!GetHarvestDetails(from, tool, toHarvest, out tileID, out map, out loc))
            {
                OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }
            else if (!def.Validate(tileID))
            {
                OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }

            if (!CheckRange(from, tool, def, map, loc, true))
            {
                return;
            }
            else if (!CheckResources(from, tool, def, map, loc, true))
            {
                return;
            }
            else if (!CheckHarvest(from, tool, def, toHarvest))
            {
                return;
            }

            if (SpecialHarvest(from, tool, def, map, loc))
            {
                return;
            }

            HarvestBank bank = def.GetBank(map, loc.X, loc.Y);

            if (bank == null)
            {
                return;
            }

            HarvestVein vein = bank.Vein;

            if (vein != null)
            {
                vein = MutateVein(from, tool, def, bank, toHarvest, vein);
            }

            if (vein == null)
            {
                return;
            }

            HarvestResource primary  = vein.PrimaryResource;
            HarvestResource fallback = vein.FallbackResource;
            HarvestResource resource = MutateResource(from, tool, def, map, loc, vein, primary, fallback);

            double skillBase  = from.Skills[def.Skill].Base;
            double skillValue = from.Skills[def.Skill].Value;

            Type type = null;

            if (skillBase >= resource.ReqSkill && from.CheckSkill(def.Skill, resource.MinSkill, resource.MaxSkill))
            {
                type = GetResourceType(from, tool, def, map, loc, resource);

                if (type != null)
                {
                    type = MutateType(type, from, tool, def, map, loc, resource);
                }

                if (type != null)
                {
                    Item item = Construct(type, from);

                    if (item == null)
                    {
                        type = null;
                    }
                    else
                    {
                        if (item.Stackable)
                        {
                            Region reg = Region.Find(from.Location, from.Map);

                            int amount        = def.ConsumedPerHarvest;
                            int feluccaAmount = def.ConsumedPerLodorHarvest;

                            int racialAmount        = (int)Math.Ceiling(amount * 1.1);
                            int feluccaRacialAmount = (int)Math.Ceiling(feluccaAmount * 1.1);

                            bool eligableForRacialBonus = (def.RaceBonus && from.Race == Race.Human);
                            bool inLodor = (map == Map.IslesDread);

                            if (item is BlankScroll)
                            {
                                amount = Utility.RandomMinMax(amount, (int)(amount + (from.Skills[SkillName.Inscribe].Value / 10)));
                                from.SendMessage("You find some blank scrolls.");
                            }

                            if (Worlds.GetMyWorld(from.Map, from.Location, from.X, from.Y) == "the Isles of Dread" && bank.Current >= feluccaAmount)
                            {
                                item.Amount = feluccaAmount;
                            }
                            else if (reg.IsPartOf("the Mines of Morinia") && item is BaseOre && Utility.RandomMinMax(1, 3) > 1)
                            {
                                item.Amount = 2 * amount;
                            }
                            else
                            {
                                item.Amount = amount;
                            }

                            bool FindSpecialOre = false;
                            if ((item is AgapiteOre || item is VeriteOre || item is ValoriteOre) && Utility.RandomMinMax(1, 2) == 1)
                            {
                                FindSpecialOre = true;
                            }

                            bool FindSpecialGranite = false;
                            if ((item is AgapiteGranite || item is VeriteGranite || item is ValoriteGranite) && Utility.RandomMinMax(1, 2) == 1)
                            {
                                FindSpecialGranite = true;
                            }

                            bool FindGhostLog = false;
                            if ((item is WalnutLog) || (item is RosewoodLog) || (item is PineLog) || (item is OakLog))
                            {
                                FindGhostLog = true;
                            }

                            bool FindBlackLog = false;
                            if ((item is AshLog) || (item is CherryLog) || (item is GoldenOakLog) || (item is HickoryLog) || (item is MahoganyLog))
                            {
                                FindBlackLog = true;
                            }

                            bool FindToughLog = false;
                            if (!(item is Log))
                            {
                                FindToughLog = true;
                            }

                            if (Worlds.IsExploringSeaAreas(from) && item is BaseLog)
                            {
                                int driftWood = item.Amount;
                                item.Delete();
                                item = new DriftwoodLog(driftWood);
                                from.SendMessage("You chop some driftwood logs.");
                            }
                            else if (Worlds.GetMyWorld(from.Map, from.Location, from.X, from.Y) == "the Underworld" && FindSpecialOre && item is BaseOre && from.Map == Map.SavagedEmpire)
                            {
                                int xormiteOre = item.Amount;
                                item.Delete();
                                item = new XormiteOre(xormiteOre);
                                from.SendMessage("You dig up some xormite ore.");
                            }
                            else if (Worlds.GetMyWorld(from.Map, from.Location, from.X, from.Y) == "the Underworld" && FindSpecialOre && item is BaseOre)
                            {
                                int mithrilOre = item.Amount;
                                item.Delete();
                                item = new MithrilOre(mithrilOre);
                                from.SendMessage("You dig up some mithril ore.");
                            }
                            else if (Worlds.GetMyWorld(from.Map, from.Location, from.X, from.Y) == "the Serpent Island" && FindSpecialOre && item is BaseOre)
                            {
                                int obsidianOre = item.Amount;
                                item.Delete();
                                item = new ObsidianOre(obsidianOre);
                                from.SendMessage("You dig up some obsidian ore.");
                            }
                            else if (Worlds.IsExploringSeaAreas(from) && FindSpecialOre && item is BaseOre)
                            {
                                int nepturiteOre = item.Amount;
                                item.Delete();
                                item = new NepturiteOre(nepturiteOre);
                                from.SendMessage("You dig up some nepturite ore.");
                            }
                            else if (Worlds.GetMyWorld(from.Map, from.Location, from.X, from.Y) == "the Underworld" && FindSpecialGranite && item is BaseGranite && from.Map == Map.SavagedEmpire)
                            {
                                int xormiteGranite = item.Amount;
                                item.Delete();
                                item = new XormiteGranite(xormiteGranite);
                                from.SendMessage("You dig up xormite granite.");
                            }
                            else if (Worlds.GetMyWorld(from.Map, from.Location, from.X, from.Y) == "the Underworld" && FindSpecialGranite && item is BaseGranite)
                            {
                                int mithrilGranite = item.Amount;
                                item.Delete();
                                item = new MithrilGranite(mithrilGranite);
                                from.SendMessage("You dig up mithril granite.");
                            }
                            else if (Worlds.GetMyWorld(from.Map, from.Location, from.X, from.Y) == "the Serpent Island" && FindSpecialGranite && item is BaseGranite)
                            {
                                int obsidianGranite = item.Amount;
                                item.Delete();
                                item = new ObsidianGranite(obsidianGranite);
                                from.SendMessage("You dig up obsidian granite.");
                            }
                            else if (Worlds.IsExploringSeaAreas(from) && FindSpecialGranite && item is BaseGranite)
                            {
                                int nepturiteGranite = item.Amount;
                                item.Delete();
                                item = new NepturiteGranite(nepturiteGranite);
                                from.SendMessage("You dig up nepturite granite.");
                            }
                            else if (reg.IsPartOf(typeof(NecromancerRegion)) && FindBlackLog && item is BaseLog)
                            {
                                int blackLog = item.Amount;
                                item.Delete();
                                item = new EbonyLog(blackLog);
                                from.SendMessage("You chop some ebony logs.");
                            }
                            else if (reg.IsPartOf(typeof(NecromancerRegion)) && FindGhostLog && item is BaseLog)
                            {
                                int ghostLog = item.Amount;
                                item.Delete();
                                item = new GhostLog(ghostLog);
                                from.SendMessage("You chop some ghost logs.");
                            }
                            else if (Worlds.GetMyWorld(from.Map, from.Location, from.X, from.Y) == "the Underworld" && FindToughLog && item is BaseLog)
                            {
                                int toughLog = item.Amount;
                                item.Delete();
                                item = new PetrifiedLog(toughLog);
                                from.SendMessage("You chop some petrified logs.");
                            }
                            else if ((reg.IsPartOf("Shipwreck Grotto") || reg.IsPartOf("Barnacled Cavern")) && FindToughLog && item is BaseLog)
                            {
                                int driftWood = item.Amount;
                                item.Delete();
                                item = new DriftwoodLog(driftWood);
                                from.SendMessage("You chop some driftwood logs.");
                            }
                            else if ((reg.IsPartOf("Shipwreck Grotto") || reg.IsPartOf("Barnacled Cavern") || reg.IsPartOf("Savage Sea Docks") || reg.IsPartOf("Serpent Sail Docks") || reg.IsPartOf("Anchor Rock Docks") || reg.IsPartOf("Kraken Reef Docks") || reg.IsPartOf("the Forgotten Lighthouse")) && FindSpecialGranite && item is BaseGranite)
                            {
                                int nepturiteGranite = item.Amount;
                                item.Delete();
                                item = new NepturiteGranite(nepturiteGranite);
                                from.SendMessage("You dig up nepturite granite.");
                            }
                            else if ((reg.IsPartOf("Shipwreck Grotto") || reg.IsPartOf("Barnacled Cavern") || reg.IsPartOf("Savage Sea Docks") || reg.IsPartOf("Serpent Sail Docks") || reg.IsPartOf("Anchor Rock Docks") || reg.IsPartOf("Kraken Reef Docks") || reg.IsPartOf("the Forgotten Lighthouse")) && FindSpecialOre && item is BaseOre)
                            {
                                int nepturiteOre = item.Amount;
                                item.Delete();
                                item = new NepturiteOre(nepturiteOre);
                                from.SendMessage("You dig up some nepturite ore.");
                            }

                            else if (item is IronOre)
                            {
                                from.SendMessage("You dig up some ore.");
                            }
                            else if (item is DullCopperOre)
                            {
                                from.SendMessage("You dig up some dull copper ore.");
                            }
                            else if (item is ShadowIronOre)
                            {
                                from.SendMessage("You dig up some shadow iron ore.");
                            }
                            else if (item is CopperOre)
                            {
                                from.SendMessage("You dig up some copper ore.");
                            }
                            else if (item is BronzeOre)
                            {
                                from.SendMessage("You dig up some bronze ore.");
                            }
                            else if (item is GoldOre)
                            {
                                from.SendMessage("You dig up some golden ore.");
                            }
                            else if (item is AgapiteOre)
                            {
                                from.SendMessage("You dig up some agapite ore.");
                            }
                            else if (item is VeriteOre)
                            {
                                from.SendMessage("You dig up some verite ore.");
                            }
                            else if (item is ValoriteOre)
                            {
                                from.SendMessage("You dig up some valorite ore.");
                            }

                            else if (item is Granite)
                            {
                                from.SendMessage("You dig up granite.");
                            }
                            else if (item is DullCopperGranite)
                            {
                                from.SendMessage("You dig up dull copper granite.");
                            }
                            else if (item is ShadowIronGranite)
                            {
                                from.SendMessage("You dig up shadow iron granite.");
                            }
                            else if (item is CopperGranite)
                            {
                                from.SendMessage("You dig up copper granite.");
                            }
                            else if (item is BronzeGranite)
                            {
                                from.SendMessage("You dig up bronze granite.");
                            }
                            else if (item is GoldGranite)
                            {
                                from.SendMessage("You dig up golden granite.");
                            }
                            else if (item is AgapiteGranite)
                            {
                                from.SendMessage("You dig up agapite granite.");
                            }
                            else if (item is VeriteGranite)
                            {
                                from.SendMessage("You dig up verite granite.");
                            }
                            else if (item is ValoriteGranite)
                            {
                                from.SendMessage("You dig up valorite granite.");
                            }

                            else if (item is Log)
                            {
                                from.SendMessage("You chop some logs.");
                            }
                            else if (item is AshLog)
                            {
                                from.SendMessage("You chop some ash logs.");
                            }
                            else if (item is CherryLog)
                            {
                                from.SendMessage("You chop some cherry logs.");
                            }
                            else if (item is EbonyLog)
                            {
                                from.SendMessage("You chop some ebony logs.");
                            }
                            else if (item is GoldenOakLog)
                            {
                                from.SendMessage("You chop some golden oak logs.");
                            }
                            else if (item is HickoryLog)
                            {
                                from.SendMessage("You chop some hickory logs.");
                            }
                            else if (item is MahoganyLog)
                            {
                                from.SendMessage("You chop some mahogany logs.");
                            }
                            else if (item is OakLog)
                            {
                                from.SendMessage("You chop some oak logs.");
                            }
                            else if (item is PineLog)
                            {
                                from.SendMessage("You chop some pine logs.");
                            }
                            else if (item is RosewoodLog)
                            {
                                from.SendMessage("You chop some rosewood logs.");
                            }
                            else if (item is WalnutLog)
                            {
                                from.SendMessage("You chop some walnut logs.");
                            }
                            else if (item is ElvenLog)
                            {
                                from.SendMessage("You chop some elven logs.");
                            }

                            if (Worlds.GetMyWorld(from.Map, from.Location, from.X, from.Y) == "the Savaged Empire" && from.Skills[SkillName.Mining].Value > Utility.RandomMinMax(1, 500))
                            {
                                Container pack = from.Backpack;
                                DugUpCoal coal = new DugUpCoal(Utility.RandomMinMax(1, 2));
                                from.AddToBackpack(coal);
                                from.SendMessage("You dig up some coal.");
                            }
                            else if (Worlds.GetMyWorld(from.Map, from.Location, from.X, from.Y) == "the Island of Umber Veil" && from.Skills[SkillName.Mining].Value > Utility.RandomMinMax(1, 500))
                            {
                                Container pack = from.Backpack;
                                DugUpZinc zinc = new DugUpZinc(Utility.RandomMinMax(1, 2));
                                from.AddToBackpack(zinc);
                                from.SendMessage("You dig up some zinc.");
                            }

                            if (tool is FishingPole && Server.Engines.Harvest.Fishing.IsNearHugeShipWreck(from) && from.Skills[SkillName.Fishing].Value >= Utility.RandomMinMax(1, 250))
                            {
                                Server.Engines.Harvest.Fishing.FishUpFromMajorWreck(from);
                            }
                            else if (tool is FishingPole && Server.Engines.Harvest.Fishing.IsNearSpaceCrash(from) && from.Skills[SkillName.Fishing].Value >= Utility.RandomMinMax(1, 250))
                            {
                                Server.Engines.Harvest.Fishing.FishUpFromSpaceship(from);
                            }
                            else if (tool is FishingPole && Server.Engines.Harvest.Fishing.IsNearUnderwaterRuins(from) && from.Skills[SkillName.Fishing].Value >= Utility.RandomMinMax(1, 250))
                            {
                                Server.Engines.Harvest.Fishing.FishUpFromRuins(from);
                            }
                        }
                        else if (item is BlueBook || item is LoreBook || item is DDRelicBook || item is MyNecromancerSpellbook || item is MySpellbook || item is MyNinjabook || item is MySamuraibook || item is MyPaladinbook || item is MySongbook || item is ArtifactManual)
                        {
                            from.SendMessage("You find a book.");
                            if (item is DDRelicBook)
                            {
                                ((DDRelicBook)item).RelicGoldValue = ((DDRelicBook)item).RelicGoldValue + Utility.RandomMinMax(1, (int)(from.Skills[SkillName.Inscribe].Value * 2));
                            }
                            else if (item is BlueBook)
                            {
                                item.Name = "Book"; item.Hue = Utility.RandomColor(0); item.ItemID = RandomThings.GetRandomBookItemID();
                            }
                        }
                        else if (item is SomeRandomNote || item is ScrollClue || item is LibraryScroll1 || item is LibraryScroll2 || item is LibraryScroll3 || item is LibraryScroll4 || item is LibraryScroll5 || item is LibraryScroll6 || item is DDRelicScrolls)
                        {
                            from.SendMessage("You find a scroll.");
                            if (item is DDRelicScrolls)
                            {
                                ((DDRelicScrolls)item).RelicGoldValue = ((DDRelicScrolls)item).RelicGoldValue + Utility.RandomMinMax(1, (int)(from.Skills[SkillName.Inscribe].Value * 2));
                            }
                        }

                        bank.Consume(item.Amount, from);

                        if (Give(from, item, def.PlaceAtFeetIfFull))
                        {
                            SendSuccessTo(from, item, resource);
                        }
                        else
                        {
                            SendPackFullTo(from, item, def, resource);
                            item.Delete();
                        }

                        BonusHarvestResource bonus = def.GetBonusResource();

                        if (bonus != null && bonus.Type != null && skillBase >= bonus.ReqSkill)
                        {
                            Item bonusItem = Construct(bonus.Type, from);

                            if (Give(from, bonusItem, true))                                    //Bonuses always allow placing at feet, even if pack is full irregrdless of def
                            {
                                bonus.SendSuccessTo(from);
                            }
                            else
                            {
                                item.Delete();
                            }
                        }

                        if (tool is IUsesRemaining)
                        {
                            IUsesRemaining toolWithUses = (IUsesRemaining)tool;

                            toolWithUses.ShowUsesRemaining = true;

                            if (toolWithUses.UsesRemaining > 0)
                            {
                                --toolWithUses.UsesRemaining;
                            }

                            if (toolWithUses.UsesRemaining < 1)
                            {
                                tool.Delete();
                                def.SendMessageTo(from, def.ToolBrokeMessage);
                            }
                        }
                    }
                }
            }

            if (type == null)
            {
                def.SendMessageTo(from, def.FailMessage);
            }

            OnHarvestFinished(from, tool, def, vein, bank, resource, toHarvest);
        }
        public virtual void FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked)
        {
            if (from is PlayerMobile)
            {
                ((PlayerMobile)from).EndPlayerAction();
            }

            if (!CheckHarvest(from, tool))
            {
                return;
            }

            if (!CheckAllowed(from))
            {
                return;
            }

            if (Utility.Random(1000) <= 2)
            {
                AntiMacro.AntiMacroGump.SendGumpThreaded((PlayerMobile)from);
            }

            int     tileID;
            Map     map;
            Point3D loc;

            if (!GetHarvestDetails(from, tool, toHarvest, out tileID, out map, out loc))
            {
                OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }
            else if (!def.Validate(tileID))
            {
                OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }

            if (!CheckRange(from, tool, def, map, loc, true))
            {
                return;
            }
            else if (!CheckResources(from, tool, def, map, loc, true))
            {
                return;
            }
            else if (!CheckHarvest(from, tool, def, toHarvest))
            {
                return;
            }

            if (SpecialHarvest(from, tool, def, map, loc))
            {
                return;
            }

            HarvestBank bank = def.GetBank(map, loc.X, loc.Y);

            if (bank == null)
            {
                return;
            }

            HarvestVein vein = bank.Vein;

            if (vein != null)
            {
                vein = MutateVein(from, tool, def, bank, toHarvest, vein);
            }

            if (vein == null)
            {
                return;
            }

            //Check if we can mine the vein
            CheckMutateVein(from, def, bank, vein);

            HarvestResource primary  = vein.PrimaryResource;
            HarvestResource fallback = vein.FallbackResource;
            HarvestResource resource = MutateResource(from, tool, def, map, loc, vein, primary, fallback);

            double skillBase  = from.Skills[def.Skill].Base;
            double skillValue = from.Skills[def.Skill].Value;

            Type type = null;

            //Gain the skill
            from.CheckSkill(def.Skill, resource.MinSkill, resource.MaxSkill);

            //hacky All harvest now has 15 percent, if you can mine them.
            if (skillBase >= resource.ReqSkill && 0.15 < Utility.RandomDouble())
            {
                type = GetResourceType(from, tool, def, map, loc, resource);

                if (type != null)
                {
                    type = MutateType(type, from, tool, def, map, loc, resource);
                }

                if (type != null)
                {
                    Item item = Construct(type, from);

                    if (item == null)
                    {
                        type = null;
                    }
                    else
                    {
                        //bool spawnNew = false;
                        //The whole harvest system is kludgy and I'm sure this is just adding to it.
                        if (item.Stackable)
                        {
                            int amount       = GetOreAmount(vein);
                            int racialAmount = (int)Math.Ceiling(amount * 1.1);

                            bool eligableForRacialBonus = (def.RaceBonus && from.Race == Race.Human);

                            if (eligableForRacialBonus && bank.Current >= racialAmount)
                            {
                                item.Amount = racialAmount;
                            }
                            else if (bank.Current >= amount)
                            {
                                item.Amount = amount;
                            }
                            else
                            {
                                item.Amount = bank.Current;
                            }

                            //if ( bank.Current <= item.Amount)
                            //spawnNew = true;
                        }

                        bank.Consume(def, item.Amount, from);

                        //Maka
                        //if (spawnNew)
                        //    bank.Vein = def.GetVeinAt(from.Map, from.Location.X, from.Location.Y);

                        if (Give(from, item, /*def.PlaceAtFeetIfFull*/ true))                            //Is there something we dont want to place at the feet
                        {
                            SendSuccessTo(from, item, resource);
                        }
                        else
                        {
                            SendPackFullTo(from, item, def, resource);
                            item.Delete();
                        }

                        BonusHarvestResource bonus = def.GetBonusResource();

                        if (bonus != null && bonus.Type != null && skillBase >= bonus.ReqSkill)
                        {
                            Item bonusItem = Construct(bonus.Type, from);

                            if (Give(from, bonusItem, true))    //Bonuses always allow placing at feet, even if pack is full irregrdless of def
                            {
                                bonus.SendSuccessTo(from);
                            }
                            else
                            {
                                item.Delete();
                            }
                        }

                        if (tool is IUsesRemaining)
                        {
                            IUsesRemaining toolWithUses = (IUsesRemaining)tool;

                            toolWithUses.ShowUsesRemaining = true;

                            //if ( toolWithUses.UsesRemaining > 0 )
                            //    --toolWithUses.UsesRemaining;

                            if (toolWithUses.UsesRemaining < 1)
                            {
                                tool.Delete();
                                def.SendMessageTo(from, def.ToolBrokeMessage);
                            }
                        }
                    }
                }
            }

            if (type == null)
            {
                def.SendMessageTo(from, def.FailMessage);
            }

            OnHarvestFinished(from, tool, def, vein, bank, resource, toHarvest);
        }
Exemple #14
0
        public virtual void FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked)
        {
            from.EndAction(locked);

            if (!CheckHarvest(from, tool))
            {
                return;
            }

            int     tileID;
            Map     map;
            Point3D loc;


            if (toHarvest is NubiaSpecialHarvest)
            {
                from.SendMessage("SPECIAL HARVEST 2");
                return;
            }


            if (!GetHarvestDetails(from, tool, toHarvest, out tileID, out map, out loc))
            {
                OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }
            else if (!def.Validate(tileID))
            {
                OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }

            if (!CheckRange(from, tool, def, map, loc, true))
            {
                return;
            }
            else if (!CheckResources(from, tool, def, map, loc, true))
            {
                return;
            }
            else if (!CheckHarvest(from, tool, def, toHarvest))
            {
                return;
            }

            if (SpecialHarvest(from, tool, def, map, loc))
            {
                return;
            }

            HarvestBank bank = def.GetBank(map, loc.X, loc.Y);

            if (bank == null)
            {
                return;
            }

            HarvestVein vein = bank.Vein;

            if (vein != null)
            {
                vein = MutateVein(from, tool, def, bank, toHarvest, vein);
            }

            if (vein == null)
            {
                return;
            }

            HarvestResource primary  = vein.PrimaryResource;
            HarvestResource fallback = vein.FallbackResource;
            HarvestResource resource = MutateResource(from, tool, def, map, loc, vein, primary, fallback);

            Type type = null;
            //if ( skillBase >= resource.ReqSkill && from.CheckSkill( def.Skill, resource.MinSkill, resource.MaxSkill ) )
            NubiaMobile mob   = from as NubiaMobile;
            bool        check = mob.Competences[def.Skill].roll(resource.DD);

            mob.Competences.wait(1);

            //      Console.WriteLine("Harvest Base comp " + def.Skill.ToString() + " DD " + resource.DD + " success: " + check);
            if (check)
            {
                type = GetResourceType(from, tool, def, map, loc, resource);

                if (type != null)
                {
                    type = MutateType(type, from, tool, def, map, loc, resource);
                }

                if (type != null)
                {
                    Item item = Construct(type, from);

                    if (item == null)
                    {
                        type = null;
                    }
                    else
                    {
                        //The whole harvest system is kludgy and I'm sure this is just adding to it.
                        if (item.Stackable)
                        {
                            int amount        = def.ConsumedPerHarvest;
                            int feluccaAmount = def.ConsumedPerFeluccaHarvest;

                            int racialAmount        = (int)Math.Ceiling(amount * 1.1);
                            int feluccaRacialAmount = (int)Math.Ceiling(feluccaAmount * 1.1);

                            bool eligableForRacialBonus = (def.RaceBonus && from.Race == Race.Human);
                            bool inFelucca = (map == Map.Felucca);

                            if (eligableForRacialBonus && inFelucca && bank.Current >= feluccaRacialAmount)
                            {
                                item.Amount = feluccaRacialAmount;
                            }
                            else if (inFelucca && bank.Current >= feluccaAmount)
                            {
                                item.Amount = feluccaAmount;
                            }
                            else if (eligableForRacialBonus && bank.Current >= racialAmount)
                            {
                                item.Amount = racialAmount;
                            }
                            else
                            {
                                item.Amount = amount;
                            }
                        }

                        bank.Consume(item.Amount, from);

                        if (Give(from, item, def.PlaceAtFeetIfFull))
                        {
                            SendSuccessTo(from, item, resource);
                        }
                        else
                        {
                            SendPackFullTo(from, item, def, resource);
                            item.Delete();
                        }

                        BonusHarvestResource bonus = def.GetBonusResource();

                        if (bonus != null && bonus.Type != null)
                        {
                            Item bonusItem = Construct(bonus.Type, from);

                            if (Give(from, bonusItem, true))                                    //Bonuses always allow placing at feet, even if pack is full irregrdless of def
                            {
                                bonus.SendSuccessTo(from);
                            }
                            else
                            {
                                item.Delete();
                            }
                        }

                        if (tool is IUsesRemaining)
                        {
                            IUsesRemaining toolWithUses = (IUsesRemaining)tool;

                            toolWithUses.ShowUsesRemaining = true;

                            if (toolWithUses.UsesRemaining > 0)
                            {
                                --toolWithUses.UsesRemaining;
                            }

                            if (toolWithUses.UsesRemaining < 1)
                            {
                                tool.Delete();
                                def.SendMessageTo(from, def.ToolBrokeMessage);
                            }
                        }
                    }
                }
            }

            if (type == null)
            {
                def.SendMessageTo(from, def.FailMessage);
            }

            OnHarvestFinished(from, tool, def, vein, bank, resource, toHarvest);
        }