예제 #1
0
        public void BuildItem(BuildItem item)
        {
            int num = m_BuildSystem.CanBuild(m_From, m_Tool, item.ItemType);

            if (num > 0)
            {
                m_From.SendGump(new BuildGump(m_From, m_BuildSystem, m_Tool, num));
            }
            else
            {
                Type type = null;

                BuildContext context = m_BuildSystem.GetContext(m_From);

                if (context != null)
                {
                    BuildSubResCol res      = (item.UseSubRes2 ? m_BuildSystem.BuildSubRes2 : m_BuildSystem.BuildSubRes);
                    int            resIndex = (item.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);

                    if (resIndex >= 0 && resIndex < res.Count)
                    {
                        type = res.GetAt(resIndex).ItemType;
                    }
                }

                m_BuildSystem.CreateItem(m_From, item.ItemType, type, m_Tool, item);
            }
        }
예제 #2
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                int num = m_BuildSystem.CanBuild(from, m_Tool, null);

                if (num > 0)
                {
                    from.SendGump(new BuildGump(from, m_BuildSystem, m_Tool, num));
                }
            }
예제 #3
0
        public static void Do(Mobile from, BuildSystem buildSystem, BaseBuildingTool tool)
        {
            int num = buildSystem.CanBuild(from, tool, null);

            if (num > 0)
            {
                from.SendGump(new BuildGump(from, buildSystem, tool, num));
            }
            else
            {
                from.Target = new InternalTarget(buildSystem, tool);
                from.SendLocalizedMessage(1044273);                   // Target an item to recycle.
            }
        }
예제 #4
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            // Back Button
            if (info.ButtonID == 0)
            {
                BuildGump buildGump = new BuildGump(m_From, m_BuildSystem, m_Tool, null);
                m_From.SendGump(buildGump);
            }
            else             // Make Button
            {
                int num = m_BuildSystem.CanBuild(m_From, m_Tool, m_BuildItem.ItemType);

                if (num > 0)
                {
                    m_From.SendGump(new BuildGump(m_From, m_BuildSystem, m_Tool, num));
                }
                else
                {
                    Type type = null;

                    BuildContext context = m_BuildSystem.GetContext(m_From);

                    if (context != null)
                    {
                        BuildSubResCol res      = (m_BuildItem.UseSubRes2 ? m_BuildSystem.BuildSubRes2 : m_BuildSystem.BuildSubRes);
                        int            resIndex = (m_BuildItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);

                        if (resIndex > -1)
                        {
                            type = res.GetAt(resIndex).ItemType;
                        }
                    }

                    m_BuildSystem.CreateItem(m_From, m_BuildItem.ItemType, type, m_Tool, m_BuildItem);
                }
            }
        }
