Jump to content

Recommended Posts

I am trying to create a character that can change into a Varg and back at will, getting to the Varg isn't to hard, but I can't seem to change back... The human form is invisible. I am assuming it's because I am changing inst.AnimState:SetBank to "varg" to transform, but I also have no animation for moving up or down on screen in Varg Form... I am trying to modify an existing mod, here is what I've got:

local function BallFn(inst)
if inst:HasTag("playerghost") then return end
if inst.transformed then
inst.AnimState:SetBank("player_common")
inst.AnimState:SetBuild("tamamo")
inst.components.locomotor.walkspeed = (TUNING.WILSON_WALK_SPEED)
inst.components.locomotor.runspeed = (TUNING.WILSON_RUN_SPEED)
inst.components.health.absorb = 0.05
inst.components.combat.damagemultiplier = 0.8
inst.components.temperature.inherentinsulation = 35
inst.components.hunger:SetRate(0.18310)
inst:AddTag("character")
inst:RemoveTag("monster")

else 
	inst.AnimState:SetBank("warg")
    inst.AnimState:SetBuild("warg_build")
    inst:SetStateGraph("SGvargplayer")
	inst.components.health:SetMaxHealth(300)
	inst.components.hunger:SetMax(300)
	inst.components.combat:SetDefaultDamage(80)
	inst.components.combat.damagemultiplier = 1
	inst.components.temperature.inherentinsulation = 80
	inst.components.locomotor.walkspeed = (7)
	inst.components.locomotor.runspeed = (10)
	inst.components.temperature.maxtemp = 60
	inst.components.temperature.mintemp = 20
	inst.components.eater:SetDiet({ FOODTYPE.MEAT, FOODTYPE.MEAT }, { FOODTYPE.MEAT, FOODTYPE.MEAT })
	inst.components.eater:SetAbsorptionModifiers(4,2,2)
	inst.components.eater:SetCanEatHorrible()
	AddMinimapAtlas("images/map_icons/tamamo.xml")
	inst.components.eater.strongstomach = true -- can eat monster meat!
	inst:AddTag("monster")
	inst:RemoveTag("character")
	

	local sounds = 
	{
		walk = "dontstarve/beefalo/walk",
		grunt = "dontstarve/beefalo/grunt",
		yell = "dontstarve/beefalo/yell",
		swish = "dontstarve/beefalo/tail_swish",
		curious = "dontstarve/beefalo/curious",
		angry = "dontstarve/beefalo/angry",
	}


	local NIGHTVISION_COLOURCUBES =
	{
		day = "images/colour_cubes/insane_day_cc.tex",
		dusk = "images/colour_cubes/insane_dusk_cc.tex",
		night = "images/colour_cubes/purple_moon_cc.tex",
		full_moon = "images/colour_cubes/purple_moon_cc.tex",
	}

	local function SetNightVision(inst, enable)
		if TheWorld.state.isnight or TheWorld:HasTag("cave") then
			inst.components.playervision:ForceNightVision(true)
			inst.components.playervision:SetCustomCCTable(NIGHTVISION_COLOURCUBES)
		else
			inst.components.playervision:ForceNightVision(false)
			inst.components.playervision:SetCustomCCTable(nil)
		end
	end

	local function RestoreNightvision(inst)

		inst:DoTaskInTime(3, function(inst) 
		inst.Light:Enable(true)
		inst.Light:SetRadius(0)
		inst.Light:SetFalloff(.1)
		inst.Light:SetIntensity(.1)
		inst.Light:SetColour(245/255,40/255,0/255)
		end, inst)
	end

		inst.MiniMapEntity:SetIcon( "vargplayer.tex" )

		inst:DoTaskInTime(0, function()
	if ThePlayer then
		inst:EnableMovementPrediction(false)
	end
	end)

		inst:WatchWorldState( "isday", function() SetNightVision(inst) end)
		inst:WatchWorldState( "isdusk", function() SetNightVision(inst) end)
		inst:WatchWorldState( "isnight", function() SetNightVision(inst)  end)
		inst:WatchWorldState( "iscaveday", function() SetNightVision(inst) end)
		inst:WatchWorldState( "iscavedusk", function() SetNightVision(inst) end)
		inst:WatchWorldState( "iscavenight", function() SetNightVision(inst)  end)
	
		SetNightVision(inst)
	end



	local master_postinit = function(inst)
		inst.components.combat:SetAttackPeriod(TUNING.WARG_ATTACKPERIOD)
		inst.components.combat:SetRange(TUNING.WARG_ATTACKRANGE)
		inst.components.combat:SetHurtSound("dontstarve_DLC001/creatures/vargr/hit")
		inst.AnimState:SetBank("warg")
		inst.AnimState:SetBuild("warg_build")	
		inst.OnSetSkin = function(skin_name)
		inst.AnimState:SetBuild("warg_build")
		inst:SetStateGraph("SGvargplayer")
	
		inst:ListenForEvent("ms_respawnedfromghost", DontTriggerCreep)
		DontTriggerCreep(inst)
	

		inst:SetStateGraph("SGvargplayer")
		inst.components.locomotor:SetShouldRun(false)
		inst.components.talker:IgnoreAll()

	
		local light = inst.entity:AddLight()
		inst.Light:Enable(true)
		inst.Light:SetRadius(0)
		inst.Light:SetFalloff(0.9)
		inst.Light:SetIntensity(0.6)
		inst.Light:SetColour(180/255,195/255,150/255)
	
		inst.components.talker.colour = Vector3(127/255, 0/255, 0/255)
		inst:ListenForEvent("respawnfromghost", RestoreNightvision)

		inst:DoTaskInTime(0, setChar)
		inst:ListenForEvent("respawnfromghost", function()
			inst:DoTaskInTime(3, function()  inst.components.health:SetInvincible(false)
				if inst.components.playercontroller ~= nil then
					inst.components.playercontroller:EnableMapControls(true)
					inst.components.playercontroller:Enable(true)
				end
				inst.components.inventory:Show()
				inst:ShowActions(true)
				inst:ShowHUD(true)
				inst:SetCameraDistance()
				inst.sg:RemoveStateTag("busy")
				SerializeUserSession(inst) 
			end)
			inst:DoTaskInTime(5, setChar)
			inst:DoTaskInTime(6, RemovePenalty)
			inst:DoTaskInTime(6, DontTriggerCreep)
			inst:DoTaskInTime(10, RestoreNightvision)
		end)
	
		return inst
	
	end


 
	end
	
	
 
	inst.transformed = not inst.transformed

 
	-- inst.components.health:SetCurrentHealth(1)
	-- inst.components.health:DoDelta(0)
	return true
 
end

AddModRPCHandler("tamamo", "BALL", BallFn)

I've searched all over the Forums for help, but I wasn't able to find anything that was similar to my problem, so I thought I'd make a new thread. Any help would be greatly appreiciated as I'm fairly new to modding in Don't Starve!

Edited by ThatForgottonGuy

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