yehric2018 / mmobot

1 stars 0 forks source link

Introduce consumables, resources, and fluids #17

Open yehric2018 opened 1 year ago

yehric2018 commented 1 year ago

The first step to allow for eat functionality is to create the classes of items that can be eaten. The classes of items we need to introduce are:

Once these items are introduced, we need to add some db files to describe these items. We add the new static item types by utilizing our setup_static.py script.

yehric2018 commented 1 year ago

Update 1: Just converted some basic weapons to the yaml format which we will use later for crafting. Now need to switch other items to yaml as well. It seems yaml will be much easier to parse, and we will be able to maintain items more easily by keeping them all in separate files.

yehric2018 commented 1 year ago

Update 2: Resources have been created, and ResourceInstances are on the way. Before moving on to Consumables, I am going to update the !drop, !give, !inventory, !here, and !pickup commands to condense the resources together instead of having them separate. This means that all the resource instances in your inventory will all show up together rather than as separate entities - same for when listing out all items in a zone.

yehric2018 commented 1 year ago

I'm lazy, and I now realize there's quite a bit of extra logic we would need to implement to incorporate resources with quantities.

For example, for mining resources, we need to add extra logic to decide whether to create a new ResourceInstance or to just increment the quantity by 1. Additionally, we would need to pull up the inventory or zone loot from the inventory before incrementing.

However, the main motivation for this was a UI change. So to make things simpler, we can keep Resources the same on the database end, but display them differently to the end user. We can give players the option to view a condensed inventory for ALL inventory items, and a version that lists everything as is for more fine-tuned selection.

The result of this: We only need to make changes to the !inventory command and possibly the !here command. We can show condensed by default, and then allow for !inventory all or !here all to expand things. And the default case would be pretty straightforward to implement.

Another possible change this leads to is needing to increase the entity ID to a long instead of an int. It's unlikely this change will be necessary though: Even if we had 10,000 Interaction objects each with 1,000 resources each across our game, this would only result in 10,000,000 total item instances. It's unlikely the number of entities in our game overall will cross 1 billion. If that becomes an issue later, we can migrate the database to make the fix.

We can keep the Resource class, however. We probably won't add any more functionality to resources, but it will be good to organize these items into a class of their own. But ResourceInstance will not be used for now.

yehric2018 commented 1 year ago

Update 3: The SolidFoods and SolidFoodInstances tables were both added to the database. Note that SolidFoodInstances doesn't add on any attributes beyond those already in ItemInstances - but I made it a separate table to make extensibility easier later on (This is the same case for WeaponInstances). To test that this works, I spawned a SolidFoodInstance (a raspberry) into the world in my inventory, and it appeared properly.

Now I have everything I need to start on the !eat command. However, I'm going to go ahead and implement NonSolids, FluidFoods, and FluidContainers. This way, when we get to implementing the !eat command, we can go ahead and considering both the solid and fluid case rather than have to rebuild it from the ground up again.

More importantly, we can start working on basic crafting - fluids and eating can probably wait until later. So I will leave this as an open ticket now while I plan out how to implement fluids, and I will start finalizing how the crafting system in the game will look.

yehric2018 commented 1 year ago

Update 4: The !eat command has been completely and tested thoroughly for solid foods. Adding fluid foods shouldn't be too hard - just a matter of adding another if statement.

One idea I came up with while creating the !eat command was having foods that can influence more permanent stats. For example, a really hearty food might permanently increase your HP, endurance, etc. This would make certain foods extremely valuable to eat, but these foods require thorough preparation and need to be cooked by a top tier chef. While certain drugs might actually lower your permanent stats - imagine if you get addicted to a drug because of the HP relief it provides, but it lowers your overall HP.

Besides adding the eat command, I also made a lot of simplifications to the test framework. I think the next commit I will work on cleaning up current test code so it isn't so cluttered with initializing the fixtures. I'll try to keep command tests similar to other command tests in the future so we can reduce the amount of code written for setup.

As stated before, I'll keep this issue open for implementing FluidContainers, which is the last thing that needs to be added here.

yehric2018 commented 1 year ago

Update 5: Fluid Containers now exist in the game world, although you cannot do anything with them right now. I can implement the eat command to drink water and stuff, but besides that I don't think much else will be implemented until we get more into crafting. For the eat command, we will add the following:

After the new features to the eat command are implemented and tested, I'm going to take a break from fluid containers, since there's not much to do with them until we can actually collect nonsolids. It will be good to keep in mind how to fill these containers later on with stuff from the wild such as lakes. I will still leave this issue open until we are able to put stuff in the container and take stuff out without eating.

yehric2018 commented 1 year ago

Update 6: The !eat command is complete for FluidContainers. There is one last test case that needs to finished, and then we need to add some more edge cases when we implement poisons.

Other things for nonsolids that needs to be implemented: filling and pouring FluidContainers.