Jump to content

Recommended Posts

I want to add a shapeshifter ability to a character. I have found a couple of mods that change character mid game Player2Max - The Shapeshifter and Build Switcher. Although I understand some of the things they do in terms of code I have difficulties implementing it onto my character.

Is it possible to add/remove character tags and components (such as AddTag("bookbuilder") and AddComponent("reader") ) when building or using an item?

And is it possible to change build ( SetBuild("wickerbottom") ) when building or using an item?

I have managed to make these work when I add it to a function inside a characters lua file, for example Charlie gets darkvision when she enters darkness, if I do the following she will be able to read, build books and look like wickerbottom after she has entered the darkness.

local function applydarkvision(inst)
-- removed code --
			inst:AddTag("insomniac")
			inst:AddTag("bookbuilder")
			inst:AddComponent("reader")
			inst.AnimState:SetBuild("wickerbottom")
-- removed code --
end

 

Can I do the same thing but instead when I build or use an item or when I eat a food?

This doesn't really work as a shapeshifter I believe since certain skills are not connected to tags and components, such as wormwoods planting abilities. But I haven't really found out how to do that.

You can change build at any time. You can add components any time. You can't remove some component once added, but most components can be removed safely.

When you craft an item, you can choose between inst.OnBuiltFn and inst:ListenForEvent("onbuilt"

Other actions are easier, just find the corresponding function.

45 minutes ago, Rickzzs said:

You can change build at any time. You can add components any time. You can't remove some component once added, but most components can be removed safely.

When you craft an item, you can choose between inst.OnBuiltFn and inst:ListenForEvent("onbuilt"

Other actions are easier, just find the corresponding function.

Thank you, I have been playing around with inst.OnBuiltFn the entire night but with no success, I never used inst:ListenForEvent("onbuilt") so maybe that was the problem. However I had better luck with food, I used  inst.components.edible:SetOnEatenFn(OnEaten) and managed to force a character switch with a little bit of cheating, I used Player2s identitycrises and did eater.components.identitycrisis:ChangePlayerPrefab("wilson", true).

After that my plan was to modify hunger/sanity/health stat and give it some debuff. I tried to use components.eater:SetAbsorptionModifiers(0.5,0.5,0.5) but I think the code never reach that line. After the switch is completed I think the SetOnEatenFn function is complete. Running the modifier before the switch wont work either since its overwritten with the new players prefab after the switch.

I think I have to add some kind of buff or debuff to the food, like the one Fish Cordon Blue has, because the no wetness buff carries on to the new character after the switch.

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