Isasinian Posted February 2, 2016 Share Posted February 2, 2016 So I searched the forums, found some nice threads with similiar topics, but overall I couldn't quite understand, even though I caught up to the point that it has something to do with targeting and recognizing the character as ie. a monster in case of Webber and spiders. So here's the question: Is it possible to make eyeplants neutral/friendly to your character, so the character won't be attacked by the eyeplants? Link to comment https://forums.kleientertainment.com/forums/topic/63699-eyeplants-and-their-hostility/ Share on other sites More sharing options...
Fidooop Posted February 2, 2016 Share Posted February 2, 2016 Make a postinit to the eyeplant via the modmain that replaces the retarget function and add in a condition that makes them not attack anything with a special tag. then give said special tag to your character! Link to comment https://forums.kleientertainment.com/forums/topic/63699-eyeplants-and-their-hostility/#findComment-716829 Share on other sites More sharing options...
Isasinian Posted February 3, 2016 Author Share Posted February 3, 2016 (edited) local function PlantsPostinit(inst) return FindEntity(inst, targetDist, function(guy) if inst.components.combat:CanTarget(guy) then return (guy:HasTag("character") and not guy:HasTag("monster")) end end) end local plants = {"eyeplant"} for k,v in pairs(plants) do AddPrefabPostInit(v, PlantsPostInit) end That's what I got so far since the morning. Tried to look into other mods that used similiar coding and I understood one thing - tagging is way too hard for me to imply them. I know that I had to write a code for retargeting like spiders used to have, but I couldn't make it to work as intended. So instead I started substract some code lines and add other ones, just to see if it starts working. In addition, from what I saw in many, many, MANY various threads - coding looked absolutely similiar, yet different. Tried to merge few lines, added my own coding and - what you can see above - I aoimn-\[ctually got a code that doesn't pop up an error, but also doesn't work at all. Any ideas on what am I missing in here? Yes, I did add the "plantlike" tag to the character's modinfo.lua. I didn't mention I'm using DST Extended Sample Character. Is there any difference with what I want to achieve? I also found this code in eyeplant.lua: local function retargetfn(inst) return FindEntity(inst, TUNING.EYEPLANT_ATTACK_DIST, function(guy) if not guy.components.health:IsDead() then return not checkmaster(guy, inst) end end, {"_combat","_health"}, -- see entityreplica.lua nil, {"character","monster","animal","prey","eyeplant","lureplant"} ) end Should I try to recode it to modmain.lua somehow or leave it in peace? Edited February 3, 2016 by Isasinian Link to comment https://forums.kleientertainment.com/forums/topic/63699-eyeplants-and-their-hostility/#findComment-717058 Share on other sites More sharing options...
Fidooop Posted February 3, 2016 Share Posted February 3, 2016 (edited) AddPrefabPostInit("eyeplant", function(inst) if GLOBAL.TheWorld.ismastersim then local OldRetarget = inst.components.combat.targetfn inst.components.combat:SetRetargetFunction(0.2, function() return OldRetarget and FindEntity(inst, GLOBAL.TUNING.EYEPLANT_ATTACK_DIST, function(guy) if guy:HasTag("eyeplantimmune") then return true end end) end) end end) Add the above to your modmain and add "eyeplantimmune" tag to your character's clientfn. Didn't test it so I'm not sure if it'll work or not. Edited February 4, 2016 by Fidooop Link to comment https://forums.kleientertainment.com/forums/topic/63699-eyeplants-and-their-hostility/#findComment-717140 Share on other sites More sharing options...
Isasinian Posted February 3, 2016 Author Share Posted February 3, 2016 I can't seem to understand why, but there's a problem with this line: function(guy) if guy:HasTag("eyeplantimmune") then return true end) Especially the ")" sign after the "end". It's the line 81 in my coding. I checked all these signs and they look like they're not missing any. Here's the screen: Link to comment https://forums.kleientertainment.com/forums/topic/63699-eyeplants-and-their-hostility/#findComment-717157 Share on other sites More sharing options...
Fidooop Posted February 3, 2016 Share Posted February 3, 2016 whoops, forgot the 2nd 'end' add an other 'end' between the 'end' and the ')' and it should be good. Link to comment https://forums.kleientertainment.com/forums/topic/63699-eyeplants-and-their-hostility/#findComment-717161 Share on other sites More sharing options...
Isasinian Posted February 3, 2016 Author Share Posted February 3, 2016 (edited) Works perfectly! Just needed to add "_G." before "TheWorld" to make it global I'm glad it's finally like it should Now... back to the modding cave! Edited February 3, 2016 by Isasinian Spelling mistake. Link to comment https://forums.kleientertainment.com/forums/topic/63699-eyeplants-and-their-hostility/#findComment-717168 Share on other sites More sharing options...
Fidooop Posted February 3, 2016 Share Posted February 3, 2016 Glad I could help! Link to comment https://forums.kleientertainment.com/forums/topic/63699-eyeplants-and-their-hostility/#findComment-717175 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