Jump to content

Stop follower attacking other player's followers?


Recommended Posts

Hello,

I know this seems like a super easy question, but it's given me some trouble.  I discovered that the Lamb mod doesn't tag their followers as 'companions', so the trained hounds from my mod attack them.  Apparently none of the other checks to Not attack them flagged.  I tried adding this code, but it doesn't appear to have worked, and now I'm at a bit of a loss and could use some help.

or (not TheNet:GetPVPEnabled() and target:HasTag("hostile") and target.components.follower and target.components.follower.leader and target.components.follower.leader.name ~= inst.components.follower.leader.name)

 

Edited by FurryEskimo
Link to comment
Share on other sites

Perhaps this will work?

or (not TheNet:GetPVPEnabled() and (target.components.combat and target.components.combat.target ~= nil) and target.components.follower and target.components.follower.leader and target.components.follower.leader.name ~= inst.components.follower.leader.name)

 

Link to comment
Share on other sites

I use something like this. Perhaps this helps or not.

return (not pvp) and ((leader is a player) or (leader's owner is a player))
local aoe_must_tags = {"_health"}
local aoe_cant_tags = {"playerghost", "INLIMBO", "FX", "NOCLICK", "DECOR", "notarget", "noattack", "structure"}
local benign_tags = {"companion", "abigail"}
local hate_tags = {"hostile", "epic"}
local monstertags = {"monster", "playermonster"}
local pvp = TheNet:GetPVPEnabled()
if not pvp then
  table.insert(aoe_cant_tags, "player")
  table.insert(aoe_cant_tags, "domesticated")
end
local function CanFanAttack(owner, target, maxrad)
  if target:IsValid() and target.entity:IsVisible() and not target.components.health:IsDead() then
  else
    return false
  end
  local dp = target:GetPosition() - owner:GetPosition()
  local dx, dz = dp.x, dp.z
  local angle = math.abs(anglediff(owner.Transform:GetRotation(), math.atan2(-dz, dx) / DEGREES))
  if dp:LengthSq() > 1 and angle > maxrad then return false end
  if target.components.combat and target.components.combat:TargetIs(owner) then return true end
  local benign = not pvp
                   and (target:HasOneOfTags(benign_tags)
                     or (target.replica.follower and target.replica.follower:GetLeader() == owner))
  if benign then return false end
  local domesticated = target.components.domesticatable and (target.components.domesticatable.domestication or 0) > 0.2
  if domesticated then return false end
  local leader = target.replica.follower and target.replica.follower:GetLeader()
  if not pvp and leader and leader:HasTag("player") then return false end
  if target:HasOneOfTags(hate_tags) then return true end
  -- monster check
  if owner:HasOneOfTags(monstertags) ~= target:HasOneOfTags(monstertags) then return true end
  return false
end

 

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