Project Sugar Cake v0.0.3DEV Released! (New JSON Parser and easier imports!) [Palworld Mod]

(entry also available on my personal site : https://www.michaelpstanich.com//blogpost/2024-03-21_Project_Sugar_Cake_0.0.3_DEV_Released.html )
It’s been a good while since I’d made a string parser, but I’m glad I at least had some sort of previous experience! Would have certainly taken longer if I hadn’t (manually managing search depth is a pain >.<) even if it still took longer than expected. What am I referring too? Project Sugar Cake can now register animations through .json files! I’ve added a quick how-to to the ReadMe and placed templates in “~mods/AnimJSON” within the mod’s release package and install. Now SCake comes with the previously mentioned AnimJSON folder where these register .json files will be placed, any .json files you wish to have load in-game must be added to the new “_LoadList.json” file, then when SCake loads in-game it will use that load list to pull the appropriate .json files, parse the .json as a string and properly pass that string to the register to parse and convert into animation data. I won’t go over all the metadata stuff here (there’s a lot) but one of the templates explains each parameter and those templates show how to format things, so it shouldn’t be too difficult to get started! I recommend using a JSON editor with auto-correction and error checking, I used the online editor https://jsoneditoronline.org/ to help speed up the process, and I recommend it! (Easy to understand interface and has both a raw text mode as well as a ‘tree’ mode with more intuitive visuals).

What’s really exciting about this is that .json import options are not just for animators, but users as well! Users can edit or create their own .json metadata files to customize existing animations, create alternate versions, and make their own full events using any combination of animations they like! In the future I’d like to have a UI for this, but that’s still quite far off, but the .json importer does have support within the API so once a UI is up we can implement a ‘refresh .json import’ option or something so you can edit .json files and have them re-import without having to reload your game!

I also updated the Scake_BasicsAnimPak to be compatible with the new version and now supports .json import options. SCake SDK got updated to the new version with the new API call for .json imports.

Download Links!
GDrive Folder - https://drive.google.com/drive/folders/1vYfgMom7UJs2OmJ5B4FGQTMYEOR0n9Vr?usp=drive_link
Mega Folder - https://mega.nz/folder/9hZQ2IIR#Ou77tq4qQxw9UBQsozh6zg

- Project Sugar Cake -
- Full Change Log -
SCake Version 0.0.3 DEV
Note : Data structure had changes this update, BP mods will need to be recompiled with the newest SDK release

Added : JSON string and data parser for registering animations, now you can create JSON files and place them in the ~mods/AnimJSON then add the file name to the "_LoadList.json"
 - - - - - If any errors are in the JSON file's formating it will fail to load (BP limitation)
 - - - - - Animations no longer need to be LogicMods and can be installed like any replacer mod, though BP registeration is still available
 - - - - - Users can create their own JSON files or edit existing ones to create their own events or customize animations
 - - - - - Templates are now included with SCake's main installation
 - - - - - "_LoadList.json" is required, however it is split up in distribution to prevent overwritting player's customized json when updating the mod
Added : SCake_RegisterAllJSON to the API, call this to re-register all JSON animations listed in the _LoadList
Added : "Speed Default" in registered animations now functional
Added : "StartTime" in registered animations now functional
Added : "Speed Mod" in Stages now functional
Added : Keybind K (Start animation between 2 targets) will now try to start a solo animation if the same character is selected twice
Added : "AddTags" in AnimEvent now functional (Appends additional tags to the event in addition to those added in the animations)
Added : Animation Register now sends a total successful registered count whenever there is a pause while registering

Changed : Simplified "Act Types" and introduced "Act Location" to make registering animations easier and allow easier future additions
Changed : "HasPostClimax" for registering events is now set to false by default
Changed : "EquipLocation" is now a 'name' variable type to support socket/bone names and not just presets (Equip system is still non-functional)
Changed : When characters path to animate, even a failed move (When 'Move Failed' would display) will still trigger the animation (characters will just teleport, helps the mod feel less inconsistent and buggy. This issue isn't really with the framework, it's just the quick and dirty AI which bugs out a lot.)

Removed : Anim and AnimEvent Registered messages from showing in ReportUI (Still shows failed registers with error codes)
Removed : Equip Location enum is removed and now invalid (we parse a name variable now instead to allow custom bone/slot names)

Fixed : Sexual Pleasure going into the negatives after an animation (accidentally shipped the wrong build which had this bug >.<)
Fixed : Register component not automatically starting after a game load if a register API function is never called
Fixed : "Stage Order" being ignored and erroring out if the animation playing didn't play through stages linearly
- - - - - Note : This Stage Order bug also broke things like play-time, animaiton playback, post-climax anims, all should hopefully be fixed now
Fixed : Stage Duration for non-looping animations setting to 0 seconds when the number of stages exceeded actor count (Was a very silly mistake X.x)
Fixed : AnimVersion number not working properly (Technically also fixed the internal version number not working correctly, but this means nothing front-end)
- SCake SDK -
- Full Change Log -

0.0.3
Updated for Data Structure changes in SCake 0.0.3
Removed "EquipLocation" Enum as it's no longer used by SCake
Added SCake_RegisterAllJSON function
Added missing register functions to the example mod
Updated ReadMe with variable types
- SCake_BasicAnimPak -
- Full Change Log -

BasicsAnimPack 0.0.3
Added : Now includes SCake_BasicAnimPak.json for installing with SCake's json importer
Changed : Recompiled for SCake 0.0.3 DEV
Changed : UniqueAnimID and name information
Changed : Updated Climax metadata

JSON Handling Limitations / Struggles

There’s some limitations to JSON handling in regards to mods, in a normal game project you would just create your own tools and custom nodes to handle this kind of thing or import a plugin but when working with Palworld modding I’ve decided to stick entirely to BP mods to ensure maximum compatibility and hopefully ensure better future support. This leads to some problems, because UE5’s file handling blueprints for files outside the typical asset register (which would require packaging then assets to pull from) is extremely limited, we have to use UE5’s native JSON importer. “So what’s the big deal, doesn’t UE5 have JSON parser nodes already?” Why yes, it does, except they don’t actually function properly! UE5’s native JSON support is abysmal, so instead I use it only to load the JSON and convert it into a string, then I built a fully custom string parser that searches through the string and pulls the data into a data map, which we can then search and use. I take advantage of search depth (tracking start and end points of datasets to separate them) and any with a depth above 0 would be parsed as a JSON string, then I parse those strings whenever the data needs to be pulled and put it into its own datamap. As this process goes on, I store the data pass it into the Animation Register. Well, technically I pull the full JSON string and pass that to the register, then the register calls the parser functions, but you get the idea! (probably?)

Either way, I’m super happy with this method as it’s very flexible and surprisingly fast, and it’s not even had an optimization pass yet! (I need to re-sort fail states so things fail faster if they are going to at all, add null checks to skip logic, and use more skips in places so repetition isn’t required and we don’t process unneeded variables.) Because we parse things into a data map, we can even ignore arbitrary data left in the .json so people can leave comments in there if it helps, similar to how I have the description template set up, though I recommend keeping them to a minimum or remove them before distribution to reduce memory overhead. I also have it planned to process them in batches, currently it just tries to load them all at once which isn’t that great memory wise, but given we’re still lacking animations that can come in a later update!
( Some of the larger SCake JSON parser trees in v0.0.3DEV )

But there are limitations.

Most of UE5’s file tools for blueprints is actually a plugin, and palworld doesn’t include it! This means we’re very limited on what we can do via blueprints (and I am still not confident C++ mod support will uphold compatibility, especially since SCake needs to have the SDK easily accessible/usable). This has 2 major effects, first we can’t dynamically pull arbitrary assets that are not within pak files and part of the regular asset registry so we have to put the .json into the provided _LoadList.json file so we know which files to pull. We can define a custom path to load from, but we can’t efficiently search a directory without either C++ or plugins (we can technically do it through manual crawling, but by doing so many search calls we could trigger anti-virus safety protocols, it’s also extremely slow). The second issue is when getting the strings themselves. When loading assets it needs to be a defined type, in C++ we just define the type but this isn’t exposed to blueprints without the optional plugin which we can’t use, so this is why I use the JSON function within UE5 to pull the asset itself. This means we have to follow UE5’s JSON import rules, which are very strict and it means JSON files can’t have any formatting errors at all or else it will fail to import. If I could pull the asset directly I could just pull it as a string and try to auto-correct small errors (I already do this to a certain extent with how my parser is built) but I don’t currently know a method within my current scope and limitations. Hopefully we can get around these 2 hurdles at some point, maybe I’ll cave and finally do some C++ stuff while keeping this fallback in-case things break in the future, but for now I think these 2 issues are ones we can live with and things are more than usable! (I just like to make things the best they can be >.< Why do I have to care so much Q.Q)

What’s Next?

I’m still following the same plan, but will most likely work on the next few steps in a more free-flow fashion. I want to start implementing very basic versions of various functions to try and get more of the framework filled out and create the baseline, as shown here with how much sooner this update released compared to the last version change, once the base structure is built and complete it becomes much easier to put out new additions and modifications. While making the parser and researching how UE5 handles files via blueprints I found some major leads toward what I could do about persistence and this could pave the way for the rest of the framework to truly be out of Alpha! Though, I shouldn’t understate how much work is really still left to do, I have a feeling a lot of the other parts of the framework will still need to be entirely custom and there’s still planned features for the animation player that isn’t complete yet, there’s also gender swapping systems that could help (it was believed the OK Framework was going to be the solution, but it requires more manual work and isn’t all that flexible so a new solution may still be required. Having it built into the framework also isn’t a bad idea.)

Oh, I got completely side tracked, the actual next step, like, right after I make this release, is to work on tutorials for importing animations into Palworld and how to integrate them with SCake! There’s still not really any good resources for this, so it look like it’s my time to step up and take the torch. Let’s burn some stuffs!~ ^-^ (Fire is pretty.. what were we talking about again?)

Current Road Map
1 ) Create basic tutorials for importing animations and registering them with SCake
2 ) Investigate / implement equipment altering system (for unequipping weapons/armor)
3 ) Implement a basic UI with settings control (including position adjustments for anims)
4 ) Investigate persistence more and try to get stat persistence between save/loads
5 ) Investigate multiplayer compatibility

? ) Work on building new animations