Jump to content

[HELP] Remove monster insanity aura/increase shadow damage?


Recommended Posts

I'm trying to write a character that does not suffer from insanity auras specifically from monsters, but still loses some (not as much) sanity from bosses (probably around -25 per min??)

I figured out how to remove sanity auras from specific monsters like spiders, but I don't want to adjust insanity auras for every single monster in the game. How can I change this so it specifically affects monsters under the "monster" tag and "epic" tag (for bosses)?

Additionally, this same character takes significantly more damage from shadow monsters (such as crawling horrors, terrorbeaks, and shadow pieces). How can I adjust the damage he takes from specific monsters and/or monsters under a tag? Thank you :D

Link to comment
Share on other sites

13 hours ago, Flare30 said:

 

Additionally, this same character takes significantly more damage from shadow monsters (such as crawling horrors, terrorbeaks, and shadow pieces). How can I adjust the damage he takes from specific monsters and/or monsters under a tag? Thank you :D

Use

    inst:ListenForEvent("attacked", OnAttacked)

Then set a "OnAttacked" function so the character receive additionnal damage if the attacker has the right tag. Search stuff like "data.attacker" so you'll probably find some examples, and "GetAttacked" for example of additional damages.

 

Link to comment
Share on other sites

11 hours ago, Lumina said:

Then set a "OnAttacked" function so the character receive additionnal damage if the attacker has the right tag. Search stuff like "data.attacker" so you'll probably find some examples, and "GetAttacked" for example of additional damages.

Managed to get it working after fiddling with bonusdamage stuff. Thanks for the help Lumina.  If anyone could help me with the sanity drain too, that'd be appreciated!

Link to comment
Share on other sites

If you remove the auras from all the monsters, then all other characters on the server also aren't affected by them. That's a bad solution.

If you look at the sanity component, it has a very convenient "neg_aura_mult", which is normally set to 1. If you set that to 0, then no negative auras will affect your character. That might not be exactly what you want, but it's very unintrusive. You could expand on this, by creating your own component, which checks for specific auras, and applies sanity drain appropriately, like this code from the sanity component does:

    local x, y, z = self.inst.Transform:GetWorldPosition()
    local ents = TheSim:FindEntities(x, y, z, TUNING.SANITY_EFFECT_RANGE, nil, { "FX", "NOCLICK", "DECOR","INLIMBO" })
    for i, v in ipairs(ents) do 
        if v.components.sanityaura ~= nil and v ~= self.inst then
            local aura_val = v.components.sanityaura:GetAura(self.inst) / math.max(1, self.inst:GetDistanceSqToInst(v))
            aura_delta = aura_delta + (aura_val < 0 and (self.neg_aura_absorb > 0 and self.neg_aura_absorb * -aura_val or aura_val) * self.neg_aura_mult or aura_val)
        end
    end

Remember, this code is from within the game source code, so it will need tweaking to work when placed in a mod.

Another version of the above, would be to leave the "neg_aura_mult" alone, and simply make a new component which adds back any sanity loss from certain auras, by doing the same calculations, but adding instead of subtracting. Something like that.

I would strongly advise you to not just override Recalc in the sanity component, since it's a huge piece of code, and would make your character incompatible with the popular mod Sanity Tuner.

Edited by Ultroman
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...