vacantVisionary Posted September 11, 2019 Share Posted September 11, 2019 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 More sharing options...
Ultroman Posted September 11, 2019 Share Posted September 11, 2019 It looks like it should work, since bees also only have the "cattoyairborne" tag, and not any of the other two tags targeted by Catcoons, which are "cattoy" and "catfood". Link to comment Share on other sites More sharing options...
vacantVisionary Posted September 11, 2019 Author Share Posted September 11, 2019 Hm. Well, it doesn't seem to be working on my end? Catcoons still won't attack Glommer but they do attack bees. Link to comment Share on other sites More sharing options...
Ultroman Posted September 11, 2019 Share Posted September 11, 2019 Well, maybe they don't attack it because it is a cattoyairborne, but because bees are not something their attack-filter excludes. I don't know. Link to comment Share on other sites More sharing options...
vacantVisionary Posted September 11, 2019 Author Share Posted September 11, 2019 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 More sharing options...
Ultroman Posted September 11, 2019 Share Posted September 11, 2019 (edited) 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 September 11, 2019 by Ultroman Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now