Up to Main Index Up to Journal for January, 2020 JOURNAL FOR FRIDAY 31ST JANUARY, 2020 ______________________________________________________________________________ SUBJECT: Torn between two ideas DATE: Fri 31 Jan 23:41:24 GMT 2020 Time for one quick journal entry before the end of the month, otherwise there will only be two entries for January :( I’ve been mulling over two different ideas for adding a ‘pulse’ to players. Specifically for health regeneration but also extendable to other things that make a player tick — like effect durations, hunger, thirst. The first idea I have been playing with is to use a separate Go routine that fires periodically in the background. However this would entail grabbing the BRL (big room lock) every time the Go routine fires before we can work with the Player instance. This could be a problem for a busy server. The second idea is to only update the player when requesting information like the current health of the player. For this idea we record the time when health is recalculated. The next time we recalculate the duration between updates is known and we can apply X updates all at once. For example, assume every 10 seconds the player regenerates 1 health point as long as they are not hungry or thirsty. We request the player’s current health at 00:00:00 and it is 25 out of a maximum of 30. We then request the current health again at 00:00:45. By this time we should of had four and a half updates. The current health is therefore reported as 25+(4x1) = 29 out of a maximum of 30. The time of the last update is recorded as 00:00:40 so that we don’t loose the half update of 5 seconds when we are updating every 10 seconds. It could get a little tricker. Say we regenerate health at 1 point per 10 seconds, but we then drink a potion that increases this to 2 points for a duration of 30 seconds. We calculate the health at 00:00:00 and again at 00:00:45 as before. The health is then reported as 25+(3x2)+1 or 33 — but capped at the maximum so only 30 is reported. Of the two ideas the first is the simplest and the second is more lightweight. The main difference between the two is when the information is conveyed to the player. With the first idea we can notify the player immediately, even if they are just sat at the prompt: Health: 25/30> You feel very healthy now. Health: 30/30> With the second idea we would need something to happen to the player. Either they enter a command or when a message is sent to them: Health: 25/30> You see Diddymus enter. You feel very healthy now. Health: 30/30> I’m torn (stuck) choosing between the two ideas. I like the immediate response of the first but don’t like the constant ticking of the Go routine. I like the on demand calculations of the second idea but not the delayed feedback. The second idea could also be a little more complicated to implement, but I’m not worried about that — I don’t decide based on what’s easy for me :) -- Diddymus Up to Main Index Up to Journal for January, 2020