Dudeguy Posted March 6, 2015 Share Posted March 6, 2015 I have a character I'm making, and I want to make a certain hostile animal, like a killer bee, a tall bird, or a beefalo in heat, not attack my character. I know might need to say something along the lines of"If my character attacks a Beefalo, then the beefalo should target my character, or else if the beefalo is targeting my character, then stop targeting."But I don't quite know how to say that in lua code. I know the syntax would probably work, I'm just in the dark on what to put in between all the ifs and thens. Link to comment https://forums.kleientertainment.com/forums/topic/51780-help-with-making-hostile-things-neutral-to-a-certain-character/ Share on other sites More sharing options...
rezecib Posted March 6, 2015 Share Posted March 6, 2015 (edited) @Dudeguy, Hmm, well, for beefalo you could use the same construct as the beefalo hat, inst:AddTag("beefalo")-- although you'll have to re-add it when unequipping the beefalo hat, since it removes it. Like this in the modmain:AddPrefabPostInit("beefalohat", function(inst) if GLOBAL.TheWorld.ismastersim then local old_unequip = inst.components.equippable.onunequipfn inst.components.equippable.onunequipfn = function(inst, owner) old_unequip(inst, owner) if owner.prefab == "mycharacter" then inst:AddTag("beefalo") end end endend)From tallbirdbrain, it looks like you can use the same approach-- inst:AddTag("tallbird"). There are no tallbird hats, so you shouldn't have to worry about catching any special cases. The analogous thing for killer bees looks to be inst:AddTag("insect"), but that may have some unintended consequences (mosquitos maybe?). You could also overwrite the killer bee's retarget function to exclude a tag that you give your character, for example:local function KillerRetarget(inst) return FindEntity(inst, 8, function(guy) return inst.components.combat:CanTarget(guy) end, nil, {"insect", "my_character_tag"}, {"character","animal","monster"} )endAddPrefabPostInit("killerbee", function(inst) if GLOBAL.TheWorld.ismastersim then inst.components.combat:SetRetargetFunction(2, KillerRetarget) endend) Edited March 6, 2015 by rezecib Link to comment https://forums.kleientertainment.com/forums/topic/51780-help-with-making-hostile-things-neutral-to-a-certain-character/#findComment-619574 Share on other sites More sharing options...
SenL Posted March 6, 2015 Share Posted March 6, 2015 Cool info.A question on this: "inst.components.combat:SetRetargetFunction(2, KillerRetarget)" The 2 here is also in bee.lua. Is there a way to not hardcode it on the character lua? Link to comment https://forums.kleientertainment.com/forums/topic/51780-help-with-making-hostile-things-neutral-to-a-certain-character/#findComment-619706 Share on other sites More sharing options...
rezecib Posted March 6, 2015 Share Posted March 6, 2015 @SenL, local period = inst.components.combat.retargetperiodinst.components.combat:SetRetargetFunction(2, KillerRetarget)inst.components.combat.retargetperiod = period Link to comment https://forums.kleientertainment.com/forums/topic/51780-help-with-making-hostile-things-neutral-to-a-certain-character/#findComment-619738 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now