yehric2018 / mmobot

1 stars 0 forks source link

Allow a player to be incapacitated and killed #16

Closed yehric2018 closed 1 year ago

yehric2018 commented 1 year ago

Perma-death has always been one of the main features of the MMO, so we are going to implement perma-death.

Incapacitation is a state where you are still alive, but you cannot do anything. This prevents you from performing any commands, but you can still speak. You become incapacitated if your HP hits 0 or below.

When you are incapacitated, the only way to be revived is by using an item with revitalizing effects on you. Otherwise, this is more of just a state for you to say goodbye to the world before moving to the afterlife.

Death happens after incapacitation. There are two ways to die after being incapacitated.

After death, you can no longer read messages in the world channels, and you will gain access to the #afterlife channel, where you can talk to fellow adventurers who have also passed recently. You lose access to the #afterlife channel when you create a new account.

TODO:

yehric2018 commented 1 year ago

We were originally going to introduce the hunger and thirst stats here, however to simplify things, we decided to instead combine these stats with HP and endurance. Now instead of recovering HP over time, your HP will decrease over time to show you getting hungry over time. Endurance will be incremented, but very slowly. This will encourage players to eat food that will increase their HP and endurance.

yehric2018 commented 1 year ago

The process of killing players is very clunky, especially since we need to do several things on the client side such as sending messages in the channel where the player was incapacitated/killed, which is not always readily available (especially within the scheduled decrement HP event). It would be good to find ways to factor out much of the logic and reduce computation/complexity.

yehric2018 commented 1 year ago

Much of the design for incapacitation and killing was changed over time, so the original prompt is not so relevant anymore. The main change is that we shifted away from using APScheduler and instead towards using asyncio library.

The main motivation away from using APScheduler is that it runs it's jobs separate from the Discord bot itself. This requires to pass lots of arguments over to the scheduled job, all of which need to be serializable. Unfortunately, several necessary arguments such as the Discord client itself and the database engine are not serializable. Therefore, it is much less of hassle to run the jobs inside the bot itself.

Our new design is as follows:

With this new design, we will still need to make sure to implement all the requirements for incapacitation and dying to work, along with other tasks:

yehric2018 commented 1 year ago

For incapacitation checks, we are going to check two things:

  1. Their is_active status is True, otherwise they are dead
  2. Their HP is greater than 0, otherwise they are incapacitated If they are dead and try to run a command, we should log some kind of error, since it shouldn't be possible for them to even send messages when they are dead. If their HP is equal to 0, then we can just return from the command and do nothing - this will have the affect of trying to do something but failing. Another option is to send a more detailed message in the channel or DMs that just states they are incapacitated.

For now, we do not have any error handling for invalid states (something that we should probably add later), so as of now we will just add checks for HP > 0. Following this, we need to add test cases for all the disabled commands to ensure they either don't do anything or send the correct message in the channels.

The disabled commands are as follows:

yehric2018 commented 1 year ago

Our main bulk of work here is pretty much complete - two smaller unfinished issues that are more or less optional have been converted to separate issues.

This functionality was definitely trickier and more time-intensive to implement than I expected. However, being able to die in the game is a vital to the experience this MMORPG seeks to offer, so I think the amount of work put into this task is well warranted.