Jump to content

[Help] How do I add perks that are already in the game to a custom character?


Recommended Posts

Hi. I've wanted to make a custom character mod since 2015, but they failed... So I wanted to make a DST one, and all I need to know is how to add current perks. The perks I want to add to my custom character are, Not a picky eater, and excels in battle. The character I'm making is Pac-Man... Don't know why but, Meh... Please tell me if you can!

Link to comment
Share on other sites

This is for "Not a picky eater" put it in YOURCHARACTER.lua inside the master_postinit

inst.components.eater.ignoresspoilage = true

 

And this is for "Excels in battle" put these parts in YOURCHARACTER.lua outside the master_postinit

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 Pacman_Killed(inst, data)
local victim = data.victim

	if IsValidVictim(victim) then
		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 Pacman_Attack(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 & clamp does account for 0 & 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

 

Annndd thiss is for "Excels in battle" too... Put these parts in YOURCHARACTER.lua inside the master_postinit

Spoiler

inst.battleborn = 0
inst.battleborn_time = 0

inst:ListenForEvent("killed", Pacman_Killed)
inst:ListenForEvent("onattackother", Pacman_Attack)

 

These should work, buuttt if they crash the game or soomething then tell me! Peace :D~!

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