Jump to content

Recommended Posts

Hello, 

I am making a bee themed character of a friend for her birthday. I am looking for help on making it so bees won't attack the character when she is harvesting honey or during the spring. I was able to make it so the wasps hives do not attack, but I have not figured out how to apply the code to the bee box and spring time angry bees. Any help is greatly appreciated as her birthday is in a week and I am running out of time! This is the last piece I need to complete the mod.

Here is what I have for making bees not attack: (in modmain) 

local function FriendlyWaspInit(prefab)
	local function OnNearBy(prefab, target)
	if prefab.components.childspawner ~= nil and not target:HasTag("beefriend") then
        prefab.components.childspawner:ReleaseAllChildren(target, "killerbee")
    end

	end
	
	if prefab.components.playerprox then
	prefab.components.playerprox:SetOnPlayerNear(OnNearBy)
	end
end

AddPrefabPostInit("wasphive", FriendlyWaspInit)

 

AddPrefabPostInit("beebox", function(inst)
	if not GLOBAL.TheWorld.ismastersim then return end
	if inst.components.childrenspawner then
		local _ReleaseAllChildren = inst.components.childrenspawner.ReleaseAllChildren
		inst.components.childrenspawner.ReleaseAllChildren = function(self, target, prefab,...)
			return not target:HasTag("beefriend") and _ReleaseAllChildren(self, target, prefab, ...)
		end
	end
end)

This should do it for when you harvest you won't release the bees, as for preventing them from aggroing onto you in spring you'll need to mess with the retarget code. Easiest way is to just give your character the plantkin tag if you are super short for time.

  • Health 1
19 hours ago, IronHunter said:

AddPrefabPostInit("beebox", function(inst)
	if not GLOBAL.TheWorld.ismastersim then return end
	if inst.components.childrenspawner then
		local _ReleaseAllChildren = inst.components.childrenspawner.ReleaseAllChildren
		inst.components.childrenspawner.ReleaseAllChildren = function(self, target, prefab,...)
			return not target:HasTag("beefriend") and _ReleaseAllChildren(self, target, prefab, ...)
		end
	end
end)

This should do it for when you harvest you won't release the bees, as for preventing them from aggroing onto you in spring you'll need to mess with the retarget code. Easiest way is to just give your character the plantkin tag if you are super short for time.

Thank you so much for your help! I tried the bee box code you posted and put it in modmain and unfortunately it didn't work. 

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