Jump to content

Recommended Posts

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! :D

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 by BillTheCipher

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!

 

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) 

  • Sad Dupe 1

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