Jump to content

First mod: how to make a character able to transform?


Recommended Posts

Hey there!

I can't give an exact solution to you (I'm far from expert in modding as well), but I can give you some tips to help to start your thingy.

The main lines you'll need for this are:

- inst.AnimState:SetBuild("ABC") --(replace ABC with the name of the texture folder to change your character when a defined event occur)

- inst.AnimState:SetScale(1.2, 1.2) --(you can use this to change the size of your character - this coding increases by 1.2x, change it as you wish)

Some codings I've used before:

I've used this local function (so you have to put it into your character's prefab file, somewhere below the starting inventory section) to make my character change it's texture when his Sanity reaches certain points:

Spoiler

 

local function changemymind(inst)
local sanity = inst.components.sanity.current

if inst:HasTag("playerghost") then return end
if inst.components.health:IsDead() then return end

    -- stage I
    if sanity <= 25 then
        inst.AnimState:SetBuild("wolemormnumber3")
    end
    
    -- stage II
    if sanity >= 26 and sanity <= 74 then
        inst.AnimState:SetBuild("wolemormnumber2")        
    end
    
    -- stage III
    if sanity >= 75 then
        inst.AnimState:SetBuild("wolemormnumber1")        
    end
end

 

You have to add an event listener as well to trigger the function (into the local master_postinit = function(inst) section):

Spoiler

inst:ListenForEvent("sanitydelta", changemymind)

Now, my coding does the transformation (texture change) when the survivor's Sanity reaches a certain value. You can use this coding as a skeleton for your coding, but you have to configure it a bit. The easiest thing to do is to find a mod that does this texture change thingy and combine it with the coding above (or just copy it from the mod completely). The Invader Zim mod does this for sure, but you can find plenty with this feature. To look into a mod's coding, subscribe to the mod, launch the game, quit the game, locate the DST files in your computer, find the mods folder and open the mod's folder you're looking for.

If something is unclear, feel free to ask. I'll try my best to help, but I can't promise I can some up with a solution.

Cheers!

Edited by C_Thun
  • Thanks 1
Link to comment
Share on other sites

15 hours ago, BillTheCipher said:

Hey there!

I can't give an exact solution to you (I'm far from expert in modding as well), but I can give you some tips to help to start your thingy.

The main lines you'll need for this are:

- inst.AnimState:SetBuild("ABC") --(replace ABC with the name of the texture folder to change your character when a defined event occur)

- inst.AnimState:SetScale(1.2, 1.2) --(you can use this to change the size of your character - this coding increases by 1.2x, change it as you wish)

Some codings I've used before:

I've used this local function (so you have to put it into your character's prefab file, somewhere below the starting inventory section) to make my character change it's texture when his Sanity reaches certain points:

  Reveal hidden contents

 

local function changemymind(inst)
local sanity = inst.components.sanity.current

if inst:HasTag("playerghost") then return end
if inst.components.health:IsDead() then return end

    -- stage I
    if sanity <= 25 then
        inst.AnimState:SetBuild("wolemormnumber3")
    end
    
    -- stage II
    if sanity >= 26 and sanity <= 74 then
        inst.AnimState:SetBuild("wolemormnumber2")        
    end
    
    -- stage III
    if sanity >= 75 then
        inst.AnimState:SetBuild("wolemormnumber1")        
    end
end

 

You have to add an event listener as well to trigger the function (into the local master_postinit = function(inst) section):

  Reveal hidden contents

inst:ListenForEvent("sanitydelta", changemymind)

Now, my coding does the transformation (texture change) when the survivor's Sanity reaches a certain value. You can use this coding as a skeleton for your coding, but you have to configure it a bit. The easiest to do is to find a mod that does this texture change thingy and combine it with the coding above (or just copy it from the mod completely). The Invader Zim mod does this for sure, but you can find plenty with this feature. To look into a mod's coding, subscribe to the mod, launch the game, quit the game, locate the DST files in your computer, find the mods folder and open the mod's folder you're looking for.

If something is unclear, feel free to ask. I'll try my best to help, but I can't promise I can some up with a solution.

Cheers!

Woah! Thanks a lot!

 

Link to comment
Share on other sites

16 hours ago, BillTheCipher said:

- inst.AnimState:SetScale(1.2, 1.2) --(you can use this to change the size of your character - this coding increases by 1.2x, change it as you wish)

Isn't Transform better?. It scales a few parameters like walking speed automatically

Link to comment
Share on other sites

55 minutes ago, Well-met said:

Isn't Transform better?. It scales a few parameters like walking speed automatically

That one works as well, but I prefer this one a bit more personally.

- If you want to keep the basic Wilson speed (or adjust it to a given value) with a giant or a tiny character, you should use AnimState

- If you want a proportionally increasing speed with the resize, you should use Transform

Both of them is useful, but in different scenarios.

  • Like 1
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...