Jump to content

Force attack stills target entities with "companion" tag


Recommended Posts

Hi everyone,

 

In Don't Starve Together, I can add "companion" tag to prefabs to indicate that they are friendly entities, and force attack action should ignore them.

However, I cannot do that in Don't Starve. The force attack only ignores followers, but still picks companion target. 

Does anyone know how force attack chooses targets in Don't Starve? How can I make it ignore some entities?  

Link to comment
Share on other sites

you can look into the combat.lua for the force attack target checking: 

 

function Combat:IsValidTarget(target)
    if not target 
	   or not target:IsValid()
       or not target.components
       or not target.components.combat
       or not target.entity:IsVisible()
       or not target.components.health
       or target == self.inst
       or target.components.health:IsDead()
       or (target:HasTag("shadow") and not self.inst.components.sanity)
       or Vector3(target.Transform:GetWorldPosition()).y > self.attackrange then
        return false
    else
		return true
	end
end

you could remove the combat component on your prefab or overwrite the force attack function

 

function Combat:ForceAttack()
    if self.target and self:TryAttack() then
        return true
    else
        self.inst:PushEvent("doattack")
    end
end

and add a special tag from your prefab to avoid attacking

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...