Jump to content

Recommended Posts

In the last two days I picked up a lot about Don't Stave modding and I have created a fully working playable character however I have wanted to create an npc companion to make him somewhat special. I have had next to no luck making an npc that follows my character and spawns at the start of the game. Any help?

Link to comment
https://forums.kleientertainment.com/forums/topic/34396-help-with-a-companion/
Share on other sites

In the last two days I picked up a lot about Don't Stave modding and I have created a fully working playable character however I have wanted to create an npc companion to make him somewhat special. I have had next to no luck making an npc that follows my character and spawns at the start of the game. Any help?

 

If you poke around in the .luas in the game you can gather lots of info on how to do this. Abigail seems to have a lot of the behavior you want. For the spawning i would suggest spawning it when your character loads. To avoid duplicates just add a unique tag to it. 

Use the FindEntity() function to check for other mobs with the tag, and if a copy already exists don't spawn another one. 

If you poke around in the .luas in the game you can gather lots of info on how to do this. Abigail seems to have a lot of the behavior you want. For the spawning i would suggest spawning it when your character loads. To avoid duplicates just add a unique tag to it. 

Use the FindEntity() function to check for other mobs with the tag, and if a copy already exists don't spawn another one. 

 

Just letting you know, my best experience with coding is 5 years of self taught stuff so anything I could cobble together I would need to know how to do it. So any idea on where could start I on what you said?

Just letting you know, my best experience with coding is 5 years of self taught stuff so anything I could cobble together I would need to know how to do it. So any idea on where could start I on what you said?

 

Well, to be honest i started with lua yesterday, so dont expect too much from me :razz:

 

I have gotten to the point where 1 unique bee spawns on your position. The only problem is that it wants to kill you.

function SpawnPet(inst)	local maybe = GLOBAL.GetClosestInstWithTag("uniquepet", inst, 1000)	print(maybe)	if not maybe then		local pet = GLOBAL.SpawnPrefab("bee")		pet:AddTag("uniquepet")		pet:AddComponent("follower")		pet.Transform:SetPosition(inst:GetPosition():Get())		if inst and inst.components.leader then			inst.components.leader:AddFollower(inst)		end			endendAddPrefabPostInit("wilson", SpawnPet)
Edited by Rupture

 

Well, to be honest i started with lua yesterday, so dont expect too much from me :razz:

 

I have gotten to the point where 1 unique bee spawns on your position. The only problem is that it wants to kill you.

function SpawnPet(inst)	local maybe = GLOBAL.GetClosestInstWithTag("uniquepet", inst, 1000)	print(maybe)	if not maybe then		local pet = GLOBAL.SpawnPrefab("bee")		pet:AddTag("uniquepet")		pet:AddComponent("follower")		pet.Transform:SetPosition(inst:GetPosition())		if inst and inst.components.leader then			inst.components.leader:AddFollower(inst)		end			endendAddPrefabPostInit("wilson", SpawnPet)

 

Oh cool, this could be very useful. Now the problem is making a human npc that uses a player sprite if possible. :/

Where exactly did you put that code? Was it in the charter prefab file?

 

No i put it in the modmain.lua. Make sure you use the updated version :) For some reason it always spawns at (0,0,0) tho, would love to know why if any1 pokes their head in here. Tried to reference both inst and GLOBAL.GetPlayer(), but no luck on either :(

Go for it.

 

Most of today I have been pulling apart your mod and I have made it bare bones with nothing but the clone its self and the GS file. Now, can I make it look like a set player no matter what? I have been trying but I keep breaking it.

Edited by Nmoyd

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