Jump to content

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?

 

 

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

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