Cowboypunkcolt Posted January 28, 2015 Share Posted January 28, 2015 Looking for some help to make an item that will alter the behavior of enemies when it's worn by the player (namely pacifying them or altering the range at which they see the player), and I simply don't know how to do that in particular. I dunno if this is something that can be accomplished through multiple means, but any ideas or information would be appreciated :> Link to comment https://forums.kleientertainment.com/forums/topic/49866-help-with-an-item-trait-that-triggers-changes-in-enemies/ Share on other sites More sharing options...
Zillvr Posted January 28, 2015 Share Posted January 28, 2015 I'm no modder but from what I know I think you could start looking at how the Spider Hat works, code-wise....and sadly, that's all the help I can give you. Hope that points you towards the right direction nonetheless. Link to comment https://forums.kleientertainment.com/forums/topic/49866-help-with-an-item-trait-that-triggers-changes-in-enemies/#findComment-606858 Share on other sites More sharing options...
Cowboypunkcolt Posted January 28, 2015 Author Share Posted January 28, 2015 I'm no modder but from what I know I think you could start looking at how the Spider Hat works, code-wise....and sadly, that's all the help I can give you. Hope that points you towards the right direction nonetheless. Thank you kindly, I'll give it a look and see if I can achieve the effect I'm looking for Link to comment https://forums.kleientertainment.com/forums/topic/49866-help-with-an-item-trait-that-triggers-changes-in-enemies/#findComment-606872 Share on other sites More sharing options...
Blueberrys Posted February 9, 2015 Share Posted February 9, 2015 (edited) @Cowboypunkcolt Example on how to change the target range of spiders.Note: This will affect spiders targeting any entity, even if it's not the player._G = GLOBALTUNING = _G.TUNINGFindEntity = _G.FindEntitylocal short_target_dist = 2local short_investigate_dist = 4local function spider_postinit(inst) -- Should probably preserve the functionality of this to improve compatibility.. local old_NormalRetarget = inst.components.combat.targetfn -- Copied from spider.lua local function NormalRetarget(inst) local targetDist = short_target_dist if inst.components.knownlocations:GetLocation("investigate") then targetDist = short_investigate_dist end local function enitity_search(guy) if inst.components.combat:CanTarget(guy) and not (inst.components.follower and inst.components.follower.leader == guy) then return guy:HasTag("character") end end return FindEntity(inst, targetDist, enitity_search) end inst.components.combat:SetRetargetFunction(1, NormalRetarget)endAddPrefabPostInit(spider_postinit)You should also be able to pacify the spiders in the enitity_search function by checking for the player's hat (or other equipment), then not returning the player if you find it.local function enitity_search(guy) if inst.components.combat:CanTarget(guy) and not (inst.components.follower and inst.components.follower.leader == guy) then if guy:HasTag("player") then local hat = guy.components.inventory.equipslots.HEAD and guy.components.inventory.equipslots.HEAD.prefab -- You can use another equip slot for other items if hat.prefab ~= "your_hat_prefab" then return guy:HasTag("character") end else return guy:HasTag("character") end endend Edited February 9, 2015 by Blueberrys Link to comment https://forums.kleientertainment.com/forums/topic/49866-help-with-an-item-trait-that-triggers-changes-in-enemies/#findComment-611301 Share on other sites More sharing options...
Cowboypunkcolt Posted February 9, 2015 Author Share Posted February 9, 2015 Oh, dang, thanks a ton! I'll see how I can apply and fiddle with this! Link to comment https://forums.kleientertainment.com/forums/topic/49866-help-with-an-item-trait-that-triggers-changes-in-enemies/#findComment-611350 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