[7] Improved Gathering Skills
06/24/2024, 05:45pm
For the past few months, I've been making a lot of bug fixes and changes to the item system to support improvements to the three main gathering skills: Fishing, Foraging, and Mining.
The core thing to support were the concepts of item quality and derived stats. When gathering items, they now have a chance to be of improved quality, based on the level of the respective gathering skill. Item quality itself affects the stats of the item. For equipment, higher quality means better damage, armor, maximum durability, etc. For materials and ingredients, quality can carry over to the final product.
Individual item instances already had support for properties, but stats are a bit different. They change often, don't need to be persisted to the database, and are derived from said properties (like quality, durability, and enchantments). To achieve this, each item instance can now have a block of stats associated with it that gets calculated by the server and synced to clients when needed. Instead of just using the static base stats from the item definition, the stats of each item instance are derived when the item is created in the game world or when the item is modified (e.g. if the quality or durability is changed). This was a big refactor, but it was necessary to support the new item quality system and a few other things I have in mind for the future.
As for the skills themselves, they now each have unique animations. Additionally, skills which require tools don't expect you to have the tool equipped anymore, which is a nice quality of life change. It can just be in your inventory. That was kind of a pain to get working correctly as there were a lot of edge cases to handle - dropping the tool while gathering, changing your equipment, etc.
I created an Activity system to handle the various animations and actions that can be performed in the game. An Activity is basically a visual action that the client needs to replicate. It may consist of an animation, sound, or other metadata. For example, the Fishing activity contains data about the fishing bobber position and the type of fishing rod being used. This allows the client to properly override the players equipment and animation state. It also allowed me to remove a bunch of fishing specific packets and code, as all that is now just driven through this more generic system.
Fishing
Fishing was frustrating to get working with the new water system. Since water is more dynamic now and actually moves, I had to make sure that fishing nodes and bobbers floated properly. Aside from that, the aforementioned item quality changes, and bug fixes, there is not a ton of new stuff here - I was already pretty happy with how the skill worked.
Foraging
Foraging is in a similar place. The core was already solid, but I spent a lot of time refactoring it under the hood and fixing bugs. Now it actually takes some time to forage something, instead of just being an instant item pickup.
Mining
Mining was the most busted of all the skills. I didn't even realize how broken its been for the past few years. Apparently, I just never implemented mining speed / the mining bonus stat properly. No matter what tool you used, or what your Mining level was, you would always take the same amount of time to mine some ore. Not great, but I got that fixed up. Smelting also got some work, but I'll talk more about that in the future. I'm just happy to have an actual animation here now.
Next Steps
There's still a lot of work to be done across the board. Now that I've gotten a chance to revisit gathering, I'll revisit crafting. Thanks for reading.
- Declan (@dooskington)