예제 #5
0
        public void Build(Mobile from, BuildSystem buildSystem, Type typeRes, BaseBuildingTool tool)
        {
            if (from.BeginAction(typeof(BuildSystem)))
            {
                if (RequiredExpansion == Expansion.None || (from.NetState != null && from.NetState.SupportsExpansion(RequiredExpansion)))
                {
                    bool   allRequiredLokaiSkills = true;
                    double chance = GetSuccessChance(from, typeRes, buildSystem, false, ref allRequiredLokaiSkills);

                    if (allRequiredLokaiSkills && chance >= 0.0)
                    {
                        if (this.Recipe == null)
                        {
                            int badBuild = buildSystem.CanBuild(from, tool, m_Type);

                            if (badBuild <= 0)
                            {
                                int    resHue    = 0;
                                int    maxAmount = 0;
                                object message   = null;

                                if (ConsumeRes(from, typeRes, buildSystem, ref resHue, ref maxAmount, ConsumeType.None, ref message))
                                {
                                    message = null;

                                    if (ConsumeAttributes(from, ref message, false))
                                    {
                                        BuildContext context = buildSystem.GetContext(from);

                                        if (context != null)
                                        {
                                            context.OnMade(this);
                                        }

                                        int iMin    = buildSystem.MinBuildEffect;
                                        int iMax    = (buildSystem.MaxBuildEffect - iMin) + 1;
                                        int iRandom = Utility.Random(iMax);
                                        iRandom += iMin + 1;
                                        new InternalTimer(from, buildSystem, this, typeRes, tool, iRandom).Start();
                                    }
                                    else
                                    {
                                        from.EndAction(typeof(BuildSystem));
                                        from.SendGump(new BuildGump(from, buildSystem, tool, message));
                                    }
                                }
                                else
                                {
                                    from.EndAction(typeof(BuildSystem));
                                    from.SendGump(new BuildGump(from, buildSystem, tool, message));
                                }
                            }
                            else
                            {
                                from.EndAction(typeof(BuildSystem));
                                from.SendGump(new BuildGump(from, buildSystem, tool, badBuild));
                            }
                        }
                        else
                        {
                            from.EndAction(typeof(BuildSystem));
                            from.SendGump(new BuildGump(from, buildSystem, tool, 1072847));                                 // You must learn that recipe from a scroll.
                        }
                    }
                    else
                    {
                        from.EndAction(typeof(BuildSystem));
                        from.SendGump(new BuildGump(from, buildSystem, tool, 1044153));                             // You don't have the required lokaiSkills to attempt this item.
                    }
                }
                else
                {
                    from.EndAction(typeof(BuildSystem));
                    from.SendGump(new BuildGump(from, buildSystem, tool, RequiredExpansionMessage(RequiredExpansion)));                           //The {0} expansion is required to attempt this item.
                }
            }
            else
            {
                from.SendLocalizedMessage(500119);                   // You must wait to perform another action
            }
        }
예제 #6
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);
                    }
                }
            }
