Jump to content

Help with a character perk- Transformation


Recommended Posts

So Im starting work on my second character mod, my first one really only required I changed some values that already existed in the base files for her perks, but for this character, I really want to make it so he transforms into a different form when his sanity is low. Im guessing I could probably recycle code from Woodie's beaver transformation, but I have no idea how I'd tell it to change with sanity, as well as how I'd link the sprite. Im asking now because i dont like waiting and want to finish this mod relatively quickly because it's partially for a friend. 

(Sorry if I reply late to anyone on here, im multitasking, so I might not be able to see it until tomorrow, especially since it's already quite late here)

Link to comment
Share on other sites

This sounds like an easy job for DoPeriodicTask. With it you can do things in a set interval (like checking your characters sanity)

I would do something like this:

local master_postinit = function(inst)
	inst:DoPeriodicTask(1, function()
		if inst.components.sanity:GetPercent() < 0.5 then
			-- Do stuff
		else
			-- Do other stuff
		end
	end)
end

When you wish to change a characters visual appearance, i think you mean to change it's build?

I have made a character that changes her appearance based on the season:

local winter_skin = false

local function HandleSkinChange(inst)
	if TheWorld.state.iswinter and not winter_skin then
		winter_skin = true
		inst.AnimState:SetBuild("avia_winter")
	elseif not TheWorld.state.iswinter and winter_skin then
		winter_skin = false
        inst.AnimState:SetBuild("avia")
	end
end

What does this mean? Well, in my anim folder i have two ZIP-Files: avia.zip and avia_winter.zip.

Of course avia.lua, my character prefab, loads both assets:

local assets = {
    Asset("SCRIPT", "scripts/prefabs/player_common.lua"),
	Asset( "ANIM", "anim/avia.zip" ),
	Asset( "ANIM", "anim/avia_winter.zip"),
}

If you want to, you can always check the mod yourself as a start. I attach it to this post.

avia_packed.zip

Link to comment
Share on other sites

Thanks! It is confusing to me but everything was confusing in the beginning! Ill catch on

1 hour ago, BakaSchwarz said:

This sounds like an easy job for DoPeriodicTask. With it you can do things in a set interval (like checking your characters sanity)

I would do something like this:


local master_postinit = function(inst)
	inst:DoPeriodicTask(1, function()
		if inst.components.sanity:GetPercent() < 0.5 then
			-- Do stuff
		else
			-- Do other stuff
		end
	end)
end

When you wish to change a characters visual appearance, i think you mean to change it's build?

I have made a character that changes her appearance based on the season:


local winter_skin = false

local function HandleSkinChange(inst)
	if TheWorld.state.iswinter and not winter_skin then
		winter_skin = true
		inst.AnimState:SetBuild("avia_winter")
	elseif not TheWorld.state.iswinter and winter_skin then
		winter_skin = false
        inst.AnimState:SetBuild("avia")
	end
end

What does this mean? Well, in my anim folder i have two ZIP-Files: avia.zip and avia_winter.zip.

Of course avia.lua, my character prefab, loads both assets:


local assets = {
    Asset("SCRIPT", "scripts/prefabs/player_common.lua"),
	Asset( "ANIM", "anim/avia.zip" ),
	Asset( "ANIM", "anim/avia_winter.zip"),
}

If you want to, you can always check the mod yourself as a start. I attach it to this post.

avia_packed.zip

 

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