Marmalade Posted December 31, 2020 Share Posted December 31, 2020 Hello. I'm making a custom character and I'm having trouble coding perks into him and can't really find anything online that helps me. The perks that I have planned for him: Ability to punch trees (You can probably guess what character I'm making now) Have his hunger not deplete when standing still Have his walk speed at 1.1 when above 30% hunger and below 30% at 0.9 Have his hunger go down faster when walking but reverts to normal hunger drain when at 30% or lower Have his hunger go down by like 1 or 2 whenever he attacks or does an action like digging Not be able to put on helmets, But can craft his own helmets that he can put on Able to put on a pumpkin lantern (for fun not really needed) I really hope I'm not asking too much and I'd appreciate if someone would help! Link to comment https://forums.kleientertainment.com/forums/topic/125575-help-needed-for-coding-a-few-perks-for-custom-character/ Share on other sites More sharing options...
Goregonzola Posted January 2, 2021 Share Posted January 2, 2021 (edited) Hey! I'm still relatively new into coding, this is what I can help with: Quote Have his walk speed at 1.1 when above 30% hunger and below 30% at 0.9 Spoiler local function bonus(inst) --This whole coding segment goes above your local master_postnit print (inst) if inst ~= nil then if inst.components.hunger.current <= 30 then --Replace "30" with your chosen Hunger point inst.components.locomotor.walkspeed = 1.1--This is his/her faster walkspeed else inst.components.locomotor.walkspeed = 0.9--This is his/her slower walkspeed end end end I don't really know how to do this with percentages, I can only provide a coding with an exact hunger point. I haven't tested this exact coding, if it's dysfunctional, alarm me and I'll take another shot. Quote Ability to punch trees (You can probably guess what character I'm making now) For this, check the coding of Deerclops in the Reign of Runts mod from the Steam Workshop. He also punches rocks and buildings, but this is the closest thing I can think of. Quote Have his hunger go down by like 1 or 2 whenever he attacks or does an action like digging Check the mod with Deerclops again. In there his Sanity goes up, but you can easily replace it with a Hunger drain. I've done something similar before, but it's only for attacks, not general actions. You might be able to use this and the Deerclops' coding to figure out something by the two. Spoiler local function OnHit(inst) --This whole coding segment goes into the bottom of your local master_postnit inst.components.hunger:DoDelta(-2) --Replace "-2" with the desired value. end inst:ListenForEvent("onhitother",OnHit) That's all I have at the moment. Research how others did similar perks with their custom characters by diving into their lua files. Happy coding! Edited January 2, 2021 by BillTheCipher Link to comment https://forums.kleientertainment.com/forums/topic/125575-help-needed-for-coding-a-few-perks-for-custom-character/#findComment-1412528 Share on other sites More sharing options...
Marmalade Posted January 2, 2021 Author Share Posted January 2, 2021 Thanks for your reply! I did what you did and dived in Deerclops' lua file for the reign of runts mod that I may have already dived into to search for lines of code to yoink before, And couldn't find anything inside Deerclops that could make my character be able to punch trees, and I don't know/see any character mods that have the ability to punch trees that I can use. Your code that causes him to lose hunger when he attacks works and I think I'll just settle with that, instead of it going down whenever he does an action. Your code that makes him slower when he is at or under 30 hunger (or 45 as my character's max hunger is 150, and 30% of 150 is 45) and it didn't work, But thanks for your help so far! Link to comment https://forums.kleientertainment.com/forums/topic/125575-help-needed-for-coding-a-few-perks-for-custom-character/#findComment-1412573 Share on other sites More sharing options...
Marmalade Posted January 9, 2021 Author Share Posted January 9, 2021 first time bumper bumping a bump where a bump is needed in a bump-less world Link to comment https://forums.kleientertainment.com/forums/topic/125575-help-needed-for-coding-a-few-perks-for-custom-character/#findComment-1415167 Share on other sites More sharing options...
YoshiPlayz Posted January 13, 2021 Share Posted January 13, 2021 Hi im making a couple new characters how do i do this were do i go also i can tell you my ideas if you want Link to comment https://forums.kleientertainment.com/forums/topic/125575-help-needed-for-coding-a-few-perks-for-custom-character/#findComment-1416218 Share on other sites More sharing options...
SuperMeatGoy Posted January 14, 2021 Share Posted January 14, 2021 On 1/13/2021 at 11:47 AM, YoshiPlayz said: Hi im making a couple new characters how do i do this were do i go also i can tell you my ideas if you want make your own thread lol Link to comment https://forums.kleientertainment.com/forums/topic/125575-help-needed-for-coding-a-few-perks-for-custom-character/#findComment-1416745 Share on other sites More sharing options...
. . . Posted January 15, 2021 Share Posted January 15, 2021 you can maybe look into woodie werebeaver form he can chop trees with nothing equipped idk Link to comment https://forums.kleientertainment.com/forums/topic/125575-help-needed-for-coding-a-few-perks-for-custom-character/#findComment-1417014 Share on other sites More sharing options...
Marmalade Posted January 15, 2021 Author Share Posted January 15, 2021 1 hour ago, --- -.- said: you can maybe look into woodie werebeaver form he can chop trees with nothing equipped idk Big brain Idea there, but once I dive into Woodie's files I don't see anything there that could help (or work) 1 Link to comment https://forums.kleientertainment.com/forums/topic/125575-help-needed-for-coding-a-few-perks-for-custom-character/#findComment-1417078 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