Jump to content

Recommended Posts

So i found myself confided with trying to make a weapon/item have unlimited durability for the sole purpose of it being unique for that character.. I was trying to find a way to make a "diamond tipped" pickaxe that has unlimited uses.. or a "Red wood Rod" that has unlimited uses in fishing.. but I can't seem to even find out where to edit the durability it self, after downloading mods that have unlimited durability.. I can't seem to get anywhere.. I was also wondering if there was a way to take wigfrids perks to heal sanity and hp upon damaging enemies and put it on a custom character along wiht people to craft her custom gear.. Any ideas?

I don't really know much about tools but I think if you just remove

inst:AddComponent("finiteuses")

from YOURTOOL.lua it shouldn't have durability.

 

For Wathgrithr's health stealing power you would-

 

put this code inside YOURCHARACTER.lua outside of the "master_postinit" area.

Spoiler

local smallScale = 0.5
local medScale = 0.7
local largeScale = 1.1

local function spawnspirit(inst, x, y, z, scale)
    local fx = SpawnPrefab("wathgrithr_spirit")
    fx.Transform:SetPosition(x, y, z)
    fx.Transform:SetScale(scale, scale, scale)
end

local function IsValidVictim(victim)
    return victim ~= nil
        and not ((victim:HasTag("prey") and not victim:HasTag("hostile")) or
                victim:HasTag("veggie") or
                victim:HasTag("structure") or
                victim:HasTag("wall") or
                victim:HasTag("companion"))
        and victim.components.health ~= nil
        and victim.components.combat ~= nil
end

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

 

You would put this code inside "common_postinit" to craft Wathgrithr's items

inst:AddTag("valkyrie")

You would put this code inside your "master_postinit"

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

    inst.battleborn = 0
    inst.battleborn_time = 0

I think with all this code you should get Wathgrithr's power? But It might not work... So, test it & find out :)!

4 minutes ago, Lokoluna said:

Thank you.. also uhm. How would i remove the ability to only eat meat?

I did not include that in this code.

 

4 minutes ago, Lokoluna said:

Also make a custom tool out of a already exsisting tool into a .lua file?

I'm not really familiar with tools so I don't really know, sorry :(.. 

49 minutes ago, SuperDavid said:

 

You would put this code inside your "master_postinit"


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

    inst.battleborn = 0
    inst.battleborn_time = 0

I think with all this code you should get Wathgrithr's power? But It might not work... So, test it & find out :)!

So far Game crashes after this, Testing others.

 

Everything else tested and worked Great! 

 

Edit: I seemed to have put something wrong in the code, Everything worked fantastic thank you!

Edited by Lokoluna
On 31 октября 2016 г. at 10:22 AM, Lokoluna said:

Thank you.. also uhm. How would i remove the ability to only eat meat?

It's not easy without replacing files.

But if it's your own character, you can "not to add" this ability.

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...