Faerendipitous Posted October 30, 2016 Share Posted October 30, 2016 How would one go about adding functional character perks for a character mod? I'm looking to Increase the amount of sanity picking flowers yields Increase the amount of sanity damage being near shadows deals Eliminate the sanity damage penalty for using magic and magic items I've got so far --Perk: Flowers local function onpickedfn(inst, picker) if picker and picker.components.sanity then picker.components.sanity:DoDelta(TUNING.SANITY_MED) end -- Perk: Sanity Perk for Magic inst.components.sanity.magic_drain_mult = 0 -- Perk(disavantage): Sanity Drain from Shadows inst.components.sanity.shadowcreature_drain_mult = 3 all three of these are placed at the end of my characer.lua file in mod/scripts/prefabs and I'm fairly certain at least two of them are wrong. I've also found DST's tuning.lua but I'm not 100 percent sure what I'd be looking for in there, or if it's even where I'm supposed to be for this sort of thing. Any suggestions, or worthwhile tutorials for perks or tuning? Much appreciated, Tib Link to comment https://forums.kleientertainment.com/forums/topic/71280-character-perks/ Share on other sites More sharing options...
Leonardo Cox Posted October 30, 2016 Share Posted October 30, 2016 You mentioned that these are posted at the end of your character.lua. Where is that? inside of masterpostinit or outside of masterpostinit? Maybe show us where this stuff is located in relation to everything else. Also are all of these not working? Link to comment https://forums.kleientertainment.com/forums/topic/71280-character-perks/#findComment-831287 Share on other sites More sharing options...
Faerendipitous Posted October 30, 2016 Author Share Posted October 30, 2016 24 minutes ago, DarkKingBoo said: You mentioned that these are posted at the end of your character.lua. Where is that? inside of masterpostinit or outside of masterpostinit? Maybe show us where this stuff is located in relation to everything else. Also are all of these not working? It took me a moment to figure it out, but they're currently residing outside of the masterpostinit. I'd take a wild guess that's what crashed the mod. The code for the flowers I ripped right from the flowers prefab in the original DST files, but the other two were a little more... creative, and I'm concerned about the phrasing of "[aspect]_drain_mult" in regards to the phrasing, but I've just been getting crash errors before it even starts up. Link to comment https://forums.kleientertainment.com/forums/topic/71280-character-perks/#findComment-831301 Share on other sites More sharing options...
Leonardo Cox Posted October 30, 2016 Share Posted October 30, 2016 (edited) -- Perk: Sanity Perk for Magic inst.components.sanity.magic_drain_mult = 0 -- Perk(disavantage): Sanity Drain from Shadows inst.components.sanity.shadowcreature_drain_mult = 3 These need to be inside of masterpostinit. That function needs to be above at least the common_postinit, but you'll need to replace it anyways, since that function will crash since its a function that requires the prefab to be pickable, which will never be the case for players and this isn't want you want. --I haven't tested this out yet. Remember that this goes above the common_postinit local function onpickup (inst, data) if data.prefab == "flower" then inst.components.sanity:DoDelta(10, false) end end --put this in your masterpostinit inst:ListenForEvent("onpickup", onpickup) Pretty tired so I just made it on the fly, if it crashes let me know so I can correct it. Edited October 30, 2016 by DarkKingBoo Link to comment https://forums.kleientertainment.com/forums/topic/71280-character-perks/#findComment-831308 Share on other sites More sharing options...
Tesumoto Posted October 31, 2016 Share Posted October 31, 2016 (edited) On 31.10.2016 at 1:51 AM, DarkKingBoo said: That function needs to be above at least the common_postinit, but you'll need to replace it anyways, since that function will crash since its a function that requires the prefab to be pickable, which will never be the case for players and this isn't want you want. --I haven't tested this out yet. Remember that this goes above the common_postinit local function onpickup (inst, data) if data.prefab == "flower" then inst.components.sanity:DoDelta(10, false) end end --put this in your masterpostinit inst:ListenForEvent("onpickup", onpickup) Pretty tired so I just made it on the fly, if it crashes let me know so I can correct it. The error does not appear, but the number of restore sanity remained the same (5) Fix this pls Edited November 1, 2016 by Tezumoto Link to comment https://forums.kleientertainment.com/forums/topic/71280-character-perks/#findComment-831523 Share on other sites More sharing options...
Leonardo Cox Posted November 1, 2016 Share Posted November 1, 2016 (edited) So I tried several different events that involved picking up items and couldn't get the prefab name. So instead of that method, use this one: --Put this into your modmain.lua AddPrefabPostInit("flower", function(inst) local function OnPickedfn(inst, picker) if picker and picker.components.sanity and picker.prefab ~= "\yourcharacternamehere" then picker.components.sanity:DoDelta(TUNING.SANITY_MED) elseif picker and picker.components.sanity and picker.prefab == "yourcharacternamehere" then picker.components.sanity:DoDelta(10, false) end if inst.animname == ROSE_NAME and picker.components.combat ~= nil then picker.components.combat:GetAttacked(inst, TUNING.ROSE_DAMAGE) picker:PushEvent("thorns") end GLOBAL.TheWorld:PushEvent("beginregrowth", inst) inst:Remove() end inst.components.pickable.onpickedfn = OnPickedfn end ) If anyone wants to jumpin and tell me which event that will identify the prefab being picked or just have a better method, I would also appreciate it. Edited November 1, 2016 by DarkKingBoo Link to comment https://forums.kleientertainment.com/forums/topic/71280-character-perks/#findComment-831916 Share on other sites More sharing options...
Faerendipitous Posted November 1, 2016 Author Share Posted November 1, 2016 1 hour ago, DarkKingBoo said: So I tried several different events that involved picking up items and couldn't get the prefab name. So instead of that method, use this one: --Put this into your modmain.lua AddPrefabPostInit("flower", function(inst) local function OnPickedfn(inst, picker) if picker and picker.components.sanity and picker.prefab ~= "\yourcharacternamehere" then picker.components.sanity:DoDelta(TUNING.SANITY_MED) elseif picker and picker.components.sanity and picker.prefab == "yourcharacternamehere" then picker.components.sanity:DoDelta(10, false) end if inst.animname == ROSE_NAME and picker.components.combat ~= nil then picker.components.combat:GetAttacked(inst, TUNING.ROSE_DAMAGE) picker:PushEvent("thorns") end GLOBAL.TheWorld:PushEvent("beginregrowth", inst) inst:Remove() end inst.components.pickable.onpickedfn = OnPickedfn end ) If anyone wants to jumpin and tell me which event that will identify the prefab being picked or just have a better method, I would also appreciate it. Yes!!! This worked, instead of +5 sanity, it's +15 for picking flowers. You've been an absolute LIFE saver, Boo, thank you so much!! Link to comment https://forums.kleientertainment.com/forums/topic/71280-character-perks/#findComment-831938 Share on other sites More sharing options...
Tesumoto Posted November 2, 2016 Share Posted November 2, 2016 (edited) 7 hours ago, DarkKingBoo said: So I tried several different events that involved picking up items and couldn't get the prefab name. So instead of that method, use this one: --Put this into your modmain.lua AddPrefabPostInit("flower", function(inst) local function OnPickedfn(inst, picker) if picker and picker.components.sanity and picker.prefab ~= "\yourcharacternamehere" then picker.components.sanity:DoDelta(TUNING.SANITY_MED) elseif picker and picker.components.sanity and picker.prefab == "yourcharacternamehere" then picker.components.sanity:DoDelta(10, false) end if inst.animname == ROSE_NAME and picker.components.combat ~= nil then picker.components.combat:GetAttacked(inst, TUNING.ROSE_DAMAGE) picker:PushEvent("thorns") end GLOBAL.TheWorld:PushEvent("beginregrowth", inst) inst:Remove() end inst.components.pickable.onpickedfn = OnPickedfn end ) If anyone wants to jumpin and tell me which event that will identify the prefab being picked or just have a better method, I would also appreciate it. This works, but the recovery mind is not impossible to edit. Always +15) Edited November 2, 2016 by Tezumoto Link to comment https://forums.kleientertainment.com/forums/topic/71280-character-perks/#findComment-832089 Share on other sites More sharing options...
Lumina Posted November 2, 2016 Share Posted November 2, 2016 not impossible or now impossible ? I guess the number is : TUNING.SANITY_MED So you could probably change it. Link to comment https://forums.kleientertainment.com/forums/topic/71280-character-perks/#findComment-832169 Share on other sites More sharing options...
Leonardo Cox Posted November 2, 2016 Share Posted November 2, 2016 12 hours ago, Tezumoto said: This works, but the recovery mind is not impossible to edit. Always +15) Edit the line: picker.components.sanity:DoDelta(10, false) and change the number to whatever you want. Link to comment https://forums.kleientertainment.com/forums/topic/71280-character-perks/#findComment-832238 Share on other sites More sharing options...
Tesumoto Posted November 2, 2016 Share Posted November 2, 2016 1 hour ago, DarkKingBoo said: Edit the line: picker.components.sanity:DoDelta(10, false) and change the number to whatever you want. I tried, but always remain in the game value +15 Link to comment https://forums.kleientertainment.com/forums/topic/71280-character-perks/#findComment-832250 Share on other sites More sharing options...
Leonardo Cox Posted November 2, 2016 Share Posted November 2, 2016 Which character are you playing as, the mod character or someone else? change the other line then: picker.components.sanity:DoDelta(TUNING.SANITY_MED) Link to comment https://forums.kleientertainment.com/forums/topic/71280-character-perks/#findComment-832285 Share on other sites More sharing options...
Tesumoto Posted November 2, 2016 Share Posted November 2, 2016 2 hours ago, DarkKingBoo said: Which character are you playing as, the mod character or someone else? change the other line then: picker.components.sanity:DoDelta(TUNING.SANITY_MED) I have a problem. For some reason, any character that picks up flower on the server receives +15 a mind. AddPrefabPostInit("flower", function(inst) local function OnPickedfn(inst, picker) if picker and picker.components.sanity and picker.prefab ~= "\reisen" then picker.components.sanity:DoDelta(TUNING.SANITY_MED) elseif picker and picker.components.sanity and picker.prefab == "reisen" then picker.components.sanity:DoDelta(10, false) end if inst.animname == ROSE_NAME and picker.components.combat ~= nil then picker.components.combat:GetAttacked(inst, TUNING.ROSE_DAMAGE) picker:PushEvent("thorns") end GLOBAL.TheWorld:PushEvent("beginregrowth", inst) inst:Remove() end inst.components.pickable.onpickedfn = OnPickedfn end ) I am using this code. I put it in modmain.lua one character (reisen) Link to comment https://forums.kleientertainment.com/forums/topic/71280-character-perks/#findComment-832331 Share on other sites More sharing options...
. . . Posted November 2, 2016 Share Posted November 2, 2016 2 minutes ago, Tezumoto said: I have a problem. For some reason, any character that picks up flower on the server receives +15 a mind. Add this code inside YOURCHARACTER.lua is common_postinit inst:AddTag("reisen") then change this AddPrefabPostInit("flower", function(inst) local function OnPickedfn(inst, picker) if picker and picker.components.sanity and picker.prefab ~= "\reisen" then picker.components.sanity:DoDelta(TUNING.SANITY_MED) elseif picker and picker.components.sanity and picker.prefab == "reisen" then picker.components.sanity:DoDelta(10, false) end if inst.animname == ROSE_NAME and picker.components.combat ~= nil then picker.components.combat:GetAttacked(inst, TUNING.ROSE_DAMAGE) picker:PushEvent("thorns") end GLOBAL.TheWorld:PushEvent("beginregrowth", inst) inst:Remove() end inst.components.pickable.onpickedfn = OnPickedfn end ) to this AddPrefabPostInit("flower", function(inst) local function OnPickedfn(inst, picker) if picker and picker.components.sanity and picker:HasTag("reisen") then picker.components.sanity:DoDelta(15) -- change to sanity amount u want elseif picker and picker.components.sanity and not picker:HasTag("reisen") then picker.components.sanity:DoDelta(5) end if inst.animname == ROSE_NAME and picker.components.combat ~= nil then picker.components.combat:GetAttacked(inst, TUNING.ROSE_DAMAGE) picker:PushEvent("thorns") end GLOBAL.TheWorld:PushEvent("beginregrowth", inst) inst:Remove() end inst.components.pickable.onpickedfn = OnPickedfn end ) with this any character that isn't reisen will only get 5 sanity from picking flowers but if the character is resien they will get 15 sanity Link to comment https://forums.kleientertainment.com/forums/topic/71280-character-perks/#findComment-832337 Share on other sites More sharing options...
Tesumoto Posted November 2, 2016 Share Posted November 2, 2016 (edited) 30 minutes ago, SuperDavid said: Add this code inside YOURCHARACTER.lua is common_postinit inst:AddTag("reisen") to this AddPrefabPostInit("flower", function(inst) local function OnPickedfn(inst, picker) if picker and picker.components.sanity and picker:HasTag("reisen") then picker.components.sanity:DoDelta(15) -- change to sanity amount u want elseif picker and picker.components.sanity and not picker:HasTag("reisen") then picker.components.sanity:DoDelta(5) end if inst.animname == ROSE_NAME and picker.components.combat ~= nil then picker.components.combat:GetAttacked(inst, TUNING.ROSE_DAMAGE) picker:PushEvent("thorns") end GLOBAL.TheWorld:PushEvent("beginregrowth", inst) inst:Remove() end inst.components.pickable.onpickedfn = OnPickedfn end ) with this any character that isn't reisen will only get 5 sanity from picking flowers but if the character is resien they will get 15 sanity Thank you for your advice, he helped me) Edited November 2, 2016 by Tezumoto Link to comment https://forums.kleientertainment.com/forums/topic/71280-character-perks/#findComment-832344 Share on other sites More sharing options...
Leonardo Cox Posted November 2, 2016 Share Posted November 2, 2016 @SuperDavid Any particular reason why he needed the "reisen" tag? The issue was a typo. Link to comment https://forums.kleientertainment.com/forums/topic/71280-character-perks/#findComment-832346 Share on other sites More sharing options...
. . . Posted November 2, 2016 Share Posted November 2, 2016 55 minutes ago, DarkKingBoo said: Any particular reason why he needed the "reisen" tag? Sometime's it's good to have 1 unique tag just for your character, I did same for my char. Link to comment https://forums.kleientertainment.com/forums/topic/71280-character-perks/#findComment-832362 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