Jump to content

Recommended Posts

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

 

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.

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 by Arkathorn

 

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

Ty bro, thats work ;)

 

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 by Dyk

The field 'TUNING.SANITYAURA_SMALL' is the strength of the sanity aura. To make it negative just negate it:

return -GLOBAL.TUNING.SANITYAURA_SMALL + ret

You can find the other strength presets in 'tuning.lua'.

 

Also, are you modding DST? Because if so, this is not the correct forum.

The field 'TUNING.SANITYAURA_SMALL' is the strength of the sanity aura. To make it negative just negate it:

return -GLOBAL.TUNING.SANITYAURA_SMALL + ret

You 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 :/

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...