Jump to content

Help with character modding (Nightmare creature agression)


Recommended Posts

I have a character who has a primary downside of drawing nightmare aggression regardless of sanity level

What this would mean in more detail is that once he would get to the threshold of beginning to see nightmare creatures, that unlike normal players who would only be able to see them as semi-translucent but still passive until a bit lower, he'd instead have them agro onto him as if he were at below the insanity threshold fully even though he isn't

I'm wondering if something like this is easily possible or if anyone may have some pre-existing knowledge on what the code in this perk would look like? If anyone has any information at all on a topic like this I would incredibly grateful, and thank you anyone reading for entertaining my inquiry   

Edited by OldManDan
Link to comment
Share on other sites

Perhaps it would be a good idea to look at the bone helms code, since when you unequip it, it immediately gets the aggro of all shadow creatures, I'm not 100% certain if it's the shadow shadowdominance or shadowlevel component though 

Link to comment
Share on other sites

Posted (edited)

I've looked for a hot minute now and I cant seem to find out where the "skeletonhat" prefab is, most I can find is a "skeletonhat_shadowhelmet.dyn" and I believe that's just assets

Looking into those components though, and it looks pretty promising, just need to troubleshoot how they work

Edited by OldManDan
Link to comment
Share on other sites

That did help, thank you!

Alrighty so upon looking a bit deeper I believe I'm pretty sure what those two tags do. "shadowdominance" is the tag that makes nightmare creatures passive to the player using this string of code using the ShadowSubmissive part in the "nightmarecreature.lua"

local function CLIENT_ShadowSubmissive_HostileToPlayerTest(inst, player)
    if player:HasTag("shadowdominance") then
        return false
    end
    local combat = inst.replica.combat
    if combat ~= nil and combat:GetTarget() == player then
        return true
    end
    local sanity = player.replica.sanity
    if sanity ~= nil and sanity:IsCrazy() then
        return true
    end
    return false
end

As for "shadowlevel", I'm fairly certain that's just Maxwell's shadow magic buisness at work.

What I'm trying to figure out from looking at these tags and their code, along with the code of "nightmarecreature.lua" and "sanity.lua", is how nightmare creature aggression works and how I can use it to make a character that is perpetually in a state semi-insanity, to where they always get targeted by shadow creatures that have spawned regardless of their sanity level, without spawning nightmare creatures until they actually start going into the lower sanity levels

I'm just really not code savvy enough to figure out how I'd implement this

But any bit of information on this helps!

 

 

Link to comment
Share on other sites

HOLD UP WAIT FOUND IT OUT     First off credit to this post it is very unfortunate I didn't find this sooner but I'm so glad I found it now

So basically how this works is you make a prefab to do a check for any creature with the tag "shadow" and later run a "v.components.combat:SuggestTarget(inst)" so if any shadow creature isn't already attacking something it targets you, regardless of sanity

Here is their code repurposed for "shadow" creatures

    -- Nightmare agression
    if not inst.aggro_task then
  inst.aggro_task = inst:DoPeriodicTask(3, function()
      local x,y,z = inst.Transform:GetWorldPosition()
      --TheSim:FindEntities(x, y, z, radius, musttags, canttags, mustoneoftags)
      for k, v in pairs(TheSim:FindEntities(x, y, z, 12, {"shadow"}, {"player","INLIMBO"})) do
        if not (v.components.follower and v.components.follower:GetLeader())then
          v.components.combat:SuggestTarget(inst)-- "could also use SetTarget to force them to target us, suggest means if they aren't targeting something already we will become their target."
        end
      end
    end)

Thankfully I found this trait's coding had alot more to do with mob targeting than sanity components

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...