FoxPuns Posted February 11, 2019 Share Posted February 11, 2019 I'm extremely new when it comes to coding and I'm trying to figure out how to make the ghost mobs neutral towards my character. I've found the code for ghosts/ghostbrain, but I'm unsure of what to change. Most of the tutorials are for bees, but the code is written differently for ghosts. Any help or suggestions would be very appreciated! Link to comment Share on other sites More sharing options...
Fancy_Fox_Pers Posted February 11, 2019 Share Posted February 11, 2019 Maybe this thread can help you Link to comment Share on other sites More sharing options...
Ultroman Posted February 11, 2019 Share Posted February 11, 2019 (edited) Yeah, actually I might have a better solution than I provided in that thread. Also, the shadow/nightmare creatures do not use FindEntity, like the frogs do, so there's no place to put an ignore-tag. I'm not completely sure about this, but I think you can just extend the IsValidTarget function on all the shadow/nightmare creature's combat_replica-component. Just extend it, and before you run the original function, check whether the target is your character, and if so, return false. Otherwise, return the result of the original function. Try putting this at the bottom of your modmain.lua, and change CHARACTER_PREFAB_NAME to your character's prefab name. Keep in mind, this will make it impossible for them to attack you, even if you attack them. local prefabsToChange = {"crawlinghorror", "terrorbeak", "crawlingnightmare", "nightmarebeak"} for i, v in ipairs(prefabsToChange) do AddPrefabPostInit(v, function(inst) if inst.components.combat_replica then local old_IsValidTarget = inst.components.combat_replica.IsValidTarget inst.components.combat_replica.IsValidTarget = function(self, target) if target.prefab == "CHARACTER_PREFAB_NAME" then return false end return old_IsValidTarget(self, target) end end end) end Edited February 12, 2019 by Ultroman Link to comment Share on other sites More sharing options...
FoxPuns Posted February 12, 2019 Author Share Posted February 12, 2019 20 hours ago, Ultroman said: Yeah, actually I might have a better solution than I provided in that thread. Also, the shadow/nightmare creatures do not use FindEntity, like the frogs do, so there's no place to put an ignore-tag. I'm not completely sure about this, but I think you can just extend the IsValidTarget function on all the shadow/nightmare creature's combat_replica-component. Just extend it, and before you run the original function, check whether the target is your character, and if so, return false. Otherwise, return the result of the original function. Try putting this at the bottom of your modmain.lua, and change CHARACTER_PREFAB_NAME to your character's prefab name. Keep in mind, this will make it impossible for them to attack you, even if you attack them. local prefabsToChange = {"crawlinghorror", "terrorbeak", "crawlingnightmare", "nightmarebeak"} for i, v in ipairs(prefabsToChange) do AddPrefabPostInit(v, function(inst) if inst.components.combat_replica then local old_IsValidTarget = inst.components.combat_replica.IsValidTarget inst.components.combat_replica.IsValidTarget = function(self, target) if target.prefab == "CHARACTER_PREFAB_NAME" then return false end return old_IsValidTarget(self, target) end end end) end My apologies I wasn't too clear in my post lol, but I really appreciate the response. I meant the grave ghosts instead of sanity nightmares (crawling horrors, terrorbeaks etc.). Is it possible to make them neutral? Also, I've been looking into a sanity perk that would allow my character to gain sanity by having hounds teeth in their inventory. Like how Warbucks gains sanity by holding oincs. I've found his code for this. Is it possible to edit it into hounds teeth giving my character sanity? Thanks again! Warbucks code: local function sanityfn(inst) local delta = 0 local oinc_amount = inst.components.inventory:Count("oinc") + (inst.components.inventory:Count("oinc10") * 10) + (inst.components.inventory:Count("oinc100") * 100) if oinc_amount >= 200 then delta = TUNING.SANITYAURA_MED elseif oinc_amount >= 50 then delta = TUNING.SANITYAURA_SMALL elseif oinc_amount >= 20 then delta = TUNING.SANITYAURA_TINY * 2 elseif oinc_amount >= 10 then delta = TUNING.SANITYAURA_TINY end return delta end Link to comment Share on other sites More sharing options...
Ultroman Posted February 12, 2019 Share Posted February 12, 2019 I'll do the sanity question first. I've changed the code to what you want in the section below. Just remember to "attach" it to your character's sanity-component. If you don't know how, search for sanityfn in warbucks.lua local function sanityfn(inst) local delta = 0 local tooth_amount = inst.components.inventory:Count("houndstooth") if tooth_amount >= 200 then delta = TUNING.SANITYAURA_MED elseif tooth_amount >= 50 then delta = TUNING.SANITYAURA_SMALL elseif tooth_amount >= 20 then delta = TUNING.SANITYAURA_TINY * 2 elseif tooth_amount >= 10 then delta = TUNING.SANITYAURA_TINY end return delta end About the ghosts, I'd try doing the same thing. Put this at the bottom of your modmain.lua, and remember to change the string CHARACTER_PREFAB_NAME. AddPrefabPostInit("ghost", function(inst) if inst.components.combat_replica then local old_IsValidTarget = inst.components.combat_replica.IsValidTarget inst.components.combat_replica.IsValidTarget = function(self, target) if target.prefab == "CHARACTER_PREFAB_NAME" then return false end return old_IsValidTarget(self, target) end end end) 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