07 June 2018 Tagged: eulorac++

When I started crafting this week I had level 1 Tinkering. As you can imagine, I gained levels quickly. One thing I noticed about the bot was that when I gained a level during a crafting run it would try to train for me, yet fail.

The apparent failure was that it had miss-parsed the name of the skill to train. But this one was quite the little trickster. The log message immediately after the parse was printing:

Bot Log Message
Received message and will attempt training of skill Tinkering.

And at first, I thought maybe the parse was correct after all. I mean, it looks right. But then I realized that the peroid at the end of the log message was not printed by the message but was part of the skill name. No wonder I couldn’t train the skill Tinkering. . You can hide but you can’t run.

src/client/foxybot/botactivity.cpp(823)
void CraftActivity::HandleMessage(MsgEntry* message )  (1)
{
	if (!IsOngoing())
		return;

	switch (message->GetType() )
	{
		case MSGTYPE_MODE:
		{
			break;
		}
		case MSGTYPE_GUISKILL:
		{
			craftFinished = true;
			break;
		}
		case MSGTYPE_SYSTEM:
		{
			psSystemMessage incoming(message);
			csString text = incoming.msgline;

			if (text.StartsWith(RANKING_PREFIX))
			{
				needToTrain = true;
-				size_t end = text.FindLast('!');  (2)
+				size_t end = text.FindLast('.');  (3)

				size_t start = RANKING_PREFIX.Length();
				skillToTrain = text.Slice(start, end-start);
				OutputMsg(csString("Received message and will attempt training of skill ")+skillToTrain);
			}
1 This method is the handler for incoming server messages during a craft run. Shown from the top for context: keep scrolling, my eyes are down here.
2 Ahhha, the old 'used to be a bang, but now a dot' trick.
3 And so: out with a bang!

In a nutshell, Foxybot was expecting the training message to end with a ! but in the mean time has changed to a . and so in slicing out the skill name was going too far.

With the parse fixed, the training proceeds with much success but still has a minor issue. The bot helpfully tries to move all of your recipe ingredients to the craft container to avoid a fatness-hampered training-fail. But it does not succeed in this attempt.

src/client/foxybot/botactivity.cpp(1084)
//move recipe and ingredients from inventory to container to avoid overweight issues

csHash<int, csString>::GlobalIterator iterIngredients(rcp.GetIngredientsList()->GetIterator());

int nextEmptySlot = 0;
if (!iterIngredients.HasNext())
{
        OutputMsg(csString("Empty ingredients list!"));
        Error();
        return;
}
while (iterIngredients.HasNext())
{
        csString itemName;
        iterIngredients.Next(itemName);

        psInventoryCache::CachedItemDescription* from = worldHandler::FindItemSlot(itemName, false);   (1)
        if (from)
        {
                worldHandler::MoveItems(from->containerID, from->slot, toContainer, nextEmptySlot, from->stackCount);
        }
        nextEmptySlot = nextEmptySlot + 1;
}
//move recipes too
psInventoryCache::CachedItemDescription * from = worldHandler::FindItemSlot(rcp.GetRecipeName(), false);  (2)
if (from)
        worldHandler::MoveItems(from->containerID, from->slot, toContainer, nextEmptySlot, from->stackCount);

OutputMsg(csString("Done moving items to container."));
1 This false needs to be changed to true.
2 Not so fast! Don’t change this false to true!

If you look at the code next to marker 1 you’ll see our old friend FindItemSlot() and as in times past, if you change that false to a true things will then go according to plan.

Also in that code, immediately after, you can see it tries to move your bps into the container as well. Originally I "fixed" this one two and it does in fact work. But it leads to a failure down the line when it tries to put the bps back. It seems like a race condition where it tries to move the bps back into inventory and then equip them too quickly afterwards. I didn’t see an easy solution to this so I reverted back and now leave the bps in place while training.

Anyway, I’m pretty sure this works. Realize, though, that I only had 100 bps to craft with and to test this fix I had to level up during a crafting run. I only got 6 shots at it and dispite the last one being successful, that’s not much testing. If it doesn’t work for you, I’ll give you your money back.

That was number one. Here’s number two. If you go around exploring and happen to fill you inventory for whatever reason, you’ll get a message saying you’re stuffed. And evidently everyone sees the message that you’re so stuffed. And the bot, bless her heart, keeps on keeping on: spaming the zone with some stuffed like a buritto message.

I found this tiny bit of code commented out. If you uncomment the line at the marker in the following code it helps you out by stopping further exploration when you get that message.

src/client/foxybot/botactivity.cpp(610)
if (!worldHandler::IsInBrain(scrollName))
{
        if (!worldHandler::EquipRecipe(scrollName))
         {
                        OutputMsg(csString("Missing blueprint for the claim!"));
                        //noBuild = true;  (1)
                        //Error();
            return false;
         }
}
1 Stop feeling so full with this one weird trick.

And that’s it for the quick one two. It was meant to be a quick one too.


Add a Comment