public double GetExceptionalChance(BuildSystem system, double chance, Mobile from)
        {
            if (m_ForceNonExceptional)
            {
                return(0.0);
            }

            switch (system.ECA)
            {
            default:
            case BuildECA.ChanceMinusSixty: return(chance - 0.6);

            case BuildECA.FiftyPercentChanceMinusTenPercent: return((chance * 0.5) - 0.1);

            case BuildECA.ChanceMinusSixtyToFourtyFive:
            {
                double offset = 0.60 - ((LokaiSkillUtilities.XMLGetSkills(from)[system.MainLokaiSkill].Value - 95.0) * 0.03);

                if (offset < 0.45)
                {
                    offset = 0.45;
                }
                else if (offset > 0.60)
                {
                    offset = 0.60;
                }

                return(chance - offset);
            }
            }
        }
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (targeted is Mobile)
                {
                    Mobile     targ       = (Mobile)targeted;
                    LokaiSkill lokaiSkill = LokaiSkillUtilities.XMLGetSkills(targ)[m_LokaiSkill];

                    if (lokaiSkill == null)
                    {
                        return;
                    }

                    if (m_Set)
                    {
                        lokaiSkill.Base = m_Value;
                        CommandLogging.LogChangeProperty(from, targ, String.Format("{0}.Base", m_LokaiSkill), m_Value.ToString());
                    }

                    from.SendMessage("{0} : {1} (Base: {2})", m_LokaiSkill, lokaiSkill.Value, lokaiSkill.Base);
                }
                else
                {
                    from.SendMessage("That does not have Lokai Skills!");
                }
            }
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_RawFlax.Deleted)
                {
                    return;
                }

                ISpinningWheel wheel = targeted as ISpinningWheel;

                if (wheel == null && targeted is AddonComponent)
                {
                    wheel = ((AddonComponent)targeted).Addon as ISpinningWheel;
                }

                if (wheel is Item)
                {
                    Item item = (Item)wheel;

                    if (!m_RawFlax.IsChildOf(from.Backpack))
                    {
                        from.SendLocalizedMessage(1042001);                           // That must be in your pack for you to use it.
                    }
                    else if (wheel.Spinning)
                    {
                        from.SendLocalizedMessage(502656);                           // That spinning wheel is being used.
                    }
                    else
                    {
                        LokaiSkills   skills     = LokaiSkillUtilities.XMLGetSkills(from);
                        LokaiSkill    lokaiSkill = (LokaiSkillUtilities.XMLGetSkills(from)).Spinning;
                        SuccessRating rating     = LokaiSkillUtilities.CheckLokaiSkill(from, lokaiSkill, 0.0, 100.0);

                        if (rating >= SuccessRating.PartialSuccess)
                        {
                            m_RawFlax.Consume();
                            wheel.BeginSpin(new SpinCallback(RawFlax.OnSpun), from, m_RawFlax.Hue);
                        }
                        else if (rating == SuccessRating.Failure)
                        {
                            from.SendMessage("You fail, but manage to save your Raw Flax.");
                        }
                        else if (rating == SuccessRating.HazzardousFailure || rating == SuccessRating.CriticalFailure)
                        {
                            m_RawFlax.Consume();
                            from.SendMessage("You fail, and some Raw Flax is lost.");
                        }
                        else if (rating == SuccessRating.TooDifficult)
                        {
                            m_RawFlax.Consume();
                            from.SendMessage("You have no idea how to use this thing.");
                            from.SendMessage("You fail utterly, some Raw Flax is lost.");
                        }
                    }
                }
                else
                {
                    from.SendLocalizedMessage(502658);                       // Use that on a spinning wheel.
                }
            }
        public ShowLokaiSkillsGump(Mobile mobile, bool value)
            : base(0, 0)
        {
            m_Mobile = mobile;
            m_Value  = value;
            bool        GM    = mobile.AccessLevel >= AccessLevel.GameMaster;
            LokaiSkills skils = LokaiSkillUtilities.XMLGetSkills(m_Mobile);

            m_Mobile.CloseGump(typeof(ShowLokaiSkillsGump));
            AddPage(0);
            AddBackground(564, 17, 220, 574, 9200);
            AddBackground(592, 21, 189, 537, 9300);

            AddButton(590, 560, value ? 0x25FF : 0x2602, value ? 0x2602 : 0x25FF, 19, GumpButtonType.Reply, 0);
            AddButton(680, 560, value ? 0x2602 : 0x25FF, value ? 0x25FF : 0x2602, 29, GumpButtonType.Reply, 0);
            AddHtml(621, 567, 55, 20, Color("BASE", value ? 0x20 : 0x777), false, false);
            AddHtml(711, 567, 55, 20, Color("VALUE", value ? 0x777 : 0x20), false, false);

            int y   = 32;
            int hue = 0;

            for (int x = 0; x < LokaiSkillInfo.Table.Length; x++)
            {
                if (LokaiSkillUtilities.ShowLokaiSkill(x))
                {
                    if (LokaiSkillInfo.Table[x].ClickToUse || LokaiSkillInfo.Table[x].Callback != null)
                    {
                        AddButton(573, y + 3, 1210, 1209, x + 100, GumpButtonType.Reply, 0);
                        AddButton(555, y + 7, 2101, 2101, x + 200, GumpButtonType.Reply, 0);
                    }
                    if (GM)
                    {
                        AddButton(761, y + 2, 5401, 5401, x + 300, GumpButtonType.Reply, 0);
                    }
                    hue = 0;
                }
                else
                {
                    if (GM)
                    {
                        AddButton(761, y + 2, 5402, 5402, x + 300, GumpButtonType.Reply, 0);
                    }
                    hue = 1152;
                }
                string skill = value ? skils[x].Value.ToString("F1") : skils[x].Base.ToString("F1");
                if (LokaiSkillUtilities.ShowLokaiSkill(x) || GM)
                {
                    AddLabel(647, y, hue, LokaiSkillInfo.Table[x].Name);
                }
                if (LokaiSkillUtilities.ShowLokaiSkill(x) || GM)
                {
                    AddLabel(602, y, hue, skill);
                }
                y += 17;
            }
        }
        public double GetSuccessChance(Mobile from, Type typeRes, BuildSystem buildSystem, bool gainLokaiSkills, ref bool allRequiredLokaiSkills)
        {
            double minMainLokaiSkill = 0.0;
            double maxMainLokaiSkill = 0.0;
            double valMainLokaiSkill = 0.0;

            allRequiredLokaiSkills = true;

            LokaiSkills skills = LokaiSkillUtilities.XMLGetSkills(from);

            for (int i = 0; i < m_arBuildLokaiSkill.Count; i++)
            {
                BuildLokaiSkill buildLokaiSkill = m_arBuildLokaiSkill.GetAt(i);

                double minLokaiSkill = buildLokaiSkill.MinLokaiSkill;
                double maxLokaiSkill = buildLokaiSkill.MaxLokaiSkill;
                double valLokaiSkill = skills[buildLokaiSkill.LokaiSkillToMake].Value;

                if (valLokaiSkill < minLokaiSkill)
                {
                    allRequiredLokaiSkills = false;
                }

                if (buildLokaiSkill.LokaiSkillToMake == buildSystem.MainLokaiSkill)
                {
                    minMainLokaiSkill = minLokaiSkill;
                    maxMainLokaiSkill = maxLokaiSkill;
                    valMainLokaiSkill = valLokaiSkill;
                }

                if (gainLokaiSkills)                   // This is a passive check. Success chance is entirely dependant on the main lokaiSkill
                {
                    LokaiSkillUtilities.CheckLokaiSkill(from, skills[buildLokaiSkill.LokaiSkillToMake], minLokaiSkill, maxLokaiSkill);
                }
            }

            double chance;

            if (allRequiredLokaiSkills)
            {
                chance = buildSystem.GetChanceAtMin(this) + ((valMainLokaiSkill - minMainLokaiSkill) / (maxMainLokaiSkill - minMainLokaiSkill) * (1.0 - buildSystem.GetChanceAtMin(this)));
            }
            else
            {
                chance = 0.0;
            }

            if (allRequiredLokaiSkills && valMainLokaiSkill == maxMainLokaiSkill)
            {
                chance = 1.0;
            }

            return(chance);
        }
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (targeted is Mobile)
                {
                    Mobile      targ        = (Mobile)targeted;
                    LokaiSkills lokaiSkills = LokaiSkillUtilities.XMLGetSkills(targ);

                    for (int i = 0; i < lokaiSkills.Length; ++i)
                    {
                        lokaiSkills[i].Base = m_Value;
                    }

                    CommandLogging.LogChangeProperty(from, targ, "EveryLokaiSkill.Base", m_Value.ToString());
                }
                else
                {
                    from.SendMessage("That does not have Lokai Skills!");
                }
            }
                protected override void OnTarget(Mobile from, object targeted)
                {
                    if (targeted is ResourceItem)
                    {
                        ResourceItem item = targeted as ResourceItem;
                        if (hr.IsNeeded(item))
                        {
                            LokaiSkill lokaiSkill = (LokaiSkillUtilities.XMLGetSkills(from)).Construction;

                            SuccessRating rating = LokaiSkillUtilities.CheckLokaiSkill(from, lokaiSkill, 0.0, 100.0);

                            if (rating >= SuccessRating.PartialSuccess)
                            {
                                from.SendMessage("You successfully added the Resource.");
                                hr.AddResource(item);
                            }
                            else
                            {
                                from.SendMessage("You failed to add the Resource.");
                                switch (rating)
                                {
                                case SuccessRating.HazzardousFailure: { break; } //TODO: take damage or lose resource

                                case SuccessRating.CriticalFailure: { break; }   //TODO: lose the resource and take damage

                                case SuccessRating.TooDifficult: { break; }      //TODO: "you have no idea..."

                                default: { break; }
                                }
                            }
                        }
                        else
                        {
                            from.SendMessage("That resource is not needed for this house.");
                        }
                    }
                    else
                    {
                        from.SendMessage("That is not a Resource Item!");
                    }
                    from.SendGump(new HouseRecipeGump(hr, from));
                }
        public static void BeginTarget(Mobile from, BuildSystem buildSystem, BaseBuildingTool tool)
        {
            BuildContext context = buildSystem.GetContext(from);

            if (context == null)
            {
                return;
            }

            int            lastRes = context.LastResourceIndex;
            BuildSubResCol subRes  = buildSystem.BuildSubRes;

            if (lastRes >= 0 && lastRes < subRes.Count)
            {
                BuildSubRes res = subRes.GetAt(lastRes);

                if (LokaiSkillUtilities.XMLGetSkills(from)[buildSystem.MainLokaiSkill].Value < res.RequiredLokaiSkill)
                {
                    from.SendGump(new BuildGump(from, buildSystem, tool, res.Message));
                }
                else
                {
                    BuildResource resource = BuildResources.GetFromType(res.ItemType);

                    if (resource != BuildResource.None)
                    {
                        from.Target = new InternalTarget(buildSystem, tool, res.ItemType, resource);
                        from.SendLocalizedMessage(1061004);                           // Target an item to enhance with the properties of your selected material.
                    }
                    else
                    {
                        from.SendGump(new BuildGump(from, buildSystem, tool, 1061010));                             // You must select a special material in order to enhance an item with its properties.
                    }
                }
            }
            else
            {
                from.SendGump(new BuildGump(from, buildSystem, tool, 1061010));                     // You must select a special material in order to enhance an item with its properties.
            }
        }
