Example #1
0
    public static Dictionary <ResourceType, int> GetToolCost(BaseBuildingTool tool)
    {
        Dictionary <ResourceType, int> totalCost = new Dictionary <ResourceType, int>();

        switch (tool)
        {
        case BaseBuildingTool.Default:
            break;

        case BaseBuildingTool.DestroyRoom:
            break;

        case BaseBuildingTool.Wall:
            break;

        case BaseBuildingTool.AntRoom:
            totalCost = new Dictionary <ResourceType, int>()
            {
                { ResourceType.Rock, 10 }
            };
            break;

        default:
            break;
        }

        return(totalCost);
    }
Example #2
0
    public void AntDoesAction(BaseBuildingTool tool)
    {
        switch (tool)
        {
        case BaseBuildingTool.DestroyRoom:
            if (!IsIndestructable)
            {
                DestroyRoom();
            }
            break;

        case BaseBuildingTool.Wall:
            InitializeObject(GetComponentInParent <BaseController>().WallPrefab);
            break;

        case BaseBuildingTool.AntRoom:
            if (!IsUnbuildable)
            {
                InitializeObject(GetComponentInParent <BaseController>().WorkerRoomPrefab);
            }
            break;

        default:
            if (RoomScript != null && !RoomScript.IsRoom() && !IsIndestructable)
            {
                DestroyRoom();
            }
            break;
        }
    }
 public InternalTarget(BuildSystem buildSystem, BaseBuildingTool tool, Type resourceType, BuildResource resource) :  base(2, false, TargetFlags.None)
 {
     m_BuildSystem  = buildSystem;
     m_Tool         = tool;
     m_ResourceType = resourceType;
     m_Resource     = resource;
 }
Example #4
0
 public override int CanBuild(Mobile from, BaseBuildingTool tool, Type typeItem)
 {
     if (tool.Deleted || tool.UsesRemaining < 0)
     {
         return(1044038);                // You have worn out your tool!
     }
     return(0);
 }
 public CustomBuild(Mobile from, BuildItem buildItem, BuildSystem buildSystem, Type typeRes, BaseBuildingTool tool, int quality)
 {
     m_From        = from;
     m_BuildItem   = buildItem;
     m_BuildSystem = buildSystem;
     m_TypeRes     = typeRes;
     m_Tool        = tool;
     m_Quality     = quality;
 }
 public InternalTimer(Mobile from, BuildSystem buildSystem, BuildItem buildItem, Type typeRes, BaseBuildingTool tool, int iCountMax) : base(TimeSpan.Zero, TimeSpan.FromSeconds(buildSystem.Delay), iCountMax)
 {
     m_From        = from;
     m_BuildItem   = buildItem;
     m_iCount      = 0;
     m_iCountMax   = iCountMax;
     m_BuildSystem = buildSystem;
     m_TypeRes     = typeRes;
     m_Tool        = tool;
 }
Example #7
0
 public void SetData(BuildingTaskData data)
 {
     IsRemoved        = data.IsRemoved;
     BaseBuildingTool = data.BaseBuildingTool;
     if (data.AntGuid != "")
     {
         Ant = GameWorld.Instance.FindAnt(Guid.Parse(data.AntGuid));
     }
     BaseTile     = GameObject.Find(data.BaseTileName).GetComponent <BaseTile>();
     HighlightObj = (GameObject)GameObject.Instantiate(Resources.Load($"Prefabs/BaseBuilding/{data.HighlightObjPrefab}"), BaseTile.transform);
 }
Example #8
0
    private bool CalculateAndDoCost(BaseBuildingTool tool)
    {
        Dictionary <ResourceType, int> totalCost = GameResources.GetToolCost(tool);

        if (GameResources.EnoughResources(totalCost, controller.GetGameResources()))
        {
            controller.GetGameResources().SubtractResources(totalCost);
            return(true);
        }
        return(false);
    }
 public override int CanBuild(Mobile from, BaseBuildingTool tool, Type itemType)
 {
     if (tool == null || tool.Deleted || tool.UsesRemaining < 0)
     {
         return(1044038); // You have worn out your tool!
     }
     else if (!BaseTool.CheckAccessible(tool, from))
     {
         return(1044263); // The tool must be on your person to use.
     }
     return(0);
 }
