lyall_f Posted April 7, 2014 Share Posted April 7, 2014 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 More sharing options...
Rupture Posted April 7, 2014 Share Posted April 7, 2014 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. Link to comment https://forums.kleientertainment.com/forums/topic/34396-help-with-a-companion/#findComment-446900 Share on other sites More sharing options...
lyall_f Posted April 7, 2014 Author Share Posted April 7, 2014 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? Link to comment https://forums.kleientertainment.com/forums/topic/34396-help-with-a-companion/#findComment-446906 Share on other sites More sharing options...
Rupture Posted April 7, 2014 Share Posted April 7, 2014 (edited) 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 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 April 7, 2014 by Rupture Link to comment https://forums.kleientertainment.com/forums/topic/34396-help-with-a-companion/#findComment-446945 Share on other sites More sharing options...
lyall_f Posted April 7, 2014 Author Share Posted April 7, 2014 Well, to be honest i started with lua yesterday, so dont expect too much from me 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. :/ Link to comment https://forums.kleientertainment.com/forums/topic/34396-help-with-a-companion/#findComment-446972 Share on other sites More sharing options...
lyall_f Posted April 7, 2014 Author Share Posted April 7, 2014 Where exactly did you put that code? Was it in the charter prefab file? Link to comment https://forums.kleientertainment.com/forums/topic/34396-help-with-a-companion/#findComment-447015 Share on other sites More sharing options...
Rupture Posted April 7, 2014 Share Posted April 7, 2014 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 Link to comment https://forums.kleientertainment.com/forums/topic/34396-help-with-a-companion/#findComment-447158 Share on other sites More sharing options...
Heavenfall Posted April 7, 2014 Share Posted April 7, 2014 (edited) Try a DoPeriodicTask and delay the reposition with 0.01 seconds. OP you can look at my summons mod, it has a new recipe called summonclone. I think you'll find it very useful. Edited April 7, 2014 by Heavenfall Link to comment https://forums.kleientertainment.com/forums/topic/34396-help-with-a-companion/#findComment-447177 Share on other sites More sharing options...
lyall_f Posted April 7, 2014 Author Share Posted April 7, 2014 Try a DoPeriodicTask and delay the reposition with 0.01 seconds. OP you can look at my summons mod, it has a new recipe called summonclone. I think you'll find it very useful. Do you mind if I edit and use some of your code? Link to comment https://forums.kleientertainment.com/forums/topic/34396-help-with-a-companion/#findComment-447629 Share on other sites More sharing options...
Heavenfall Posted April 8, 2014 Share Posted April 8, 2014 Go for it. Link to comment https://forums.kleientertainment.com/forums/topic/34396-help-with-a-companion/#findComment-447954 Share on other sites More sharing options...
lyall_f Posted April 8, 2014 Author Share Posted April 8, 2014 (edited) 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 April 8, 2014 by Nmoyd Link to comment https://forums.kleientertainment.com/forums/topic/34396-help-with-a-companion/#findComment-447977 Share on other sites More sharing options...
Heavenfall Posted April 8, 2014 Share Posted April 8, 2014 Yes, just change what animation build it uses. By default it uses the same one as the player. Link to comment https://forums.kleientertainment.com/forums/topic/34396-help-with-a-companion/#findComment-447997 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now