Jump to content

Recommended Posts

I took a look at it's prefab file and probably the only thing of interest it that is has a combat component. I'm pretty sure that tallbirds attack anything that gets close to their nests. The first thing I would think to do is to find some way of modifying some function in the combat component, probably a targeting system, to check if the one attacking is a tallbird and if the target is a grass gecko and then cancel the rest of the actions.

I think a good place to look for examples would be the eyeplant and wormwood. Eyeplants attack everyone except wormwood, so maybe there's a system of tags or a series of checks in one of the two files or component. Just whatever enemy/mob you can think of that has an exception (like webber and spiders)

5 hours ago, rawii22 said:

I took a look at it's prefab file and probably the only thing of interest it that is has a combat component. I'm pretty sure that tallbirds attack anything that gets close to their nests. The first thing I would think to do is to find some way of modifying some function in the combat component, probably a targeting system, to check if the one attacking is a tallbird and if the target is a grass gecko and then cancel the rest of the actions.

I think a good place to look for examples would be the eyeplant and wormwood. Eyeplants attack everyone except wormwood, so maybe there's a system of tags or a series of checks in one of the two files or component. Just whatever enemy/mob you can think of that has an exception (like webber and spiders)

Finally some help in this forum. Ok thanks man, I will take a look at the eyeplant and wormwood, thats a start.

in the tallbird lua there is the function where it is decided to target or not 

local function IsValidTarget(guy)
        return not guy.components.health:IsDead()
            and inst.components.combat:CanTarget(guy)
            --smallbirds that aren't companions are parented
            --to other tallbirds, so don't target them!
            and (not inst:HasTag("smallbird") or inst:HasTag("companion"))
    end

So the quick and dirty fix for you could be to just add the smallbird tag to the grasgeckos

AddPrefabPostInit("grassgekko", function(inst) 
	inst:AddTag("smallbird")
end)

The correct way would be to rewrite this "IsValidTarget" function in the tallbird lua.

 

Not sure if removing the combat component may help but you can try it this way:

AddPrefabPostInit("grassgekko", function(inst)
	if inst.components ~= nil and inst.components.combat ~= nil then
		inst:RemoveComponent("combat") 
	end
end)

But I think this will also end up that nobody can kill them at all.

2 hours ago, krylincy said:

in the tallbird lua there is the function where it is decided to target or not 


local function IsValidTarget(guy)
        return not guy.components.health:IsDead()
            and inst.components.combat:CanTarget(guy)
            --smallbirds that aren't companions are parented
            --to other tallbirds, so don't target them!
            and (not inst:HasTag("smallbird") or inst:HasTag("companion"))
    end

So the quick and dirty fix for you could be to just add the smallbird tag to the grasgeckos


AddPrefabPostInit("grassgekko", function(inst) 
	inst:AddTag("smallbird")
end)

The correct way would be to rewrite this "IsValidTarget" function in the tallbird lua.

 

Not sure if removing the combat component may help but you can try it this way:


AddPrefabPostInit("grassgekko", function(inst)
	if inst.components ~= nil and inst.components.combat ~= nil then
		inst:RemoveComponent("combat") 
	end
end)

But I think this will also end up that nobody can kill them at all.

Thank you man for this very well written code. I added this into my mainmod.lua, however the first bit of code for smallbird, did not work at all (they still attack them). Its strange, I would have assumed it would work, so thats a shame.
The second code however did exactly what you said. So no one can attack them., but I dont want that (just tallbird). 

Is there any other piece of code you know would work? 

Either way, thanks so very much for your help. I learned a lot from just that small bit of code you gave me. This forum felt dead until you came around man.

Edited by NamelessName

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