7.2 KiB
title | date | draft | tags | series | summary | |||
---|---|---|---|---|---|---|---|---|
Kawari Progress Report 8 - Multiplayer | 2025-04-15 | false |
|
|
Here comes several new features, including basic multiplayer! |
Here comes several new features, including basic multiplayer! I held off on making a new update for a bit, so this is just abnormally large.
Saving characters
For a while now, characters were already persistent when you created them. The thing was that you couldn't update any of their data, so your last position and zone weren't saved. This is now fixed, as when you log out your data is committed back to the database:
{{< tube "https://tube.ryne.moe/videos/embed/fTGQ9wZczkEcN2cWUHBYik" >}}
It should be noted this only happens when you purposefully log out of the client, there is nothing for accidental disconnects like on retail yet.
Service accounts
Service accounts are now an actual entity in the login database, and are communicated to the Lobby server. There's no way to manage these on the website yet. This means that there's separate character lists for each account, instead of them sharing the same one!
Oh yeah, there is an account management page now since I did some reshuffling on the login server. There's not much you can do here yet.
Multiplayer
Up until now each world server connection was "isolated", and couldn't talk to each other. I have now made the necessary architectural changes to allow them to communicate, which translates into basic multiplayer:
{{< tube "https://tube.ryne.moe/videos/embed/iTuQwLVUJPZs6Qu5Y7sNd5" >}}
There's a few caveats as you can see in the video, such as the position is the only thing propagated to other players. There's no poses, model changes, or even zone isolation. Also something to note is that I still haven't gotten the "SpawnPlayer" packet type to work, but it seems I can spawn player actors just fine using "SpawnNPC". This will work for now, but there is probably something that's not going to work until I spawn using that packet type.
If you're curious, the reason why it's fine spawning a "blue" player and not an NPC is because all of the "SpawnXYZ" packet handlers eventually end up in the same few common functions. The type of actor (player, battle NPC, event NPC, etc) is given in a "common spawn" struct, it's not decided at the packet opcode level as far as I know.
Character backups
One of the ideas I had when creating Auracite - a project to backup your FFXIV character - was being able to restore it on a server emulator. I'm happy to report that wish has been fulfilled, and you can now place Auracite archives into a folder called backups/
. The next time the World server is started, it will add any missing characters to the database1.
(If you're developing on Kawari, this is also useful as a way to quickly create between database resets!)
Scripting
There is now a way to dynamically register actions, using registerAction
. You give it an action id, and the path to the Lua script. Any actions that don't have an associated script are ignored:
registerAction(3, "actions/Sprint.lua")
registerAction(9, "actions/FastBlade.lua")
The next step would be to do the same for events, probably.
Effects
Actions have consequences effects, including: dealing damage, status effects, and even starting combos. These effects are also necessary for the client to show battle messages. A common pattern I've seen (in Sapphire and Maelstorm) is an EffectsBuilder
that helps package multiple effects into the same packet. This is now available in Lua for action scripts to use:
function doAction(player)
effects = EffectsBuilder()
effects:damage(20)
return effects
end
I can now badly create my first attack action: Fast Blade. It can damage the Tiny Mandagora we spawned earlier:
{{< tube "https://tube.ryne.moe/videos/embed/edeGeJg8quUTabP53eZQAM" >}}
The server crashes because enemies can't die yet, and their health overflows 😅 Only the Damage effect is implemented so far, at a minimum I want misses and status effects (for actions like Sprint.)
Racial attributes
In a previous update you might have seen that my character's attributes were completely wrong. This is now fixed, and the server will send the correct attributes for your chosen race/tribe.
(This isn't level scaled yet, but it's better than it was before.)
New commands
There are now several new GM commands:
//gm wireframe
: Turns on wireframe rendering for the environment. I actually wonder if this to catch bots running under the ground. Is that still a thing?//gm <item>
to give yourself an item.//gm lv <level>
to set your current level.
And of course, more debug commands to help my own testing:
!spawnclone
: Spawns a clone of yourself, this is different from!spawnactor
(now called!spawnplayer
) which creates a predefined player!classjob <id>
to change your current class/job. This is to workaround the lack of actual class switching.
Inventory
You now have all four pages of inventory available, and can move items freely around! It only swaps items for now, but that's more an enough for it work:
Equipping items now updates your character's model too, but this isn't yet reflected in the lobby. I also encountered a strange bug when displaying a weapon, so that isn't working either.
Patch 7.20h
They released a hotfix for 7.20, and Kawari was updated to the new set of opcodes. Not much has changed structure-wise, it seems. I also added a size heuristic to cfcap-expand
which helped me update to the new opcodes faster. Not the best/most accurate thing, but it's a nice hint.
Performance
I don't like premature optimizations, but this is a special case because the server takes a bit of time preparing packets. This causes the client to freak out, usually2. So I threw Kawari into Hotspot to figure out what's taking cycles. If you didn't know it supported Rust symbols, you do now!
I figured out most of the performance problems, so now there's less things happening on the hot path - such as loading game data, contacting the database, and so on. There's still a bit more work to do, but for now you should encounter less "invalid packet" errors - especially on lower end computers like laptops.
Smaller things
More of the lobby character packets are filled out now, specifically around Fantasia and a bunch of other misc character flags. Since the Lobby server is simple compared to the World server, I plan on implementing those for fun. I also found some odd differences in FFXIVClientStructs that I need to double-check and upstream.