Yakuzashi Posted November 8, 2019 Share Posted November 8, 2019 (edited) Introduction Hello everyone. I hadn't seen any tutorial dedicated to this topic. At the start I need to state that I am pretty lame in everything associated with modding, so don't expect sophisticated solutions. This tutorial is simple yet effective, I have to agree that it could be better but as I have said, I am just simple man. I have used my old projects to explain you the scheme of your custom follower. Template is based on this: Main Part To make functional follower you need to introduce the follower's: - main script [creature.lua], the corpus of you follower - anchor [anchor.lua], I have called it this way, because it attaches and provides easy summoning of the creature to your DST world - brain [creaturebrain.lua], yep, that's the brain, every action you require from your creature belongs to it - stategraph [SGcreature.lua], this file gives your creature ability to perform any visible action, because it's connected with animations and their realizations Locations Main Folder -> scripts -> prefabs -> [creature.lua] Main Folder -> scripts -> prefabs -> [anchor.lua] Main Folder -> scripts -> brains -> [creaturebrain.lua] Main Folder -> scripts -> stategraphs -> [SGcreature.lua] How to make mine template yours ? That's simple! Follow me this way! At the start, change my names [name.lua] into yours. [taern.lua] That should be your character's name. into local common_postinit = function(inst) goes inst:AddTag("summonerally") Add this tag to prevent summoned creature from attacking your character and vice versa. and local master_postinit = function(inst) goes inst:AddComponent("reader") It will let you read books, which is crucial for this method of summoning follower. [creature.lua] Change name 'creature' into yours follower's name. Using Ctrl+F in Notepad++ as shown in ESCT tutorial by Dragon Wolf Leo. Quote Asset("ANIM", "anim/creature.zip" ), That's your follower's appearance [Main Folder -> exported -> creature] You can call it what you want to, but it must match [name in exported] and all other references in whole mod to work properly. [anchor.lua] Change name 'anchor' into your summoning item. [creaturebrain.lua] I am not sure if changing CreatureBrain name will affect anything but just to be sure you can try. function CreatureBrain:OnStart() local root = PriorityNode( { WhileNode(function() return IsNearLeader(self.inst, KEEP_WORKING_DIST) end, "Leader In Range", PriorityNode({ IfNode(function() return self.inst.prefab == "creature" end, "Is Duelist", PriorityNode({ WhileNode(function() return self.inst.components.combat:GetCooldown() > .5 and ShouldKite(self.inst.components.combat.target, self.inst) end, "Dodge", RunAway(self.inst, { fn = ShouldKite, tags = { "_combat", "_health" }, notags = { "INLIMBO" } }, KITING_DIST, STOP_KITING_DIST)), ChaseAndAttack(self.inst), }, .25)), IfNode(function() return self.inst.prefab == "creature" end, "Keep Chopping", DoAction(self.inst, function() return FindEntityToWorkAction(self.inst, ACTIONS.CHOP) end)), IfNode(function() return self.inst.prefab == "creature" end, "Keep Mining", DoAction(self.inst, function() return FindEntityToWorkAction(self.inst, ACTIONS.MINE) end)), IfNode(function() return self.inst.prefab == "creature" end, "Keep Digging", DoAction(self.inst, function() return FindEntityToWorkAction(self.inst, ACTIONS.DIG, DIG_TAGS) end)), }, .25)), Follow(self.inst, GetLeader, MIN_FOLLOW_DIST, TARGET_FOLLOW_DIST, MAX_FOLLOW_DIST), WhileNode(function() return GetLeader(self.inst) ~= nil end, "Has Leader", FaceEntity(self.inst, GetFaceTargetFn, KeepFaceTargetFn)), }, .25) self.bt = BT(self.inst, root) end Those lines inside of this chunk must match your prefab's name. If it won't match your follower is not going to perform those actions (fighting,mining,chopping,digging) ex. 'Creature' =/= 'creature' and your follower will not dig out objects in this case. Quote IfNode(function() return self.inst.prefab == "Creature" end, "Keep Digging", DoAction(self.inst, function() return FindEntityToWorkAction(self.inst, ACTIONS.DIG, DIG_TAGS) end)), [SGcreature.lua] Change name 'creature' into yours follower's name. If you want your creature to be non-humanoid you can play with stategraph to match your animation's frames, but I don't know how to achieve rewarding results. [modmain.lua] PrefabFiles = { "taern", "taern_none", ------------ "creature", } Change name 'creature' into yours follower's name one more. Add this: Assets = { Asset("ATLAS", "images/inventoryimages/anchor.xml"), Asset("IMAGE", "images/inventoryimages/anchor.tex"), Asset("ANIM", "anim/creature.zip"), } This will make your item [anchor] avaible to craft and use. Just remember about CAPITALS. GLOBAL.STRINGS.NAMES.ANCHOR = "Anchor" GLOBAL.STRINGS.RECIPE_DESC.ANCHOR = "Allows you to summon your custom creature into this world." GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.ANCHOR = "Is this a Ouija board ?" local anchor = Ingredient( "anchor", 1 ) anchor.atlas = "images/inventoryimages/anchor.xml" local anchor = AddRecipe("anchor", { Ingredient("feather_crow", 2), Ingredient(GLOBAL.CHARACTER_INGREDIENT.SANITY, 20), Ingredient("goldnugget", 4)}, RECIPETABS.WAR, TECH.NONE, nil, nil, nil, nil, nil, "images/inventoryimages/anchor.xml") You will need to create additional: - [Main Folder -> exported -> anchor] for your item if you want to see it in game. - [Main Folder -> images -> inventoryimages] and place your 64x64 icon of item TEX and XML. Change names in XML too. Appendix So everything beyond 'vanilla' tutorial is added by me to make your life easier. If you have created your first custom character you won't have problems with distinguishing extraordinary files connected with custom follower. I have attached my template just few lines under this block of text. Have fun with your digital friend P.S. I know my english is not perfect, but I think it's pretty understandable. Well if not just write a comment below and I will try to help you the best I can Download the template here -----> Taern - Follower Tutorial.zip Edited November 8, 2019 by Yakuzashi Some SPACEBARS 4 2 1 Link to comment Share on other sites More sharing options...
Thomas Die Posted November 9, 2019 Share Posted November 9, 2019 you can also add the chatter function if you want your follower to have some speech Link to comment Share on other sites More sharing options...
mchoneybee Posted June 20, 2020 Share Posted June 20, 2020 On 11/9/2019 at 4:14 AM, thomas4846 said: you can also add the chatter function if you want your follower to have some speech How does one add the chatter function? owo? Link to comment Share on other sites More sharing options...
red1500z Posted November 7, 2020 Share Posted November 7, 2020 hi, i made the follower fabricable but i don't know how to make it follow me do you know how to fix it? Link to comment Share on other sites More sharing options...
Yakuzashi Posted November 7, 2020 Author Share Posted November 7, 2020 2 hours ago, red1500z said: hi, i made the follower fabricable but i don't know how to make it follow me do you know how to fix it? The "anchor" should act as a book. In my case it works fine. You can send me your mod folder in .zip and I will take a look. Link to comment Share on other sites More sharing options...
Hiru315 Posted November 8, 2020 Share Posted November 8, 2020 Just have some questions: _ So I used your anim .zip file for the creature. It does appear in sprite. The reading animation did work but the creature is invisible. Is it normal? _ And also how will I change the nil value of "chakra" like instead of sanity it's maxhealth? Link to comment Share on other sites More sharing options...
Yakuzashi Posted November 8, 2020 Author Share Posted November 8, 2020 1 hour ago, Hiru315 said: Just have some questions: _ So I used your anim .zip file for the creature. It does appear in sprite. The reading animation did work but the creature is invisible. Is it normal? _ And also how will I change the nil value of "chakra" like instead of sanity it's maxhealth? Send me your folder. It's too much to write about. It will be better if I fix it and then you analize my changes. Link to comment Share on other sites More sharing options...
red1500z Posted November 8, 2020 Share Posted November 8, 2020 red1500 v2.rarthis is the folder I'm new to this so it must have a lot of mistakes Link to comment Share on other sites More sharing options...
Yakuzashi Posted November 8, 2020 Author Share Posted November 8, 2020 @red1500z Well you have skipped some steps/files thus it didn't work. red1500 v2.rar Link to comment Share on other sites More sharing options...
red1500z Posted November 8, 2020 Share Posted November 8, 2020 thanks but is there a way to invoke them without the anchor? Link to comment Share on other sites More sharing options...
Thomas Die Posted November 8, 2020 Share Posted November 8, 2020 (edited) local creature = SpawnPrefab("creature") creature.Transform:SetPosition(inst.Transform:GetWorldPosition()) creature.components.follower:SetLeader(reader) --relplace reader with the variable that shows your character Put this almost anywhere and it'll happen, The anchor is simply a tool used to spawn the creature having a builder for the creature can make you spawn in the creature with a crafting recipe but i'd rather not clog the tutorial Edited November 8, 2020 by thomas4846 extra 1 Link to comment Share on other sites More sharing options...
Yakuzashi Posted November 8, 2020 Author Share Posted November 8, 2020 It's fine. Mostly I don't know what I am doing, so every help is appreciated Link to comment Share on other sites More sharing options...
Thomas Die Posted November 8, 2020 Share Posted November 8, 2020 (edited) yes Edited November 8, 2020 by thomas4846 i don't know slang Link to comment Share on other sites More sharing options...
red1500z Posted November 9, 2020 Share Posted November 9, 2020 21 hours ago, thomas4846 said: interesting this helps me a lot now I have to find out where thecode goes Link to comment Share on other sites More sharing options...
Thomas Die Posted November 9, 2020 Share Posted November 9, 2020 ok Link to comment Share on other sites More sharing options...
Hiru315 Posted November 15, 2020 Share Posted November 15, 2020 When I resume the world again. Followers stop following me. -When they die the game crashes with "leader" nil value. Link to comment Share on other sites More sharing options...
Thomas Die Posted November 15, 2020 Share Posted November 15, 2020 followers automatically stop following you because the game does that too i think make it run smoother, --you can fix this by either saving them as pets or saving their data so they spawn in with you which is basically the same thing The death problem needs code to fix probs 2 Link to comment Share on other sites More sharing options...
Hiru315 Posted November 22, 2020 Share Posted November 22, 2020 Is there a way to set limit of followers? Since it's unbalance when player could heal sanity/hunger/health then massive summoning them- Link to comment Share on other sites More sharing options...
Thomas Die Posted November 24, 2020 Share Posted November 24, 2020 Definitelt not Link to comment Share on other sites More sharing options...
Goregonzola Posted November 26, 2020 Share Posted November 26, 2020 Might be a silly idea, but is it possible to make the follower hostile against the survivor, and set a respawn time to it? Possibly making this coding into a custom hound-wave-like attack? If so, how could I achieve that? Link to comment Share on other sites More sharing options...
Yakuzashi Posted November 26, 2020 Author Share Posted November 26, 2020 8 hours ago, BillTheCipher said: set a respawn time to it inst:DoPeriodicTask 8 hours ago, BillTheCipher said: to make the follower hostile against the survivor I would recommend to dig into any monster brain and script. ...\Steam\steamapps\common\Don't Starve Together\data\databundles -> scripts.zip 1 Link to comment Share on other sites More sharing options...
Goregonzola Posted November 26, 2020 Share Posted November 26, 2020 @Yakuzashi Thanks, I'll search it up. Link to comment Share on other sites More sharing options...
AAAContinue Posted January 13, 2021 Share Posted January 13, 2021 (edited) Thanks for sharing a template. It really helped But I have a question. I've done all the things in the tutorials then changed the recipe of the anchor (to make it easy to check how it works... ) But my character only said 'I can't do that' The ingredients were 2 petals, and it disappears when I craft anchor(with no creature) Edited January 13, 2021 by AAAContinue Link to comment Share on other sites More sharing options...
Yakuzashi Posted January 14, 2021 Author Share Posted January 14, 2021 @AAAContinue you can post your mod folder and I will take a look Link to comment Share on other sites More sharing options...
AAAContinue Posted January 14, 2021 Share Posted January 14, 2021 11 hours ago, Yakuzashi said: @AAAContinue you can post your mod folder and I will take a look This is my mod folder. Since the image of my character is not completed, I've only changed the scripts. So the image files would be the same as yours but I'll change it soon. patch.zip Link to comment 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