Zackreaver Posted March 31, 2015 Share Posted March 31, 2015 First off, A great thanks to everyone on this forum for all the help they have given. Especially DarkXero, Rezecib, Kzisor, Blueberrys, And Mobbstar,. I have gotten so much help from you and through your examples I have learned so much that modding in Don't starve is becoming second nature to me. Now I've managed to get a majority of character perks that were originally complex, and turned them into very simple procedures. My newest task today is personal companions! I have a couple characters that I'm making whom I want to have personal companions that follow them around permanently, some of them have simple tasks and other's a little more complex. Through my little brain surgery thread http://forums.kleientertainment.com/topic/52402-scriptsbrains-surgery-time-making-nightmares-fear-you/#entry625424I learned how brains work (stabbing them with a scalpel tends to be fatal apparently, who would've thought) And for the most part, I can understand how companions work by reading chester, abigail, pigs, and just about any of the follower's scripts to figure out what makes them tick and what makes them move. For the most part, I could probably figure this out on my own, but as the title suggests "Assistance appreciated" I'd like to know a good base to work off of, where should I start exactly? Any recommended guides for creating a companion? Any particular things I should look out for when creating the networking for it? Anything I should avoid doing? The first companion I want to create is a rather simple one. I want to create a butterfly that simply follows a custom character I made, I figure glommer is a good base to start for this, since it pretty much does exactly just that. Adding in special things afterwards will be pretty simple for me at this point. Next companion is a little more detailed, it's a bunnyman that follows the custom character around and never runs out of loyalty, along with a couple other features I can put on as soon as I get the initial setup process done. The next parts gonna be a doozy, but rather fun. One of my characters is going to have some custom items that allows them to essentially give orders to followers. A scepter that's used to declare an attack from a distance (essentially a ranged weapon that deals 0 damage and applies a tag that amplifies attacks by followers) an orb that calls a defense (cancels attack, makes the followers follow their leader closely and take less damage from attacks) and a flag that signals a retreat (cancels attack, makes followers follow their leader closely, and prevents them from acquiring new targets) so that the player can better keep their followers from picking fights with things that might murder them (like tentacles or bosses) I'm going to have alot of fun making these companions, along with my companion based character. Examples for references would be most appreciated. Now if you'll excuse me, it's time to build a friend Link to comment https://forums.kleientertainment.com/forums/topic/52514-character-perk-creation-part-3-assistance-appreciated/ Share on other sites More sharing options...
Zackreaver Posted April 1, 2015 Author Share Posted April 1, 2015 (edited) Okay I think this particular issue I'm having is taking more time to fix than necessary. I made a companion that's supposed to look like a butterfly, but when I spawn it in it's invisible. I copied Glommer's prefab and replaced the assets and animations to be similar to the Butterfly's prefab. I changed the require("stategraphs/SGglommer") to require("stategraphs/SGbutterfly") and inst.AnimState:SetBank("glommer") inst.AnimState:SetBuild("glommer") inst.AnimState:PlayAnimation("idle_loop") --Too inst.AnimState:SetBank("butterfly_basic") inst.AnimState:SetBuild("butterfly") inst.AnimState:PlayAnimation("idle")Why isn't it appearing? What am I missing here? FYI: I know that it's successfully spawning in since the shadow is there and it's behaving how it should normally, it's just not showing it's butterfly self. Edit: That moment when you realize, the butterfly.lua has SetBuild before SetBank, while glommer has set bank before set build. I should've seen this sooner. Edit 2: And would you look at that, hours and hours of trying to figure out what was wrong and after this 1 little change everything works as expected. Gotta love that feeling of relief after solving a simple problem. Edited April 1, 2015 by Zackreaver Link to comment https://forums.kleientertainment.com/forums/topic/52514-character-perk-creation-part-3-assistance-appreciated/#findComment-626546 Share on other sites More sharing options...
rezecib Posted April 1, 2015 Share Posted April 1, 2015 Edit: That moment when you realize, the butterfly.lua has SetBuild before SetBank, while glommer has set bank before set build. I should've seen this sooner. That's... really weird. I would not have expected that to matter. I'll keep that in mind... If you have other partial/buggy implementations that you want help with I'll try to chime in, but your first post was a bit too general of a problem for me to feel like I could contribute much to-- you already had the right ideas for looking at existing follower prefabs. Link to comment https://forums.kleientertainment.com/forums/topic/52514-character-perk-creation-part-3-assistance-appreciated/#findComment-626577 Share on other sites More sharing options...
Zackreaver Posted April 1, 2015 Author Share Posted April 1, 2015 (edited) That's... really weird. I would not have expected that to matter. I'll keep that in mind...It doesn't matter, I just put the wrong string name in because I thought glommer and butterfly set things in the same order --I had inst.AnimState:SetBuild("butterfly") inst.AnimState:SetBank("butterfly_basic") --It was supposed to be inst.AnimState:SetBuild("butterfly_basic") inst.AnimState:SetBank("butterfly")I was just being an idiot and didn't notice, bank and build look almost identical at a glance so I didn't realize I was putting the wrong string name into each one. At any rate I have a new particular question. For my butterfly follower, it's going to be used in don't starve together, and when the player logs out of the server I need the butterfly to disappear with it. Then when they join back in I'll need the butterfly to return with the same stats that it had before. I'm guessing I have to do things with OnSave and OnLoad functions to store information and trigger the respawn upon reentry. But also I'm not sure what's going to happen client side with followers until I do some client side tests. I already know I'm gonna have the butterfly store the owners steamid to make sure it follows the correct owner specifically, my concerns are what's gonna start happening when the players leave and rejoin the server? but your first post was a bit too general of a problem for me to feel like I could contribute much to-- you already had the right ideas for looking at existing follower prefabs. You all taught me well, I can handle alot of the gruff myself, thing is my examples fall flat at the "exclusive follower" portion. Abigail slightly works as an example, but she doesn't spawn immediately with wendy and she's mostly controlled through her flower. I currently spawn in the butterfly using a TheWorld Listener TheWorld:ListenForEvent("ms_newplayercharacterspawned", butterflypetspawn)since ms_newplayercharacterspawned triggers only when a player joins for the first time ever, it work's for getting the butterfly here the first time. This is my approach on it at the moment, but followers are a little strange to me since I dunno what could happen if I do something a certain way. I'm trying to figure out all the things that can be broken with followers in Don't Starve Together in particular, especially before I get to a more follower focused character. Edit: Actually that raises a curious question, if the build is called "butterfly_basic" does that mean klei intended to have a... non-basic butterfly? BUTTERFLY BOSS CONFIRMED!!! Edit 2: Okay, turns out abigail is linked to wendy through an inst function called LinkToPlayer which gets called whenever wendy joins a game, wendy has her own set to her which properly pairs her with abigail and wendy has an OnLoad and OnSave which apparently handles bringing abigail back. I'll borrow this and see how it turns out after some testing Edited April 1, 2015 by Zackreaver 1 Link to comment https://forums.kleientertainment.com/forums/topic/52514-character-perk-creation-part-3-assistance-appreciated/#findComment-626584 Share on other sites More sharing options...
rezecib Posted April 1, 2015 Share Posted April 1, 2015 I already know I'm gonna have the butterfly store the owners steamid to make sure it follows the correct owner specifically Use userid (that's Klei's identifier). You can use the ms_playerjoined event to respawn the butterfly, and ms_playerleft to despawn it. I don't think save/load will work properly, since when a player leaves their entity actually gets removed. It's stored through the C++ code in some way, as you can see with calls to SerializeUserSession(player). So... You'll probably have to add a component to TheWorld to keep track of your butterfly followers if they have data that needs to persist, and reapply it when you spawn it back in as a player joins. Another scenario you might have to check for is if the world crashes, when it resumes the butterfly will by default spawn in, but the player attached to it won't be there. So in that case you'll also have to despawn it. 1 Link to comment https://forums.kleientertainment.com/forums/topic/52514-character-perk-creation-part-3-assistance-appreciated/#findComment-626671 Share on other sites More sharing options...
Zackreaver Posted April 1, 2015 Author Share Posted April 1, 2015 (edited) So... You'll probably have to add a component to TheWorld to keep track of your butterfly followers if they have data that needs to persist, and reapply it when you spawn it back in as a player joins. taking from wendy's examplelocal function OnSave(inst, data) if inst.abigail ~= nil then data.abigail = inst.abigail:GetSaveRecord() endendlocal function OnLoad(inst, data) if data.abigail ~= nil and inst.abigail == nil then local abigail = SpawnSaveRecord(data.abigail) if abigail ~= nil then abigail.SoundEmitter:PlaySound("dontstarve/common/ghost_spawn") abigail:LinkToPlayer(inst) end endendit looks like wendy grabs all the information for abigail from :GetSaveRecord() which I checked is basically getting everything from map position and prefab names, to a table containing stats and records. If I just store the information I need into my version of abigail.data then shouldn't i be able to get that same information back? At least for something basic like a custom loyalty meter, etc. Another scenario you might have to check for is if the world crashes, when it resumes the butterfly will by default spawn in, but the player attached to it won't be there. So in that case you'll also have to despawn it.Hmm I should check for this little detail. Abigail doesn't have anything in her that really appears to signify this issue. I noticed Wendy has an OnDespawn function that makes abigail disappear if wendy leaves, which is what I use normally to despawn the butterfly. But your point is valid, I should have something in here that clears out the trash butterflies for when the clients don't give the call to despawn them. Hmm, well along with glommer my companion is now borrowing alot of stuff from abigail at the moment, I wonder how abigail handles this problem. Edited April 1, 2015 by Zackreaver Link to comment https://forums.kleientertainment.com/forums/topic/52514-character-perk-creation-part-3-assistance-appreciated/#findComment-626693 Share on other sites More sharing options...
rezecib Posted April 1, 2015 Share Posted April 1, 2015 @Zackreaver, Oh, good point, you could also store it in the player's save/load. That would be a neater approach. As for the crash/load, you can test it pretty easily with a dedicated server (which you probably have already for testing stuff client-side). Load in as the character, c_save(), click [x] on the dedicated server's console window, relaunch the server, and check for the butterfly (c_list('butterflyfollower')). Link to comment https://forums.kleientertainment.com/forums/topic/52514-character-perk-creation-part-3-assistance-appreciated/#findComment-626697 Share on other sites More sharing options...
Zackreaver Posted April 3, 2015 Author Share Posted April 3, 2015 (edited) @rezecib, Having a little trouble with changing the butterfly's bank and build. So I exported the butterfly_basic animation to make adjustments to the sprite so that it's a different color. And when I was finished I renamed it so I can distinguish it and select it specifically. I even went into the custombutterfly.scml and changed the entity name to custombutterfly. But the problem is when I change the Animstate the butterfly doesn't show up, and I even added the assets as welllocal assets={ Asset("ANIM", "anim/custombutterfly.zip"),}local function fn()--Stuff above inst.AnimState:SetBuild("custombutterfly") inst.AnimState:SetBank("custombutterfly")--Stuff below)When I set the build back to it's original, the butterfly shows up normally, but when I try to change it to the one I modified, the butterfly doesn't appear. Is there something I'm missing for changing this? What exactly is a bank and a build? Edit: I fixed it to show up somehow, autocompiler might have had an issue or something, but the animation appears broken on the idle_flight_loop. Might just have to go back to the regular butterfly for now. Is the bank just the name of the entity in spriter, while the build being the scml's file name? Edit 2: Yeah looks like the autocompiler screwed something up, I can see what kzisor was talking about now. Edited April 3, 2015 by Zackreaver Link to comment https://forums.kleientertainment.com/forums/topic/52514-character-perk-creation-part-3-assistance-appreciated/#findComment-627008 Share on other sites More sharing options...
rezecib Posted April 3, 2015 Share Posted April 3, 2015 (edited) @Zackreaver, "build" basically labels the parts of the texture. the "bank" is a collection of animations that specify movements/rotations/scaling of the parts as labeled by the build. As for where the names for the bank, build, etc come from:Name things the right things!The Spriter filename is the “build”The “Entity” (top level in Animations panel) is the “bank”The sub-entries in the Animations panel are the “animations” But I'm not that comfortable with animation/build stuff. I've done it a couple of times, but it's a complicated process where a lot can go wrong. I prefer to stick to the coding whenever possible Edited April 3, 2015 by rezecib Link to comment https://forums.kleientertainment.com/forums/topic/52514-character-perk-creation-part-3-assistance-appreciated/#findComment-627015 Share on other sites More sharing options...
Zackreaver Posted April 3, 2015 Author Share Posted April 3, 2015 @rezecib, Glad to see I was right on the money. Another simple question, how do I declare a function in modmain but call it in my other prefabs? There's a couple functions I want to condense but I'm having trouble figuring out how to make a function public. Link to comment https://forums.kleientertainment.com/forums/topic/52514-character-perk-creation-part-3-assistance-appreciated/#findComment-627025 Share on other sites More sharing options...
rezecib Posted April 3, 2015 Share Posted April 3, 2015 (edited) @Zackreaver, You can attach them to the GLOBAL table (I do not recommend this), or you can attach them to some other entity that will be available. I guess the "neatest" (as in least likely way to overwrite stuff in a visible place) would be to have AddPrefabPostInits in the modmain that attach the functions to those prefabs specifically. So something like this:local function whee(inst, things) return inst .. things endlocal prefabs_to_attach = {"myfavoriteprefab", "mysecondfavoriteprefab"}for k,v in pairs(prefabs_to_attach) do AddPrefabPostInit(v, function(inst) inst.whee = whee end)end-- then later, you can do inst:whee(things)Other approaches could be... adding a component to TheWorld that has these functions, or making an entry in global with your mod's name and attaching the functions directly to that:GLOBAL.MY_MODS_NAME = { whee = function(stuff) return stuff end, yayy = function(wut) return not wut end,}-- later, MY_MODS_NAME.whee(stuff) Edited April 3, 2015 by rezecib Link to comment https://forums.kleientertainment.com/forums/topic/52514-character-perk-creation-part-3-assistance-appreciated/#findComment-627044 Share on other sites More sharing options...
Zackreaver Posted April 3, 2015 Author Share Posted April 3, 2015 (edited) global with your mod's name and attaching the functions directly to that: That has the result I was looking for. @rezecib, Okay I'm having some issues with my dedicated server. I create the server with my mod just fine, but I can't issue any remote console commands. I open the command console with ~ but when I press left CTRL it doesn't switch to remote. Do you know why this is happening? I'm in the RoG beta and so is the server if that narrows it down. Edited April 3, 2015 by Zackreaver Link to comment https://forums.kleientertainment.com/forums/topic/52514-character-perk-creation-part-3-assistance-appreciated/#findComment-627059 Share on other sites More sharing options...
rezecib Posted April 3, 2015 Share Posted April 3, 2015 @Zackreaver, Hmm... I think that would be the case if you're not an admin for your server? Shouldn't happen otherwise. Link to comment https://forums.kleientertainment.com/forums/topic/52514-character-perk-creation-part-3-assistance-appreciated/#findComment-627075 Share on other sites More sharing options...
Zackreaver Posted April 3, 2015 Author Share Posted April 3, 2015 @rezecib, I've been doing some searching in the forum's but I can't get the answer I'm looking for. Are CUSTOM RECIPE TABS doable at the moment? All the examples I look at appear to be broken. Link to comment https://forums.kleientertainment.com/forums/topic/52514-character-perk-creation-part-3-assistance-appreciated/#findComment-627255 Share on other sites More sharing options...
rezecib Posted April 3, 2015 Share Posted April 3, 2015 @Zackreaver, I'm not sure. They should still be doable using the same approach, which involved copying a ton of code from recipetabs and making some modifications to it. Link to comment https://forums.kleientertainment.com/forums/topic/52514-character-perk-creation-part-3-assistance-appreciated/#findComment-627268 Share on other sites More sharing options...
Zackreaver Posted April 5, 2015 Author Share Posted April 5, 2015 @rezecib, Like I said I haven't found an example that works. I'm mostly using the RoG beta if thats any distinction. Do you know of a mod that I can take a look at for a reference? Link to comment https://forums.kleientertainment.com/forums/topic/52514-character-perk-creation-part-3-assistance-appreciated/#findComment-627457 Share on other sites More sharing options...
rezecib Posted April 5, 2015 Share Posted April 5, 2015 @Zackreaver, I'm saying you certainly won't be able to just copy the example code, you'll have to look at what it was copying from recipetabs and then make adjustments based on code that's changed meanwhile. I believe the Tiny Tina mod has a recipe tab? Link to comment https://forums.kleientertainment.com/forums/topic/52514-character-perk-creation-part-3-assistance-appreciated/#findComment-627518 Share on other sites More sharing options...
DarkXero Posted April 6, 2015 Share Posted April 6, 2015 (edited) http://steamcommunity.com/sharedfiles/filedetails/?id=418604101STRINGS.TABS.GEAR_TAB = "Gears"GLOBAL.RECIPETABS['GEAR_TAB'] = {str = "GEAR_TAB", sort=1, icon = "gear_tab.tex", icon_atlas = "images/inventoryimages/gear_tab.xml"}Mod has custom tab.Mod has custom craftable pets. Edited April 6, 2015 by DarkXero Link to comment https://forums.kleientertainment.com/forums/topic/52514-character-perk-creation-part-3-assistance-appreciated/#findComment-627651 Share on other sites More sharing options...
Zackreaver Posted April 6, 2015 Author Share Posted April 6, 2015 (edited) @rezecib, I get that, but the examples I had were all of code that didn't work and was commented out by the author. So I was mostly looking for an example mod that's currently working with a recipe tab. @DarkXero, Yup, like that, that works perfectly. Edit: Wow that was alot easier to implement than any of the other examples I was working with. My custom tab works perfectly now. Edited April 6, 2015 by Zackreaver Link to comment https://forums.kleientertainment.com/forums/topic/52514-character-perk-creation-part-3-assistance-appreciated/#findComment-627833 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