Minitay Posted May 20, 2019 Share Posted May 20, 2019 good day everyone alright so, i know this is comlicated stuff, but still i wanna give my character a second form, like a werepig or beaver, and i tried digging woodie's and wilba's files and couldnt find anything i could understand - it seems that everything relating to these form is coded to match them very specifically from the start basically i wanna make so that at 0 sanity, the character will change his form to something else (not too complicated like a werebeaver, more like wilbas werepig, where the body shape is mostly the same) and this form will also make weapons un-equippable, multiply damage, add speed, and change speech lines and voice. fun stuff like that my question is - where do i even start? Link to comment Share on other sites More sharing options...
Ultroman Posted May 21, 2019 Share Posted May 21, 2019 (edited) This will tell you how to change the animation build at your wim. You just need to instead listen to your character's "sanitydelta" event. See which parameters you get with it. You get oldpercent and newpercent in the data parameter. If you'd rather cut at percentages you can do it like that. If you want the thresholds to be an integer sanity value instead, here's the code for that. local isInSecondForm = false local function TurnBackToNormal(inst) -- Do whatever is needed to be in the normal state. -- You at least need to change the animation build, if your character needs to look different. inst.AnimState:SetBuild("normal") isInSecondForm = false end local function TurnIntoSecondForm(inst) -- Do whatever is needed to be in the shadow creature state. -- You at least need to change the animation build, if your character needs to look different. inst.AnimState:SetBuild("secondform") isInSecondForm = true end local function OnSanityDrop(inst, data) -- Make sure not to react while the player is dead. if inst:HasTag("playerghost") or inst.components.health and inst.components.health:IsDead() then return end -- If sanity drops below 1, we become a shadow creature. if not isInSecondForm and inst.components.sanity.current < 1 then TurnIntoSecondForm(inst) -- Otherwise, if sanity gets back above 50, we become normal again. elseif isInSecondForm and inst.components.sanity.current > 50 then TurnBackToNormal(inst) end end -- Put this in master_postinit function inst:ListenForEvent("sanitydelta", OnSanityDrop) Edited May 21, 2019 by Ultroman Link to comment Share on other sites More sharing options...
Minitay Posted May 21, 2019 Author Share Posted May 21, 2019 15 hours ago, Ultroman said: This will tell you how to change the animation build at your wim. You just need to instead listen to your character's "sanitydelta" event. See which parameters you get with it. You get oldpercent and newpercent in the data parameter. If you'd rather cut at percentages you can do it like that. If you want the thresholds to be an integer sanity value instead, here's the code for that. local isInSecondForm = false local function TurnBackToNormal(inst) -- Do whatever is needed to be in the normal state. -- You at least need to change the animation build, if your character needs to look different. inst.AnimState:SetBuild("normal") isInSecondForm = false end local function TurnIntoSecondForm(inst) -- Do whatever is needed to be in the shadow creature state. -- You at least need to change the animation build, if your character needs to look different. inst.AnimState:SetBuild("secondform") isInSecondForm = true end local function OnSanityDrop(inst, data) -- Make sure not to react while the player is dead. if inst:HasTag("playerghost") or inst.components.health and inst.components.health:IsDead() then return end -- If sanity drops below 1, we become a shadow creature. if not isInSecondForm and inst.components.sanity.current < 1 then TurnIntoSecondForm(inst) -- Otherwise, if sanity gets back above 50, we become normal again. elseif isInSecondForm and inst.components.sanity.current > 50 then TurnBackToNormal(inst) end end -- Put this in master_postinit function inst:ListenForEvent("sanitydelta", OnSanityDrop) i made a test build with the head colored differently, and named it differently. i also edited the scml file name in the build.xml to the new one, named the folder the same, and the compiled .zip file the same. now when the character reaches 0 sanity, they are completely invisible attached are my mod.lua, build.xml. and log mod logs.rar Link to comment Share on other sites More sharing options...
Ultroman Posted May 21, 2019 Share Posted May 21, 2019 I'd need your whole mod. I need to see the references to the files, the file structure, etc. But I think you at least need to do this at the top of your character's LUA file. local assets = { Asset("SCRIPT", "scripts/prefabs/player_common.lua"), Asset( "ANIM", "anim/hungry.zip" ), Asset( "ANIM", "anim/hungry10.zip" ), } Link to comment Share on other sites More sharing options...
Minitay Posted May 22, 2019 Author Share Posted May 22, 2019 12 hours ago, Ultroman said: I'd need your whole mod. I need to see the references to the files, the file structure, etc. But I think you at least need to do this at the top of your character's LUA file. local assets = { Asset("SCRIPT", "scripts/prefabs/player_common.lua"), Asset( "ANIM", "anim/hungry.zip" ), Asset( "ANIM", "anim/hungry10.zip" ), } awesome, it works now! thank you sooo much! Link to comment Share on other sites More sharing options...
Minitay Posted May 22, 2019 Author Share Posted May 22, 2019 alright, so, with the form working and everything, i have another question from the main topic: i wanna make the character change their lines, like wilba and woodie do, when in the second form. basically i want them to pick from 5 random lines whenever inspecting something in that form. i checked and saw that the other werepeople have custom strings for it, but i didnt really understand how they came into play whenever the characters changed form. so how do i add different lines to the different state of the character? Link to comment Share on other sites More sharing options...
Ultroman Posted May 23, 2019 Share Posted May 23, 2019 Just change the STRINGS variables for your character for those particular items. STRINGS.CHARACTERS.<character prefab name in CAPS>.DESCRIBE.LANTERN = "It's a lantern" STRINGS.CHARACTERS.<character prefab name in CAPS>.DESCRIBE.BUNNYMAN = "It's a bunnyman" You can put those anywhere. Link to comment Share on other sites More sharing options...
Minitay Posted May 23, 2019 Author Share Posted May 23, 2019 4 hours ago, Ultroman said: Just change the STRINGS variables for your character for those particular items. STRINGS.CHARACTERS.<character prefab name in CAPS>.DESCRIBE.LANTERN = "It's a lantern" STRINGS.CHARACTERS.<character prefab name in CAPS>.DESCRIBE.BUNNYMAN = "It's a bunnyman" You can put those anywhere. what i meant to ask is, how do i make it so while in < 1 sanity, the character doesnt use their regular speech file, but rather, a different one? Link to comment Share on other sites More sharing options...
Ultroman Posted May 24, 2019 Share Posted May 24, 2019 Maybe this overwrites current variables under the example character "GIR"'s strings here? STRINGS.CHARACTERS.GIR = require "speech_gir" For switching between them, you can add that line referencing the different speech files in your "sanitydelta" listener function. 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