Thank you all for taking the time to read this.
Me and my wife have taken up creating our own characters recently (she does the art, I do the coding). I'm not experienced by any means, I have almost zero experience doing anything like this, but I can read code and kind of make sense of what is going on and have been picking through other mods learning some things as I go.
Here are some things I haven't been able to work out on my own yet, and I'm hoping someone out there can help me.
1. Trigger instant insanity (sanity = 0) when a mandrake is killed near her.
-I tried this one for a little but I felt like there might be a simple command out there to make this work
2. She has a custom mandrake bush-hat. I'm looking to trigger an invincible state while she is hidden, aka "planted". However, I'm worried about being able to abuse invincibility in combat. The normal "hide" state doesn't stop Charlie or Hounds, and I'm trying to make this like an AFK-type mode, without someone being able to spam-hide to avoid damage (maybe something like a timer before triggering invincible state)
3. Following along the same line as #2, while I was working on the hat I started adding the tags like "equippable", "waterproofer", "insulator", etc. I was trying to make it where if I couldn't become "invincible", I could at least counter-act anything harmful that might occur during these "AFK periods".
I ended up with a code that looked like this:
However, using owner in the stopuse caused a crash. I tried adding " local owner = inst.components.inventoryitem.owner " above local hat AND below it (mimicking the onuse code, which was the only place I could see owner called out in any way special. Removing this from the stopuse lets me see that the onuse owner.hungerrate modifier is working, but not getting removed with stopuse.
(sidenote, healer is for on-use healing not health regen, which is what I am looking for, so healer component doesnt work for what i want)
3A) Is there any way I can fix this so I can call on player components in the stopuse like it did in the onuse to reset values?
3B) Is there a way I can add these things to an item so I don't have to mess with the player components?
--Health Regen (over time
--Insulation (Max / Min Temps), I don't want her freezing or overheating while "planted"
3C) Is there a way to bypass that altogether and set a ListenForEvent type thing with "mandrakebush_onuse" and "stopusingmandrakebush" in the character.lua? Essentially, I'm looking for something like this