Jump to content

Help with character-based drops?


Recommended Posts

Hey! Just uh, I got a very basic understanding of what to do when it comes to modding. I'm trying to make my own character mod, and all my friends are like, "Every character has their own special ability! Even Wilson grows his own beard!" So, on that note, I'm trying to get the character I'm making to do two things specifically outside of the base stuff, and thats it.

1) More sanity gain from killing shadow creatures

2) More nightmare fuel from killed shadow creatures

Now, my issue is, I have absolutely no idea on how I would even begin to do this. :?

Link to comment
Share on other sites

This one is quite easy. You can do both in one fell swoop. Put this at the bottom of your modmain.lua. If I forgot some Shadow Creatures, just add the to the list of prefabs to change. You can easily add more loot and change the sanity gained. There are also ways to randomize it, but I think yu can handle those :) Just search for "random" in the game files or on the forum.

local prefabsToChange = {"crawlinghorror", "terrorbeak", "crawlingnightmare", "nightmarebeak"}

for i, v in ipairs(prefabsToChange) do
	AddPrefabPostInit(v, function(inst)
		if inst.components.combat_replica then
			local orig_onkilledbyother = inst.components.combat.onkilledbyother
			
			inst.components.combat.onkilledbyother = function(inst, attacker)
				if attacker.prefab == "CHARACTER_PREFAB_NAME" then
					-- Fling one nightmarefuel from the position of the shadow creature.
					inst.components.lootdropper:FlingItem(SpawnPrefab("nightmarefuel"), Vector3(inst.Transform:GetWorldPosition()))
					attacker.components.sanity:DoDelta(5) -- Get 5 sanity for the kill
					attacker.components.sanity:DoDelta(5, true) -- Same as above, but does not make the sanity badge "pulse"
				end
				if orig_onkilledbyother then
					orig_onkilledbyother(inst, attackertarget)
				end
			end
		end
	end)
end

 

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