Jump to content

Recommended Posts

Spoiler

local MakePlayerCharacter = require "prefabs/player_common"

local assets = {
    Asset("ANIM", "anim/drecalen.zip"),
    Asset("ANIM", "anim/insane_drecalen.zip"),
    Asset("ANIM", "anim/psycho_drecalen.zip"),
    Asset("ANIM", "anim/ghost_drecalen_build.zip"),
}

local prefabs = {
    "goldnugget",
    "gears",
}

local start_inv = {
    "goldnugget",
    "goldnugget",
    "goldnugget",
    "gears",
    "gears",
    "gears",
}

local function OnLocomote(inst)

local sanity = inst.components.sanity.current

if inst.AnimState:GetCurrentFacing() == 2 and sanity > 40 then 
inst.AnimState:SetBuild("drecalen") -- left normal

elseif inst.AnimState:GetCurrentFacing() == 0 and sanity > 40 then 
inst.AnimState:SetBuild("drecalen_right") -- right normal

elseif inst.AnimState:GetCurrentFacing() == 2 and sanity > 5 then
inst.AnimState:SetBuild("insane_drecalen") -- left insane, remove "inst.AnimState:GetCurrentFacing() == 2" if he doesn't have a insane right_build

elseif inst.AnimState:GetCurrentFacing() == 0 and sanity > 5 then
inst.AnimState:SetBuild("insane_drecalen_right") -- right insane, remove this elseif if he doesn't have insane right_build

elseif inst.AnimState:GetCurrentFacing() == 2 and sanity < 5 then
inst.AnimState:SetBuild("psycho_drecalen") -- left psycho, remove "inst.AnimState:GetCurrentFacing() == 2" if he doesn't have a psycho right_build

elseif inst.AnimState:GetCurrentFacing() == 0 and sanity < 5 then
inst.AnimState:SetBuild("psycho_drecalen_right") -- right psycho, remove this elseif if he doesn't have psycho right_build

end
end

local function update_stats(inst)
    local newstatus = GetStatus(inst)
    if inst.status == newstatus then
        return
    end

 if newstatus ~= nil and newstatus == "drecalen" then
        inst.components.combat.damagemultiplier = 0.75
        inst.components.hunger:SetRate(0.07)
        inst.Transform:SetScale(0.94, 0.94, 0.94)
        inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.1)
        inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.1)
        inst.status = "drecalen"
        inst.components.skinner:SetSkinMode("normal_skin", "drecalen")
    elseif newstatus ~= nil and newstatus == "insane_drecalen" then
        inst.components.talker:Say("Kekeke...")
        inst.components.combat.damagemultiplier = 2.0
        inst.components.hunger:SetRate(0.02)
        inst.Transform:SetScale(1.1, 1.1, 1.1)
        inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 2.0)
        inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 2.0)
        inst.status = "insane_drecalen"
        inst.components.skinner:SetSkinMode("insane_skin", "insane_drecalen")
    elseif newstatus ~= nil and newstatus == "psycho_drecalen" then
        inst.components.talker:Say(".....")
        inst.components.combat.damagemultiplier = 5.0
        inst.components.hunger:SetRate(0.001)
        inst.Transform:SetScale(1.5, 1.5, 1.5)
        inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 0.2)
        inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 0.2)
        inst.status = "psycho_drecalen"
        inst.components.skinner:SetSkinMode("psycho_skin", "psycho_drecalen")
    elseif newstatus ~= nil and newstatus == "ghost_drecalen" then
        inst.Transform:SetScale(1, 1, 1)
        inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 20)
        inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 20)
        inst.status = "ghost_drecalen"
    end
end

local function on_become_ghost(inst)
    update_stats(inst)
    inst:RemoveEventCallback("sanitydelta", update_stats)
end

local function on_become_dragon(inst)
    update_stats(inst)
    inst:ListenForEvent("sanitydelta", update_stats)
end

local function OnLoad(inst)
    inst:ListenForEvent("ms_respawnedfromghost", on_become_dragon)
    inst:ListenForEvent("ms_becameghost", on_become_ghost)

    if inst:HasTag("playerghost") then
        on_become_ghost(inst)
    else
        on_become_dragon(inst)
    end
end
 
-- This initializes for both clients and the host
local common_postinit = function(inst)
    -- choose which sounds this character will play
    inst.soundsname = "wendy"
    -- Minimap icon
    inst.MiniMapEntity:SetIcon("drecalen.tex")
end

local function AdeptMiner(inst)
    inst:ListenForEvent("finishedwork", function(inst, data)
        if data and data.action == ACTIONS.MINE then
            local lootpack = SpawnPrefab("drecalen_mineloot")
            lootpack.Transform:SetPosition(inst.Transform:GetWorldPosition())
            local lootdropper = lootpack.components.lootdropper
            if math.random() < 0.7 then
                lootdropper:AddChanceLoot("redgem", 0.1)
                lootdropper:AddChanceLoot("bluegem", 0.1)
                lootdropper:AddChanceLoot("purplegem", 0.1)
            else
                lootdropper:AddChanceLoot("orangegem", 0.1)
                lootdropper:AddChanceLoot("yellowgem", 0.1)
                lootdropper:AddChanceLoot("greengem", 0.1)
            end
            lootdropper:DropLoot()
            lootpack:Remove()
        end
    end)
end

-- This initializes for the host only
local master_postinit = function(inst)
    -- Stats
    inst.components.health:SetMaxHealth(200)
    inst.components.hunger:SetMax(300)
    inst.components.sanity:SetMax(100)
        
    inst.components.temperature.inherentsummerinsulation = 120
    inst.components.health.fire_damage_scale = 0

    inst.components.sanity.night_drain_mult = 0.1
    inst.components.sanity.neg_aura_mult = 0.3

    inst.OnLoad = OnLoad
    inst.OnNewSpawn = OnLoad

    -- Fix for hats, although it would be better to look at the art and recompile
    inst:ListenForEvent("equip", function(inst, data)
        if data and data.eslot == EQUIPSLOTS.HEAD then
            inst.AnimState:Show("HEAD")
            inst.AnimState:Hide("HEAD_HAT")
        end
    inst:ListenForEvent("locomote", OnLocomote)
    end)

    AdeptMiner(inst)
end

return MakePlayerCharacter("drecalen", prefabs, assets, common_postinit, master_postinit, start_inv)
 

ok, i have a bug with this script. apparently the "Getstatus" doesnt exist, which is causing this character mod to crash. 

i dont know how to write this out, and i cannot find anything else online.

Link to comment
https://forums.kleientertainment.com/forums/topic/71509-getstatus/
Share on other sites

this is obviously a mod character with stuff saved in inst (it uses inst.status which is not used by the game). This is not recommend, cause this status is not saved and other problems.

So it is very likely, that also this "GetStatus" function is a function that was made from the modder.
So you have to ask the author.

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