Jump to content

Recommended Posts

So, I am making a character mod of SCP-049. If you are familiar with that character, you are aware that he can make zombie-like things. I need to recreate that in Don't Starve, somehow.

What I need:

  • A mob that spawns from a dead pigman when killed by a specific (mod) character. (in other words, when this character kills a pigman, it becomes this mob)
  • That mob to be permanently befriended towards said character, until death.
  • That mob to die on it's own after 3 days. (it doesn't need to drop anything on death)

I also need to know how to make custom art for it. It's basically just going to be a zombie pig.

 

So basically, I need to know how to make a mob from scratch, and I have no clue how to mod, beyond very simple changes and art stuff.

If you require more information, I'll happily give it to you.

 

Edited by Canis

This is a very complicated mod to start out with. If you're a newcomer I'd advise you to take a look at this post to get you set up.

I haven't ever made an actual monster/friendly AI creature, but I know there are mods out there that have done it. If I were you, I'd take a look at the code for those, and study them. There is also this great tutorial on the forum on how to make new creatures, but I don't know if it still works.

To make something happen when a pigman dies AND be able to check who the attacker is, you cannot use a listener for the event "killed", because that event only give the data about who the victim is, and not the attacker. You CAN however use a rarely used extra function called onkilledbyother, which DOES include the attacker. Then you can spawn your custom creature once you get it made.

local OnPigmanDeath = function(inst, attacker)
	if attacker and attacker == GetPlayer() then
		-- Spawn your custom prefab (creature)
	end
end

AddPrefabPostInit("pigman", function(inst)
	if inst.components.combat then
		if inst.components.combat.onkilledbyother == nil then
			inst.components.combat.onkilledbyother = OnPigmanDeath
		else
			local old_onkilledbyother = inst.components.combat.onkilledbyother
			inst.components.combat.onkilledbyother = function(inst, attacker)
				old_onkilledbyother(inst, attacker)
				OnPigmanDeath(inst, attacker)
			end
		end
	end
end)

 

Edited by Ultroman

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