Example #9
0
 protected override void OnTarget(Mobile from, object targeted)
 {
     from.RevealingAction();
     if (targeted is Corpse)
     {
         Corpse corpse = targeted as Corpse;
         if (corpse.Owner != null && corpse.Owner is BaseCreature)
         {
             BaseCreature creature   = (targeted as Corpse).Owner as BaseCreature;
             LokaiSkill   lokaiSkill = (LokaiSkillUtilities.XMLGetSkills(from)).Butchering;
             OnCarve(from, corpse, creature, lokaiSkill);
         }
         else
         {
             from.SendMessage("You may not butcher that type of corpse.");
         }
     }
     else
     {
         from.SendMessage("You may not butcher that!");
     }
 }
        public virtual void Resource_OnTarget(Mobile from, object targ)
        {
            LokaiSkills skills         = LokaiSkillUtilities.XMLGetSkills(from);
            LokaiSkill  brewLokaiSkill = skills[LokaiSkillName.Brewing];
            LokaiSkill  herbLokaiSkill = skills[LokaiSkillName.Herblore];

            if (this.grindable)
            {
                if (targ is MortarPestle)
                {
                    Container pack = from.Backpack;
                    if (!(pack == null || pack.Deleted))
                    {
                        Grind(this, from, LokaiSkillUtilities.CheckLokaiSkill(from, herbLokaiSkill, 0.0, 100.0), grindResult, pack);
                    }
                }
                else
                {
                    from.SendMessage("Try using this on a mortar and pestle.");
                }
            }
            else if (this.cookable)
            {
                if (IsHeatSource(targ))
                {
                    Container pack = from.Backpack;
                    if (!(pack == null || pack.Deleted))
                    {
                        Cook(this, from, LokaiSkillUtilities.CheckLokaiSkill(from, brewLokaiSkill, 0.0, 100.0), cookResult, pack);
                    }
                }
                else
                {
                    from.SendMessage("Try using this on a heat source.");
                }
            }
        }
        public static void SailBoat(Mobile from, BaseBoat boat)
        {
            bool newsail = true;

            if (m_SailTime.ContainsKey(from))
            {
                if (m_SailTime[from] >= DateTime.Now)
                {
                    newsail = false;
                }
                else
                {
                    m_SailTime.Remove(from);
                }
            }

            if (newsail)
            {
                int MinLevel = 10;
                int MaxLevel = 100;
                //if (Core.Debug) from.SendMessage("TEST: SAILING IN A BOAT");

                Mobile sailor = from;

                LokaiSkills skils = LokaiSkillUtilities.XMLGetSkills(sailor);

                List <Mobile> crew = GetMobilesOn(boat);

                SuccessRating rating = SuccessRating.LokaiSkillNotEnabled;

                foreach (Mobile seaman in crew)
                {
                    skils = LokaiSkillUtilities.XMLGetSkills(sailor);

                    LokaiSkills seamanAbs = LokaiSkillUtilities.XMLGetSkills(seaman);
                    if (seamanAbs.Sailing.Value > skils.Sailing.Value)
                    {
                        sailor = seaman;
                    }
                    MinLevel--;
                    MaxLevel--;
                    if ((MinLevel == 5 && (boat is SmallBoat || boat is SmallDragonBoat)) ||
                        (MinLevel == 0 && (boat is MediumBoat || boat is MediumDragonBoat)) ||
                        (MinLevel == -5 && (boat is LargeBoat || boat is LargeDragonBoat)))
                    {
                        break;
                    }
                }

                int count = 0;
                foreach (Mobile seaman in crew)
                {
                    if ((count == 5 && (boat is SmallBoat || boat is SmallDragonBoat)) ||
                        (count == 10 && (boat is MediumBoat || boat is MediumDragonBoat)) ||
                        (count == 15 && (boat is LargeBoat || boat is LargeDragonBoat)))
                    {
                        break;
                    }
                    else
                    {
                        count++;
                        skils = LokaiSkillUtilities.XMLGetSkills(seaman);
                        if (seaman != sailor)
                        {
                            rating = LokaiSkillUtilities.CheckLokaiSkill(seaman, skils.Sailing, MinLevel, MaxLevel);
                            if (rating >= SuccessRating.PartialSuccess)
                            {
                                seaman.SendMessage("You did your part.");
                            }
                            else
                            {
                                seaman.SendMessage("You could have been more helpful.");
                            }
                        }
                    }
                }

                skils = LokaiSkillUtilities.XMLGetSkills(sailor);

                rating = LokaiSkillUtilities.CheckLokaiSkill(sailor, skils.Sailing, MinLevel, MaxLevel);
                if (rating <= SuccessRating.Failure)
                {
                    int severity = 25;
                    if (rating == SuccessRating.HazzardousFailure)
                    {
                        severity += 4;
                    }
                    else if (rating == SuccessRating.CriticalFailure)
                    {
                        severity += 8;
                    }

                    bool crash = false;

                    foreach (Mobile seaman in crew)
                    {
                        if (!m_SailTime.ContainsKey(seaman))
                        {
                            m_SailTime.Add(seaman, DateTime.Now.AddSeconds(FAILSECONDS));
                        }
                    }

                    switch (Utility.Random(severity))
                    {
                    case 0:
                    case 1:
                    case 2: boat.StartMove(Direction.Down, true); goto case 24;

                    case 3:
                    case 4:
                    case 5: boat.StartMove(Direction.East, true); goto case 24;

                    case 6:
                    case 7:
                    case 8: boat.StartMove(Direction.Left, true); goto case 24;

                    case 9:
                    case 10:
                    case 11: boat.StartMove(Direction.North, true); goto case 24;

                    case 12:
                    case 13:
                    case 14: boat.StartMove(Direction.Right, true); goto case 24;

                    case 15:
                    case 16:
                    case 17: boat.StartMove(Direction.South, true); goto case 24;

                    case 18:
                    case 19:
                    case 20: boat.StartMove(Direction.Up, true); goto case 24;

                    case 21:
                    case 22:
                    case 23: boat.StartMove(Direction.West, true); goto case 24;

                    case 24: boat.StartTurn(Utility.RandomList(2, -2, -4), false); goto case 99;

                    case 99:
                    {
                        foreach (Mobile mobile in crew)
                        {
                            MightGetSick(mobile);
                        }
                        break;
                    }

                    default: crash = true; break;
                    }

                    if (crash)
                    {
                        boat.LowerAnchor(false);
                        List <Item> items = CheckForItems(boat);

                        BaseDockedBoat dboat = boat.DockedBoat;

                        foreach (Mobile seaman in crew)
                        {
                            seaman.SendMessage("The boat runs aground at some nearby land.");
                            boat.RemoveKeys(seaman);
                            if (seaman == boat.Owner)
                            {
                                if (dboat != null)
                                {
                                    seaman.AddToBackpack(dboat);
                                }
                            }
                        }

                        boat.Delete();

                        foreach (Mobile seaman in crew)
                        {
                            Strand(seaman);
                        }
                        if (items.Count > 0)
                        {
                            for (int v = 0; v < items.Count; v++)
                            {
                                int x = from.X + Utility.Random(7) - 3;
                                int y = from.Y + Utility.Random(7) - 3;
                                items[v].MoveToWorld(new Point3D(x, y, from.Z));
                            }
                        }
                    }
                    else
                    {
                        foreach (Mobile seaman in crew)
                        {
                            seaman.SendMessage("You go off course slightly.");
                        }
                    }
                }
                else
                {
                    //if (Core.Debug) from.SendMessage("TEST: SAILING SUCCESSFUL.");

                    foreach (Mobile seaman in crew)
                    {
                        seaman.SendMessage("You feel the gentle breeze of the open sea.");
                        if (!m_SailTime.ContainsKey(seaman))
                        {
                            m_SailTime.Add(seaman, DateTime.Now.AddSeconds(SAILSECONDS));
                        }
                    }
                }
            }
        }
Example #12
0
                public override void OnResponse(Mobile from, string text)
                {
                    if (targeted is Item && ((Item)targeted).Parent != null)
                    {
                        targeted = ((Item)targeted).Parent;
                        OnResponse(from, text);
                    }
                    LokaiSkills skills     = LokaiSkillUtilities.XMLGetSkills(from);
                    LokaiSkill  lokaiSkill = (LokaiSkillUtilities.XMLGetSkills(from)).Ventriloquism;

                    if (targeted is Mobile)
                    {
                        Mobile mob = (Mobile)targeted;
                        if (mob == from)
                        {
                            from.SendMessage("That's not much of a trick.");
                        }
                        else if (!mob.Alive || mob.Deleted || mob.Hidden)
                        {
                            from.SendMessage("I don't know who or what you mean.");
                        }
                        else if (!from.InRange(mob.Location, 5))
                        {
                            from.SendMessage("They are too far away.");
                        }
                        else if (!from.CanSee(mob))
                        {
                            from.SendMessage("You can't see them well enough to make them talk.");
                        }
                        else
                        {
                            double distance = Math.Sqrt((double)((mob.X - from.X) * (mob.X - from.X) +
                                                                 (double)((mob.Y - from.Y) * (mob.Y - from.Y))));
                            double        minLokaiSkill = 10.0 + (distance * 5.0);
                            double        maxLokaiSkill = 75.0 + (distance * 5.0);
                            SuccessRating rating        = LokaiSkillUtilities.CheckLokaiSkill(from, lokaiSkill, minLokaiSkill, maxLokaiSkill);
                            if (rating >= SuccessRating.PartialSuccess)
                            {
                                mob.PublicOverheadMessage(MessageType.Emote, 0, false, text);
                            }
                            else
                            {
                                from.Say(text);
                                from.SendMessage("Your attempt at ventriloquism fails.");
                            }
                        }
                    }
                    else if (targeted is Item)
                    {
                        Item item = (Item)targeted;
                        if (!from.InRange(item.Location, 5))
                        {
                            from.SendMessage("That is too far away.");
                        }
                        else if (!from.CanSee(item))
                        {
                            from.SendMessage("You can't see that well enough to make it talk.");
                        }
                        else
                        {
                            double distance = Math.Sqrt((double)((item.X - from.X) * (item.X - from.X) +
                                                                 (double)((item.Y - from.Y) * (item.Y - from.Y))));
                            double        minLokaiSkill = 0.0 + (distance * 5.0);
                            double        maxLokaiSkill = 65.0 + (distance * 5.0);
                            SuccessRating rating        = LokaiSkillUtilities.CheckLokaiSkill(from, lokaiSkill, minLokaiSkill, maxLokaiSkill);
                            if (rating >= SuccessRating.PartialSuccess)
                            {
                                item.PublicOverheadMessage(MessageType.Emote, 0, false, text);
                            }
                            else
                            {
                                from.Say(text);
                                from.SendMessage("Your attempt at ventriloquism fails.");
                            }
                        }
                    }
                    else if (targeted is StaticTarget)
                    {
                        StaticTarget stat = (StaticTarget)targeted;
                        if (!from.InRange(stat.Location, 5))
                        {
                            from.SendMessage("That is too far away.");
                        }
                        else
                        {
                            double distance = Math.Sqrt((double)((stat.X - from.X) * (stat.X - from.X) +
                                                                 (double)((stat.Y - from.Y) * (stat.Y - from.Y))));
                            double        minLokaiSkill = -10.0 + (distance * 5.0);
                            double        maxLokaiSkill = 55.0 + (distance * 5.0);
                            SuccessRating rating        = LokaiSkillUtilities.CheckLokaiSkill(from, lokaiSkill, minLokaiSkill, maxLokaiSkill);
                            if (rating >= SuccessRating.PartialSuccess)
                            {
                                IPoint3D p    = targeted as IPoint3D;
                                Item     item = new Item(stat.ItemID);
                                if (p == null)
                                {
                                    from.SendMessage("Unable to target that.");
                                    return;
                                }

                                if (p is Item)
                                {
                                    p = ((Item)p).GetWorldTop();
                                    if (Core.Debug)
                                    {
                                        from.SendMessage("TEMP: Set Point3D to ((Item)p).GetWorldTop().");
                                    }
                                }
                                else
                                {
                                    p = new Point3D(stat.X, stat.Y, stat.Z - item.ItemData.CalcHeight);
                                    if (Core.Debug)
                                    {
                                        from.SendMessage("TEMP: IPoint3D was not an Item.");
                                    }
                                }
                                item.MoveToWorld(new Point3D(p), from.Map);
                                item.PublicOverheadMessage(MessageType.Emote, 0, false, text);
                                new InternalTimer(from, item).Start();
                            }
                            else
                            {
                                from.Say(text);
                                from.SendMessage("Your attempt at ventriloquism fails.");
                            }
                        }
                    }
                }
