jimmeh57 Posted October 14, 2013 Share Posted October 14, 2013 So I am basically designing a character who 's form will change based on his sanity; if it drops below 50%, he will take form of a different body. Additionally, some base stats would change too, including max hunger, max health, damage, and hunger rate. My issue is, I have little experience in coding. This is what I have got so far, from looking at codes such as Wolfgang and several mods:local function becomehed(inst) inst.AnimState:SetBuild("hed") inst.components.health:SetMaxHealth(133) inst.components.hunger:SetMax(133) inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 0)endlocal function becomebody(inst) inst.AnimState:SetBuild("body") inst.components.health:SetMaxHealth(200) inst.components.hunger:SetMax(200) inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE)end local function sanitychange(inst, data) if inst.components.sanity.current < 66 then becomebody(inst) else becomehed(inst) end endlocal fn = function(inst) -- choose which sounds this character will play inst.soundsname = "wx78" -- a minimap icon must be specified inst.MiniMapEntity:SetIcon( "wx78.png" ) -- todo: Add an example special power here. inst.components.health.maxhealth = 133 inst.components.health.currenthealth = 100 inst.components.sanity.max = 133 inst.components.sanity.current = 100 inst.components.hunger.max = 133 inst.components.hunger.current = 100 inst:ListenForEvent(sanitychange)endAny and all help would be appreciated. Link to comment https://forums.kleientertainment.com/forums/topic/28753-coding-question/ Share on other sites More sharing options...
Heavenfall Posted October 14, 2013 Share Posted October 14, 2013 inst:ListenForEvent("sanitydelta", sanitychange) Link to comment https://forums.kleientertainment.com/forums/topic/28753-coding-question/#findComment-343403 Share on other sites More sharing options...
jimmeh57 Posted October 14, 2013 Author Share Posted October 14, 2013 inst:ListenForEvent("sanitydelta", sanitychange) Wow, thanks! This does transform the character, except for one thing.. the character becomes invisible. I think that may have something to do with the .zip files, but I am not quite sure. I've been testing this mod for the past few days and everytime i enable body.zip, he becomes invisible. Would you happen to know how to fix this as well? Link to comment https://forums.kleientertainment.com/forums/topic/28753-coding-question/#findComment-343417 Share on other sites More sharing options...
Heavenfall Posted October 14, 2013 Share Posted October 14, 2013 Make sure that it is registered in the assets table in the prefab file (see other prefab files for examples) and that the texture works (build.bin is right, atlas-0.tex is right). Link to comment https://forums.kleientertainment.com/forums/topic/28753-coding-question/#findComment-343427 Share on other sites More sharing options...
jimmeh57 Posted October 14, 2013 Author Share Posted October 14, 2013 (edited) Make sure that it is registered in the assets table in the prefab file (see other prefab files for examples) and that the texture works (build.bin is right, atlas-0.tex is right). Asset( "ANIM", "anim/hed.zip" ), Asset( "ANIM", "anim/body.zip"), When I comment out the first asset, the character becomes invisible, I think this means that the second .zip file isn't working. But I did set the .tex file and build.bin seperately, I'm not sure what to do. Additionally, I made some minor changes to the hunger rate, yet the hunger still NEVER drops. And whenever I am hit by an enemy, the health will drop once, and then stay at the same number. local function becomehed(inst) inst.AnimState:SetBuild("hed") inst.components.health:SetMaxHealth(133) inst.components.hunger:SetMax(133) inst.components.sanity:SetMax(133) inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 0.50)end local function becomebody(inst) inst.AnimState:SetBuild("body") inst.components.health:SetMaxHealth(200) inst.components.hunger:SetMax(200) inst.components.sanity:SetMax(133) inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 1.25)end local function sanitychange(inst, data) if inst.components.sanity.current < 66 then becomebody(inst) else becomehed(inst) end end local fn = function(inst) -- choose which sounds this character will playinst.soundsname = "wx78" -- a minimap icon must be specifiedinst.MiniMapEntity:SetIcon( "wx78.png" ) -- todo: Add an example special power here. inst.components.health.maxhealth = 133 inst.components.health.currenthealth = 100 inst.components.hunger.max = 133 inst.components.hunger.current = 100 inst.components.sanity.max = 133 inst.components.sanity.current = 100 inst:ListenForEvent("sanitydelta", sanitychange)end Edited October 14, 2013 by jimmeh57 Link to comment https://forums.kleientertainment.com/forums/topic/28753-coding-question/#findComment-343438 Share on other sites More sharing options...
jimmeh57 Posted October 14, 2013 Author Share Posted October 14, 2013 Okay, so I fixed the animation not showing up, turns out I zipped the file containing the atlas-0 and build, rather than zipping those separately. Link to comment https://forums.kleientertainment.com/forums/topic/28753-coding-question/#findComment-343486 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