Jump to content

Marotter food logic issues


Bumber64
  • Pending

Marotters won't target food on their raft or in their den for eating when hungry, instead letting it rot as they hunt for far away food. (This mechanic is meant to prevent picking up already gathered items, but is erroneously duplicated in the eating function. There's no logic to select items in the den.)

Hungry marotters that gather pig skins will repeatedly pick up and drop the item. This doesn't happen when not hungry. (From what I can tell they should be able to eat "horrible" food, but it seems they're failing to do so for whatever reason.)


Steps to Reproduce

Find a marotter den and c_spawn('pigskin') over the water. A marotter should attempt to swim to the item to eat it, but will fumble after picking it up. This loop will repeat a number of times, but the delay between attempts will eventually cause them to catch and eat a fish instead. This will allow them to gather the pig skin and put it in their den instead.

You can c_spawn('fishmeat') on the water when they're not hungry, or over their boat at any time. Having it stolen from your inventory while on the boat also works. Marotters will ignore the meat from then on, preferring to fish for new food instead.

  • Like 1



User Feedback


You already pointed out the issue with not eating food from the den. But regarding the bit about not eating horrible food, this seems to be the cause:

local function FindGroundFoodToEatAction(inst)
    if inst.sg:HasStateTag("busy") or inst.components.timer:TimerExists(INTERACT_COOLDOWN_NAME) then
        return nil
    end

    -- Try to avoid picking up things that are on our home boat,
    -- because they'll get dropped there when our den is full.
    local home_position = GetHomeLocation(inst)
    local test_ground_item_for_food = function(item)
        return item:GetTimeAlive() >= 1
            and item.prefab ~= "mandrake"
            and item.components.edible ~= nil
            and item.components.edible.foodtype == FOODTYPE.MEAT -- HERE
            and inst.components.eater:CanEat(item)
            and item.components.inventoryitem ~= nil
            and (not home_position or item:GetDistanceSqToPoint(home_position) > BOAT_SIZE_SQ)
    end

There's a hardcoded check specifically for eating, the food type has to be meat. Given that they normally only eat meat otherwise, they might've forgotten to account for it here. CanEat already covers meat + horrible, so they could just get rid of it, or remove the horrible eater property from them instead.

 

Also, something else I noticed is that they don't always make use of inst.components.eater:GetEdibleTags() to send as "one of" tags for these searches? Not just for Marotters, but for many other similar cases of searching for food entities.

Using it could lighten the searches quite a bit and it'd be consistent with whatever the eater component of the entity has set at the time. Well, they'd need to set the cache to nil on adding or removing eater tags, to support changing the tags at any point and ensure this will still work properly, as it won't update otherwise, or simply set the cache variable to false so it doesn't cache at all, if memory usage is a concern.

  • Like 1

Share this comment


Link to comment
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...