Jump to content

Recommended Posts

I'm writing a mod in which the character I've created is scared of a canon character.

I won't go into details, but this mod character's prefab is "will", and I need him to have a very small (We're talking Evil Flower small) sanity drain around Wilson because he's scared of him. (If this works, I'll do sanity tuning for other characters too.)

I've tried some of the codes that were put up in the forums, but, nothing. Is it possible for a specific character to have a drain? Or a specific player?

 

For the record, I don't want to use

    inst:AddComponent("sanityaura")
    inst.components.sanityaura.aura = -TUNING.SANITYAURA_SMALL

Because this means Wilson will drain everybody's sanity.

I tried adding and changing up a code from spider.lua that looks for a tag on someone, or if their sanity is 0, to avoid the sanity drop. So I tried adding a "sciencephobia" tag to them but alas, nothing.

For the record, I have never worked in lua before.

Edited by DextersComicLaboratory
Wanted to add the code detail.

This can be locked, my friend @halfrose got it figured out. Now we just need to nerf the sanity loss. -40/min... I think that's the equivalent of Hounds or Spiders. I don't think Wilson is that traumatizing, lol.

On 1/16/2016 at 2:05 PM, DextersComicLaboratory said:

This can be locked, my friend @halfrose got it figured out. Now we just need to nerf the sanity loss. -40/min... I think that's the equivalent of Hounds or Spiders. I don't think Wilson is that traumatizing, lol.

 

Mind letting us know how you fixed it? It's good to answer the topic even if you fix it yourself because then other users with this problem can look to this thread for help.

Also I'm trying to do something similar so I'd like to know d:

Sure thing. I eventually reversed it and just used a positive sanity Aura around characters, since adding distance took away from teamwork. Regardless, this could be useful for a monster character of sorts!

 

1. Open up the prefab file for your character giving off the aura in the scripts folder, and look for local function master_postinit(inst)

Add the following code beneath master_postinit(inst) :

inst:AddComponent("sanityaura")

inst.components.sanityaura.aurafn = function(inst, observer)

if observer.prefab == "character_prefab" then

return -TUNING.SANITYAURA_SMALL

end

return 0

end

((Change character_prefab to your characters prefab, like "willow" or "wilson" or "wathgrithr".))

I think DarkXero posted this code? I know I was given the code, and for some reason we had problems at first. 

 

If it doesn't work, what I did was ad sanityaura.lua to a components folder inside of "scripts".

 

If this character giving off an aura is a canon character, you need to go to Steam\steamapps\common\Don't Starve Together\data\scripts\prefabs and copy the characters prefab into your mods' scripts\prefabs folder, and edit the lua in either Notepad++ or LuaEdit by pasting the code above into their master_postinit code branch.

Remember, when you do that, you are overriding the canon character's prefab. You need to be careful, since others might be doing the same thing in their mod. If you get two overrides, expect bugs or even crashes. 

If you want to make it a positive aura, just change return -TUNING.SANITYAURA_SMALL to just return TUNING.SANITYAURA_SMALL

 

You get an aura approximately this big if you use SMALL and not something else like TINY or MED or LARGE:

tumblr_inline_o19v8eRqfC1r52aqk_540.png

Also, another note. The bigger the aura, the faster sanity will drain or regenerate.

 

Hope this helps!

Edited by DextersComicLaboratory

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