Jump to content

how would I go about adding special things to my custom character?


Recommended Posts

bump?

 

Mhm...

 

maybe this?

you can search for it in the wigfrid.lua/wathgrithr.lua

 

 

 

local function onkilled(inst, data)

    local victim = data.victim

    if IsValidVictim(victim) then

        -- local delta = victim.components.combat.defaultdamage * 0.25

        -- inst.components.health:DoDelta(delta, false, "battleborn")

        -- inst.components.sanity:DoDelta(delta)

        if not victim.components.health.nofadeout and (victim:HasTag("epic") or math.random() < .1) then

            local time = victim.components.health.destroytime or 2

            local x, y, z = victim.Transform:GetWorldPosition()

            local scale = (victim:HasTag("smallcreature") and smallScale)

                        or (victim:HasTag("largecreature") and largeScale)

                        or medScale

            inst:DoTaskInTime(time, spawnspirit, x, y, z, scale)

        end

    end

end

local BATTLEBORN_STORE_TIME = 3

local BATTLEBORN_DECAY_TIME = 5

local BATTLEBORN_TRIGGER_THRESHOLD = 1

local function onattack(inst, data)

    local victim = data.target

    if not inst.components.health:IsDead() and IsValidVictim(victim) then

        local total_health = victim.components.health:GetMaxWithPenalty()

        local damage = data.weapon ~= nil and data.weapon.components.weapon.damage or inst.components.combat.defaultdamage

        local percent = (damage <= 0 and 0)

                    or (total_health <= 0 and math.huge)

                    or damage / total_health

        --math and clamp does account for 0 and infinite cases

        local delta = math.clamp(victim.components.combat.defaultdamage * .25 * percent, .33, 2)

        --decay stored battleborn

        if inst.battleborn > 0 then

            local dt = GetTime() - inst.battleborn_time - BATTLEBORN_STORE_TIME

            if dt >= BATTLEBORN_DECAY_TIME then

                inst.battleborn = 0

            elseif dt > 0 then

                local k = dt / BATTLEBORN_DECAY_TIME

                inst.battleborn = Lerp(inst.battleborn, 0, k * k)

            end

        end

        --store new battleborn

        inst.battleborn = inst.battleborn + delta

        inst.battleborn_time = GetTime()

        --consume battleborn if enough has been stored

        if inst.battleborn > BATTLEBORN_TRIGGER_THRESHOLD then

            inst.components.health:DoDelta(inst.battleborn, false, "battleborn")

            inst.components.sanity:DoDelta(inst.battleborn)

            inst.battleborn = 0

        end

    end

end

local function ondeath(inst)

    inst.battleborn = 0

end

 

wathgrithr.lua

Edited by EulenMarie
Link to comment
Share on other sites

Yeah ive tried this and have had so many crashes and problems it just isn't working so I took to the forums... Also worth noting I want my character to sap health and hunger instead of hunger and sanity! D: problems

Update: added Wigfrids code to my character and launched it without errors or crashing but doens't seem to be working... added file for character.

Link to comment
Share on other sites

Update: added Wigfrids code to my character and launched it without errors or crashing but doens't seem to be working... added file for character.

 

I'm not god @coding but, pls make screenshots if the games crashed.

Do you haven't a crash, send the log.txt

 

documents>klei>dont starve together>log.txt

 

 

then the people with knowledge can see whats going wrong ^^

Edited by EulenMarie
Link to comment
Share on other sites

I'm not god @coding but, pls make screenshots if the games crashed.

Do you haven't a crash, send the log.txt

 

documents>klei>dont starve together>log.txt

 

 

then the people with knowledge can see whats going wrong ^^

This is a non-crash log. Not sure if anyone needs but yeah, Wigfrid's code is going in fine and starting up without crashes it just isn't working with my character like he isn't sapping health or anything.

log.txt

Link to comment
Share on other sites

That would be because your onkilled and onattack functions are doing nothing. You need to attach them to the events "killed" and "onattackother" by putting these lines in the master_postinit:

inst:ListenForEvent("killed", onkilled)inst:ListenForEvent("onattackother", onattack)inst:ListenForEvent("death", ondeath)

Also the ondeath function.

And it's just a me thing but I preffer putting common_postinit and master_postinit in the bottom next to each other.

Changed it so it saps health and hunger instead of health and sanity. Try it:

wilber.lua

Edited by DrSmugleaf
Link to comment
Share on other sites

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
 Share

×
  • Create New...