Jump to content

Recommended Posts

I can't figure out how to make a special sanity regen bonus only for cpecific character?For example, i wear bearger vest and gain +10 sanity/minute.
I tried this, but it doesnt seem to work:
 

Spoiler

AddPrefabPostInit("beargervest", function(inst)
local function onequip(inst, owner) 
    owner.AnimState:OverrideSymbol("swap_body", "torso_bearger", "swap_body")
    if owner.components.hunger then
        owner.components.hunger.burnrate = TUNING.ARMORBEARGER_SLOW_HUNGER
    end
    inst.components.fueled:StartConsuming()
        if owner:HasTag("nikmikwrithe") then
    inst.components.equippable.dapperness = TUNING.DAPPERNESS_HUGE * 3.5
    --owner.components.sanity.dapperness = TUNING.DAPPERNESS_HUGE * 2.5
end
end

    --inst.components.equippable:SetOnEquip( onequip )
end)

 

Edited by Zer000
AddPrefabPostInit("beargervest", function(inst)
	if not GLOBAL.TheWorld.ismastersim then return inst end
	local _onequipfn = inst.components.equippable.onequipfn
	inst.components.equippable.onequipfn = function (inst, owner)
		_onequipfn(inst, owner)
		if owner:HasTag("nikmikwrithe") then
			inst.components.equippable.dapperness = GLOBAL.TUNING.DAPPERNESS_HUGE * 3.5
		end
	end
end)

Try this. Make sure your character already have "nikmiwrithe" tag.

Edited by zUsername
15 minutes ago, Zer000 said:

Sorry, i forgot to reply here :D
Thank you dude, that really helped me so i used it in my mods.

Problem with the code snippet there is that it doesn't reset its value for other classes, so if you equip it with the custom character and then give it to someone else it'll be buffed.

A better approach is to edit the GetDapperness function instead:

AddPrefabPostInit(
    "beargervest",
    function(inst)
        if not GLOBAL.TheWorld.ismastersim
        then
            return
        end
        local GetDapperness_old = inst.components.equippable.GetDapperness
        inst.components.equippable.GetDapperness = function(self, owner, ...)
            local original_dapperness = GetDapperness_old(self, owner, ...)
            if owner.prefab=="wilson"
            then
                return original_dapperness - inst.components.equippable.dapperness + GLOBAL.TUNING.DAPPERNESS_HUGE * 3.5
            end
            return original_dapperness
        end
    end
)

Using prefab name instead of a tag for server-side optimization (HasTag is more expensive than a string check, but it works on both client/server).

Since this edit is server-side only the method isn't used.

If you have multiple characters sharing the same tag then go for the tag usage.

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