Jump to content

Saving Catcoons From Bees


Recommended Posts

I'm trying to do something very simple, which is to stop Catcoons from attacking Bees. The goal here is to prevent the Catcoons from getting themselves killed by aggroing an entire hive, because I feel bad when the cute cats die.

Anyways, I decided to start with an existing mod called Cat Friendly, which stops Catcoons from attacking Glommer. I added Bees and Killer Bees to the existing code, but it doesn't seem to be working. Any idea what I'm doing wrong?

modmain.lua

modinfo.lua

Link to comment
Share on other sites

Ok, so, I'm digging through the code, and this appears to be the function that lets the Catcoon choose its target. It looks like one of the options is to go after anything with the tag "monster" or "small creature," but I'm not quite sure. Is that what the code is saying here?

local function RetargetFn(inst)
    return FindEntity(inst, TUNING.CATCOON_TARGET_DIST,
        function(guy)
        	if guy:HasTag("catcoon") then
        		return 	not (inst.components.follower and guy.components.follower and inst.components.follower.leader ~= nil and inst.components.follower.leader == guy.components.follower.leader) and
        				not (inst.components.follower and guy.components.follower and inst.components.follower.leader == nil and guy.components.follower.leader == nil) and
        				guy.components.health and 
	            		not guy.components.health:IsDead() and 
	            		inst.components.combat:CanTarget(guy)
        	else
            	return 	((guy:HasTag("monster") or guy:HasTag("smallcreature")) and 
	            		guy.components.health and 
	            		not guy.components.health:IsDead() and 
	            		inst.components.combat:CanTarget(guy) and 
	            		not (inst.components.follower and inst.components.follower.leader ~= nil and guy:HasTag("abigail"))) and
            			not (inst.components.follower and guy.components.follower and inst.components.follower.leader ~= nil and inst.components.follower.leader == guy.components.follower.leader) and
            			not (inst.components.follower and guy.components.follower and inst.components.follower.leader ~= nil and guy.components.follower.leader and guy.components.follower.leader.components.inventoryitem and guy.components.follower.leader.components.inventoryitem.owner and inst.components.follower.leader == guy.components.follower.leader.components.inventoryitem.owner)
	            	or 	(guy:HasTag("cattoyairborne") and 
	            		not (inst.components.follower and guy.components.follower and inst.components.follower.leader ~= nil and inst.components.follower.leader == guy.components.follower.leader) and 
	            		not (inst.components.follower and guy.components.follower and inst.components.follower.leader ~= nil and guy.components.follower.leader and guy.components.follower.leader.components.inventoryitem and guy.components.follower.leader.components.inventoryitem.owner and inst.components.follower.leader == guy.components.follower.leader.components.inventoryitem.owner)) 
	        end
        end)
end

 

Link to comment
Share on other sites

Yes, because bees have the tag "smallcreature". You are reading it right.

But there is also another place with code for this; the catcoonbrain.lua in the "brains" folder. That has some code for what they can play with, while the targeting code seems to be in its prefab file.

But if you look at the targeting code, it requires that the CanTarget() function returns true, so if you just extend that function, and before returning the result of the original function, you just return false if the target is a bee.

Edited by Ultroman
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...