Example #10
0
    public void AddNewJob(BaseTile tile, BaseBuildingTool tool)
    {
        BuildingTask existingTask = Queue.FirstOrDefault(task => task.BaseTile == tile) ?? WaitQueue.FirstOrDefault(task => task.BaseTile == tile);

        if (existingTask == null)
        {
            BuildingTask buildingTask = new BuildingTask(tile, tool);
            switch (tool)
            {
            case BaseBuildingTool.DestroyRoom:
                if (!tile.IsIndestructable && tile.RoomScript != null && tile.RoomScript.IsRoom())
                {
                    Add(buildingTask);
                }
                break;

            case BaseBuildingTool.Wall:
                //Queue.Add(buildingTask); // TODO: when building walls is gonna be a thing
                break;

            case BaseBuildingTool.AntRoom:
                if (!tile.IsUnbuildable && tile.RoomScript == null && CalculateAndDoCost(BaseBuildingTool.AntRoom))
                {
                    Add(buildingTask);
                }
                break;

            default:
                if (tile.RoomScript != null && !tile.RoomScript.IsRoom() && !tile.IsIndestructable)
                {
                    bool able = false;
                    foreach (var neighbor in buildingTask.BaseTile.Neighbors)
                    {
                        if (Astar.CanFindQueen(neighbor, controller.QueenRoom.GetBaseTile()))
                        {
                            able = true;
                            break;
                        }
                    }

                    Add(buildingTask, !able);
                }
                break;
            }
        }
        else
        {
            if (existingTask.BaseBuildingTool == tool || tool == BaseBuildingTool.DestroyRoom)
            {
                Remove(existingTask, true);
            }
        }
    }
        public void CreateItem(Mobile from, Type type, Type typeRes, BaseBuildingTool tool, BuildItem realBuildItem)
        {
            // Verify if the type is in the list of the buildable item
            BuildItem buildItem = m_BuildItems.SearchFor(type);

            if (buildItem != null)
            {
                // The item is in the list, try to create it
                realBuildItem.Build(from, this, typeRes, tool);
                //buildItem.Build( from, this, typeRes, tool );
            }
        }
Example #12
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.
            }
        }
Example #13
0
 public BuildingTaskData(bool isRemoved, BaseBuildingTool baseBuildingTool, Ant ant, GameObject highlightObj, BaseTile baseTile)
 {
     IsRemoved        = isRemoved;
     BaseBuildingTool = baseBuildingTool;
     if (ant != null && ant.myGuid != null)
     {
         AntGuid = ant.myGuid.ToString();
     }
     if (highlightObj != null && highlightObj.GetComponent <HighLightScript>() != null)
     {
         HighlightObjPrefab = highlightObj.GetComponent <HighLightScript>().Prefab;
     }
     if (baseTile != null)
     {
         BaseTileName = baseTile.gameObject.name;
     }
 }
Example #14
0
 public BaseControllerData(int teamID, BaseBuildingTool currentTool, Vector3 teleporterExit, Vector3 teleporterEntrance, BuildingQueue buildingQueue, Transform transform, GameResources gameResources)
 {
     TeamID              = teamID;
     CurrentTool         = currentTool;
     TeleporterExitX     = teleporterExit.x;
     TeleporterExitY     = teleporterExit.y;
     TeleporterExitZ     = teleporterExit.z;
     TeleporterEntranceX = teleporterEntrance.x;
     TeleporterEntranceY = teleporterEntrance.y;
     TeleporterEntranceZ = teleporterEntrance.z;
     queueData           = buildingQueue.GetData();
     foreach (Transform myTransform in transform)
     {
         if (myTransform.GetComponent <BaseTile>() != null)
         {
             BaseTileData.Add(myTransform.GetComponent <BaseTile>().GetData());
         }
     }
     GameResources = gameResources.GetData();
 }
        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.
            }
        }
        public QueryMakersMarkGump(int quality, Mobile from, BuildItem buildItem, BuildSystem buildSystem, Type typeRes, BaseBuildingTool tool) : base(100, 200)
        {
            from.CloseGump(typeof(QueryMakersMarkGump));

            m_Quality     = quality;
            m_From        = from;
            m_BuildItem   = buildItem;
            m_BuildSystem = buildSystem;
            m_TypeRes     = typeRes;
            m_Tool        = tool;

            AddPage(0);

            AddBackground(0, 0, 220, 170, 5054);
            AddBackground(10, 10, 200, 150, 3000);

            AddHtmlLocalized(20, 20, 180, 80, 1018317, false, false);               // Do you wish to place your maker's mark on this item?

            AddHtmlLocalized(55, 100, 140, 25, 1011011, false, false);              // CONTINUE
            AddButton(20, 100, 4005, 4007, 1, GumpButtonType.Reply, 0);

            AddHtmlLocalized(55, 125, 140, 25, 1011012, false, false);               // CANCEL
            AddButton(20, 125, 4005, 4007, 0, GumpButtonType.Reply, 0);
        }
