hikaruohayashi Posted April 13, 2017 Share Posted April 13, 2017 I'm making a few character mods for myself and my friends to play in the same server. I've finished the art of the first character and now I'm adding quirks. I managed to implement a few of the character quirks already myself, but I am unsure of how to implement these two: - can eat nightmare fuel for health and hunger boost (is this even possible? I know some can get their characters to eat rocks. I understand how they did it, but I'm not exactly sure if FOODTYPE.(whatevernightmarefuelisclassifiedas) can be done or where I can find the necessary information in the files. I know wx78 can eat gears, but I'm kind of stuck with that) - loses sanity faster around insect/bug/worm type creatures Any help is appreciated! Link to comment Share on other sites More sharing options...
Whitefang45 Posted April 13, 2017 Share Posted April 13, 2017 (edited) I can help with the second one. Slap these into your modmain.lua file: AddPrefabPostInit("worm", function(inst) if inst.components.sanityaura then inst.components.sanityaura.aura = -TUNING.SANITY_LARGE else inst:AddComponent("sanityaura") inst.components.sanityaura.aura = -TUNING.SANITY_LARGE end end And at the very top, on the line before PrefabFiles, insert this: TUNING = GLOBAL.TUNING Where "worm" is, that's the prefab file name of the creature you want to apply a sanity aura to. In this case, it's the depths worm. I'm not sure if there's a way to specify that all insectoid/annelid creatures get the same neg sanity aura, so you may have to copy and paste this several times and each time insert the prefab of the creature you want your character to fear. Also, it works for objects, too. Just in case you want a character in the future to fear skeletons or something. I'm uncertain if it works with every object, though. Edited April 13, 2017 by Whitefang45 Link to comment Share on other sites More sharing options...
hikaruohayashi Posted April 13, 2017 Author Share Posted April 13, 2017 (edited) Thank you so much still! I'm trying it out now. Am I correct to assume I can replace the "LARGE" with "MEDIUM" and "SMALL" respectively or do they call the function respectively I'm on the impression that referring to all monsters in general can be used, but the character I had in mind has very specific phobias. Copy pasting for every type of creature with an insect/bug/worm-like trait might be best indeed. Edit: I think there might be a few elements missing in the code you gave me. I tested my mod after the changes but the game crashes just after I load up my server. (It actually goes into the character select screen first even though I have already selected one. And, once I click on the screen, the game crashes.) Here's the modmain code I currently have: Spoiler TUNING = GLOBAL.TUNING PrefabFiles = { "salem", "salem_none", } Assets = { Asset( "IMAGE", "images/saveslot_portraits/salem.tex" ), Asset( "ATLAS", "images/saveslot_portraits/salem.xml" ), Asset( "IMAGE", "images/selectscreen_portraits/salem.tex" ), Asset( "ATLAS", "images/selectscreen_portraits/salem.xml" ), Asset( "IMAGE", "images/selectscreen_portraits/salem_silho.tex" ), Asset( "ATLAS", "images/selectscreen_portraits/salem_silho.xml" ), Asset( "IMAGE", "bigportraits/salem.tex" ), Asset( "ATLAS", "bigportraits/salem.xml" ), Asset( "IMAGE", "images/map_icons/salem.tex" ), Asset( "ATLAS", "images/map_icons/salem.xml" ), Asset( "IMAGE", "images/avatars/avatar_salem.tex" ), Asset( "ATLAS", "images/avatars/avatar_salem.xml" ), Asset( "IMAGE", "images/avatars/avatar_ghost_salem.tex" ), Asset( "ATLAS", "images/avatars/avatar_ghost_salem.xml" ), Asset( "IMAGE", "images/avatars/self_inspect_salem.tex" ), Asset( "ATLAS", "images/avatars/self_inspect_salem.xml" ), Asset( "IMAGE", "images/names_salem.tex" ), Asset( "ATLAS", "images/names_salem.xml" ), Asset( "IMAGE", "bigportraits/salem_none.tex" ), Asset( "ATLAS", "bigportraits/salem_none.xml" ), } local require = GLOBAL.require local STRINGS = GLOBAL.STRINGS -- The character select screen lines STRINGS.CHARACTER_TITLES.salem = "The Demon Lord" STRINGS.CHARACTER_NAMES.salem = "Salem" STRINGS.CHARACTER_DESCRIPTIONS.salem = "*Powerful Demon\n*Clean Freak\n*Fear of Bugs" STRINGS.CHARACTER_QUOTES.salem = "\"Maddie, darling, I beg you... Not this!\"" -- Custom speech strings STRINGS.CHARACTERS.SALEM = require "speech_salem" -- The character's name as appears in-game STRINGS.NAMES.SALEM = "Salem" AddMinimapAtlas("images/map_icons/salem.xml") -- Add mod character to mod character list. Also specify a gender. Possible genders are MALE, FEMALE, ROBOT, NEUTRAL, and PLURAL. AddModCharacter("salem", "MALE") --adds a sanity drain to the specified file AddPrefabPostInit("wormhole", function(inst) if inst.components.sanityaura then inst.components.sanityaura.aura = -TUNING.SANITY_LARGE else inst:AddComponent("sanityaura") inst.components.sanityaura.aura = -TUNING.SANITY_LARGE end end I thought that it only lacked a ")" at AddPrefabPostInit("wormhole", function(inst) but that wasn't the case and the problem persisted. Edited April 13, 2017 by hikaruohayashi code is not working Link to comment Share on other sites More sharing options...
Aquaterion Posted April 13, 2017 Share Posted April 13, 2017 (edited) This is how you make nightmarefuel edible //modmain.lua GLOBAL.FOODTYPE.NIGHTMARE = "NIGHTMARE" AddPrefabPostInit("nightmarefuel", function(inst) if not GLOBAL.TheWorld.ismastersim then return inst end inst:AddComponent("edible") inst.components.edible.foodtype = GLOBAL.FOODTYPE.NIGHTMARE inst.components.edible.healthvalue = 0//change these as you please inst.components.edible.hungervalue = 0 inst.components.edible.sanityvalue = 0 end) All you gotta do is make your character be able to eat the foodtype NIGHTMARE Edited April 13, 2017 by Aquaterion Link to comment Share on other sites More sharing options...
Whitefang45 Posted April 13, 2017 Share Posted April 13, 2017 10 minutes ago, hikaruohayashi said: Thank you so much still! I'm trying it out now. Am I correct to assume I can replace the "LARGE" with "MEDIUM" and "SMALL" respectively or do they call the function respectively Yep, you can use TINY, SMALL, MEDIUM, LARGE, and HUGE for the sanity tuning. You can have the worms have HUGE sanity drain, for instance, and you could have the dragonfly larva things have TINY sanity drain. Some fiddling may be required to see which one really works best. Go too high and your sanity could be down to 0 in seconds! Link to comment Share on other sites More sharing options...
hikaruohayashi Posted April 13, 2017 Author Share Posted April 13, 2017 6 minutes ago, Aquaterion said: This is how you make nightmarefuel edible //modmain.lua GLOBAL.FOODTYPE.NIGHTMARE = "NIGHTMARE" AddPrefabPostInit("nightmarefuel", function(inst) if not GLOBAL.TheWorld.ismastersim then return inst end inst:AddComponent("edible") inst.components.edible.foodtype = GLOBAL.FOODTYPE.NIGHTMARE inst.components.edible.healthvalue = 0//change these as you please inst.components.edible.hungervalue = 0 inst.components.edible.sanityvalue = 0 end) All you gotta do is make your character be able to eat the foodtype NIGHTMARE This will be within the modmain.lua file as well, correct? (Sorry, I just want to make sure |D) Thank you by the way! Link to comment Share on other sites More sharing options...
Aquaterion Posted April 13, 2017 Share Posted April 13, 2017 11 minutes ago, hikaruohayashi said: This will be within the modmain.lua file as well, correct? (Sorry, I just want to make sure |D) Thank you by the way! if u by 'this' you mean your character being able to eat FOODTYPE.NIGHTMARE then u can do it directly in your characterprefab.lua, in the masterpostinit function. Link to comment Share on other sites More sharing options...
hikaruohayashi Posted April 13, 2017 Author Share Posted April 13, 2017 (edited) 10 hours ago, Aquaterion said: if u by 'this' you mean your character being able to eat FOODTYPE.NIGHTMARE then u can do it directly in your characterprefab.lua, in the masterpostinit function. I meant the code. owo; so I place the code you gave me within the prefab of my character, is that right? edit: It works now, thank you! Edited April 13, 2017 by hikaruohayashi problem solved Link to comment Share on other sites More sharing options...
hikaruohayashi Posted April 13, 2017 Author Share Posted April 13, 2017 (edited) 10 hours ago, Whitefang45 said: Yep, you can use TINY, SMALL, MEDIUM, LARGE, and HUGE for the sanity tuning. You can have the worms have HUGE sanity drain, for instance, and you could have the dragonfly larva things have TINY sanity drain. Some fiddling may be required to see which one really works best. Go too high and your sanity could be down to 0 in seconds! Okay! That's helpful. Thank you. I'm having a bit of a problem though (sort of stated in my edited post above that you may have missed.) I am not sure if it's an error on my part or maybe i just can use it on the specific object I chose for testing purposes? edit: I managed to find what's wrong! Thank you again Edited April 13, 2017 by hikaruohayashi problem solved Link to comment Share on other sites More sharing options...
CarlZalph Posted April 13, 2017 Share Posted April 13, 2017 12 hours ago, Whitefang45 said: I can help with the second one. Slap these into your modmain.lua file: AddPrefabPostInit("worm", function(inst) if inst.components.sanityaura then inst.components.sanityaura.aura = -TUNING.SANITY_LARGE else inst:AddComponent("sanityaura") inst.components.sanityaura.aura = -TUNING.SANITY_LARGE end end Where "worm" is, that's the prefab file name of the creature you want to apply a sanity aura to. In this case, it's the depths worm. I'm not sure if there's a way to specify that all insectoid/annelid creatures get the same neg sanity aura, so you may have to copy and paste this several times and each time insert the prefab of the creature you want your character to fear. An issue is that this is DST so this will affect every player instead of the mod character only. A fix to this as well as providing a generator for multiple prefabs: local function Hook_Increase_Insanity(prefab) AddPrefabPostInit( prefab, function(inst) if not GLOBAL.TheWorld.ismastersim then return end if inst.components.sanityaura==nil then inst:AddComponent("sanityaura") end local aura = inst.components.sanityaura local aurafn_old = aura.aurafn aura.aurafn = function(owner, observer) local retVal = aurafn_old and aurafn_old(owner, observer) or aura.aura if observer.prefab=="waxwell" then retVal = retVal - GLOBAL.TUNING.SANITY_LARGE end return retVal end end ) end local MakeScarier = {"worm", "rabbit"} for _,v in pairs(MakeScarier) do Hook_Increase_Insanity(v) end Link to comment Share on other sites More sharing options...
hikaruohayashi Posted April 13, 2017 Author Share Posted April 13, 2017 56 minutes ago, CarlZalph said: An issue is that this is DST so this will affect every player instead of the mod character only. A fix to this as well as providing a generator for multiple prefabs: local function Hook_Increase_Insanity(prefab) AddPrefabPostInit( prefab, function(inst) if not GLOBAL.TheWorld.ismastersim then return end if inst.components.sanityaura==nil then inst:AddComponent("sanityaura") end local aura = inst.components.sanityaura local aurafn_old = aura.aurafn aura.aurafn = function(owner, observer) local retVal = aurafn_old and aurafn_old(owner, observer) or aura.aura if observer.prefab=="waxwell" then retVal = retVal - GLOBAL.TUNING.SANITY_LARGE end return retVal end end ) end local MakeScarier = {"worm", "rabbit"} for _,v in pairs(MakeScarier) do Hook_Increase_Insanity(v) end I see! I need to replace "waxwell" with the prefab of my character, is that correct? Will I place this in the modmain.lua like the earlier code or does this go into another file location? Link to comment Share on other sites More sharing options...
CarlZalph Posted April 13, 2017 Share Posted April 13, 2017 5 minutes ago, hikaruohayashi said: I see! I need to replace "waxwell" with the prefab of my character, is that correct? Will I place this in the modmain.lua like the earlier code or does this go into another file location? Correct, and yeah modmain. Link to comment Share on other sites More sharing options...
hikaruohayashi Posted April 13, 2017 Author Share Posted April 13, 2017 19 minutes ago, CarlZalph said: Correct, and yeah modmain. I tried it out and it works well! Thank you very much. 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