Dyk Posted January 4, 2016 Share Posted January 4, 2016 So I'm working on a character for my first mod, and i got a lot of problems with the perks --Perk 1 - Gain 2x dmg when is with 45 less sanity --Perk 2 - Loses sanity when is close to women --Perk 3 - Take more fire dmg --Perk 4 - Recover more hunger with food sry for bad english i'm using a translator Link to comment https://forums.kleientertainment.com/forums/topic/61848-help-character-perk/ Share on other sites More sharing options...
Dyk Posted January 4, 2016 Author Share Posted January 4, 2016 So I'm working on a character for my first mod, and i got a lot of problems with the perks --Perk 1 - Gain 2x dmg when is with 45 less sanity --Perk 2 - Loses sanity when is close to women --Perk 3 - Take more fire dmg --Perk 4 - Recover more hunger with food sry for bad english i'm using a translator I tried this for the dmg mult but doesnt work if inst.components.sanity.currentSanity < 45 then inst.components.combat.damagemultiplier = 5 end I dont know how use the "local" i have searched but i realy dont fond nothing. Link to comment https://forums.kleientertainment.com/forums/topic/61848-help-character-perk/#findComment-705088 Share on other sites More sharing options...
Arkathorn Posted January 4, 2016 Share Posted January 4, 2016 (edited) That should work, but only if you call the code from the right place. The 'fn' function is only called once, when the prefab is created (or loaded). Try putting this code in 'fn':inst:ListenForEvent("sanitydelta", function(inst, data) if data.newpercent <= 22.5 then inst.components.combat.damagemultiplier = 5 else inst.components.combat.damagemultiplier = 1 endend)The 'local' keyword defines a local variable. This means that the variable can only be used in the same scope (the file or function that the variable is created in). In general (at least when modding), you should always make your variables local. Use it like this:local a = 5 Edited January 4, 2016 by Arkathorn Link to comment https://forums.kleientertainment.com/forums/topic/61848-help-character-perk/#findComment-705094 Share on other sites More sharing options...
Dyk Posted January 4, 2016 Author Share Posted January 4, 2016 That should work, but only if you call the code from the right place. The 'fn' function is only called once, when the prefab is created (or loaded). Try putting this code in 'fn':inst:ListenForEvent("sanitydelta", function(inst, data) if data.newpercent <= 22.5 then inst.components.combat.damagemultiplier = 5 else inst.components.combat.damagemultiplier = 1 endend)The 'local' keyword defines a local variable. This means that the variable can only be used in the same scope (the file or function that the variable is created in). In general (at least when modding), you should always make your variables local. Use it like this:local a = 5Ty bro, thats work Link to comment https://forums.kleientertainment.com/forums/topic/61848-help-character-perk/#findComment-705180 Share on other sites More sharing options...
Dyk Posted January 4, 2016 Author Share Posted January 4, 2016 (edited) From the 2nd perk i have take a code of a another mod, "sanji", but he gain sanity when is close to women, how i can change to lose?local function isWoman(name) for k, v in ipairs(GLOBAL.CHARACTER_GENDERS.FEMALE) do if v == name then return true end end return falseend AddPlayerPostInit(function(inst) if isWoman(inst.prefab) then if not inst.components.sanityaura then inst:AddComponent("sanityaura") end local old = inst.components.sanityaura.aurafn inst.components.sanityaura.aurafn = function(inst, observer) local ret = 0 if old ~= nil then ret = old(inst, observer) end if observer.prefab == "sanji" then return GLOBAL.TUNING.SANITYAURA_SMALL + ret end return ret end endend) Edited January 4, 2016 by Dyk Link to comment https://forums.kleientertainment.com/forums/topic/61848-help-character-perk/#findComment-705181 Share on other sites More sharing options...
Arkathorn Posted January 4, 2016 Share Posted January 4, 2016 The field 'TUNING.SANITYAURA_SMALL' is the strength of the sanity aura. To make it negative just negate it:return -GLOBAL.TUNING.SANITYAURA_SMALL + retYou can find the other strength presets in 'tuning.lua'. Also, are you modding DST? Because if so, this is not the correct forum. Link to comment https://forums.kleientertainment.com/forums/topic/61848-help-character-perk/#findComment-705187 Share on other sites More sharing options...
Dyk Posted January 4, 2016 Author Share Posted January 4, 2016 The field 'TUNING.SANITYAURA_SMALL' is the strength of the sanity aura. To make it negative just negate it:return -GLOBAL.TUNING.SANITYAURA_SMALL + retYou can find the other strength presets in 'tuning.lua'. Also, are you modding DST? Because if so, this is not the correct forum.ty, you saved me, and im making a dst mod, i have not see have a forum for the singleplayer and another to dst, but ty for the help sry bad english, i using a translator :/ Link to comment https://forums.kleientertainment.com/forums/topic/61848-help-character-perk/#findComment-705191 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