Example #17
0
        public BuildGumpItem(Mobile from, BuildSystem buildSystem, BuildItem buildItem, BaseBuildingTool tool) : base(40, 40)
        {
            m_From        = from;
            m_BuildSystem = buildSystem;
            m_BuildItem   = buildItem;
            m_Tool        = tool;

            from.CloseGump(typeof(BuildGump));
            from.CloseGump(typeof(BuildGumpItem));

            AddPage(0);
            AddBackground(0, 0, 530, 417, 5054);
            AddImageTiled(10, 10, 510, 22, 2624);
            AddImageTiled(10, 37, 150, 148, 2624);
            AddImageTiled(165, 37, 355, 90, 2624);
            AddImageTiled(10, 190, 155, 22, 2624);
            AddImageTiled(10, 217, 150, 53, 2624);
            AddImageTiled(165, 132, 355, 80, 2624);
            AddImageTiled(10, 275, 155, 22, 2624);
            AddImageTiled(10, 302, 150, 53, 2624);
            AddImageTiled(165, 217, 355, 80, 2624);
            AddImageTiled(10, 360, 155, 22, 2624);
            AddImageTiled(165, 302, 355, 80, 2624);
            AddImageTiled(10, 387, 510, 22, 2624);
            AddAlphaRegion(10, 10, 510, 399);

            AddHtmlLocalized(170, 40, 150, 20, 1044053, LabelColor, false, false);                                // ITEM
            AddHtmlLocalized(10, 192, 150, 22, 1070722, "<CENTER>ABILITIIES</CENTER>", LabelColor, false, false); // ABILITIIES
            //AddHtmlLocalized(10, 192, 150, 22, 1060857, LabelColor, false, false); // Primary LokaiSkill
            AddHtmlLocalized(10, 277, 150, 22, 1044055, LabelColor, false, false);                                // <CENTER>MATERIALS</CENTER>
            AddHtmlLocalized(10, 362, 150, 22, 1044056, LabelColor, false, false);                                // <CENTER>OTHER</CENTER>

            if (buildSystem.GumpTitleNumber > 0)
            {
                AddHtmlLocalized(10, 12, 510, 20, buildSystem.GumpTitleNumber, LabelColor, false, false);
            }
            else
            {
                AddHtml(10, 12, 510, 20, buildSystem.GumpTitleString, false, false);
            }

            AddButton(15, 387, 4014, 4016, 0, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 390, 150, 18, 1044150, LabelColor, false, false);               // BACK

            bool needsRecipe = false;

            if (needsRecipe)
            {
                AddButton(270, 387, 4005, 4007, 0, GumpButtonType.Page, 0);
                AddHtmlLocalized(305, 390, 150, 18, 1044151, GreyLabelColor, false, false);                   // MAKE NOW
            }
            else
            {
                AddButton(270, 387, 4005, 4007, 1, GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 390, 150, 18, 1044151, LabelColor, false, false);                   // MAKE NOW
            }

            if (buildItem.NameNumber > 0)
            {
                AddHtmlLocalized(330, 40, 180, 18, buildItem.NameNumber, LabelColor, false, false);
            }
            else
            {
                AddLabel(330, 40, LabelHue, buildItem.NameString);
            }

            if (buildItem.UseAllRes)
            {
                AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1048176, LabelColor, false, false);                    // Makes as many as possible at once
            }
            DrawItem();
            DrawLokaiSkill();
            DrawRessource();

            /*
             * if( buildItem.RequiresSE )
             *      AddHtmlLocalized( 170, 302 + (m_OtherCount++ * 20), 310, 18, 1063363, LabelColor, false, false ); //* Requires the "Samurai Empire" expansion
             * */

            if (buildItem.RequiredExpansion != Expansion.None)
            {
                bool supportsEx = (from.NetState != null && from.NetState.SupportsExpansion(buildItem.RequiredExpansion));
                TextDefinition.AddHtmlText(this, 170, 302 + (m_OtherCount++ *20), 310, 18, RequiredExpansionMessage(buildItem.RequiredExpansion), false, false, supportsEx ? LabelColor : RedLabelColor, supportsEx ? LabelHue : RedLabelHue);
            }

            if (needsRecipe)
            {
                AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1073620, RedLabelColor, false, false);                    // You have not learned this recipe.
            }
        }
 public override int CanBuild(Mobile from, BaseBuildingTool tool, Type itemType)
 {
     return(0);
 }
 public abstract int CanBuild(Mobile from, BaseBuildingTool tool, Type itemType);
