Jump to content

{ Help } Need assistance with codes for certain traits


Recommended Posts

I'm modding for the first time but i'm a little familiar with coding from high school. I'm also new to this forum and couldn't seem to find these codes listed anywhere?

if anyone could give me some tips on coding lines for the objectives below for a custom character mod?

- Either immune to damage from shadow tentacles or them not appearing due to the character.

- Health/insanity gained from eating raw meat.

- Vulnerable to fire damage.

I'm currently following a detailed tutorial at http://dont-starve.surge.sh/ so i know where to add the code, just not the code itself. 

TYSM for any help!

Link to comment
Share on other sites

inst.components.health.fire_damage_scale = 3
    	inst.components.locomotor.walkspeed = TUNING.WILSON_WALK_SPEED * 1.2
    	inst.components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED * 1.2

I'm not exactly sure if this works but it should, and what do you mean by shadow tentacles? the only ones I know of spawn when using the thucelite club and they don't harm the player.

Link to comment
Share on other sites

Oh those, Alright, and the code I had for a while and had removed it from my character when I didn't want it any more. this part of the code

inst.components.locomotor.walkspeed = TUNING.WILSON_WALK_SPEED * 1.2
    	inst.components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED * 1.2

should make the character run faster when on fire. (Though I am not too sure if it works completely as I didn't notice a difference in the walkspeed when testing)

Link to comment
Share on other sites

any way these codes are simple if you get a basic understanding of the Don't starve API the part with making the tentacles passive towards the character on the other hand... I cant even think how that would be coded.

 

The eating of raw/monstermeat I think you can find in Webber's LUA under don'tstarvetogehter/data/scripts webber.lua I believe there might be something there that could help.

Edited by Andreasgamming
Link to comment
Share on other sites

1 hour ago, Andreasgamming said:

Oh those, Alright, and the code I had for a while and had removed it from my character when I didn't want it any more. this part of the code


inst.components.locomotor.walkspeed = TUNING.WILSON_WALK_SPEED * 1.2
    	inst.components.locomotor.runspeed = TUNING.WILSON_RUN_SPEED * 1.2

should make the character run faster when on fire. (Though I am not too sure if it works completely as I didn't notice a difference in the walkspeed when testing)

That would just make the character run faster in general, not linked to being on fire.

About the tentacles, you would need to modify their behaviour directly if you don't want them to come out.

If you modify their targeting function to ignore your character that should odo the job.

Let's say you add a tag into your character prefab

inst:AddTag("notentacletarget")

then in you modmain you could add something along these lines

local function MyTentacleTargetModFn(inst)
	if inst.components and inst.components.combat then
		if inst.components.combat.target ~= nil and inst.components.combat.target:HasTag("notentacletarget") then
			inst.components.combat:TryRetarget()
			if inst.components.combat.target:HasTag("notentacletarget") then 	-- retargeting failed because no other valid target around
				inst.components.combat:DropTarget()								-- we make the tentacle drop the target (your character)
				return
			end
		end
	end
end

AddPrefabPostInit("tentacle", function(tentacle)
	if TheWorld.ismastersim then
		local OriginalTargetFn = tentacle.components.combat.targetfn

		tentacle.components.combat.targetfn = function(inst)
			OriginalTargetFn(inst)			-- we call the original targeting function
			MyTentacleTargetModFn(inst)		-- we post check if the target is your character by executing the function defined above
		end
	end
end)

Untested but that gives you the idea

Link to comment
Share on other sites

2 hours ago, Andreasgamming said:

should make the character run faster when on fire. (Though I am not too sure if it works completely as I didn't notice a difference in the walkspeed when testing)

You need a condition for it to work, like "if character is on fire, then, [improved stat], else [base stat]"

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