Jump to content

Recommended Posts

I have a question/request regarding something @SuperDavid said in a thread in General Discussion:

Quote

Only entities with a Sanity component can attack nightmare creatures, I have a custom pet hound but he has Sanity and he is able to attack nightmare creatures with me.

Since human is the only creature in all of plane of existence that possess sanity then only humans can sense nightmare creatures, I think nightmare creatures cannot even sense other nightmare creatures because they always start bumping into each other  trying to shove each other out of the way like they can't see each other or maybe they're just stupid.

(Pardon me if this is a dumb question since I don't know the first thing about coding.)

Is it possible to mod Abigail to be able to attack nightmare creatures as well? Either with that Sanity method, or by using Bernie's code? (Haunting your living twin sister is sort of like being an imaginary friend like Bernie! Wendy could certainly use the help against nightmares because of her weaker base damage.)

I *think* this is the relevant code for how Bernie senses nightmare creatures? It's from steam/steamapps/common/Don't Starve Together/data/databundles/scripts.zip in scripts/brains/berniebrain.lua

Quote

local function IsTauntable(inst, target)
    return target.components.combat ~= nil
        and not target.components.combat:TargetIs(inst)
        and target.components.combat:CanTarget(inst)
end

local function FindShadowCreatures(inst)
    local x, y, z = inst.Transform:GetWorldPosition()
    local ents = TheSim:FindEntities(x, y, z, TAUNT_DIST, { "shadowcreature", "_combat", "locomotor" })
    for i = #ents, 1, -1 do
        if not IsTauntable(inst, ents) then
            table.remove(ents, i)
        end
    end
    return #ents > 0 and ents or nil
end

local function TauntCreatures(self)
    local taunted = false
    if self._targets ~= nil then
        for i, v in ipairs(self._targets) do
            if IsTauntable(self.inst, v) then
                v.components.combat:SetTarget(self.inst)
                taunted = true
            end
        end
    end
    if taunted then
        self.inst.sg:GoToState("taunt")
    end
end

(Abigail doesn't need to taunt the nightmare creatures, just be able to target and damage them when they attack Wendy or when Wendy attacks them.)

Anyway, thank you for taking the time to read this! Any help from anyone is greatly appreciated. :)

Edited by Squats

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
×
  • Create New...