Example #20
0
 private void RefundCost(BaseBuildingTool tool)
 {
     controller.GetGameResources().AddResources(GameResources.GetToolCost(tool));
 }
        /*public BuildGump( Mobile from, BuildSystem buildSystem, BaseBuildingTool tool ): this( from, buildSystem, -1, -1, tool, null )
         * {
         * }*/

        public BuildGump(Mobile from, BuildSystem buildSystem, BaseBuildingTool tool, object notice) : this(from, buildSystem, tool, notice, BuildPage.None)
        {
        }
        private BuildGump(Mobile from, BuildSystem buildSystem, BaseBuildingTool tool, object notice, BuildPage page) : base(40, 40)
        {
            m_From        = from;
            m_BuildSystem = buildSystem;
            m_Tool        = tool;
            m_Page        = page;

            BuildContext context = buildSystem.GetContext(from);

            from.CloseGump(typeof(BuildGump));
            from.CloseGump(typeof(BuildGumpItem));

            AddPage(0);

            AddBackground(0, 0, 530, 437, 5054);
            AddImageTiled(10, 10, 510, 22, 2624);
            AddImageTiled(10, 292, 150, 45, 2624);
            AddImageTiled(165, 292, 355, 45, 2624);
            AddImageTiled(10, 342, 510, 85, 2624);
            AddImageTiled(10, 37, 200, 250, 2624);
            AddImageTiled(215, 37, 305, 250, 2624);
            AddAlphaRegion(10, 10, 510, 417);

            if (buildSystem.GumpTitleNumber > 0)
            {
                AddHtmlLocalized(10, 12, 510, 20, buildSystem.GumpTitleNumber, LabelColor, false, false);
            }
            else
            {
                AddHtml(10, 12, 510, 20, MakeTitle(buildSystem.GumpTitleString), false, false);
            }

            AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor, false, false);               // <CENTER>CATEGORIES</CENTER>
            AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor, false, false);              // <CENTER>SELECTIONS</CENTER>
            AddHtmlLocalized(10, 302, 150, 25, 1044012, LabelColor, false, false);              // <CENTER>NOTICES</CENTER>

            AddButton(15, 402, 4017, 4019, 0, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 405, 150, 18, 1011441, LabelColor, false, false);               // EXIT

            AddButton(270, 402, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0);
            AddHtmlLocalized(305, 405, 150, 18, 1044013, LabelColor, false, false);               // MAKE LAST

            // Mark option
            if (buildSystem.MarkOption)
            {
                AddButton(270, 362, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false);                   // MARK ITEM
            }
            // ****************************************

            // Resmelt option
            if (buildSystem.Resmelt)
            {
                AddButton(15, 342, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0);
                AddHtmlLocalized(50, 345, 150, 18, 1044259, LabelColor, false, false);                   // SMELT ITEM
            }
            // ****************************************

            // Repair option
            if (buildSystem.Repair)
            {
                AddButton(270, 342, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 345, 150, 18, 1044260, LabelColor, false, false);                   // REPAIR ITEM
            }
            // ****************************************

            // Enhance option
            if (buildSystem.CanEnhance)
            {
                AddButton(270, 382, 4005, 4007, GetButtonID(6, 8), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 385, 150, 18, 1061001, LabelColor, false, false);                   // ENHANCE ITEM
            }
            // ****************************************

            if (notice is int && (int)notice > 0)
            {
                AddHtmlLocalized(170, 295, 350, 40, (int)notice, LabelColor, false, false);
            }
            else if (notice is string)
            {
                AddHtml(170, 295, 350, 40, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice), false, false);
            }

            // If the system has more than one resource
            if (buildSystem.BuildSubRes.Init)
            {
                string nameString = buildSystem.BuildSubRes.NameString;
                int    nameNumber = buildSystem.BuildSubRes.NameNumber;

                int resIndex = (context == null ? -1 : context.LastResourceIndex);

                Type resourceType = buildSystem.BuildSubRes.ResType;

                if (resIndex > -1)
                {
                    BuildSubRes subResource = buildSystem.BuildSubRes.GetAt(resIndex);

                    nameString   = subResource.NameString;
                    nameNumber   = subResource.NameNumber;
                    resourceType = subResource.ItemType;
                }

                int resourceCount = 0;

                if (from.Backpack != null)
                {
                    Item[] items = from.Backpack.FindItemsByType(resourceType, true);

                    for (int i = 0; i < items.Length; ++i)
                    {
                        resourceCount += items[i].Amount;
                    }
                }

                AddButton(15, 362, 4005, 4007, GetButtonID(6, 0), GumpButtonType.Reply, 0);

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(50, 365, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false);
                }
                else
                {
                    AddLabel(50, 362, LabelHue, String.Format("{0} ({1} Available)", nameString, resourceCount));
                }
            }
            // ****************************************

            // For dragon scales
            if (buildSystem.BuildSubRes2.Init)
            {
                string nameString = buildSystem.BuildSubRes2.NameString;
                int    nameNumber = buildSystem.BuildSubRes2.NameNumber;

                int resIndex = (context == null ? -1 : context.LastResourceIndex2);

                Type resourceType = buildSystem.BuildSubRes.ResType;

                if (resIndex > -1)
                {
                    BuildSubRes subResource = buildSystem.BuildSubRes2.GetAt(resIndex);

                    nameString   = subResource.NameString;
                    nameNumber   = subResource.NameNumber;
                    resourceType = subResource.ItemType;
                }

                int resourceCount = 0;

                if (from.Backpack != null)
                {
                    Item[] items = from.Backpack.FindItemsByType(resourceType, true);

                    for (int i = 0; i < items.Length; ++i)
                    {
                        resourceCount += items[i].Amount;
                    }
                }

                AddButton(15, 382, 4005, 4007, GetButtonID(6, 7), GumpButtonType.Reply, 0);

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(50, 385, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false);
                }
                else
                {
                    AddLabel(50, 385, LabelHue, String.Format("{0} ({1} Available)", nameString, resourceCount));
                }
            }
            // ****************************************

            CreateGroupList();

            if (page == BuildPage.PickResource)
            {
                CreateResList(false);
            }
            else if (page == BuildPage.PickResource2)
            {
                CreateResList(true);
            }
            else if (context != null && context.LastGroupIndex > -1)
            {
                CreateItemList(context.LastGroupIndex);
            }
        }
Example #23
0
 public BuildingTask(BaseTile tile, BaseBuildingTool tool)
 {
     BaseTile         = tile;
     BaseBuildingTool = tool;
     Ant = null;
 }
 public static EnhanceResult Invoke(Mobile from, BuildSystem buildSystem, BaseBuildingTool tool, Item item, BuildResource resource, Type resType, ref object resMessage)
 {
     return(EnhanceResult.BadItem);
 }
Example #25
0
 public InternalTarget(BuildSystem buildSystem, BaseBuildingTool tool) :  base(2, false, TargetFlags.None)
 {
     m_BuildSystem = buildSystem;
     m_Tool        = tool;
 }
        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);
                }
            }
        }
 public ToolChangedEventArgs(BaseBuildingTool oldTool, BaseBuildingTool newTool)
 {
     this.oldTool = oldTool;
     this.newTool = newTool;
 }
        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
            }
        }
Example #29
0
 public static void Do(Mobile from, BuildSystem buildSystem, BaseBuildingTool tool)
 {
     from.Target = new InternalTarget(buildSystem, tool);
     from.SendLocalizedMessage(1044276);               // Target an item to repair.
 }