Exemplo n.º 1
0
        public override void OnHarvestFinished(Mobile from, Item tool, HarvestDefinition def, HarvestVein vein, HarvestBank bank, HarvestResource resource, object harvested, Type type)
        {
            if (tool is GargoylesAxe && 0.1 < Utility.RandomDouble())
            {
                HarvestResource res = vein.PrimaryResource;

                Map map = from.Map;
                if (map == null)
                {
                    return;
                }
                BaseCreature spawned = null;

                int i_Level = 0;
                if (OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.DAAT99_LUMBERJACKING))
                {
                    i_Level = CraftResources.GetIndex(CraftResources.GetFromType(type)) + 301;
                }
                else if (res == resource)
                {
                    try
                    {
                        i_Level = Array.IndexOf(def.Veins, vein) + 301;
                    }
                    catch { }
                }
                //		if (i_Level > 300 && OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.HARVEST_GIVE_TOKENS))
                //			TokenSystem.GiveTokensToPlayer(from as PlayerMobile, (i_Level - 300)*10);
                if (i_Level > 301)
                {
                    spawned = new Elementals(i_Level);
                }
                else
                {
                    spawned = null;
                }

                try
                {
                    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.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.MoveToWorld(new Point3D(x, y, z), map);
                                    spawned.Combatant = from;
                                    return;
                                }
                            }
                        }
                        spawned.MoveToWorld(from.Location, from.Map);
                        spawned.Combatant = from;
                    }
                }
                catch
                {
                }
            }
        }
Exemplo n.º 2
0
        public override void OnHarvestFinished(Mobile from, Item tool, HarvestDefinition def, HarvestVein vein, HarvestBank bank, HarvestResource resource, object harvested, Type type)
        {
            if (tool is GargoylesPickaxe && def == this.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;
                        }
                        //daat99 OWLTR start - gargoyle spawn
                        BaseCreature spawned = null;
                        try
                        {
                            int i_Level = CraftResources.GetIndex(CraftResources.GetFromType(type)) + 1;
                            if (i_Level > 1)
                            {
                                spawned = new Elementals(i_Level);
                            }
                        } catch {}
                        if (spawned == null)
                        {
                            //daat99 OWLTR end - gargoyle spawn
                            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 (Math.Abs(z - from.Z) < 10 && 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
                    {
                    }
                }
            }
        }
/* 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);
                            }
                        }
                    }
                }
            }
        }