Example #13
0
        public ResourceGump(Mobile from, TreeHarvestTool tool)
            : base(0, 0)
        {
            m_From = from;
            m_Tool = tool;
            LokaiSkills    skills     = LokaiSkillUtilities.XMLGetSkills(from);
            LokaiSkillName skil       = LokaiSkillName.TreePicking;
            string         lokaiSkill = "Current Tree";

            switch (m_Tool.ResourceType)
            {
            case TreeResourceType.BarkSkin: lokaiSkill += " Carving Skill: "; skil = LokaiSkillName.TreeCarving; break;

            case TreeResourceType.FruitNut: lokaiSkill += " Picking Skill: "; skil = LokaiSkillName.TreePicking; break;

            case TreeResourceType.LeafSpine: lokaiSkill += " Picking Skill: "; skil = LokaiSkillName.TreePicking; break;

            case TreeResourceType.RootBranch: lokaiSkill += " Digging Skill: "; skil = LokaiSkillName.TreeDigging; break;

            case TreeResourceType.SapJuice: lokaiSkill += " Sapping Skill: "; skil = LokaiSkillName.TreeSapping; break;
            }
            lokaiSkill += skills[skil].Value.ToString("F1");

            m_From.CloseGump(typeof(ResourceGump));

            Closable  = true;
            Dragable  = true;
            Resizable = false;
            int bark  = m_Tool.ResourceType == TreeResourceType.BarkSkin ? 2361 : 2360;
            int fruit = m_Tool.ResourceType == TreeResourceType.FruitNut ? 2361 : 2360;
            int leaf  = m_Tool.ResourceType == TreeResourceType.LeafSpine ? 2361 : 2360;
            int root  = m_Tool.ResourceType == TreeResourceType.RootBranch ? 2361 : 2360;
            int sap   = m_Tool.ResourceType == TreeResourceType.SapJuice ? 2361 : 2360;

            AddPage(0);
            AddBackground(40, 40, 404, 445, 9250);
            AddImage(40, 40, from.Female ? 13 : 12, 146);
            AddImage(40, 40, 50981);
            AddImage(40, 40, 60479);
            AddImage(40, 40, 60517);
            AddImage(40, 40, 50617);
            AddImage(40, -30, 50650);
            AddImage(-3, 178, 50497);
            AddImage(95, 81, 11374);
            AddImage(51, 52, 11374);
            AddImage(55, 99, 11374);
            AddImage(56, 135, 11374);
            AddImage(61, 233, 11374);
            AddLabel(57, 57, 1378, @"A");
            AddLabel(99, 84, 1378, @"B");
            AddLabel(60, 102, 1378, @"C");
            AddLabel(61, 137, 1378, @"D");
            AddLabel(66, 236, 1378, @"E");
            AddLabel(70, 300, 1378, @"A");
            AddLabel(70, 330, 1378, @"B");
            AddLabel(70, 360, 1378, @"C");
            AddLabel(70, 390, 1378, @"D");
            AddLabel(70, 420, 1378, @"E");
            AddLabel(170, 54, 0, @"Tree Harvest Tool");
            AddLabel(88, 300, 0, @"Fruit Picking Tool: for harvesting fruit and nuts");
            AddLabel(88, 330, 0, @"Leaf Picking Tool: for harvesting leaves and spines");
            AddLabel(88, 360, 0, @"Carving Tool: for harvesting bark and skin");
            AddLabel(88, 390, 0, @"Sapping Tool: for harvesting sap and juice");
            AddLabel(88, 420, 0, @"Digging Tool: for harvesting roots and buried branches");
            AddLabel(55, 274, 0, lokaiSkill);
            AddButton(55, 304, fruit, 2362, (int)Buttons.FruitNut, GumpButtonType.Reply, 0);
            AddButton(55, 394, sap, 2362, (int)Buttons.SapJuice, GumpButtonType.Reply, 0);
            AddButton(55, 364, bark, 2362, (int)Buttons.BarkSkin, GumpButtonType.Reply, 0);
            AddButton(55, 334, leaf, 2362, (int)Buttons.LeafSpine, GumpButtonType.Reply, 0);
            AddButton(55, 424, root, 2362, (int)Buttons.RootBranch, GumpButtonType.Reply, 0);
            AddItem(300, 65, 0x0C96);
            AddItem(167, 201, 0x194F);
            AddItem(207, 211, 0x0993);
            AddItem(220, 75, 0x0D94);
            AddItem(220, 75, 0x0D96);
            AddItem(270, 145, 0x0CDA);
            AddItem(270, 145, 0x0CDC);
            AddButton(133, 447, 9904, 9905, (int)Buttons.Investigate, GumpButtonType.Reply, 0);
            AddLabel(159, 448, 0, @"Investigate Tree");
        }
Example #14
0
        public LokaiSkillsGump(Mobile from, Mobile target, LokaiSkillsGumpGroup selected)
            : base(GumpOffsetX, GumpOffsetY)
        {
            m_From   = from;
            m_Target = target;

            m_Groups   = LokaiSkillsGumpGroup.Groups;
            m_Selected = selected;

            int count = m_Groups.Length;

            if (selected != null)
            {
                count += selected.LokaiSkills.Length;
            }

            int totalHeight = OffsetSize + ((EntryHeight + OffsetSize) * (count + 1));

            AddPage(0);

            AddBackground(0, 0, BackWidth, BorderSize + totalHeight + BorderSize, BackGumpID);
            AddImageTiled(BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), totalHeight, OffsetGumpID);

            int x = BorderSize + OffsetSize;
            int y = BorderSize + OffsetSize;

            int emptyWidth = TotalWidth - PrevWidth - NextWidth - (OffsetSize * 4) - (OldStyle ? SetWidth + OffsetSize : 0);

            if (OldStyle)
            {
                AddImageTiled(x, y, TotalWidth - (OffsetSize * 3) - SetWidth, EntryHeight, HeaderGumpID);
            }
            else
            {
                AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID);
            }

            x += PrevWidth + OffsetSize;

            if (!OldStyle)
            {
                AddImageTiled(x - (OldStyle ? OffsetSize : 0), y, emptyWidth + (OldStyle ? OffsetSize * 2 : 0), EntryHeight, HeaderGumpID);
            }

            x += emptyWidth + OffsetSize;

            if (!OldStyle)
            {
                AddImageTiled(x, y, NextWidth, EntryHeight, HeaderGumpID);
            }

            for (int i = 0; i < m_Groups.Length; ++i)
            {
                x  = BorderSize + OffsetSize;
                y += EntryHeight + OffsetSize;

                LokaiSkillsGumpGroup group = m_Groups[i];

                AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID);

                if (group == selected)
                {
                    AddButton(x + PrevOffsetX, y + PrevOffsetY, 0x15E2, 0x15E6, GetButtonID(0, i), GumpButtonType.Reply, 0);
                }
                else
                {
                    AddButton(x + PrevOffsetX, y + PrevOffsetY, 0x15E1, 0x15E5, GetButtonID(0, i), GumpButtonType.Reply, 0);
                }

                x += PrevWidth + OffsetSize;

                x -= (OldStyle ? OffsetSize : 0);

                AddImageTiled(x, y, emptyWidth + (OldStyle ? OffsetSize * 2 : 0), EntryHeight, EntryGumpID);
                AddLabel(x + TextOffsetX, y, TextHue, group.Name);

                x += emptyWidth + (OldStyle ? OffsetSize * 2 : 0);
                x += OffsetSize;

                if (SetGumpID != 0)
                {
                    AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
                }

                if (group == selected)
                {
                    int indentMaskX = BorderSize;
                    int indentMaskY = y + EntryHeight + OffsetSize;

                    for (int j = 0; j < group.LokaiSkills.Length; ++j)
                    {
                        LokaiSkill skil = (LokaiSkillUtilities.XMLGetSkills(m_Target))[group.LokaiSkills[j]];

                        x  = BorderSize + OffsetSize;
                        y += EntryHeight + OffsetSize;

                        x += OffsetSize;
                        x += IndentWidth;

                        AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID);

                        AddButton(x + PrevOffsetX, y + PrevOffsetY, 0x15E1, 0x15E5, GetButtonID(1, j), GumpButtonType.Reply, 0);

                        x += PrevWidth + OffsetSize;

                        x -= (OldStyle ? OffsetSize : 0);

                        AddImageTiled(x, y, emptyWidth + (OldStyle ? OffsetSize * 2 : 0) - OffsetSize - IndentWidth, EntryHeight, EntryGumpID);
                        AddLabel(x + TextOffsetX, y, TextHue, skil == null ? "(null)" : skil.Name);

                        x += emptyWidth + (OldStyle ? OffsetSize * 2 : 0) - OffsetSize - IndentWidth;
                        x += OffsetSize;

                        if (SetGumpID != 0)
                        {
                            AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
                        }

                        if (skil != null)
                        {
                            int buttonID1, buttonID2;
                            int xOffset, yOffset;

                            switch (skil.Lock)
                            {
                            default:
                            case LokaiSkillLock.Up: buttonID1 = 0x983; buttonID2 = 0x983; xOffset = 6; yOffset = 4; break;

                            case LokaiSkillLock.Down: buttonID1 = 0x985; buttonID2 = 0x985; xOffset = 6; yOffset = 4; break;

                            case LokaiSkillLock.Locked: buttonID1 = 0x82C; buttonID2 = 0x82C; xOffset = 5; yOffset = 2; break;
                            }

                            AddButton(x + xOffset, y + yOffset, buttonID1, buttonID2, GetButtonID(2, j), GumpButtonType.Reply, 0);

                            y += 1;
                            x -= OffsetSize;
                            x -= 1;
                            x -= 50;

                            AddImageTiled(x, y, 50, EntryHeight - 2, OffsetGumpID);

                            x += 1;
                            y += 1;

                            AddImageTiled(x, y, 48, EntryHeight - 4, EntryGumpID);

                            AddLabelCropped(x + TextOffsetX, y - 1, 48 - TextOffsetX, EntryHeight - 3, TextHue, skil.Base.ToString("F1"));

                            y -= 2;
                        }
                    }

                    AddImageTiled(indentMaskX, indentMaskY, IndentWidth + OffsetSize, (group.LokaiSkills.Length * (EntryHeight + OffsetSize)) - (i < (m_Groups.Length - 1) ? OffsetSize : 0), BackGumpID + 4);
                }
            }
        }