예제 #7
0
        public void CompleteBuild(int quality, bool makersMark, Mobile from, BuildSystem buildSystem, Type typeRes, BaseBuildingTool tool, CustomBuild customBuild)
        {
            int badBuild = buildSystem.CanBuild(from, tool, m_Type);

            if (badBuild > 0)
            {
                if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                {
                    from.SendGump(new BuildGump(from, buildSystem, tool, badBuild));
                }
                else
                {
                    from.SendLocalizedMessage(badBuild);
                }

                return;
            }

            int    checkResHue = 0, checkMaxAmount = 0;
            object checkMessage = null;

            // Not enough resource to build it
            if (!ConsumeRes(from, typeRes, buildSystem, ref checkResHue, ref checkMaxAmount, ConsumeType.None, ref checkMessage))
            {
                if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                {
                    from.SendGump(new BuildGump(from, buildSystem, tool, checkMessage));
                }
                else if (checkMessage is int && (int)checkMessage > 0)
                {
                    from.SendLocalizedMessage((int)checkMessage);
                }
                else if (checkMessage is string)
                {
                    from.SendMessage((string)checkMessage);
                }

                return;
            }
            else if (!ConsumeAttributes(from, ref checkMessage, false))
            {
                if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                {
                    from.SendGump(new BuildGump(from, buildSystem, tool, checkMessage));
                }
                else if (checkMessage is int && (int)checkMessage > 0)
                {
                    from.SendLocalizedMessage((int)checkMessage);
                }
                else if (checkMessage is string)
                {
                    from.SendMessage((string)checkMessage);
                }

                return;
            }

            bool toolBroken = false;

            int ignored    = 1;
            int endquality = 1;

            bool allRequiredLokaiSkills = true;

            if (CheckLokaiSkills(from, typeRes, buildSystem, ref ignored, ref allRequiredLokaiSkills))
            {
                // Resource
                int resHue    = 0;
                int maxAmount = 0;

                object message = null;

                // Not enough resource to build it
                if (!ConsumeRes(from, typeRes, buildSystem, ref resHue, ref maxAmount, ConsumeType.All, ref message))
                {
                    if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                    {
                        from.SendGump(new BuildGump(from, buildSystem, tool, message));
                    }
                    else if (message is int && (int)message > 0)
                    {
                        from.SendLocalizedMessage((int)message);
                    }
                    else if (message is string)
                    {
                        from.SendMessage((string)message);
                    }

                    return;
                }
                else if (!ConsumeAttributes(from, ref message, true))
                {
                    if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                    {
                        from.SendGump(new BuildGump(from, buildSystem, tool, message));
                    }
                    else if (message is int && (int)message > 0)
                    {
                        from.SendLocalizedMessage((int)message);
                    }
                    else if (message is string)
                    {
                        from.SendMessage((string)message);
                    }

                    return;
                }

                tool.UsesRemaining--;

                if (tool.UsesRemaining < 1)
                {
                    toolBroken = true;
                }

                if (toolBroken)
                {
                    tool.Delete();
                }

                int num = 0;

                Item item;
                if (customBuild != null)
                {
                    item = customBuild.CompleteBuild(out num);
                }
                else if (typeof(MapItem).IsAssignableFrom(ItemType) && from.Map != Map.Trammel && from.Map != Map.Felucca)
                {
                    item = new IndecipherableMap();
                    from.SendLocalizedMessage(1070800);                       // The map you create becomes mysteriously indecipherable.
                }
                else
                {
                    if (m_Arg != null)
                    {
                        item = Activator.CreateInstance(ItemType, new object[] { m_Arg }) as Item;
                    }
                    else
                    {
                        item = Activator.CreateInstance(ItemType) as Item;
                    }
                }

                if (item != null)
                {
                    if (item is IBuildable)
                    {
                        endquality = ((IBuildable)item).OnBuild(quality, makersMark, from, buildSystem, typeRes, tool, this, resHue);
                    }
                    else if (item.Hue == 0)
                    {
                        item.Hue = resHue;
                    }

                    if (maxAmount > 0)
                    {
                        item.Amount = maxAmount;
                    }

                    from.AddToBackpack(item);

                    if (from.AccessLevel > AccessLevel.Player)
                    {
                        CommandLogging.WriteLine(from, "Building {0} with build system {1}", CommandLogging.Format(item), buildSystem.GetType().Name);
                    }

                    //from.PlaySound( 0x57 );
                }

                if (num == 0)
                {
                    num = buildSystem.PlayEndingEffect(from, false, true, toolBroken, endquality, makersMark, this);
                }

                if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                {
                    from.SendGump(new BuildGump(from, buildSystem, tool, num));
                }
                else if (num > 0)
                {
                    from.SendLocalizedMessage(num);
                }
            }
            else if (!allRequiredLokaiSkills)
            {
                if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                {
                    from.SendGump(new BuildGump(from, buildSystem, tool, 1044153));
                }
                else
                {
                    from.SendLocalizedMessage(1044153);                       // You don't have the required lokaiSkills to attempt this item.
                }
            }
            else
            {
                ConsumeType consumeType = (UseAllRes ? ConsumeType.Half : ConsumeType.All);
                int         resHue      = 0;
                int         maxAmount   = 0;

                object message = null;

                // Not enough resource to build it
                if (!ConsumeRes(from, typeRes, buildSystem, ref resHue, ref maxAmount, consumeType, ref message, true))
                {
                    if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                    {
                        from.SendGump(new BuildGump(from, buildSystem, tool, message));
                    }
                    else if (message is int && (int)message > 0)
                    {
                        from.SendLocalizedMessage((int)message);
                    }
                    else if (message is string)
                    {
                        from.SendMessage((string)message);
                    }

                    return;
                }

                tool.UsesRemaining--;

                if (tool.UsesRemaining < 1)
                {
                    toolBroken = true;
                }

                if (toolBroken)
                {
                    tool.Delete();
                }

                // LokaiSkillCheck failed.
                int num = buildSystem.PlayEndingEffect(from, true, true, toolBroken, endquality, false, this);

                if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                {
                    from.SendGump(new BuildGump(from, buildSystem, tool, num));
                }
                else if (num > 0)
                {
                    from.SendLocalizedMessage(num);
                }
            }
        }