AlbertDelRiver Posted April 14, 2018 Share Posted April 14, 2018 Far as I know, there is no item in the game allowing specific bonuses for a specified character. So how do I make a line of code for this? For example, if I wanted Wickerbottom to be 33% faster when holding a walking cane, how would I do it? inst.components.equippable.walkspeedmult = TUNING.CANE_SPEED_MULT Link to comment Share on other sites More sharing options...
. . . Posted April 15, 2018 Share Posted April 15, 2018 (edited) you could do something in YOURCHAR.lua above master_postinit local function Equip_Special_Item(inst) local equipped = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) if equipped and equipped.prefab == "cane" then inst.components.locomotor:SetExternalSpeedMultiplier(inst, "cane_bonus", 1.33) end if not equipped or (equipped and not equipped.prefab == "cane") then inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "cane_bonus") end end --inside master_postinit inst:ListenForEvent("equip", Equip_Special_Item) inst:ListenForEvent("unequip", Equip_Special_Item) Now if you'd want to add this to a existing character like wickerbottom you would put this in modmain.lua AddPrefabPostInit("wickerbottom", function(inst) local equipped = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) inst:ListenForEvent("unequip", function(inst) if equipped and equipped.prefab == "cane" then inst.components.locomotor:SetExternalSpeedMultiplier(inst, "cane_bonus", 1.33) end if not equipped or (equipped and not equipped.prefab == "cane") then inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "cane_bonus") end end) inst:ListenForEvent("equip", function(inst) if equipped and equipped.prefab == "cane" then inst.components.locomotor:SetExternalSpeedMultiplier(inst, "cane_bonus", 1.33) end if not equipped or (equipped and not equipped.prefab == "cane") then inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "cane_bonus") end end) end) Edited April 15, 2018 by SuperDavid fixed coding a bit Link to comment Share on other sites More sharing options...
AlbertDelRiver Posted April 15, 2018 Author Share Posted April 15, 2018 Wow, thanks! This will be useful for future character item specific stats. Link to comment Share on other sites More sharing options...
Recommended Posts
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