Jump to content

Recommended Posts

So, I've been working on a character mod mod for some time now, and I want to make a character to whom some of the mobs would be passive, while he gets sanity drain on attacking all monsters/animals in game.

I have managed to achieve passive tallbirds with the following, plan to do same with beefalo and frogs

local function PassiveUntilAttack(self)
	if self.inst.prefab ~= "tallbird" then
		return
	end
	
	local _SetRetargetFunction = self.SetRetargetFunction
	self.SetRetargetFunction = function(self, period, fn)
		if fn then
			local _fn = fn
			fn = function(...)
				local _target = _fn(...)
				if _target and _target.HasTag("magizoologist") then
					return
				end
				return _target
			end
		end
		return _SetRetargetFunction(self, period, fn)
	end
end

AddComponentPostInit("combat", PassiveUntilAttack)


local function tallbirdpostinit(inst)
	if not GLOBAL.TheWorld.ismastersim then
		return
	end
	
	if inst.components.combat then
		inst.components.combat:SetRetargetFunction(3, Retarget)
	end
end

AddPrefabPostInit("tallbird", tallbirdpostinit)

The character looses sanity on attacking, like this:

	inst:ListenForEvent("onattackother", function(inst, data) 
	if data.target.prefab == "tallbird" then
	inst.components.sanity:DoDelta(-TUNING.SANITY_TINY)
	end
	end)

So, I wonder, if there is a shorter way to get sanity drain from attack, as I really don't want to copy/paste this for every mob in game.... Can I make it depend on tags which mobs have and set different sanity drain for monsters/bosses/prey?

And last but not least: is there a possibility to make bunnymen passive to this character even when he has meat in the inventory? Preferably without modifying bunnymen's prefab?

 

Thank you in advance)

Link to comment
https://forums.kleientertainment.com/forums/topic/86577-passive-bunnymen/
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...