Example #15
0
        public static void RideEthereal(Mobile from, Item ethereal)
        {
            bool newride = true;

            if (m_RideTime.ContainsKey(from))
            {
                if (m_RideTime[from] >= DateTime.Now)
                {
                    newride = false;
                }
                else
                {
                    m_RideTime.Remove(from);
                }
            }


            LokaiSkills skills = LokaiSkillUtilities.XMLGetSkills(from);

            if (newride)
            {
                int MinLevel = 20;
                int MaxLevel = 100;
                int fame     = 0;
                if (Core.Debug)
                {
                    from.SendMessage("TEST: RIDING AN ETHEREAL MOUNT");
                }

                SuccessRating rating = LokaiSkillUtilities.CheckLokaiSkill(from, skills.AnimalRiding, MinLevel, MaxLevel);
                if (rating <= SuccessRating.Failure)
                {
                    int    scalar      = from.TotalWeight / (from.Dex + from.Str);
                    double penaltyTime = 0.0;

                    if (Core.Debug)
                    {
                        from.SendMessage("TEST: RIDING FAILED CHECK.");
                    }
                    IMount mount = ethereal as IMount;

                    if (mount != null)
                    {
                        mount.Rider = null;
                        from.SendMessage("You were dismounted.");
                    }
                    switch (rating)
                    {
                    case SuccessRating.HazzardousFailure:
                    {
                        if (Utility.RandomBool())
                        {
                            from.Damage(Utility.Random(5 * scalar));
                            from.SendMessage("You took some damage!");
                            fame = -200 * Utility.Random(1, 2);
                            Misc.Titles.AwardFame(from, fame, true);
                            penaltyTime = 4.0;
                        }
                        break;
                    }

                    case SuccessRating.CriticalFailure:
                    {
                        if (Utility.RandomBool())
                        {
                            from.Damage(Utility.Random(15 * scalar));
                            from.SendMessage("You took serious damage!");
                            fame = -400 * Utility.Random(1, 2);
                            Misc.Titles.AwardFame(from, fame, true);
                            penaltyTime = 10.0;
                        }
                        break;
                    }

                    case SuccessRating.TooDifficult:
                    {
                        from.SendMessage("This mount is too difficult for you!");
                        break;
                    }

                    default: break;
                    }
                    m_RideTime.Add(from, DateTime.Now.AddSeconds(FAILSECONDS + penaltyTime));
                }
                else
                {
                    double bonusTime = 0.0;
                    if (Core.Debug)
                    {
                        from.SendMessage("TEST: RIDING SUCCEEDED CHECK.");
                    }
                    switch (rating)
                    {
                    case SuccessRating.ExceptionalSuccess:
                    {
                        if (Utility.RandomBool())
                        {
                            fame = 400 * Utility.Random(1, 2);
                            Misc.Titles.AwardFame(from, fame, true);
                            bonusTime = 20.0;
                        }
                        break;
                    }

                    case SuccessRating.CompleteSuccess:
                    {
                        if (Utility.RandomBool())
                        {
                            fame = 200 * Utility.Random(1, 2);
                            Misc.Titles.AwardFame(from, fame, true);
                            bonusTime = 10.0;
                        }
                        break;
                    }

                    case SuccessRating.Success:
                    {
                        if (Utility.RandomBool())
                        {
                            fame = 100 * Utility.Random(1, 2);
                            Misc.Titles.AwardFame(from, fame, true);
                            bonusTime = 4.0;
                        }
                        break;
                    }

                    case SuccessRating.TooEasy:
                    {
                        from.SendMessage("This mount does not provide enough of a challenge for you.");
                        bonusTime = 120.0;
                        break;
                    }

                    default: break;
                    }
                    m_RideTime.Add(from, DateTime.Now.AddSeconds(RIDESECONDS + bonusTime));
                }
                skills.LastLokaiSkillCheck[(int)LokaiSkillName.AnimalRiding] = rating;
            }
            else
            {
                SuccessRating rating = skills.LastCheck(LokaiSkillName.AnimalRiding);
                if (rating <= SuccessRating.Failure)
                {
                    double wait = ((TimeSpan)(m_RideTime[from] - DateTime.Now)).TotalSeconds;
                    if (Core.Debug)
                    {
                        from.SendMessage("TEST: FAILED LAST RIDING CHECK.");
                    }
                    IMount mount = ethereal as IMount;

                    if (mount != null)
                    {
                        mount.Rider = null;
                        if (rating > SuccessRating.TooDifficult)
                        {
                            from.SendMessage("You must wait {0} seconds before you attempt this again.", wait.ToString("F1"));
                        }
                        else
                        {
                            from.SendMessage("This mount is too difficult for you!");
                        }
                    }
                }
            }
        }
                protected override void OnTick()
                {
                    m_Count++;

                    if (isCreature)
                    {
                        DamageEntry de           = m_Creature.FindMostRecentDamageEntry(false);
                        bool        alreadyOwned = m_Creature.Owners.Contains(m_From);

                        if (!m_From.InRange(m_Creature, 6))
                        {
                            m_From.NextSkillTime = Core.TickCount;
                            m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, true, "You are too far away to continue hypnotizing.", m_From.NetState);
                            Stop();
                        }
                        else if (!m_From.CheckAlive())
                        {
                            m_From.NextSkillTime = Core.TickCount;
                            m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, true, "You are dead, and cannot continue hypnotizing.", m_From.NetState);
                            Stop();
                        }
                        else if (!m_Creature.CheckAlive())
                        {
                            m_From.NextSkillTime = Core.TickCount;
                            m_From.PrivateOverheadMessage(MessageType.Regular, 0x3B2, true, "The creature is dead, so you cannot continue hypnotizing it.", m_From.NetState);
                            Stop();
                        }
                        else if (m_Creature.Controlled && m_Creature.ControlMaster == m_From)
                        {
                            m_From.NextSkillTime = Core.TickCount;
                            m_From.PrivateOverheadMessage(MessageType.Regular, 0x3B2, true, "The creature will already obey you.", m_From.NetState);
                            Stop();
                        }
                        else if (!m_From.CanSee(m_Creature) || !m_From.InLOS(m_Creature))
                        {
                            m_From.NextSkillTime = Core.TickCount;
                            m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, true, "You do not have a clear path to the creature you are hypnotizing, and must cease your attempt.", m_From.NetState);
                            Stop();
                        }
                        else if (m_Creature.Frozen && m_Creature.Paralyzed)
                        {
                            m_From.NextSkillTime = Core.TickCount;
                            m_From.PrivateOverheadMessage(MessageType.Regular, 0x3B2, true, "It appears to be already in a trance.", m_From.NetState);
                            Stop();
                        }
                        else if (m_Count < m_FullCount)
                        {
                            m_From.RevealingAction();

                            switch (Utility.Random(5))
                            {
                            case 0: m_From.PublicOverheadMessage(MessageType.Regular, 0x3B2, true, "You are getting sleepy....", false); break;

                            case 1: m_From.PublicOverheadMessage(MessageType.Regular, 0x3B2, true, "Look into my eyes....", false); break;

                            case 2: m_From.PublicOverheadMessage(MessageType.Regular, 0x3B2, true, "Look deep into my eyes....", false); break;

                            case 3: m_From.PublicOverheadMessage(MessageType.Regular, 0x3B2, true, "Your eyes are getting very heavy....", false); break;

                            case 4: m_From.PublicOverheadMessage(MessageType.Regular, 0x3B2, true, "Sleepy....very sleepy....", false); break;
                            }

                            if (!alreadyOwned) // Passively check animal lore for gain
                            {
                                m_From.CheckTargetSkill(SkillName.AnimalLore, m_Creature, 0.0, 120.0);
                            }
                        }
                        else
                        {
                            m_From.RevealingAction();
                            m_From.NextSkillTime = Core.TickCount;

                            double minSkill = (double)m_Creature.Int / 3.0;

                            if (minSkill < -10.0)
                            {
                                minSkill = -10.0;
                            }
                            if (minSkill > 90.0)
                            {
                                minSkill = 90.0;
                            }

                            minSkill += 8.3;

                            LokaiSkill    lokaiSkill = LokaiSkillUtilities.XMLGetSkills(m_From).Hypnotism;
                            SuccessRating rating     = LokaiSkillUtilities.CheckLokaiSkill(m_From, lokaiSkill, minSkill, alreadyOwned ? minSkill : minSkill + 40);

                            if (rating >= SuccessRating.PartialSuccess)
                            {
                                if (rating == SuccessRating.TooEasy)
                                {
                                    m_From.SendLocalizedMessage(502797); // That wasn't even challenging.
                                }
                                else
                                {
                                    m_From.SendMessage("You succeed in hypnotizing the creature.");
                                }

                                double duration = 15.0;
                                switch (rating)
                                {
                                case SuccessRating.PartialSuccess: break;

                                case SuccessRating.Success: duration += 5.0; break;

                                case SuccessRating.CompleteSuccess: duration += 15.0; break;

                                case SuccessRating.ExceptionalSuccess: duration += 25.0; break;

                                case SuccessRating.TooEasy: duration += 45; break;
                                }

                                m_Creature.Freeze(TimeSpan.FromSeconds(duration));
                                m_Creature.Paralyze(TimeSpan.FromSeconds(duration));
                                m_Creature.Pacify(m_From, DateTime.Now.AddSeconds(duration));
                            }
                            else
                            {
                                m_From.SendMessage("You fail to hypnotize the creature.");
                            }
                        }
                    }
                    else
                    {
                        DamageEntry de = m_Mobile.FindMostRecentDamageEntry(false);

                        if (!m_From.InRange(m_Mobile, 6))
                        {
                            m_From.NextSkillTime = Core.TickCount;
                            m_Mobile.PrivateOverheadMessage(MessageType.Regular, 0x3B2, true, "You are too far away to continue hypnotizing.", m_From.NetState);
                            Stop();
                        }
                        else if (!m_From.CheckAlive())
                        {
                            m_From.NextSkillTime = Core.TickCount;
                            m_Mobile.PrivateOverheadMessage(MessageType.Regular, 0x3B2, true, "You are dead, and cannot continue hypnotizing.", m_From.NetState);
                            Stop();
                        }
                        else if (!m_From.CanSee(m_Mobile) || !m_From.InLOS(m_Mobile))
                        {
                            m_From.NextSkillTime = Core.TickCount;
                            m_Mobile.PrivateOverheadMessage(MessageType.Regular, 0x3B2, true, "You do not have a clear path to the person you are hypnotizing, and must cease your attempt.", m_From.NetState);
                            Stop();
                        }
                        else if (!m_Mobile.CheckAlive())
                        {
                            m_From.NextSkillTime = Core.TickCount;
                            m_From.PrivateOverheadMessage(MessageType.Regular, 0x3B2, true, "The person is dead, so you cannot continue hypnotizing them.", m_From.NetState);
                            Stop();
                        }
                        else if (m_Mobile is BaseEscortable && ((BaseEscortable)m_Mobile).Controlled && ((BaseEscortable)m_Mobile).ControlMaster == m_From)
                        {
                            m_From.NextSkillTime = Core.TickCount;
                            m_From.PrivateOverheadMessage(MessageType.Regular, 0x3B2, true, "They will already obey you.", m_From.NetState);
                            Stop();
                        }
                        else if (m_Mobile.Frozen && m_Mobile.Paralyzed)
                        {
                            m_From.NextSkillTime = Core.TickCount;
                            m_From.PrivateOverheadMessage(MessageType.Regular, 0x3B2, true, "They appear to be already in a trance.", m_From.NetState);
                            Stop();
                        }
                        else if (m_Count < m_FullCount)
                        {
                            m_From.RevealingAction();

                            switch (Utility.Random(5))
                            {
                            case 0: m_From.PublicOverheadMessage(MessageType.Regular, 0x3B2, true, "You are getting sleepy....", false); break;

                            case 1: m_From.PublicOverheadMessage(MessageType.Regular, 0x3B2, true, "Look into my eyes....", false); break;

                            case 2: m_From.PublicOverheadMessage(MessageType.Regular, 0x3B2, true, "Look deep into my eyes....", false); break;

                            case 3: m_From.PublicOverheadMessage(MessageType.Regular, 0x3B2, true, "Your eyes are getting very heavy....", false); break;

                            case 4: m_From.PublicOverheadMessage(MessageType.Regular, 0x3B2, true, "Sleepy....very sleepy....", false); break;
                            }

                            m_From.CheckTargetSkill(SkillName.EvalInt, m_Mobile, 0.0, 120.0);
                        }
                        else
                        {
                            m_From.RevealingAction();
                            m_From.NextSkillTime = Core.TickCount;

                            m_From.CheckTargetSkill(SkillName.EvalInt, m_Mobile, 0.0, 120.0);

                            double minSkill = (double)m_Mobile.Int / 3.0;

                            if (minSkill < -10.0)
                            {
                                minSkill = -10.0;
                            }
                            if (minSkill > 90.0)
                            {
                                minSkill = 90.0;
                            }

                            minSkill += 10.0;

                            LokaiSkill    lokaiSkill = LokaiSkillUtilities.XMLGetSkills(m_From).Hypnotism;
                            SuccessRating rating     = LokaiSkillUtilities.CheckLokaiSkill(m_From, lokaiSkill, minSkill, minSkill + 40);

                            if (rating >= SuccessRating.PartialSuccess)
                            {
                                double duration = 15.0;
                                switch (rating)
                                {
                                case SuccessRating.PartialSuccess: break;

                                case SuccessRating.Success: duration += 5.0; break;

                                case SuccessRating.CompleteSuccess: duration += 15.0; break;

                                case SuccessRating.ExceptionalSuccess: duration += 25.0; break;

                                case SuccessRating.TooEasy: duration += 45; break;
                                }
                                m_From.SendMessage("You successfully put your subject in a trance.");

                                Mobile master = null;

                                if (m_Mobile is BaseEscortable)
                                {
                                    BaseEscortable target = (BaseEscortable)m_Mobile;
                                    if (((BaseEscortable)m_Mobile).Controlled)
                                    {
                                        master = target.ControlMaster;
                                    }
                                    target.Controlled    = true;
                                    target.ControlMaster = m_From;
                                    m_From.SendMessage("The target will obey you for {0} seconds.", duration.ToString("F1"));
                                    new EscortableTimer(m_From, master, target, (int)duration).Start();
                                }
                                else
                                {
                                    m_Mobile.Freeze(TimeSpan.FromSeconds(duration));
                                    m_Mobile.Paralyze(TimeSpan.FromSeconds(duration));
                                    m_Mobile.SendMessage("You have been hypnotized!");
                                    m_From.SendGump(new HypnotismGump(m_From, m_Mobile, duration, 1));
                                }
                            }
                            else
                            {
                                m_From.SendMessage("You fail to hypnotize your subject.");
                            }
                        }
                    }
                }
