Jump to content

Making an aggressive mob passive - help?


Recommended Posts

Sorry if this is easily answered, but this has been confusing me all day. My end goal is to make frogs not target my own character, but nobody else's. Obviously this isn't a particularly groundbreaking concept, so I went around the forums trying to get some information. Pretty much everybody agreed on what to do, so I did it too. However, I continue getting errors.

inst:AddTag("frogfriend")

done in the prefab file, adds the tag to my character, whatever. not a problem.

local function retargetfn(inst)    if not inst.components.health:IsDead() and not inst.components.sleeper:IsAsleep() then        return FindEntity(inst, TUNING.FROG_TARGET_DIST, function(guy)             if not guy.components.health:IsDead() then                return guy.components.inventory ~= nil            end        end,        {"_combat","_health"},-- see entityreplica.lua		{"frogfriend"}        )    endendAddPrefabPostInit("frog", function(inst)	if GLOBAL.TheWorld.ismastersim then		inst.components.combat:SetRetargetFunction(3, retargetfn)	endend)

copied straight from the frog.lua file and put in modmain, all I did was add the tag "frogfriend" to the list of tags to never target. My error message always comes up along the lines of "attempt to call global 'FindEntity' (a nil value)... in (field) targetfn".

 

I figure it has something to do with the "guy.components.inventory ~= nil" line, but im not sure since that was in the original frog code. I'd appreciate the help! ^^

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