Sannom Posted February 2, 2014 Share Posted February 2, 2014 I'm currently modding a character into the game, and I can't seem to find much on this topic, so here I am, requesting help from the scripting gods ( you! ).The character in question needs to move faster the lower its health goes.I'd also like to know if it's possible to reverse night/day sanity loss and make it so daytime induces sanity loss, as opposed to night. And perhaps night could make it -regain- sanity to a very small degree?( The character has night vision, and I'd rather make it a night-based character, as odd as it sounds. )And one last thing-- the character is a carnivore, and I'd like to know if there's a way to prevent sanity loss from eating raw meats.Note: I successfully implemented night vision and carnivore, so no need to help me with those.Thanks in advance! Link to comment https://forums.kleientertainment.com/forums/topic/31329-health-sanity-and-speed-modding-help-request/ Share on other sites More sharing options...
Dryicefox Posted February 2, 2014 Share Posted February 2, 2014 I'm currently modding a character into the game, and I can't seem to find much on this topic, so here I am, requesting help from the scripting gods ( you! ).The character in question needs to move faster the lower its health goes.I'd also like to know if it's possible to reverse night/day sanity loss and make it so daytime induces sanity loss, as opposed to night. And perhaps night could make it -regain- sanity to a very small degree?( The character has night vision, and I'd rather make it a night-based character, as odd as it sounds. )And one last thing-- the character is a carnivore, and I'd like to know if there's a way to prevent sanity loss from eating raw meats.Note: I successfully implemented night vision and carnivore, so no need to help me with those.Thanks in advance! You are going to want to look at William Danninghar, he has a custom ability that mimics what you want for speed. Check out Isis for the no meat damage AND reversed sanity loss. Link to comment https://forums.kleientertainment.com/forums/topic/31329-health-sanity-and-speed-modding-help-request/#findComment-411668 Share on other sites More sharing options...
Sannom Posted February 2, 2014 Author Share Posted February 2, 2014 Thanks a bunch, this will set me on the right track.I'll update here if I ever get stumped somehow. Link to comment https://forums.kleientertainment.com/forums/topic/31329-health-sanity-and-speed-modding-help-request/#findComment-411669 Share on other sites More sharing options...
Sannom Posted February 2, 2014 Author Share Posted February 2, 2014 Sorry for the double post. Seems there's no edit button.Couldn't find anything I was looking for in these mods-- or I just can't seem to get them to work, one or the other. I have terrible difficulty with coding/scripting/thingamajigs, ...If anyone could show me how, it'd be greatly appreciated, because borrowing from other mods doesn't seem to work for me. Link to comment https://forums.kleientertainment.com/forums/topic/31329-health-sanity-and-speed-modding-help-request/#findComment-411698 Share on other sites More sharing options...
NikMik Posted February 3, 2014 Share Posted February 3, 2014 You are going to want to look at William Danninghar, he has a custom ability that mimics what you want for speed. Check out Isis for the no meat damage AND reversed sanity loss.that depends on what Sannom wants. If they want it so just the lower the character's sanity is, the faster they run, William does not do that. He just goes into his nightmare form when his sanity is below 40ish. Warwick http://forums.kleientertainment.com/files/file/455-warwick/ becomes slower as his sanity goes down, so I'm sure you could look in his coding to see how that's done. Link to comment https://forums.kleientertainment.com/forums/topic/31329-health-sanity-and-speed-modding-help-request/#findComment-411783 Share on other sites More sharing options...
Dryicefox Posted February 3, 2014 Share Posted February 3, 2014 that depends on what Sannom wants. If they want it so just the lower the character's sanity is, the faster they run, William does not do that. He just goes into his nightmare form when his sanity is below 40ish. Warwick http://forums.kleientertainment.com/files/file/455-warwick/ becomes slower as his sanity goes down, so I'm sure you could look in his coding to see how that's done.Thank you for correcting me. I thought I had seen in it one of the better mods. Link to comment https://forums.kleientertainment.com/forums/topic/31329-health-sanity-and-speed-modding-help-request/#findComment-411804 Share on other sites More sharing options...
Sannom Posted February 3, 2014 Author Share Posted February 3, 2014 (edited) Would you happen to have any idea how to use a similar code with health rather than sanity? I'm really not the best at coding and whatnot, as you can already tell. Beginner steps, I'd never touched any of that stuff before, ... three days ago!Edit: This is what I tried, but it crashes the game after loading a save; local function healthcheck(inst) local healthcurr = inst.components.health.healthcurrent if healthcurr >= 90 then inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.1) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.1) elseif healthcurr >= 70 then inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.2) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.2) inst.components.combat.damagemultiplier = 1.2 elseif healthcurr >= 50 then inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.3) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.3) inst.components.combat.damagemultiplier = 1.4 elseif healthcurr >= 40 then inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.4) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.4) inst.components.combat.damagemultiplier = 1.6 elseif healthcurr >= 25 then inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.5) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.5) inst.components.combat.damagemultiplier = 2 else inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.5) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.5) inst.components.combat.damagemultiplier = 2 endendI also added the "Inst:ListenForEvent("healthdelta", healthcheck)" under "local fn = function(inst)", but... no good.I'm stumped. Edited February 5, 2014 by Sannom Link to comment https://forums.kleientertainment.com/forums/topic/31329-health-sanity-and-speed-modding-help-request/#findComment-411958 Share on other sites More sharing options...
Sannom Posted February 5, 2014 Author Share Posted February 5, 2014 (edited) Bumping this... Sorry in advance.Why the heck does it work with inst.components.sanity.current, but not with inst.components.health.healthcurrent? Can anyone help? I've been trying to fix this for a whole day, without success. Edited February 5, 2014 by Sannom Link to comment https://forums.kleientertainment.com/forums/topic/31329-health-sanity-and-speed-modding-help-request/#findComment-412556 Share on other sites More sharing options...
Sannom Posted February 8, 2014 Author Share Posted February 8, 2014 Requesting help concerning this again... I'm getting a bit desperate here.I don't like bumping, but I feel like I have very little options if I don't want this request to get buried. Link to comment https://forums.kleientertainment.com/forums/topic/31329-health-sanity-and-speed-modding-help-request/#findComment-413495 Share on other sites More sharing options...
seronis Posted February 8, 2014 Share Posted February 8, 2014 (edited) Not saying I can help.. but 'no one' can really help with what you posted. IE: you forgot to zip up and upload your mod folder so someone can look at it and see whats wrong. Also when you posted that it crashed you didnt post the -exact- crash message. The message itself is designed to tell you where the problem is and would be useful in debugging Edited February 8, 2014 by seronis Link to comment https://forums.kleientertainment.com/forums/topic/31329-health-sanity-and-speed-modding-help-request/#findComment-413527 Share on other sites More sharing options...
Sannom Posted February 8, 2014 Author Share Posted February 8, 2014 Alright, here goes nothing.The only issue is in the prefab, I'm fairly certain. Everything else worked before I edited it.Modstuff.zip Link to comment https://forums.kleientertainment.com/forums/topic/31329-health-sanity-and-speed-modding-help-request/#findComment-413665 Share on other sites More sharing options...
MayleanCall Posted February 8, 2014 Share Posted February 8, 2014 Would you happen to have any idea how to use a similar code with health rather than sanity? I'm really not the best at coding and whatnot, as you can already tell. Beginner steps, I'd never touched any of that stuff before, ... three days ago!Edit: This is what I tried, but it crashes the game after loading a save; local function healthcheck(inst) local healthcurr = inst.components.health.healthcurrent if healthcurr >= 90 then inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.1) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.1) elseif healthcurr >= 70 then inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.2) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.2) inst.components.combat.damagemultiplier = 1.2 elseif healthcurr >= 50 then inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.3) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.3) inst.components.combat.damagemultiplier = 1.4 elseif healthcurr >= 40 then inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.4) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.4) inst.components.combat.damagemultiplier = 1.6 elseif healthcurr >= 25 then inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.5) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.5) inst.components.combat.damagemultiplier = 2 else inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.5) inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.5) inst.components.combat.damagemultiplier = 2 endendI also added the "Inst:ListenForEvent("healthdelta", healthcheck)" under "local fn = function(inst)", but... no good.I'm stumped. In your logic code (specifically the elseif statements) it should read like this:elseif healthcurrent >= 70 then you forgot the "ent" of most of those lines. Link to comment https://forums.kleientertainment.com/forums/topic/31329-health-sanity-and-speed-modding-help-request/#findComment-413670 Share on other sites More sharing options...
MayleanCall Posted February 8, 2014 Share Posted February 8, 2014 In your logic code (specifically the elseif statements) it should read like this:elseif healthcurrent >= 70 then you forgot the "ent" of most of those lines. I'm an idiot. Please ignore this. Link to comment https://forums.kleientertainment.com/forums/topic/31329-health-sanity-and-speed-modding-help-request/#findComment-413692 Share on other sites More sharing options...
Sannom Posted February 8, 2014 Author Share Posted February 8, 2014 Haha, thanks for trying to help anyway! Link to comment https://forums.kleientertainment.com/forums/topic/31329-health-sanity-and-speed-modding-help-request/#findComment-413694 Share on other sites More sharing options...
Dryicefox Posted March 5, 2014 Share Posted March 5, 2014 Can we get a final opinion on this?I'd really like to make a character that changes based on health. Thanks guys. Link to comment https://forums.kleientertainment.com/forums/topic/31329-health-sanity-and-speed-modding-help-request/#findComment-424195 Share on other sites More sharing options...
squeek Posted March 5, 2014 Share Posted March 5, 2014 (edited) Can we get a final opinion on this?I'd really like to make a character that changes based on health. Thanks guys.The variable is currenthealth, not healthcurrent. Look at components/health.lua. The line should be:local healthcurr = inst.components.health.currenthealthor you could use the GetPercent function instead:local percenthealth = inst.components.health:GetPercent()-- less than 50% healthif percenthealth < .5 then -- do stuffend Edited March 5, 2014 by squeek Link to comment https://forums.kleientertainment.com/forums/topic/31329-health-sanity-and-speed-modding-help-request/#findComment-424209 Share on other sites More sharing options...
TheDanaAddams Posted March 5, 2014 Share Posted March 5, 2014 The variable is currenthealth, not healthcurrent. Look at components/health.lua. The line should be:local healthcurr = inst.components.health.currenthealthor you could use the GetPercent function instead:local percenthealth = inst.components.health:GetPercent()-- less than 50% healthif percenthealth < .5 then -- do stuffend local percenthealth = inst.components.health:GetPercent()if percenthealth < .2 thensoundmanager.loop "f***ing annoying incessant beeping.wav"end[snickers]Yes, I know that code is total bull. It's a joke. In case you can't tell. Link to comment https://forums.kleientertainment.com/forums/topic/31329-health-sanity-and-speed-modding-help-request/#findComment-424226 Share on other sites More sharing options...
squeek Posted March 5, 2014 Share Posted March 5, 2014 local percenthealth = inst.components.health:GetPercent()if percenthealth < .2 thensoundmanager.loop "f***ing annoying incessant beeping.wav"end[snickers]Yes, I know that code is total bull. It's a joke. In case you can't tell.I am familiar with that beeping.http://youtu.be/0M7IINwTFVw?t=13m34s Link to comment https://forums.kleientertainment.com/forums/topic/31329-health-sanity-and-speed-modding-help-request/#findComment-424237 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