Example #17
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            int buttonID = info.ButtonID - 1;

            int index = buttonID / 3;
            int type  = buttonID % 3;

            switch (type)
            {
            case 0:
            {
                if (index >= 0 && index < m_Groups.Length)
                {
                    LokaiSkillsGumpGroup newSelection = m_Groups[index];

                    if (m_Selected != newSelection)
                    {
                        m_From.SendGump(new LokaiSkillsGump(m_From, m_Target, newSelection));
                    }
                    else
                    {
                        m_From.SendGump(new LokaiSkillsGump(m_From, m_Target, null));
                    }
                }

                break;
            }

            case 1:
            {
                if (m_Selected != null && index >= 0 && index < m_Selected.LokaiSkills.Length)
                {
                    LokaiSkill skil = (LokaiSkillUtilities.XMLGetSkills(m_Target))[m_Selected.LokaiSkills[index]];

                    if (skil != null)
                    {
                        if (m_From.AccessLevel >= AccessLevel.GameMaster)
                        {
                            m_From.SendGump(new EditLokaiSkillGump(m_From, m_Target, skil, m_Selected));
                        }
                        else
                        {
                            m_From.SendMessage("You may not change that.");
                            m_From.SendGump(new LokaiSkillsGump(m_From, m_Target, m_Selected));
                        }
                    }
                    else
                    {
                        m_From.SendGump(new LokaiSkillsGump(m_From, m_Target, m_Selected));
                    }
                }

                break;
            }

            case 2:
            {
                if (m_Selected != null && index >= 0 && index < m_Selected.LokaiSkills.Length)
                {
                    LokaiSkill skil = (LokaiSkillUtilities.XMLGetSkills(m_Target))[m_Selected.LokaiSkills[index]];

                    if (skil != null)
                    {
                        if (m_From.AccessLevel >= AccessLevel.GameMaster)
                        {
                            switch (skil.Lock)
                            {
                            case LokaiSkillLock.Up: skil.SetLockNoRelay(LokaiSkillLock.Down); skil.Update(); break;

                            case LokaiSkillLock.Down: skil.SetLockNoRelay(LokaiSkillLock.Locked); skil.Update(); break;

                            case LokaiSkillLock.Locked: skil.SetLockNoRelay(LokaiSkillLock.Up); skil.Update(); break;
                            }
                        }
                        else
                        {
                            m_From.SendMessage("You may not change that.");
                        }

                        m_From.SendGump(new LokaiSkillsGump(m_From, m_Target, m_Selected));
                    }
                }

                break;
            }
            }
        }
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile m = state.Mobile;

            if (info.ButtonID > 299)
            {
                int change = info.ButtonID - 300;
                LokaiSkillUtilities.ChangeShowLokaiSkill(change);
                m.SendGump(new ShowLokaiSkillsGump(m, m_Value));
            }
            else if (info.ButtonID > 199)
            {
                LokaiSkillName showAb     = (LokaiSkillName)(info.ButtonID - 200);
                LokaiSkill     lokaiSkill = LokaiSkillUtilities.XMLGetSkills(m)[showAb];
                int            offset     = ((int)showAb * 17) - 9;
                switch (showAb)
                {
                case LokaiSkillName.Butchering: m.SendGump(new ShowButcheringGump(m, lokaiSkill, offset)); break;

                case LokaiSkillName.Skinning: m.SendGump(new ShowSkinningGump(m, lokaiSkill, offset)); break;

                case LokaiSkillName.DetectEvil: m.SendGump(new ShowDetectEvilGump(m, lokaiSkill, offset)); break;

                case LokaiSkillName.CureDisease: m.SendGump(new ShowCureDiseaseGump(m, lokaiSkill, offset)); break;

                case LokaiSkillName.PickPocket: m.SendGump(new ShowPickPocketGump(m, lokaiSkill, offset)); break;

                case LokaiSkillName.Pilfering: m.SendGump(new ShowPilferingGump(m, lokaiSkill, offset)); break;

                case LokaiSkillName.Ventriloquism: m.SendGump(new ShowVentriloquismGump(m, lokaiSkill, offset)); break;

                case LokaiSkillName.Hypnotism: m.SendGump(new ShowHypnotismGump(m, lokaiSkill, offset)); break;

                case LokaiSkillName.SpeakToAnimals: m.SendGump(new ShowSpeakToAnimalsGump(m, lokaiSkill, offset)); break;

                case LokaiSkillName.Brewing: m.SendGump(new ShowBrewingGump(m, lokaiSkill, offset)); break;

                case LokaiSkillName.Commerce: m.SendGump(new ShowCommerceGump(m, lokaiSkill, offset)); break;

                case LokaiSkillName.Herblore: m.SendGump(new ShowHerbloreGump(m, lokaiSkill, offset)); break;
                }
                m.SendGump(new ShowLokaiSkillsGump(m, m_Value));
            }
            else if (info.ButtonID > 99)
            {
                int useSkill = info.ButtonID - 100;
                if (m.Spell == null && !m.Meditating)
                {
                    if (LokaiSkillInfo.Table[useSkill].Callback != null)
                    {
                        if (m.NextSkillTime <= Core.TickCount || (LokaiSkillName)useSkill == LokaiSkillName.SpeakToAnimals)
                        {
                            m.NextSkillTime = Core.TickCount + (int)LokaiSkillInfo.Table[useSkill].Callback(m).TotalSeconds;
                        }
                        else
                        {
                            m.SendMessage("You must wait to use another skill.");
                        }
                    }
                    else
                    {
                        m.SendMessage("That skill is not yet active.");
                    }
                }
                else
                {
                    m.SendMessage("You are too busy to use that skill now.");
                }

                m.SendGump(new ShowLokaiSkillsGump(m, m_Value));
            }
            else if (info.ButtonID == 19)
            {
                m.SendGump(new ShowLokaiSkillsGump(m, false));
            }
            else if (info.ButtonID == 29)
            {
                m.SendGump(new ShowLokaiSkillsGump(m, true));
            }
        }
