AnimSparrow Posted December 23, 2015 Share Posted December 23, 2015 Hello guys. I'm new here but I have a question.How to make nightmare monsters not attack my character when I go insane? Link to comment Share on other sites More sharing options...
ZupaleX Posted December 23, 2015 Share Posted December 23, 2015 You would have to modify the targetting function of the nightmare creature to ignore your character. Link to comment Share on other sites More sharing options...
AnimSparrow Posted December 23, 2015 Author Share Posted December 23, 2015 You would have to modify the targetting function of the nightmare creature to ignore your character. Yes I know, but no metter how hard I try they still agresive Link to comment Share on other sites More sharing options...
ZupaleX Posted December 23, 2015 Share Posted December 23, 2015 Can you post your current try so we can see together? Link to comment Share on other sites More sharing options...
AnimSparrow Posted December 23, 2015 Author Share Posted December 23, 2015 function NightmarecreaturePostInit(inst) if GLOBAL.TheWorld.ismastersim then local function retargetfn1(inst) return FindEntity(inst, TUNING.SHADOWCREATURE_TARGET_DIST, function(guy) return inst.components.combat:CanTarget(guy) and not guy:HasTag("animsparrow") end, { "playerghost" } ) end inst.components.combat:SetRetargetFunction(3, retargetfn1) end end AddPrefabPostInit("nightmarecreature", NightmarecreaturePostInit) Link to comment Share on other sites More sharing options...
ZupaleX Posted December 23, 2015 Share Posted December 23, 2015 (edited) There is a first issue in the retarget function you wrote. You replaced the musttags from FindEntity function which was supposed to be "{ "player" }" and replaced it by "playerghost" and removed the notags.It means that if your postinit was working, nightmare creatures would just attack ghost players. But the main issue is that you add that function to "nightmarecreature" which is actually not a prefab. nightmarecreature.lua creates 2 separate prefabs : "crawlingnightmare" and "nightmarebeak" Try to do a AddPrefabPostInit on these 2 prefabs instead (after correcting the FindEntity function to put back the proper musttags and notags). If you have still issues, could you post your complete mod so I can just download it and try it out please? Edited December 23, 2015 by ZupaleX Link to comment Share on other sites More sharing options...
AnimSparrow Posted December 23, 2015 Author Share Posted December 23, 2015 I have no idea... I made everything you said and still nothing. Here you go http://sendfile.es/pokaz/621887---60kd.html Link to comment Share on other sites More sharing options...
ZupaleX Posted December 23, 2015 Share Posted December 23, 2015 I have no idea where i'm supposed to click on the website you uploaded your mod on. Just uploaded on the klei's forum directly using "attach file". Link to comment Share on other sites More sharing options...
AnimSparrow Posted December 23, 2015 Author Share Posted December 23, 2015 I have no idea where i'm supposed to click on the website you uploaded your mod on. Just uploaded on the klei's forum directly using "attach file". here you go on zippyshared coz "You aren't permitted to upload this kind of file" http://www96.zippyshare.com/v/nzvUlLtW/file.html Link to comment Share on other sites More sharing options...
ZupaleX Posted December 24, 2015 Share Posted December 24, 2015 Here is the fixed modmain.luaNightmare creatures will keep the same behavior toward any entity except your character, against who they will be peaceful. I made it so it's more compatible with other mods which would affect the nightmare creatures. I don't know what you want to do with the sanity widget and sanity of your character at all but I think you fucked up something. I may be able to help if you explain what you want to achieve.modmain.lua Link to comment Share on other sites More sharing options...
AnimSparrow Posted December 24, 2015 Author Share Posted December 24, 2015 Here is the fixed modmain.luaNightmare creatures will keep the same behavior toward any entity except your character, against who they will be peaceful. I made it so it's more compatible with other mods which would affect the nightmare creatures. I don't know what you want to do with the sanity widget and sanity of your character at all but I think you fucked up something. I may be able to help if you explain what you want to achieve. I'm glad you decided to help me but still nothing happen. Don't work at all. Link to comment Share on other sites More sharing options...
ZupaleX Posted December 24, 2015 Share Posted December 24, 2015 What you wanted to do is working : Nightmare Creatures doesn't attack your character but attack other characters. I tested it out by spawning nightmare creatures next to the player when using your character or not. If something else is not working this is an other issue that need to be addressed separatly.What do you mean by "Don't work at all"? Link to comment Share on other sites More sharing options...
AnimSparrow Posted December 24, 2015 Author Share Posted December 24, 2015 What I want to do is that when I'm insane my character should be not attacked by shadow monsters. Others are targeted as usual. When I attack them though, they become aggresive. But right now it doesnt work if I'm my character or any other, nightmare monsters still target everybody.About sanity, my character has no sanity badge because his sanity scales with his beard Link to comment Share on other sites More sharing options...
ZupaleX Posted December 24, 2015 Share Posted December 24, 2015 Well the issue is that I tried it and the shadow creatures were not targetting your character. So I don't know what to tell you. Link to comment Share on other sites More sharing options...
DarkXero Posted December 24, 2015 Share Posted December 24, 2015 local function MakeNeutral(inst) if GLOBAL.TheWorld.ismastersim then local _CanTarget = inst.components.combat.CanTarget inst.components.combat.CanTarget = function(self, target) local ret = _CanTarget(self, target) if ret and target:HasTag("animsparrow") then local playertarget = target.components.combat.target local shadowtarget = playertarget and playertarget:HasTag("shadowcreature") if not shadowtarget then return false end end return ret end end end AddPrefabPostInit("crawlinghorror", MakeNeutral) AddPrefabPostInit("terrorbeak", MakeNeutral) Link to comment Share on other sites More sharing options...
ZupaleX Posted December 24, 2015 Share Posted December 24, 2015 (edited) That's doing the same that what is already in the modmain.lua currently (except for making the creature agressive whe, attacked by his character). The issue he is referring to must be something else. Edited December 24, 2015 by ZupaleX Link to comment Share on other sites More sharing options...
AnimSparrow Posted December 24, 2015 Author Share Posted December 24, 2015 DarkXero it works! You are the best. Thx ZupaleX as well. All works now! Link to comment Share on other sites More sharing options...
ZupaleX Posted December 24, 2015 Share Posted December 24, 2015 Glad it works but I don't understand the difference Link to comment Share on other sites More sharing options...
Kzisor Posted December 24, 2015 Share Posted December 24, 2015 @ZupaleX, the names of the nightmare creatures was never right, DarkXero simply corrected the name of the creatures. Link to comment Share on other sites More sharing options...
ZupaleX Posted December 24, 2015 Share Posted December 24, 2015 (edited) Ahah, it's because I started from the lua file nightmarecreature.lua since that's what AnimSparrow was modifying... and this file indeed return 2 prefabs : "crawlingnightmare" and "nightmarebeak". But it's not the prefab which are spawned when the sanity drop below the threshold, which are the prefabs created by shadowcreature.lua This explain the mystery of why, when I was spawning these 2 prefabs it was working the targeting while AnimSparrow was claiming it was not, because I guess he was not popping them but trigerring their spawn by lowering the sanity. Thanks for solving this mystery for me, I was really puzzled. EDIT: btw, you know what's the use of nightmarecreature.lua and the 2 prefabs it returns which are totally similar to the shadow creatures? I am a bit lazy to search so if you already know... Edited December 24, 2015 by ZupaleX Link to comment Share on other sites More sharing options...
AnimSparrow Posted December 27, 2015 Author Share Posted December 27, 2015 (edited) the other one are from ruins/caves Edited December 28, 2015 by AnimSparrow Link to comment Share on other sites More sharing options...
ZupaleX Posted December 28, 2015 Share Posted December 28, 2015 Thanks for the info. Link to comment 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