Jump to content

How to fix mobs doing nothing after embarking


Recommended Posts

Mobs neither continue or abort buffered actions upon embarking, which leads to them standing idle until interrupted. For example, Sea Striders will be idle for 15 seconds after jumping off a platform to eat a fish. I assume this timeout was added specifically for that issue.

This can be fixed by adding this to behaviours/doaction:

Quote

function DoAction:Visit()
    if self.status == RUNNING and self.inst.sg:HasStateTag("idle") then
        self.status = READY --try again if we're idle for some reason...
    end

    
    if self.status == READY then
        local action = self.getactionfn(self.inst)
    
        if action then
            action:AddFailAction(function() self:OnFail() end)
            action:AddSuccessAction(function() self:OnSucceed() end)
            self.pendingstatus = nil
            self.inst.components.locomotor:PushAction(action, self.shouldrun)
            self.action = action
            self.time = GetTime()
            self.status = RUNNING
        else
            self.status = FAILED
        end
    end
    
    if self.status == RUNNING then
        if self.timeout and (GetTime() - self.time > self.timeout) then
            self.status = FAILED
            --print("Action timed out, failing")
        end
    
        if self.pendingstatus then
            self.status = self.pendingstatus
        elseif not self.action:IsValid() then
            self.status = FAILED
        end
    end    
end

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...