Jump to content

Recommended Posts

Alrighty, I really want to learn how to make a character transform. I did look through the codes but... My knowledge of codes have become Rusty. I wish there was a template or something for transformations but as far as I have looked, there is none. Any good pointers? I have looked at Woodies prefab file so don't bother trying to point me there, I can't find a thing in the main files.

Okay, I ripped this code from the Daisy piggy princess mod, I understand some of it, but not all of it, Yes I did also grab the Watchworldstate code too. Just some variables I need to be clarified.

 

local function andreasform(inst)
        inst.strength == "moondaisy" then --???
	
        inst.AnimState:SetBuild("angel_of_darkness") --I know this is calling the Anim build
		
		local x, y, z = inst.Transform:GetWorldPosition()
		local fx = SpawnPrefab("maxwell_smoke")
		fx.Transform:SetPosition(x, y, z)
		SpawnPrefab("statue_transition").Transform:SetPosition(inst:GetPosition():Get())	
		inst.SoundEmitter:PlaySound("dontstarve/creatures/werepig/grunt")					
		inst:AddTag("angel_of_darkness")		--Special custom tag
		inst:AddTag("insomniac")		--Player can't Sleep
		inst:AddTag("scarytoprey")		--Makes rabits and birds run away

		inst.components.eater.ignoresspoilage = true
		inst.components.eater.strongstomach = true		
	    inst.components.combat.damagemultiplier = 6
		inst.components.hunger.hungerrate = 2 * TUNING.WILSON_HUNGER_RATE
		inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.6)
		inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.6)
		inst.components.sanity.dapperness = TUNING.DAPPERNESS_LARGE * (-4)	
 
	end


local function OnPigMoon(inst, isfullmoon) [[I Have no clue what this one does at all.]]

	if isfullmoon then
	inst.strength = "moondaisy"		
		daisyform(inst)	
		piggychange(inst)		
	else 		
		inst.strength = "hungrypig"		
		daisyform(inst)		
		piggychange(inst)

	end 
end

In the actual code it isn't commented out, I messed up with doing the comments here.

you probably want to look at the daisyform and piggy change functions. All you really need to do though to transform is change your bank and build and probably stategraph (depends on what you're wanting to transform into), then have something watch the conditions you want and call that function when conditions are met.

Edited by DarkKingBoo
On 6/22/2018 at 6:32 AM, DarkKingBoo said:

you probably want to look at the daisyform and piggy change functions. All you really need to do though to transform is change your bank and build and probably stategraph (depends on what you're wanting to transform into), then have something watch the conditions you want and call that function when conditions are met.

I'm Getting confused and lost >.< I found the functions for piggychange and Daisy form but I hve no clue what they are refering too exactly. I may search for a different mod to rip the code from, this one is based on her hunger and what she eats. I want a my character to change when there is a new moon.

local function isaform(inst)

    if inst.strength == "isa" then 		
	inst:RemoveTag("insomniac")	
	inst:RemoveTag("scarytoprey")		

    inst.AnimState:SetBuild("isa")
	inst.components.talker:Say("...", 2.5,true)		
		local x, y, z = inst.Transform:GetWorldPosition()
		local fx = SpawnPrefab("maxwell_smoke")
		fx.Transform:SetPosition(x, y, z)
		SpawnPrefab("statue_transition").Transform:SetPosition(inst:GetPosition():Get())
		
	inst.components.eater.ignoresspoilage = false				
	inst.components.eater.strongstomach = false
	inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.3)
	inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.3)	
	inst.components.hunger.hungerrate = 0.5 * TUNING.WILSON_HUNGER_RATE					
	inst.components.combat.damagemultiplier = 0.75	
	inst.components.sanity.dapperness = 0
	inst.entity:AddLight()
    inst.Light:Enable(false) 
	inst.Light:SetRadius(40) 
	inst.Light:SetFalloff(.5)
    inst.Light:SetColour(245/255,255/255,245/255)
	
    elseif inst.strength == "ehvas" then
	inst:AddTag("insomniac")	
	inst:AddTag("scarytoprey")		
	
	inst.AnimState:SetBuild("ehvas")
		local x, y, z = inst.Transform:GetWorldPosition()
		local fx = SpawnPrefab("maxwell_smoke")
		fx.Transform:SetPosition(x, y, z)
		SpawnPrefab("statue_transition").Transform:SetPosition(inst:GetPosition():Get())	
		
	inst.components.eater.ignoresspoilage = true
	inst.components.eater.strongstomach = true		
	inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED * 1.7)
	inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED * 1.7)				
	inst.components.hunger.hungerrate = 3 * TUNING.WILSON_HUNGER_RATE
	inst.components.combat.damagemultiplier = 2
	inst.components.sanity.dapperness = 0
	inst.entity:AddLight()
    inst.Light:Enable(true) 
	inst.Light:SetRadius(5) 
	inst.Light:SetFalloff(.5)
    inst.Light:SetColour (255/255, 0/255, 0/255)
	
	end
	
	
end



local function isachange(inst, phase)

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

    if inst.strength == "ehvas" then
            if inst.components.sanity.current > 50 then
			inst.strength = "isa"			
			isaform(inst)
            end
    end
	
    if inst.strength == "isa" then
            if inst.components.sanity.current < 50 then
			inst.strength = "ehvas"		
			isaform(inst)
            end
    end
	
	
end

Alrighty this one makes a little bit more sense to me, it has less variables to change. I know that the code is set to make the character change when her sanity is at a certain amount below 50% So What I gotta do is change it to make the character to change when there is no moon... Problem is I have no clue of how to do that...

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