Jump to content

Recommended Posts

As the title says I've been trying to figure how this could be achievable--at least with the limited amount of knowledge I have with Lua since this is my first modding project. I've been mainly learning programming off of the simple crash courses and reading the game scripts themselves. I know in Wormwood's skill tree his Bee Kind skill does the exact thing that I'm looking for, however I don't see it anywhere when I look in the files so I'm kind of clueless. Would really appreciate the help!

Apparently Wormwood's checks will only see if his skill is activated and prevents butterflies from flying away from him, no tags involved.. This is stored inside a butterfly's brain file, so that's a bit beyond my knowledge.

I do not really see any possible solutions to this myself. Hopefully others can help, though.

  • Like 2

:distracted:

AddGlobalClassPostConstruct("behaviours/runaway", "RunAway", function(self)
    local _shouldrunfn = self.shouldrunfn or function() return true end
    function self.shouldrunfn(hunter, inst)
        if inst.prefab == "butterfly" and hunter:HasTag("player") then
            return false
        else
            return _shouldrunfn(hunter, inst)
        end
    end
end)
  • Like 3
AddBrainPostInit("butterflybrain", function(brain) --print(brain) if u need to debug
	local runaway
	for i,node in ipairs(brain.bt.root.children) do
		if node.name == "RunAway" then
			runaway = node
			break
		end
	end
	if not runaway then
		print("[butterflybrain] Couldn't find the 'RunAway' behaviour in this brain!")
		return
	else
		runaway.hunternotags = runaway.hunternotags or {}
		table.insert(runaway.hunternotags, "butterflywhisperer")
	end
end)

Anything with the "butterflywhisperer" tag will not have the butterfly run away

Edited by oregu
  • Like 3
8 hours ago, yanecc said:

:distracted:

AddGlobalClassPostConstruct("behaviours/runaway", "RunAway", function(self)
    local _shouldrunfn = self.shouldrunfn or function() return true end
    function self.shouldrunfn(hunter, inst)
        if inst.prefab == "butterfly" and hunter:HasTag("player") then
            return false
        else
            return _shouldrunfn(hunter, inst)
        end
    end
end)
7 hours ago, oregu said:
AddBrainPostInit("butterflybrain", function(brain) --print(brain) if u need to debug
	local runaway
	for i,node in ipairs(brain.bt.root.children) do
		if node.name == "RunAway" then
			runaway = node
			break
		end
	end
	if not runaway then
		print("[butterflybrain] Couldn't find the 'RunAway' behaviour in this brain!")
		return
	else
		runaway.hunternotags = runaway.hunternotags or {}
		table.insert(runaway.hunternotags, "butterflywhisperer")
	end
end)

Anything with the "butterflywhisperer" tag will not have the butterfly run away

Both of these work really well! Thanks a bunch for the help I would've no idea what to do otherwise.

 

 

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