This applies to both the mermbrain and mermguardbrain files (this stuff could also be consolidated into a single common brain file).
Here's an example with GetClosestToolShed:
local function GetClosestToolShed(inst, dist) dist = dist or FIND_SHED_RANGE local x, y, z = inst.Transform:GetWorldPosition() local ents = TheSim:FindEntities(x, 0, z, dist, nil, nil, TOOLSHED_ONEOF_TAGS) if #ents <= 0 then return nil end local shed = nil for _, ent in ipairs(ents) do if ent:CanSupply() then if ent:HasTag("merm_toolshed_upgraded") then return ent -- High priority. end shed = ent end end return shed end
These work fine for the upgraded versions, as entity searches return results in order based on distance, and the return will stop on finding a valid one. But the ones that aren't upgraded will return the furthest one away instead, as iteration will keep going.
This probably needs a bit of reformatting, or to simply use a return statement for unupgraded ones as well, if no other arguments to determine the ideal shed/tool are added.
Steps to Reproduce
- Place multiple sheds or drop multiple tools around for merms to go to or pick up, that aren't upgraded.
- Notice how the furthest one should be chosen out of all the possible candidates.
A developer has marked this issue as fixed. This means that the issue has been addressed in the current development build and will likely be in the next update.
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 accountSign in
Already have an account? Sign in here.
Sign In Now