Jump to content

[SOLVED] Can't Modify Ghost Aggro


Recommended Posts

EDIT2: You need to use TheWorld.ismastersim to check whether serverside in those functions or it will crash when on a server. Didn't figure that out till after I made this post, but it's not really a hard fix.

EDIT: Nevermind, I went back after a while of solving other problems and finally figured it out. It turns out that the ghost doesn't "attack", it just has an aura component that damages everything around it (I didn't know what this was at the time).

Overriding the follow behavior was a bit harder because the follow function in the brain was a local one which i could not directly override.

For the curious, this is what I did:

-Don't aggro

local function IgnoreYuyu(inst)	
	local follow_node = nil
    for i,v in ipairs(inst.bt.root.children) do
        --print(v.name)
        if v.name == "Follow" then
            --print("Node found:", v.name)
            follow_node = v
			break
        end
    end
	
	if follow_node then
		old_target = follow_node.target
		follow_node.target = function() 
			ent = old_target()
			if ent and ent:HasTag("yuyuko") then
				return nil
			end
			return ent
		end
	end
end

AddBrainPostInit("ghostbrain", IgnoreYuyu)

-Don't harm

local function NonSaneGhost(inst)
	-- Exclude yuyuko (the character) from things that are damaged by the aura
	table.insert(inst.components.aura.auraexcludetags, "yuyuko")

	-- Make sanity drain calc return 0 if observer is yuyuko
	inst.components.sanityaura.aurafn = function(instance, observer)
		return observer:HasTag("yuyuko") and 0 or inst.components.sanityaura.aura
	end
end

AddPrefabPostInit("ghost", NonSaneGhost)

 

ORIGINAL TEXT

Quote

 

I'm trying to make a character to whom ghosts are friendly. While I have succeeded at negating the sanity drain via the ghost's sanityaura.aurafn, I haven't been able to figure out how to make the ghost not follow and attack.

Long story short I discovered that:

  • ghost doesn't use combat.targetfn (it's nil by default) so changing that doesn't do anything
  • ghostbrain's GetFollowTarget is nil at the time AddBrainPostInit is executed, so I can't seem to change that either

Spent several hours trying to decipher this with no luck, so I'm finally throwing in the towel and asking for help :wilsondisapproving:

 

 

Edited by code4240
Solved my own question
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...