Jump to content

More help with my first character mod...


Recommended Posts

I need to add a tag to my custom character, such as, "robotwhisperer", that will make clockwork mobs be passive towards him. What code do I need to use to make sure the clockwork mobs detect the tag and then are passive?

 

Thanks

Link to comment
Share on other sites

local robots = {"knight", "rook", "bishop"}for _, robot in pairs(robots) do	AddPrefabPostInit(robot, function(inst)		local old_set = inst.components.combat.SetTarget		inst.components.combat.SetTarget = function(self, target)			if target and target:HasTag("robotwhisperer") then				local enemytarget = target.components.combat.target				if not (enemytarget and enemytarget:HasTag("chess")) then					return				end			end			return old_set(self, target)		end	end)end

In modmain should make the tag work.

Link to comment
Share on other sites

local robots = {"knight", "rook", "bishop"}for _, robot in pairs(robots) do	AddPrefabPostInit(robot, function(inst)		local old_set = inst.components.combat.SetTarget		inst.components.combat.SetTarget = function(self, target)			if target and target:HasTag("robotwhisperer") then				local enemytarget = target.components.combat.target				if not (enemytarget and enemytarget:HasTag("chess")) then					return				end			end			return old_set(self, target)		end	end)end

In modmain should make the tag work.

 

thanks!

 

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