Daniel P. Barron

Category: Eulora Published: May 9

Craft Bot Replace Tool

Here's how to make your FoxyBot change worn out tools during a craft run. This is not a simple fix. Please read carefully.

First, open up botactivity.h and add this to the protected section of the CraftActivity class.

        void DoReplaceTool();

While you're in that file, also add this to the private section of the same class.

        bool needToReplaceTool;
        pawsSlot* toolSlot;             //for worn-out tools
        csString toolName;

And add this constant to enum CRAFT_ACTIONS.

CRAFTING_REPLACE_TOOL = 27,

Write the file and open up botactivity.cpp ; add this function somewhere among the other CraftActivity functions.

void CraftActivity::DoReplaceTool()
{
        if (needToReplaceTool)
        {
                toolName = rcp.GetToolName();

                if (toolSlot == NULL)
                        toolSlot = worldHandler::GetNextFreeInvSlot();

                if (toolName == "Chair for the Head" || toolName == "Pincered Skullcap")
                        worldHandler::MoveItems(CONTAINER_INVENTORY_EQUIPMENT, PSCHARACTER_SLOT_HELM, toolSlot->ContainerID(), toolSlot->ID(), 1);
                else if (toolName == "Demeaning Urabihs Harness")
                        worldHandler::MoveItems(CONTAINER_INVENTORY_EQUIPMENT, PSCHARACTER_SLOT_TORSO, toolSlot->ContainerID(), toolSlot->ID(), 1);
                else if (toolName == "Penance Clogs")
                        worldHandler::MoveItems(CONTAINER_INVENTORY_EQUIPMENT, PSCHARACTER_SLOT_BOOTS, toolSlot->ContainerID(), toolSlot->ID(), 1);

                worldHandler::Equip(toolName);
                needToReplaceTool = false;
        }
}

Add this case to the switch in CraftActivity::Perform.

                case CRAFTING_REPLACE_TOOL:
                {
                        DoReplaceTool();
                        NextAction(2*MIN_DELAY);
                        break;
                }

Put these somewhere at the top of CraftActivity::DoInit().

        needToReplaceTool = false;
        toolSlot = NULL;
        toolName = csString("");

And another case in CraftActivity::NextAction.

        case CRAFTING_REPLACE_TOOL:
        {
                if (!needToReplaceTool)
                        actionToDo = CRAFTING_INIT;
                break;
        }

And finally, change this else if in CraftActivity::HandleMessage.

                        else if (text.StartsWith(TOOL_WORN))
                        {
                                OutputMsg("Tool worn-out; will try to replace it.");

                                needToReplaceTool = true;
                                DoReplaceTool();
                                if (!worldHandler::TargetEID(containerEID))
                                {
                                        OutputMsg(csString("Could not find container within reach!"));
                                        Error();
                                        break;
                                }

                                csString contName = worldHandler::GetTargetName().Collapse();
                                if (!contName.CompareNoCase(rcp.GetContainerName()))
                                {
                                        OutputMsg(rcp.GetContainerName());
                                        OutputMsg(contName);
                                        OutputMsg(csString("Wrong container targeted! Kindly target the right container for the task and /bot craft again."));
                                        Error();
                                        break;
                                }

                                if (!worldHandler::OpenTarget())
                                {
                                        OutputMsg(csString("Could not open the container!"));
                                        Error();
                                        break;
                                }
                                worldHandler::UseTarget();
                        }

Save that file, change directory to ~/development/EuloraV0.1.2 and run jam -aq client to recompile the changes.




Comment on this page.