Jump to content

Changing Charcter model based off phase of game.


Recommended Posts

I'm building Escanor from seven deadly sins. So basically what I'm trying to do is make it so that escanor changes stats and body model(wimpy to mighty) based off the phase of the game (Day, Dusk, Night). Like wolfgang but instead of using hunger uses time of day. The mod works perfectly for what I can see EXCEPT when reviving. When reviving the character the game is choosing the default escanor.zip over the skin assigned in the phase check function. I've tried coding in two ways. The current iteration checks for the phase of the game then assigns the character the appropriate skin then assigns the appreciate states(which for now is move speed). Upon reviving it is assigning the correct stats but it's not assigning the correct sprite. The function appears to work as intended during phase changes. Also, my previous iteration was just separating the check phase function from the set wimpy, mighty, normal functions and letting phasecheck call wimpy, mighty, normal function depending on what phase was found. The function also works as intended when leaving a game on say dusk phase and rejoining and day phase it DOES assign the correct skin/stats on load. 

 

--checking phase
local function phasecheck(inst)
if not inst:HasTag("playerghost") then
    --checks for cave
    if TheWorld:HasTag("cave") then
        becomewimpy(inst, true)
    --checks if day    
    elseif TheWorld.state.phase == "day" then
        --sets skin

        inst.components.skinner:SetSkinMode("mighty_skin", "escanor_mighty")
        inst:AddTag("groggy")    
        local x, y, z = inst.Transform:GetWorldPosition()
        y = y + 1 + math.random() * 1.5
        SpawnPrefab("sparks").Transform:SetPosition(x, y, z)    
        inst.talksoundoverride = "dontstarve/characters/wx78/talk_LP"
        inst.hurtsoundoverride = "dontstarve/characters/wx78/hurt"
        --setspeed
        inst.components.locomotor:SetExternalSpeedMultiplier(inst, "escanor_speed_mod", 2.0)

        
    --checks if dusk
    elseif TheWorld.state.phase == "dusk" then
        --sets skin
        inst:RemoveTag("groggy")    
        inst.components.skinner:SetSkinMode("normal_skin", "escanor")
        local x, y, z = inst.Transform:GetWorldPosition()
        y = y + 1 + math.random() * 1.5
        SpawnPrefab("sparks").Transform:SetPosition(x, y, z)
        inst.talksoundoverride = "dontstarve/characters/wilson/talk_LP"
        inst.hurtsoundoverride = "dontstarve/characters/wilson/hurt"
        
        --sets speed
        inst.components.locomotor:SetExternalSpeedMultiplier(inst, "escanor_speed_mod", 1.2)
        
    --checks if night    
    elseif TheWorld.state.phase == "night" then
        --sets skin
        inst.components.skinner:SetSkinMode("wimpy_skin", "escanor_skinny")
        inst:RemoveTag("groggy")    
        local x, y, z = inst.Transform:GetWorldPosition()
        y = y + 1 + math.random() * 1.5
        SpawnPrefab("sparks").Transform:SetPosition(x, y, z)    
        inst.talksoundoverride = "dontstarve/characters/wilson/talk_LP"
        inst.hurtsoundoverride = "dontstarve/characters/wilson/hurt"
        
        --set speed
        inst.components.locomotor:SetExternalSpeedMultiplier(inst, "escanor_speed_mod", 0.9)

        end
    end
end

 


-- When the character is revived from human
local function onbecamehuman(inst)
    inst.components.talker:Say("pooop...")
    inst:DoTaskInTime(0,phasecheck)
    

    -- Set speed when not a ghost (optional)


end
 

 

 

 

 

 

 

 

 

 

 

 

 

Edited by methodmane
Link to comment
Share on other sites

That does not make a lot of sense. The only thing I can imagine, is that maybe after doing the revival animation it resets the build to the default build, so you actually have to wait more than 1 frame (your 0 time for the DoTaskInTime call) in order to have it change the build at the right time. Start by setting the time to 5 seconds, and see if that works. Then try other time ranges. You may find out that the time you get to matches the amount of frames used for the revival animation. You could also start there, and calculate the exact time you'd have to wait, but personally I like to do broad strokes first, just to see if I can get it to work "roughly" :)

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