Jump to content

Recommended Posts

Hi there.

I would like the character to slow down when wearing armor. I added "inst.components.equippable.walkspeedmult" to all armor, but if both body and head are equipped, the effect stacks. In general, this suits me, but I would like to have an alternative option, so that the characters slows down by a fixed amount if they are protected by any slot (head, body, hand).

I tried to come up with this, but I failed:

Edited by sjtdhiqbwczfzpu
Link to comment
Share on other sites

i've considered similiar function,maybe you can refer to this

local function noheavything(inst)
    local itembody = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.BODY)
    local itemhead = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HEAD)
    if (itembody ~= nil and itembody.components.armor ~= nil )
    or(itemhead ~= nil and itemhead.components.armor ~= nil ) then
        inst.components.locomotor:SetExternalSpeedMultiplier(inst, "character_speed_mod", 0.5)
        if inst.components.talker then
            inst.components.talker:Say("armor doesn't fit me)
        end
    else
        inst.components.locomotor:SetExternalSpeedMultiplier(inst, "character_speed_mod", 1)
    end
end

master_postinit = function(inst)

inst:ListenForEvent("equip", noheavything)
inst:ListenForEvent("unequip", noheavything)

end

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
 Share

×
  • Create New...