Jump to content

Pirates rowing away from their target


Littlefat1213
  • Fixed

The pirate monkeys appear and keep away from my boat after i use a hostile flare.

And it seems a kind man optimized the code but inadvertently introduced a bug

Solution:

function Boatcrew:GetHeadingNormal()
    local pt = nil
    local boatpt = self.inst:GetPosition()

    if self.target then
        if self.status == "retreat" and self:areAllCrewOnBoat() then
            local x, _, z = self.target.Transform:GetWorldPosition()
            local heading = self.inst:GetAngleToPoint(x, 0, z) * DEGREES
            pt = boatpt + Vector3(math.cos(heading), 0, -math.sin(heading))
            pt.y = 0
        else
            pt = self.target:GetPosition()

            if self.target.components.boatphysics then
                local scaler = Remap(distsq(pt.x, pt.z, boatpt.x, boatpt.z), 0, 100, 0, 1)
                pt.x  = pt.x + (self.target.components.boatphysics.velocity_x * scaler)
                pt.z  = pt.z + (self.target.components.boatphysics.velocity_z * scaler)
            end
        end

    elseif self.heading then
        local heading = self.heading * DEGREES
        pt = boatpt + Vector3(math.cos(heading), 0, -math.sin(heading))
        pt.y = 0
    end

    return (pt ~= nil and VecUtil_Normalize(pt.x - boatpt.x, pt.z - boatpt.z)) or nil
    --- only get one return value in this way XD --
    --- HERE'S THE FIX -----
    -- if pt ~= nil then
    --     return VecUtil_Normalize(pt.x - boatpt.x, pt.z - boatpt.z)
    -- end
end

 

43c51368108a670daba211471d0d2083.png.e45fca2362699ada7ef241c47a4c159b.png

 


Steps to Reproduce

As Above




User Feedback


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.

There are no comments to display.



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...