Jump to content

Making a character "allergic" to monsters other than bee's

Recommended Posts

My current character I've been developing is supposed to be very frightened of spirits and shadow creatures, so I figured they should also take more damage from them. I looked into Walter's code for being allergic to bee's, but the only thing in his script is a tag in postinit that sets him as allergictobees.

It seems the damage increase, from what I can tell, is done in the bee's script, condensed here:

local function bonus_damage_via_allergy(inst, target, damage, weapon)
    return (target:HasTag("allergictobees") and TUNING.BEE_ALLERGY_EXTRADAMAGE) or 0

If I wanted to make this work for shadow creatures, is there a way to properly append functions onto the vanilla game, like a version of this one made for shadow creatures (example here), or do I have to do a workaround, like replacing the shadow creatures script with my own completely?

Edited by DocterRedstone
forgot to link to example
Link to comment
Share on other sites

You'll need to add some code to the shadow creatures, for example:

AddPrefabPostInit("crawlinghorror", function(inst) -- AddPrefabPostInit for the shadow creature
	local function bonus_damage_via_fear(inst, target, damage, weapon) -- Bonus damage function
		return (target:HasTag("shadowfear") and TUNING.BEE_ALLERGY_EXTRADAMAGE) or 0 -- You can set the tag to whatever you want. TUNING.BEE_ALLERGY_EXTRADAMAGE is 10 but you can set it to whatever you want.

	inst.components.combat.bonusdamagefn = bonus_damage_via_fear -- Setting the function for bonus damage

You need to add this to all of the shadow creatures.

Then just add the tag to your character:



  • Like 1
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

  • Create New...