Jump to content

Equippable does not consistently check for owner


penguin0616
  • Fixed

In the beta, Equippable:GetWalkSpeedMult() added the following logic for speed modifiers.

local speedmodifierfn = owner.components.inventory:GetEquippableWalkSpeedMultModifier()
    if speedmodifierfn ~= nil then
        speed = speedmodifierfn(owner, speed, self.inst)
    end
 

This code does not check whether owner is nil, like this portion above it does

local owner = self.inst.components.inventoryitem and self.inst.components.inventoryitem.owner
    if speed < 1 and self.isequipped and owner and owner:HasTag("vigorbuff") then
        speed = math.min(1, speed + 0.25)
    end

This means that any code calling GetWalkSpeedMult on an equippable without an owner (such as a blowpipe resting on the ground) will trigger a crash (in my particular case, by mods, for example).

It would be great to see this fixed by making the check for owner consistent -- one potential example:

function Equippable:GetWalkSpeedMult()
    local speed = self.walkspeedmult or 1.0
    local owner = self.inst.components.inventoryitem and self.inst.components.inventoryitem.owner

    if owner then
        if speed < 1 and self.isequipped and owner:HasTag("vigorbuff") then
            speed = math.min(1, speed + 0.25)
        end

        local speedmodifierfn = owner.components.inventory:GetEquippableWalkSpeedMultModifier()
        if speedmodifierfn ~= nil then
            speed = speedmodifierfn(owner, speed, self.inst)
        end
    end

    return speed
end

Thanks!


Steps to Reproduce

1. Leave equippable such as blowpipe on ground

2. Use something that tries to evaluate the walk speed multiplier of said equippable

3. Crash and burn

  • Spooky 1



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.


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