• Content Count

  • Joined

  • Last visited

Community Reputation

20 Excellent

About code4240

  • Rank
    Junior Member


Recent Profile Visitors

1466 profile views
  1. EDIT: nevermind! I figured out what was wrong! A) The reason the krane output was bugged is because some of the textures were used for more than one frame and it didn't realize this so it exported them with weird names and the build didn't reuse anything. I was able to fix this by duplicating some frames in the scml in notepad++. (I ended up duplicating the textures instead later, just for future uses) B) The BUILD animation in the scml has to have only a single frame in order for the anim to not override the normal ingame anim. Once I fixed that it started using the frames properly. (it was also possible to just delete anim.bin from the zip file that was output but having to do that every time I recompiled would be tedious.) Since it doesn't seem like there's any other resources for this problem, I'll be posting a template axe for future modders who have trouble with this once I'm done working on it. ORIGINAL POST: I'm trying to make a custom axe. I followed the "handslot item from scratch" tutorial and it worked pretty well for my spear, but it doesn't explain how to do anything that has more than one frame in its movements. I tried decompiling the axe build into an scml project with krane to look at it, and while it did get the symbols out, the output seemed to be pretty buggy in terms of build data. When I tried copying the data from that (pivot points etc) from that into the custom build to see if it worked, it did animate but they were in the wrong order and not all the frames were showing properly. I haven't been able to find any templates for axes, I'm not personally aware of any mods that add axes with custom graphics, and I've only see one other question about this problem which went unanswered. So basically I'm wondering whether anyone could tell me how to get a custom axe that actually looks right. (I've attached the swap anim so people can look at it. It's using the normal axe frames right now, I wanna get the anim to work before I start making the textures)
  2. The hairfront_hat is not visible, but it can still be used to override the hairfront symbol that is there. It's intentionally not visible when the player isn't wearing a hat just like hair_hat isn't visible when the player isn't wearing a hat. I just use override instead of hide/show because it doesn't have its own animations to match hairfront the way hair_hat does to hair.
  3. BTW this is what she looks like That hair only works if I either: A) Put it in hairfront (which causes it to clip through hats) B) Put it on the head sprite hair and hairfront aren't actually synced up in the animations so trying to just stick the bits that go in front of her face looks pretty stupid as well, and putting the whole thing on the face sprite removes the bounciness the hair normally has, so adding a hairfront_hat symbol so I can prevent clipping through hats produces the best result. Basically, this allows me to have my cake and eat it too.
  4. That would just remove the hair entirely lol. Anyway, when I looked into changing the z-order of sprites I found it would require basically remaking all the player animations in the game so that's a huge can of nope. I'll just stick with the hairfront_hat symbol.
  5. Nope. It already does that, I'm trying to make it not do that. Though it just occurred to me to try and see if I could just move the regular hair symbol's Z order up and use that instead. That would probably be better so I'm gonna go try that.
  6. Oh no, this is actually pretty simple to me lol. The reason I wasn't more thorough is because I had to work last night. I realized my error in my first code while I was in the middle of my shift lol. And when I issued my correction was right before I went to bed so I didn't test anything. Anyway, I'm awake and not at work now so allow me to clarify on what I meant: local function OverrideCombat(comp) local OldCombat = comp.CalcDamage comp.CalcDamage = function(self, target, weapon, multiplier) local dmg = OldCombat(self, target, weapon, multiplier) if target:HasTag("superspecial") then print("------") print(dmg) if self.playerdamagepercent ~= nil then dmg = dmg * self.playerdamagepercent print(dmg) print(self.playerdamagepercent) -- print the modifier to see what you're multiplying by else print("1") -- If the value is nil then it's not multiplied end end return dmg end end I tested this and it works. (You'll want to remove or comment the prints at some point)
  7. AddPrefabPostInitAny is good to know about. Honestly if I were interested purely in performance I'd stick with doing the "manual list of prefabs" for it (in fact that's what I was doing before this thread got answered), but checking all the prefabs allows me to account for new hats or modded hats that I don't know about and can't write in manually. Course, some of the hats don't need this (open top hats such as the garland) so I'd have to write a blacklist for those. I'm not really sure what you mean by this. hairfront goes in front of the headbase, hair goes behind it. I need the hairfront in order for my character to look correct from the side, so I can't use the regular hair symbol for it either hatted or hatless. It's just that unlike hair, hairfront does not have a hat version. Disclaimer: I'm pretty clueless about how the graphics side works, this is the first time I've ever modified a build at all. I'm not even hiding/showing the hair; I'm using symbol override because I'm not even sure how to make the hairfront_hat use the same animations as hairfront by default. All I really did was open up the .scml in notepad++ and duplicate all the entries with hairfront and changing the name to hairfront_hat (and the ids of course). Dealing with animations is something I want to learn but I haven't gotten around to it yet.
  8. You'll wanna study the general technique I used because it's pretty important to modding pretty much anything in the game that isn't brand new content. Luckily it's pretty simple since prefabs and components actually aren't all that different. Basically there are a lot of "AddXPostInit" functions, like AddPrefabPostInit, AddComponentPostInit, AddBrainPostInit, etc. They all pretty much do the same thing, which is modify a prefab/component/etc. that you specify by tacking whatever function you write onto the end of the init function for that thing. Basically, you could pretend that whatever function you gave it (in our case we passed the OverrideCombat function we wrote) just got stuck inside the prefab on the very last line of the init, right before it returns at the end, and you have to figure out how you would modify the rest of the file only using that one function there. As for the part where you actually change the calc, we basically save a copy the function the component was using for calc to a variable, and then replace the calc in the component with a new function we wrote that calls the copy of the old function inside it to ensure the original code still gets called. This is the standard practice for replacing functions in Don't Starve because it allows mods to be compatible; if multiple mods modify the same function this way, it has a sort of nesting doll effect where each one wraps around the other and they all still get called. As opposed to just overriding the function entirely or the whole file, in which case any other modifications that had been made to that function / file before the new one got loaded would be wiped out. Prefabs are changed the same way, and prefabs can actually modify their individual copies of a component. So for example, you could go into the bearger file via AddPrefabPostInit and modify its copy of the combat component by setting the calc function to multiply the damage by 5,000 if it was your NPC. In this case, only the bearger would do 5,000x damage to your NPC and everyone else would be the same because only the copy of the combat component that belongs to the bearger gets modified, while when using AddComponentPostInit you'd be modifying the base file for the combat component and all the prefabs that later used combat would start out with those changes. This also applies to brains but those are a whole other can of worms in terms of how the code you're modifying is actually structured tbh.
  9. Actually, my answer was wrong. It just occurred to me that multiplier stacks with playermultiplier so changing it would give inaccurate results if it was supposed to be not 1. So actually what you'll want to do is multiply the result of the old function by the value instead of changing the multiplier. Also, don't use 0.5, use playerdamagepercent. Changing this value is how mobs do different damage to players. I haven't looked but I'm assuming if you look at the files for the bosses such as deerclops you'll see them setting that value to 0.5 (probably using the setter function in combat.lua, though I'm too lazy to go look) which would mean that if the mob would do half damage to players then playerdamagepercent would be 0.5 like you want. Or any other value the mob might do to players.
  10. I've added a hairfront_hat symbol to my character's build because their hairfront clips through hats normally. What I want to do now is override the OnEquip function in hats.lua. There's a problem though; it's a local function that's created inside of another local function (MakeHat(string)) so I don't think I can access it directly. The hats.lua file doesn't return an actual hats prefab; rather, it returns a whole bunch of hats made by MakeHat(string). I think this prevents me from adding a postinit to it because a hats prefab technically never gets made. Because of this, trying to modify components.equippable.onequipfn for hats didn't work. But I DID get it to work by modifing the onequipfn for the "tophat" prefab specifically. So here's what I want to know: is there a convenient way to do add a postinit for every prefab that MakeHat() can return, without overwriting the file? Or will I have to go through the list of return values in hats.lua and manually add the post init to every single one?
  11. Okay, I actually did it in game and this works. I made a really fast custom char with the tag "superspecial" and then did this in modmain: local function OverrideCombat(comp) local OldCombat = comp.CalcDamage comp.CalcDamage = function(self, target, weapon, multiplier) if target:HasTag("superspecial") then multiplier = 0 -- replace this part with the necessary number / calculation end return OldCombat(self, target, weapon, multiplier) end end AddComponentPostInit("combat", OverrideCombat) This made my character immune to damage. You'd replace the 0 with whatever you'd need to in order to cancel out the playermult. EDIT: I'm guessing you'd want to set multiplier to be equal to self.playerdamagepercent, as implied by this line: playermultiplier = playermultiplier and self.playerdamagepercent or 1 -which sets playermult to playerdamagepercent if it's true. However, I don't have a custom NPC to add this code to so I can't actually test this.
  12. Give your NPC a unique tag. Then override the CalcDamage function in combat.lua the regular way you override functions ('m assuming you can do this, I haven't tested this) and add a check before calling the regular function that divides the damage by some value that cancels out the player multiplier if the mob has your NPCs unique tag. If you can't replace the function *at all* then I'm not sure what to do off the top of my head. EDIT: I've never edited a component but I'm guessing you'd use the normal trick where you copy the function and embed it into a new function oldCombatcalc = component.whateverfunction component.whateverfunction = function(arguments) --Do the division oldCombatCalc(arguments) end AddComponentPostInit(whatever) I've never used AddComponentPostInit so if this isn't how it would work for components then you'll have to look into that I guess. nvm, check second post
  13. So I came back for a few days... probably so I can just leave for a year again later.