Jump to content

Coding help for specific damage immunity


Recommended Posts

Hi!  I'm just making a mod for fun and I'm pretty new to it.  I've gotten just about everything done except for a few final touches I'm having trouble with.  
I'd like to make the character immune to damage dealt by plant based monsters and plant based items (ie. spiny bush will no longer cause damage by picking it, eyeplants won't cause damage from biting, etc) I currently have no knowledge of how to do this.  I thought it might possibly be like Willow's fire resistance, but simply copying that code and replacing it will individual plant prefabs won't work of course. 

 

Can anyone help me out with this?  Possibly give me a code that I can work from?

 

 

Link to comment
Share on other sites

I think the best way to do this may be to use a function called "AddPrefabPostInit". Basically, it takes a prefab and changes it after loading the world.

Here's my idea in a concept. I didn't test it, but I explained the individual bits after the "--".

local function NoThorns(inst) --we need a function that says what to change    inst.components.pickable.onpickedfn = nil --remove the bit that hurtsendif GLOBAL.GetPlayer() == "Replace" then --make sure this only applies to your character!    AddPrefabPostInit("marsh_bush",NoThorns) --the marsh bush will loose the properties removed aboveend

It would be tricky for lureplants, since the combat component doesn't really care about the target all that much. It should be possible to restore the taken damage instantly, but that still can kill you.

Link to comment
Share on other sites

I think the best way to do this may be to use a function called "AddPrefabPostInit". Basically, it takes a prefab and changes it after loading the world.

Here's my idea in a concept. I didn't test it, but I explained the individual bits after the "--".

local function NoThorns(inst) --we need a function that says what to change    inst.components.pickable.onpickedfn = nil --remove the bit that hurtsendif GLOBAL.GetPlayer() == "Replace" then --make sure this only applies to your character!    AddPrefabPostInit("marsh_bush",NoThorns) --the marsh bush will loose the properties removed aboveend

It would be tricky for lureplants, since the combat component doesn't really care about the target all that much. It should be possible to restore the taken damage instantly, but that still can kill you.

 

I tested this out and tried fiddling with it a bit, but couldn't get it to work, all it did was crash the game when I tried to apply the mod.  Though that might just be my lack of knowledge with these codes.  

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...