Jump to content

[Help Request] Sanity Perk Near Koalefants


Recommended Posts

Hello!

I hope I'm making this post properly, it's my first time posting here!

 

Long story short, I'm trying to make a character mod for my friend's birthday. She really loves Koalefants, so I'm kind of building the whole character around that. I'm doing pretty well so far considering it's my first time ever making a mod of any sort, but I'm a little hung up on the sanity part.

 

The way I'm thinking of it is like the way Willow gains sanity near fire, I want this character to gain sanity near Koalefants. How would I go about doing this?

 

I apologize for my lack of knowledge on the subject. I'll try my best to understand!

 

And thanks in advance. I appreciate any help I get :)

Link to comment
Share on other sites

@lozersneeze
Yup, it's implemented the same way Willow gains sanity from being close to fire:

    local function sanityfn(inst)        local x,y,z = inst.Transform:GetWorldPosition()	        local delta = 0        local ents = TheSim:FindEntities(x,y,z, 20, {"koalefant"})        for k,v in pairs(ents) do             local bonus_sanity = TUNING.SANITYAURA_LARGE            local distsq = math.max(inst:GetDistanceSqToInst(v),1)            delta = delta + bonus_sanity/distsq        end        return delta    end        inst.components.sanity.custom_rate_fn = sanityfn

A little problem here though: Koalefants will run away as soon as they see her; you'll need to tamper with their brains a bit to make her an exception. You can also add them a trader component and play around with them a bit more in order to make them follow her/fight for her.

Link to comment
Share on other sites

@lozersneeze

Yup, it's implemented the same way Willow gains sanity from being close to fire:

    local function sanityfn(inst)        local x,y,z = inst.Transform:GetWorldPosition()	        local delta = 0        local ents = TheSim:FindEntities(x,y,z, 20, {"koalefant"})        for k,v in pairs(ents) do             local bonus_sanity = TUNING.SANITYAURA_LARGE            local distsq = math.max(inst:GetDistanceSqToInst(v),1)            delta = delta + bonus_sanity/distsq        end        return delta    end        inst.components.sanity.custom_rate_fn = sanityfn

A little problem here though: Koalefants will run away as soon as they see her; you'll need to tamper with their brains a bit to make her an exception. You can also add them a trader component and play around with them a bit more in order to make them follow her/fight for her.

 

I've been researching the code from another character mod to make it so that Koalefants will follow her if she feeds them, so that shouldn't be too much of an issue.

 

Sorry for my ignorance, but where would I put that code? in the modmain.lua? And if so, does it matter where I stick it in there?

 

Thank you so much for taking the time to help me out :)

Link to comment
Share on other sites

So, I'm having a bit of trouble getting this to work... Whenever I try to turn on the mod, I get this, and I'm not quite sure how to fix it:

 

 

...n/dont_starve/data/scripts/prefabs/player_common.lua:150: bad argument #1 to 'pairs' (table expected, got function)

LUA ERROR stack traceback:
        =[C] in function 'pairs'
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/prefabs/player_common.lua(150,1)
        =(tail call) ?
        C:/Program Files (x86)/Steam/steamapps/common/dont_starve/data/scripts/mainfunctions.lua(74,1)
        =(tail call) ?
        =[C] in function 'xpcall'

 

I'm beginning to feel like I've bitten off more than I can chew here since I have ZERO experience with anything like this, but I'd really like to get it done for her :(

 

If anyone would be willing to help me figure out how to code a couple perks, I'd be so grateful!

 

This is what I'd like for the perks:

 

Sanity boost near Koalefants

Can tame a Koalefant (probably by feeding it something)

Can move fast

 

Any help would be wonderful :)

Link to comment
Share on other sites

@lozersneeze, Did you mean to be making your mod in the single-player Don't Starve folder (or posting this in the DST mod section)? Mismatch there :p

 

Looking at single-player's player_common, though, it looks like it's crashing on starting_inventory. My guess is that you're passing the wrong set of arguments to MakePlayerCharacter -- in DS singleplayer, for example, you only pass one function (usually called simple "fn"), while in DST you need to pass two, usually called "common_postinit" and "master_postinit".

Link to comment
Share on other sites

@lozersneeze, Did you mean to be making your mod in the single-player Don't Starve folder (or posting this in the DST mod section)? Mismatch there :razz:

 

Looking at single-player's player_common, though, it looks like it's crashing on starting_inventory. My guess is that you're passing the wrong set of arguments to MakePlayerCharacter -- in DS singleplayer, for example, you only pass one function (usually called simple "fn"), while in DST you need to pass two, usually called "common_postinit" and "master_postinit".

 

I am in fact trying to make it for DST, but my lack of knowing anything about making a mod is making it incredibly hard for me to do lol. 

 

I've decided to go a more simple route (although being able to have a sanity perk near koalefants would be great).. I've created an item for the character to wear in game that gives sanity (which I have working) and will also make nearby koalefant follow her and protect her (which I don't have working).

 

I was thinking something along the lines of what a Spider Hat would do, but with koalefants and it doesn't perish. I'm looking at the code for the Spider Hat and I'm just utterly lost. I've been at this for 3 days now and I've scrapped the code for the character and rethought the perks more times than I'd care to admit just because I'm so inexperienced with anything like this.

 

At this point, I'm able to load the character into the game, her hat gives a sanity perk, the art looks great, she runs at the speed I want her to run at.. I just need to make koalefants follow her lol

Link to comment
Share on other sites

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
 Share

×
  • Create New...