Example #19
0
        public IncreaseLokaiSkillsGump(PlayerMobile mobile, LokaiSkillBall ball, bool first, int page)
            : base(50, 50)
        {
            m_Page   = page;
            m_Ball   = ball;
            m_Points = m_Ball.Points;
            m_Mobile = mobile;

            m_LokaiSkills = LokaiSkillUtilities.XMLGetSkills(m_Mobile);

            if (first)
            {
                m_StartValue = new double[30];
                m_Page       = 0;
                for (int x = 0; x < 30; x++)
                {
                    m_StartValue[x] = m_LokaiSkills[x].Base;
                }
            }

            m_Mobile.CloseGump(typeof(IncreaseLokaiSkillsGump));

            AddPage(0);

            AddBackground(0, 0, 476, 440, 0x13BE);

            AddLabel(10, 7, 2100, "Choose Skills");

            if (m_Page > 0)
            {
                AddButton(275, 7, 250, 251, 2, GumpButtonType.Reply, 0); // Prev Page
            }

            if (m_Page < 2)
            {
                AddButton(275, 395, 252, 253, 3, GumpButtonType.Reply, 0); // Next Page
            }

            AddLabel(160, 7, 2100, "Points Left: " + m_Points.ToString());

            //			We only need this "if" condition if we want to make them use it all up right now.
            //			if ( m_Points == 0 )
            //			{
            AddButton(305, 335, 0xFB7, 0xFB9, 1, GumpButtonType.Reply, 0); // OK button
            //			}

            AddImage(170, -10, 0x58A);

            m_StartPos = m_Page * 10;
            int z = 0;

            for (int i = m_StartPos; i < m_StartPos + 10; i++)
            {
                int y = 20 + (30 * (++z));

                if (LokaiSkillUtilities.ShowLokaiSkill(i))
                {
                    m_LokaiSkill = m_LokaiSkills[i];

                    AddLabel(10, y, 2124, m_LokaiSkill.Name.ToString());

                    AddLabel(170, y, 2100, (((double)m_LokaiSkill.BaseFixedPoint) / 10).ToString());

                    if (CanLowerLokaiSkill(m_LokaiSkill, i, 1))
                    {
                        AddButton(220, y, 0x1519, 0x1519, 1000 + i, GumpButtonType.Reply, 0); // Decrease
                    }
                    if (CanRaiseLokaiSkill(m_LokaiSkill, i, 1))
                    {
                        AddButton(240, y, 0x151A, 0x151A, 2000 + i, GumpButtonType.Reply, 0); // Increase
                    }
                    if (CanLowerLokaiSkill(m_LokaiSkill, i, 5))
                    {
                        AddButton(200, y - 2, 2229, 2229, 3000 + i, GumpButtonType.Reply, 0); // Decrease by 5
                    }
                    if (CanRaiseLokaiSkill(m_LokaiSkill, i, 5))
                    {
                        AddButton(256, y - 2, 2229, 2229, 4000 + i, GumpButtonType.Reply, 0); // Increase by 5
                    }
                }
            }
        }
            protected override void OnTarget(Mobile from, object targeted)
            {
                Container cont = from.Backpack;

                if (targeted is Item && cont != null && ((Item)targeted).IsChildOf(cont))
                {
                    IShopSellInfo[] info = m_Vendor.GetSellInfo();
                    Item            item = targeted as Item;

                    int    totalCost = 0;
                    string name      = null;

                    foreach (IShopSellInfo ssi in info)
                    {
                        if (ssi.IsSellable(item))
                        {
                            totalCost = ssi.GetBuyPriceFor(item);
                            name      = ssi.GetNameFor(item);
                            break;
                        }
                    }

                    if (name == null)
                    {
                        m_Vendor.SayTo(from, "I won't buy that.");
                    }
                    else if (totalCost == 0)
                    {
                        m_Vendor.SayTo(from, "I won't negotiate on free items.");
                    }
                    else
                    {
                        int        commerceCost  = totalCost;
                        string     commerceSkill = "non-existent";
                        LokaiSkill lokaiSkill    = (LokaiSkillUtilities.XMLGetSkills(from)).Commerce;

                        SuccessRating rating = LokaiSkillUtilities.CheckLokaiSkill(from, lokaiSkill, 0.0, 100.0);
                        switch (rating)
                        {
                        case SuccessRating.CriticalFailure:
                            commerceCost  = (int)(totalCost / CriticalFailure);
                            commerceSkill = "horrible";
                            break;

                        case SuccessRating.HazzardousFailure:
                            commerceCost  = (int)(totalCost / HazzardousFailure);
                            commerceSkill = "terrible";
                            break;

                        case SuccessRating.Failure:
                            commerceCost  = (int)(totalCost / Failure);
                            commerceSkill = "lousy";
                            break;

                        case SuccessRating.PartialSuccess:
                            commerceCost  = (int)(totalCost / PartialSuccess);
                            commerceSkill = "mediocre";
                            break;

                        case SuccessRating.Success:
                            commerceCost  = (int)(totalCost / Success);
                            commerceSkill = "good";
                            break;

                        case SuccessRating.CompleteSuccess:
                            commerceCost  = (int)(totalCost / CompleteSuccess);
                            commerceSkill = "adept";
                            break;

                        case SuccessRating.ExceptionalSuccess:
                            commerceCost  = (int)(totalCost / ExceptionalSuccess);
                            commerceSkill = "exceptional";
                            break;

                        case SuccessRating.TooEasy:
                            commerceCost  = (int)(totalCost / TooEasy);
                            commerceSkill = "unquestionable";
                            break;

                        default:
                        case SuccessRating.TooDifficult:
                            commerceCost  = (int)(totalCost / TooDifficult);
                            commerceSkill = "non-existent";
                            break;
                        }
                        m_Vendor.SayTo(from, "Normally, I would pay {0} for that (1), but due to your {2} commerce skill, I am paying you {3}.",
                                       totalCost, name, commerceSkill, commerceCost);
                        totalCost = commerceCost;
                        item.Consume();

                        if (totalCost > 1000)
                        {
                            from.AddToBackpack(new BankCheck(totalCost));
                        }
                        else if (totalCost > 0)
                        {
                            from.AddToBackpack(new Gold(totalCost));
                        }
                    }
                }
                else
                {
                    from.SendMessage("You can only sell items in your backpack.");
                }
            }
Example #21
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                from.RevealingAction();
                LokaiSkill lokaiSkill = (LokaiSkillUtilities.XMLGetSkills(from)).PickPocket;

                if (targeted is Mobile)
                {
                    Mobile    mobile = targeted as Mobile;
                    Container pack   = mobile.Backpack;

                    if (!from.InRange(mobile.Location, 1))
                    {
                        from.NextSkillTime = Core.TickCount;
                        from.SendMessage("You are too far away to do that.");
                        return;
                    }
                    else if (pack == null)
                    {
                        from.NextSkillTime = Core.TickCount;
                        from.SendMessage("That target has no backpack.");
                        return;
                    }
                    else if (!from.CheckAlive())
                    {
                        from.NextSkillTime = Core.TickCount;
                        from.SendMessage("You cannot do that while you are dead.");
                        return;
                    }
                    else if (!mobile.CheckAlive())
                    {
                        from.NextSkillTime = Core.TickCount;
                        from.SendMessage("That is dead, so you cannot do that.");
                        return;
                    }
                    else if (mobile == from)
                    {
                        from.NextSkillTime = Core.TickCount;
                        from.SendMessage("You wish to pick your own pocket?");
                        return;
                    }
                    else
                    {
                        bool withoutNotice = true;
                        if (targeted is PlayerMobile)
                        {
                            if (ALLOW_PLAYER_THEFT)
                            {
                                SuccessRating rating = LokaiSkillUtilities.CheckLokaiSkill(from, lokaiSkill, 40.0, 100.0);
                                withoutNotice = PickTry(from, mobile, rating, lokaiSkill, pack);
                            }
                            else
                            {
                                from.SendMessage("Pick-pocketing players is not allowed around here!");
                            }
                        }
                        else if (targeted is BaseVendor)
                        {
                            SuccessRating rating = LokaiSkillUtilities.CheckLokaiSkill(from, lokaiSkill, 0.0, 60.0);
                            withoutNotice = PickTry(from, mobile, rating, lokaiSkill, pack);
                        }
                        else if (targeted is BaseCreature &&
                                 (!((targeted as BaseCreature).Controlled && (targeted as BaseCreature).ControlMaster == from)))
                        {
                            SuccessRating rating = LokaiSkillUtilities.CheckLokaiSkill(from, lokaiSkill, 20.0, 80.0);
                            withoutNotice = PickTry(from, mobile, rating, lokaiSkill, pack);
                        }
                        else
                        {
                            from.NextSkillTime = Core.TickCount;
                            from.SendMessage("You may not pick their pocket.");
                            return;
                        }

                        if (!withoutNotice)
                        {
                            if (mobile is PlayerMobile)
                            {
                                from.CriminalAction(true);
                                from.OnHarmfulAction(mobile, from.Criminal);
                            }
                            else if (mobile is BaseVendor)
                            {
                                mobile.Direction = mobile.GetDirectionTo(from);
                                from.Direction   = from.GetDirectionTo(mobile);
                                mobile.Animate(31, 5, 1, true, false, 0);
                                mobile.Say(Utility.RandomList(1005560, 1013046, 1079127, 1013038, 1013039, 1010634));
                                from.Animate(20, 5, 1, true, false, 0);
                                from.Damage(Math.Max((Utility.Random(3) + 3), (int)(from.Hits / (Utility.Random(8) + 8))));
                            }
                            else if (mobile is BaseCreature)
                            {
                                (mobile as BaseCreature).AggressiveAction(from, from.Criminal);
                            }
                        }
                    }
                }
                else
                {
                    from.SendMessage("That does not have a pocket you can pick.");
                }
            }
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (targeted is StaticTarget)
                {
                    StaticTarget target = targeted as StaticTarget;
                    if (target.Location.CompareTo(from.Location) > 2)
                    {
                        from.SendMessage("You are too far away to do that.");
                        return;
                    }
                    PilferFlags flags = PilferTarget(target, from);

                    if (flags != PilferFlags.None)
                    {
                        if (Core.Debug)
                        {
                            from.SendMessage("TEST: pilfering target: {0}.", flags.ToString());
                        }
                        List <PilferFlags> list = new List <PilferFlags>();
                        foreach (PilferFlags flag in Enum.GetValues(typeof(PilferFlags)))
                        {
                            if (flag != PilferFlags.None && GetFlag(flag, flags))
                            {
                                list.Add(flag);
                            }
                        }

                        if (list.Count > 0)
                        {
                            PilferFlags pilfer = PilferFlags.None;
                            if (list.Count > 1)
                            {
                                pilfer = list[Utility.Random(list.Count)];
                            }
                            else
                            {
                                pilfer = list[0];
                            }

                            ///TEST FOR SUCCESSRATING
                            /// ---------------------

                            LokaiSkill    lokaiSkill = (LokaiSkillUtilities.XMLGetSkills(from)).Pilfering;
                            SuccessRating rating     = LokaiSkillUtilities.CheckLokaiSkill(from, lokaiSkill, 0.0, 100.0);

                            ///IF SUCCESSFUL
                            /// ------------

                            if (rating >= SuccessRating.PartialSuccess)
                            {
                                CreateItem(pilfer, rating, from);
                            }
                            else
                            {
                                from.SendMessage("You fail to pilfer anything.");
                            }
                        }
                        else
                        {
                            from.SendMessage("There is nothing to pilfer there.");
                        }
                    }
                    else
                    {
                        from.SendMessage("There is nothing to pilfer there.");
                    }
                }
            }
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID <= 0)
            {
                return;                 // Canceled
            }
            int buttonID = info.ButtonID - 1;
            int type     = buttonID % 7;
            int index    = buttonID / 7;

            BuildSystem   system  = m_BuildSystem;
            BuildGroupCol groups  = system.BuildGroups;
            BuildContext  context = system.GetContext(m_From);

            switch (type)
            {
            case 0:                     // Show group
            {
                if (context == null)
                {
                    break;
                }

                if (index >= 0 && index < groups.Count)
                {
                    context.LastGroupIndex = index;
                    m_From.SendGump(new BuildGump(m_From, system, m_Tool, null));
                }

                break;
            }

            case 1:                     // Create item
            {
                if (context == null)
                {
                    break;
                }

                int groupIndex = context.LastGroupIndex;

                if (groupIndex >= 0 && groupIndex < groups.Count)
                {
                    BuildGroup group = groups.GetAt(groupIndex);

                    if (index >= 0 && index < group.BuildItems.Count)
                    {
                        BuildItem(group.BuildItems.GetAt(index));
                    }
                }

                break;
            }

            case 2:                     // Item details
            {
                if (context == null)
                {
                    break;
                }

                int groupIndex = context.LastGroupIndex;

                if (groupIndex >= 0 && groupIndex < groups.Count)
                {
                    BuildGroup group = groups.GetAt(groupIndex);

                    if (index >= 0 && index < group.BuildItems.Count)
                    {
                        m_From.SendGump(new BuildGumpItem(m_From, system, group.BuildItems.GetAt(index), m_Tool));
                    }
                }

                break;
            }

            case 3:                     // Create item (last 10)
            {
                if (context == null)
                {
                    break;
                }

                ArrayList lastTen = context.Items;

                if (index >= 0 && index < lastTen.Count)
                {
                    BuildItem((BuildItem)lastTen[index]);
                }

                break;
            }

            case 4:                     // Item details (last 10)
            {
                if (context == null)
                {
                    break;
                }

                ArrayList lastTen = context.Items;

                if (index >= 0 && index < lastTen.Count)
                {
                    m_From.SendGump(new BuildGumpItem(m_From, system, (BuildItem)lastTen[index], m_Tool));
                }

                break;
            }

            case 5:                     // Resource selected
            {
                if (m_Page == BuildPage.PickResource && index >= 0 && index < system.BuildSubRes.Count)
                {
                    int groupIndex = (context == null ? -1 : context.LastGroupIndex);

                    BuildSubRes res = system.BuildSubRes.GetAt(index);

                    if (LokaiSkillUtilities.XMLGetSkills(m_From)[system.MainLokaiSkill].Base < res.RequiredLokaiSkill)
                    {
                        m_From.SendGump(new BuildGump(m_From, system, m_Tool, res.Message));
                    }
                    else
                    {
                        if (context != null)
                        {
                            context.LastResourceIndex = index;
                        }

                        m_From.SendGump(new BuildGump(m_From, system, m_Tool, null));
                    }
                }
                else if (m_Page == BuildPage.PickResource2 && index >= 0 && index < system.BuildSubRes2.Count)
                {
                    int groupIndex = (context == null ? -1 : context.LastGroupIndex);

                    BuildSubRes res = system.BuildSubRes2.GetAt(index);

                    if (LokaiSkillUtilities.XMLGetSkills(m_From)[system.MainLokaiSkill].Base < res.RequiredLokaiSkill)
                    {
                        m_From.SendGump(new BuildGump(m_From, system, m_Tool, res.Message));
                    }
                    else
                    {
                        if (context != null)
                        {
                            context.LastResourceIndex2 = index;
                        }

                        m_From.SendGump(new BuildGump(m_From, system, m_Tool, null));
                    }
                }

                break;
            }

            case 6:                     // Misc. buttons
            {
                switch (index)
                {
                case 0:                                 // Resource selection
                {
                    if (system.BuildSubRes.Init)
                    {
                        m_From.SendGump(new BuildGump(m_From, system, m_Tool, null, BuildPage.PickResource));
                    }

                    break;
                }

                case 1:                                 // Smelt item
                {
                    if (system.Resmelt)
                    {
                        Resmelt.Do(m_From, system, m_Tool);
                    }

                    break;
                }

                case 2:                                 // Make last
                {
                    if (context == null)
                    {
                        break;
                    }

                    BuildItem item = context.LastMade;

                    if (item != null)
                    {
                        BuildItem(item);
                    }
                    else
                    {
                        m_From.SendGump(new BuildGump(m_From, m_BuildSystem, m_Tool, 1044165, m_Page));                                             // You haven't made anything yet.
                    }
                    break;
                }

                case 3:                                 // Last 10
                {
                    if (context == null)
                    {
                        break;
                    }

                    context.LastGroupIndex = 501;
                    m_From.SendGump(new BuildGump(m_From, system, m_Tool, null));

                    break;
                }

                case 4:                                 // Toggle use resource hue
                {
                    if (context == null)
                    {
                        break;
                    }

                    context.DoNotColor = !context.DoNotColor;

                    m_From.SendGump(new BuildGump(m_From, m_BuildSystem, m_Tool, null, m_Page));

                    break;
                }

                case 5:                                 // Repair item
                {
                    if (system.Repair)
                    {
                        Repair.Do(m_From, system, m_Tool);
                    }

                    break;
                }

                case 6:                                 // Toggle mark option
                {
                    if (context == null || !system.MarkOption)
                    {
                        break;
                    }

                    switch (context.MarkOption)
                    {
                    case BuildMarkOption.MarkItem: context.MarkOption = BuildMarkOption.DoNotMark; break;

                    case BuildMarkOption.DoNotMark: context.MarkOption = BuildMarkOption.PromptForMark; break;

                    case BuildMarkOption.PromptForMark: context.MarkOption = BuildMarkOption.MarkItem; break;
                    }

                    m_From.SendGump(new BuildGump(m_From, m_BuildSystem, m_Tool, null, m_Page));

                    break;
                }

                case 7:                                 // Resource selection 2
                {
                    if (system.BuildSubRes2.Init)
                    {
                        m_From.SendGump(new BuildGump(m_From, system, m_Tool, null, BuildPage.PickResource2));
                    }

                    break;
                }

                case 8:                                 // Enhance item
                {
                    if (system.CanEnhance)
                    {
                        Enhance.BeginTarget(m_From, system, m_Tool);
                    }

                    break;
                }
                }

                break;
            }
            }
        }
