Maxwell .LUA files


Tenjuin

Recommended Posts

Hello, I'm currently learning how to make my own custom character. He's an artist and I'd like to him to be able to make real life paintings which come to life and help the artist during his adventure. The art of the character is done. As a special power, I want the living paintings to work exactly like Maxwell shadow puppets.

I'd like to duplicate some codes into my artist files or maybe to understand the coding.

My problem is that I do not have Maxwells .LUA files. My question towards you is, how am I able to view the files of Maxwell?

Don't go hard on me for my english writting mistakes, I try my best to learn the laguage.
Thank you in advance.

 

Cedric

Link to comment
Share on other sites

I hope someone could help me.
I'd like to be able to summon the shadow puppets like Waxwell does, but I'd love to do it with my own custom made character. I tried to do some copy-paste but sadly it doesn't seem to work.
My character has the materials Waxwell has, but he's not able to interact with the Codex Umbra and the Shadow Tab doesn't show up.
I seem to miss something with he code, maybe I have to adjust the Shadow Puppet ULA file?

This is my ULA file of the character who I'd like to be able to summon the shadow puppets.
Thank you in advance.

 


local MakePlayerCharacter = require "prefabs/player_common"


local assets = {
    Asset("SCRIPT", "scripts/prefabs/player_common.lua"),
    Asset("SOUND", "sound/maxwell.fsb"),
}
local prefabs = {
    "shadow_despawn",
    "statue_transition_2",
}

-- Custom starting items
local start_inv = {

    "waxwelljournal",
    "nightmarefuel",
    "nightmarefuel",
    "nightmarefuel",
    "nightmarefuel",
    "nightmarefuel",
    "nightmarefuel",
}

local function DoEffects(pet)
    local x, y, z = pet.Transform:GetWorldPosition()
    SpawnPrefab("shadow_despawn").Transform:SetPosition(x, y, z)
    SpawnPrefab("statue_transition_2").Transform:SetPosition(x, y, z)
end

local function KillPet(pet)
    pet.components.health:Kill()
end

local function OnSpawn(inst, pet)
    --Delayed in case we need to relocate for migration spawning
    pet:DoTaskInTime(0, DoEffects)

    if not (inst.components.health:IsDead() or inst:HasTag("playerghost")) then
        inst.components.sanity:AddSanityPenalty(pet, TUNING.SHADOWWAXWELL_SANITY_PENALTY[string.upper(pet.prefab)])
        inst:ListenForEvent("onremove", inst._onpetlost, pet)
    elseif pet._killtask == nil then
        pet._killtask = pet:DoTaskInTime(math.random(), KillPet)
    end
end

local function OnDespawn(inst, pet)
    DoEffects(pet)
    pet:Remove()
end

local function OnDeath(inst)
    for k, v in pairs(inst.components.petleash:GetPets()) do
        if v._killtask == nil then
            v._killtask = v:DoTaskInTime(math.random(), KillPet)
        end
    end
end

local function common_postinit(inst)


    --reader (from reader component) added to pristine state for optimization
    inst:AddTag("reader")
    inst:AddTag("shadowmagic")
    inst:AddTag("dappereffects")
end


-- When the character is revived from human
local function onbecamehuman(inst)
    -- Set speed when reviving from ghost (optional)
    inst.components.locomotor:SetExternalSpeedMultiplier(inst, "cedric_speed_mod", 1)
end

local function onbecameghost(inst)
    -- Remove speed modifier when becoming a ghost
   inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "cedric_speed_mod")
end

-- When loading or spawning the character
local function onload(inst)
    inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman)
    inst:ListenForEvent("ms_becameghost", onbecameghost)

    if inst:HasTag("playerghost") then
        onbecameghost(inst)
    else
        onbecamehuman(inst)
    end
end


-- This initializes for both the server and client. Tags can be added here.
local common_postinit = function(inst) 
    -- Minimap icon
    inst.MiniMapEntity:SetIcon( "cedric.tex" )
end

-- This initializes for the server only. Components are added here.
local master_postinit = function(inst)
    -- choose which sounds this character will play
    inst.soundsname = "willow"
    
    -- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used
    --inst.talker_path_override = "dontstarve_DLC001/characters/"
    
    -- Stats    
    inst.components.health:SetMaxHealth(150)
    inst.components.hunger:SetMax(250)
    inst.components.sanity:SetMax(130)
    inst.components.health:StartRegen(1,8)
    
        inst:AddComponent("reader")

    inst:AddComponent("petleash")
    inst.components.petleash:SetOnSpawnFn(OnSpawn)
    inst.components.petleash:SetOnDespawnFn(OnDespawn)
    inst.components.petleash:SetMaxPets(4)

    inst.components.sanity.dapperness = TUNING.DAPPERNESS_LARGE
    inst.components.health:SetMaxHealth(TUNING.WILSON_HEALTH * .5)

    inst._onpetlost = function(pet) inst.components.sanity:RemoveSanityPenalty(pet) end
    -- Damage multiplier (optional)
    inst.components.combat.damagemultiplier = 1
    
    -- Hunger rate (optional)
    inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE
    
    inst.OnLoad = onload
    inst.OnNewSpawn = onload
    
end

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

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.