Example #24
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_Material.Deleted)
                {
                    return;
                }

                ILoom loom = targeted as ILoom;

                if (loom == null && targeted is AddonComponent)
                {
                    loom = ((AddonComponent)targeted).Addon as ILoom;
                }

                if (loom != null)
                {
                    if (!m_Material.IsChildOf(from.Backpack))
                    {
                        from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
                    }
                    else
                    {
                        LokaiSkills   skills     = LokaiSkillUtilities.XMLGetSkills(from);
                        LokaiSkill    lokaiSkill = skills[LokaiSkillName.Weaving];
                        SuccessRating rating     = LokaiSkillUtilities.CheckLokaiSkill(from, lokaiSkill, 0.0, 100.0);

                        if (rating >= SuccessRating.PartialSuccess)
                        {
                            if (loom.Phase < 4)
                            {
                                if (targeted is Item)
                                {
                                    ((Item)targeted).SendLocalizedMessageTo(from, 1010001 + loom.Phase++);
                                }
                                m_Material.Consume();
                            }
                            else
                            {
                                Item create = new BoltOfCloth();
                                create.Hue = m_Material.Hue;
                                loom.Phase = 0;
                                from.SendLocalizedMessage(500368); // You create some cloth and put it in your backpack.
                                from.AddToBackpack(create);
                                m_Material.Consume();
                            }
                        }
                        else if (rating == SuccessRating.Failure)
                        {
                            from.SendMessage("You fail, but manage to save your material.");
                        }
                        else if (rating == SuccessRating.HazzardousFailure)
                        {
                            m_Material.Consume();
                            from.SendMessage("You fail, and some material is lost.");
                        }
                        else if (rating == SuccessRating.CriticalFailure)
                        {
                            m_Material.Consume();
                            loom.Phase = 0;
                            from.SendMessage("You fail utterly, some material is lost, and you need to start over.");
                        }
                        else if (rating == SuccessRating.TooDifficult)
                        {
                            m_Material.Consume();
                            loom.Phase = 0;
                            from.SendMessage("You have no idea how to work this thing.");
                            from.SendMessage("You fail utterly, some material is lost, and you need to start over.");
                        }
                    }
                }
                else
                {
                    from.SendLocalizedMessage(500367);                       // Try using that on a loom.
                }
            }
Example #25
0
            protected override void OnTick()
            {
                m_Count++;
                if (m_Count < m_MaxCount)
                {
                    switch (Utility.Random(6))
                    {
                    case 0: m_From.PublicOverheadMessage(MessageType.Emote, 0x47, true, "Hear me, animal friends!"); break;

                    case 1: m_From.PublicOverheadMessage(MessageType.Emote, 0x47, true, "Come to my aid."); break;

                    case 2: m_From.PublicOverheadMessage(MessageType.Emote, 0x47, true, "I am a friend to the animals."); break;

                    case 3: m_From.PublicOverheadMessage(MessageType.Emote, 0x47, true, "I call to you my friends."); break;

                    case 4: m_From.PublicOverheadMessage(MessageType.Emote, 0x47, true, "Hear me, my friends!"); break;

                    case 5: m_From.PublicOverheadMessage(MessageType.Emote, 0x47, true, "** whistles softly **"); break;
                    }

                    LokaiSkill lokaiSkill = LokaiSkillUtilities.XMLGetSkills(m_From).SpeakToAnimals;

                    int Max = m_From.FollowersMax - m_From.Followers;
                    int Cur = 0;

                    foreach (Mobile mob in m_From.GetMobilesInRange(10))
                    {
                        if (mob is BaseCreature)
                        {
                            BaseCreature creature = mob as BaseCreature;
                            if (m_Animals.Contains(creature) || creature.Controlled)
                            {
                                continue;
                            }
                            if (creature.AI == AIType.AI_Animal && AllowPackAnimal(creature, lokaiSkill) && creature.Combatant != m_From)
                            {
                                if (Cur >= Max)
                                {
                                    break;
                                }
                                Cur++;
                                m_Animals.Add(creature);
                            }
                        }
                    }

                    foreach (BaseCreature animal in m_Animals)
                    {
                        if (m_Controlled >= m_CreatureMax)
                        {
                            break;
                        }
                        if (Utility.RandomBool() && !animal.Controlled)
                        {
                            m_Controlled++;
                            animal.Owners.Add(m_From);
                            animal.SetControlMaster(m_From);
                            animal.ControlOrder = OrderType.Guard;
                        }
                    }
                }
                else
                {
                    foreach (BaseCreature animal in m_Animals)
                    {
                        animal.Controlled = false;
                        animal.Owners.Remove(m_From);
                        animal.SetControlMaster(null);
                    }
                    m_From.FollowersMax = m_Slots;
                    m_From.SendMessage("The animals have stopped listening to you.");
                    item.Delete();
                }
                m_From.NextSkillTime = Core.TickCount + (int)TimeSpan.FromSeconds(3.0 * (m_MaxCount - m_Count)).TotalSeconds;
            }
Example #26
0
        public static TimeSpan OnUse(Mobile from)
        {
            if (from.NextSkillTime > Core.TickCount)
            {
                double time = (double)(from.NextSkillTime - Core.TickCount);
                from.SendMessage("You must wait another {0} seconds before using this lokaiSkill.", time.ToString("F1"));
                return(TimeSpan.FromSeconds(time));
            }

            LokaiSkill          lokaiSkill = (LokaiSkillUtilities.XMLGetSkills(from)).SpeakToAnimals;
            List <BaseCreature> animals    = new List <BaseCreature>();

            int Max = from.FollowersMax - from.Followers;
            int Cur = 0;

            foreach (Mobile mob in from.GetMobilesInRange(10))
            {
                if (mob is BaseCreature)
                {
                    BaseCreature creature = mob as BaseCreature;
                    if (creature.AI == AIType.AI_Animal && AllowPackAnimal(creature, lokaiSkill) &&
                        !creature.Controlled && creature.Combatant != from)
                    {
                        if (Cur >= Max)
                        {
                            break;
                        }
                        Cur++;
                        animals.Add(creature);
                    }
                }
            }
            if (animals.Count <= 0)
            {
                from.SendMessage("You are unable to find any animals nearby with which you can speak.");
                from.NextSkillTime = Core.TickCount + (int)TimeSpan.FromSeconds(4.0).TotalSeconds;
            }
            else
            {
                SuccessRating rating = LokaiSkillUtilities.CheckLokaiSkill(from, lokaiSkill, 0.0, 100.0);
                if (rating >= SuccessRating.PartialSuccess)
                {
                    int count = 3;
                    switch (rating)
                    {
                    case SuccessRating.PartialSuccess: count++; break;

                    case SuccessRating.Success: count += 3; break;

                    case SuccessRating.CompleteSuccess: count += 6; break;

                    case SuccessRating.ExceptionalSuccess: count += 9; break;

                    case SuccessRating.TooEasy: count += 12; break;
                    }
                    from.PublicOverheadMessage(MessageType.Emote, 0x47, true, "** Begins to call to the animals. **");
                    from.FixedParticles(0x376A, 9, 32, 5030, EffectLayer.Waist);
                    new InternalTimer(from, count, count + 5, animals).Start();
                }
                else
                {
                    from.SendMessage("You fail to speak to the surrounding animals.");
                }
            }
            return(TimeSpan.FromSeconds(3.0));
        }
            protected override void OnTick()
            {
                m_iCount++;

                m_From.DisruptiveAction();

                if (m_iCount < m_iCountMax)
                {
                    m_BuildSystem.PlayBuildEffect(m_From);
                }
                else
                {
                    m_From.EndAction(typeof(BuildSystem));

                    int badBuild = m_BuildSystem.CanBuild(m_From, m_Tool, m_BuildItem.m_Type);

                    if (badBuild > 0)
                    {
                        if (m_Tool != null && !m_Tool.Deleted && m_Tool.UsesRemaining > 0)
                        {
                            m_From.SendGump(new BuildGump(m_From, m_BuildSystem, m_Tool, badBuild));
                        }
                        else
                        {
                            m_From.SendLocalizedMessage(badBuild);
                        }

                        return;
                    }

                    int  quality = 1;
                    bool allRequiredLokaiSkills = true;

                    m_BuildItem.CheckLokaiSkills(m_From, m_TypeRes, m_BuildSystem, ref quality, ref allRequiredLokaiSkills, false);

                    BuildContext context = m_BuildSystem.GetContext(m_From);

                    if (context == null)
                    {
                        return;
                    }

                    if (typeof(CustomBuild).IsAssignableFrom(m_BuildItem.ItemType))
                    {
                        CustomBuild cc = null;

                        try{ cc = Activator.CreateInstance(m_BuildItem.ItemType, new object[] { m_From, m_BuildItem, m_BuildSystem, m_TypeRes, m_Tool, quality }) as CustomBuild; }
                        catch {}

                        if (cc != null)
                        {
                            cc.EndBuildAction();
                        }

                        return;
                    }

                    bool makersMark = false;

                    if (quality == 2 && LokaiSkillUtilities.XMLGetSkills(m_From)[m_BuildSystem.MainLokaiSkill].Base >= 100.0)
                    {
                        makersMark = m_BuildItem.IsMarkable(m_BuildItem.ItemType);
                    }

                    if (makersMark && context.MarkOption == BuildMarkOption.PromptForMark)
                    {
                        m_From.SendGump(new QueryMakersMarkGump(quality, m_From, m_BuildItem, m_BuildSystem, m_TypeRes, m_Tool));
                    }
                    else
                    {
                        if (context.MarkOption == BuildMarkOption.DoNotMark)
                        {
                            makersMark = false;
                        }

                        m_BuildItem.CompleteBuild(quality, makersMark, m_From, m_BuildSystem, m_TypeRes, m_Tool, null);
                    }
                }
            }
        private static string Translate(Mobile speaker, Mobile hearer, string speech)
        {
            LokaiSkill lokaiSkill = LokaiSkillUtilities.XMLGetSkills(hearer).Linguistics;

            SuccessRating rating = LokaiSkillUtilities.CheckLokaiSkill(hearer, lokaiSkill, 10, 100);

            if (rating >= SuccessRating.Success)
            {
                return(speech);
            }

            int percent = 0;

            switch (rating)
            {
            case SuccessRating.PartialSuccess: percent = 50; break;

            case SuccessRating.Failure: percent = 20; break;

            case SuccessRating.HazzardousFailure: percent = 10; break;

            case SuccessRating.CriticalFailure: percent = 5; break;
            }

            StringBuilder phrase = new StringBuilder("");

            string[] words = speech.Split(' ');
            if (words.Length > 0)
            {
                if (percent < Utility.Random(100))
                {
                    if (m_Words.Contains(words[0]))
                    {
                        phrase.Append(m_ForeignWords[m_Words.IndexOf(words[0])]);
                    }
                    else
                    {
                        phrase.Append(m_ForeignWords[Utility.Random(m_ForeignWords.Length)]); // temporary
                    }
                }
                else
                {
                    phrase.Append(words[0]);
                }
                if (words.Length > 1)
                {
                    for (int x = 1; x < words.Length; x++)
                    {
                        phrase.Append(" ");
                        if (percent < Utility.Random(100))
                        {
                            if (m_Words.Contains(words[x]))
                            {
                                phrase.Append(m_ForeignWords[m_Words.IndexOf(words[x])]);
                            }
                            else
                            {
                                phrase.Append(m_ForeignWords[Utility.Random(m_ForeignWords.Length)]); // temporary
                            }
                        }
                        else
                        {
                            phrase.Append(words[x]);
                        }

                        phrase.Append(" ");
                    }
                }
            }

            return(phrase.ToString());
        }
        public bool ConsumeRes(Mobile from, Type typeRes, BuildSystem buildSystem, ref int resHue, ref int maxAmount, ConsumeType consumeType, ref object message, bool isFailure)
        {
            Container ourPack = from.Backpack;

            if (ourPack == null)
            {
                return(false);
            }

            if (m_NeedHeat && !Find(from, m_HeatSources))
            {
                message = 1044487;                 // You must be near a fire source to cook.
                return(false);
            }

            if (m_NeedOven && !Find(from, m_Ovens))
            {
                message = 1044493;                 // You must be near an oven to bake that.
                return(false);
            }

            if (m_NeedMill && !Find(from, m_Mills))
            {
                message = 1044491;                 // You must be near a flour mill to do that.
                return(false);
            }

            if (m_NeedWoodworker && !Find(from, m_WoodworkersBench))
            {
                message = "You must be near a woodworker's bench to do that.";
                return(false);
            }

            if (m_NeedCooper && !Find(from, m_CoopersBench))
            {
                message = "You must be near a cooper's bench to do that.";
                return(false);
            }

            if (m_NeedForeman && !Find(from, typeof(Foreman), 3))
            {
                message = "You must be near a foreman to do that.";
                return(false);
            }

            if (m_arBuildRes.Count == 0)
            {
                message = "Resource count is 0?";
                return(false);
            }

            Type[][] types   = new Type[m_arBuildRes.Count][];
            int[]    amounts = new int[m_arBuildRes.Count];

            maxAmount = int.MaxValue;

            BuildSubResCol resCol = (m_UseSubRes2 ? buildSystem.BuildSubRes2 : buildSystem.BuildSubRes);

            for (int i = 0; i < types.Length; ++i)
            {
                BuildRes buildRes = m_arBuildRes.GetAt(i);
                Type     baseType = buildRes.ItemType;

                // Resource Mutation
                if ((baseType == resCol.ResType) && (typeRes != null))
                {
                    baseType = typeRes;

                    BuildSubRes subResource = resCol.SearchFor(baseType);

                    if (subResource != null && LokaiSkillUtilities.XMLGetSkills(from)[buildSystem.MainLokaiSkill].Base < subResource.RequiredLokaiSkill)
                    {
                        message = subResource.Message;
                        return(false);
                    }
                }
                // ******************

                for (int j = 0; types[i] == null && j < m_TypesTable.Length; ++j)
                {
                    if (m_TypesTable[j][0] == baseType)
                    {
                        types[i] = m_TypesTable[j];
                    }
                }

                if (types[i] == null)
                {
                    types[i] = new Type[] { baseType }
                }
                ;

                amounts[i] = buildRes.Amount;

                // For stackable items that can be built more than one at a time
                if (UseAllRes)
                {
                    int tempAmount = ourPack.GetAmount(types[i]);
                    tempAmount /= amounts[i];
                    if (tempAmount < maxAmount)
                    {
                        maxAmount = tempAmount;

                        if (maxAmount == 0)
                        {
                            BuildRes res = m_arBuildRes.GetAt(i);

                            if (res.MessageNumber > 0)
                            {
                                message = res.MessageNumber;
                            }
                            else if (!String.IsNullOrEmpty(res.MessageString))
                            {
                                message = res.MessageString;
                            }
                            else
                            {
                                message = 502925;                                 // You don't have the resources required to make that item.
                            }
                            return(false);
                        }
                    }
                }
                // ****************************

                if (isFailure && !buildSystem.ConsumeOnFailure(from, types[i][0], this))
                {
                    amounts[i] = 0;
                }
            }

            // We adjust the amount of each resource to consume the max possible
            if (UseAllRes)
            {
                for (int i = 0; i < amounts.Length; ++i)
                {
                    amounts[i] *= maxAmount;
                }
            }
            else
            {
                maxAmount = -1;
            }

            int index = 0;

            // Consume ALL
            if (consumeType == ConsumeType.All)
            {
                m_ResHue = 0; m_ResAmount = 0; m_System = buildSystem;

                if (IsQuantityType(types))
                {
                    index = ConsumeQuantity(ourPack, types, amounts);
                }
                else
                {
                    index = ourPack.ConsumeTotalGrouped(types, amounts, true, new OnItemConsumed(OnResourceConsumed), new CheckItemGroup(CheckHueGrouping));
                }

                resHue = m_ResHue;
            }

            // Consume Half ( for use all resource build type )
            else if (consumeType == ConsumeType.Half)
            {
                for (int i = 0; i < amounts.Length; i++)
                {
                    amounts[i] /= 2;

                    if (amounts[i] < 1)
                    {
                        amounts[i] = 1;
                    }
                }

                m_ResHue = 0; m_ResAmount = 0; m_System = buildSystem;

                if (IsQuantityType(types))
                {
                    index = ConsumeQuantity(ourPack, types, amounts);
                }
                else
                {
                    index = ourPack.ConsumeTotalGrouped(types, amounts, true, new OnItemConsumed(OnResourceConsumed), new CheckItemGroup(CheckHueGrouping));
                }

                resHue = m_ResHue;
            }

            else             // ConstumeType.None ( it's basicaly used to know if the builder has enough resource before starting the process )
            {
                index = -1;

                if (IsQuantityType(types))
                {
                    for (int i = 0; i < types.Length; i++)
                    {
                        if (GetQuantity(ourPack, types[i]) < amounts[i])
                        {
                            index = i;
                            break;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < types.Length; i++)
                    {
                        if (ourPack.GetBestGroupAmount(types[i], true, new CheckItemGroup(CheckHueGrouping)) < amounts[i])
                        {
                            index = i;
                            break;
                        }
                    }
                }
            }

            if (index == -1)
            {
                return(true);
            }
            else
            {
                BuildRes res = m_arBuildRes.GetAt(index);

                if (res.MessageNumber > 0)
                {
                    message = res.MessageNumber;
                }
                else if (res.MessageString != null && res.MessageString != String.Empty)
                {
                    message = res.MessageString;
                }
                else
                {
                    message = 502925;                     // You don't have the resources required to make that item.
                }
                return(false);
            }
        }
Example #30
0
 private int GetWeakenChance(Mobile mob, LokaiSkillName lokaiSkill, int curHits, int maxHits)
 {
     // 40% - (1% per hp lost) - (1% per 10 build lokaiSkill)
     return((40 + (maxHits - curHits)) - (int)((LokaiSkillUtilities.XMLGetSkills(mob)[lokaiSkill].Value) / 10));
 }