14 June 2006

Sending the player buffs

The way things are now, only a player can see his or her own buffs (modifiers). This is not necessarily bad, because I am not sure whether or not we should let the other players see all the modifiers a player has (such as the shield spell, poisoned or not, and so on).
However, for some buffs it makes sense to let other players know. For example, it's important to tell all the clients that can see an invisible player that this player is invisible, so it will be rendered in a semi transparent way.

So the idea is that SOME buffs should be sent to the other players, while some should be private.
There are two cases:
1. A player gets/loses a buff while others are near him.
2. A new player request the info about that entity. For example, when you move and some other entities apear in your range, the server will send you the information about that entity; stuff such as the name, location, clothes, and so on.

The first case is straightforward. When an entity aquires or loses a buff that is to be sent to the other players immediately, then we just send it's buffs in a single packet (sending the actor_id and a 32b integer that acts as a bitmap; each bit indicates a flag).

The second case is a little bit more tricky. I really didn't want to send more octets down the network each time the entity information is sent to the nearby players. That particular operation is one of the biggest bandwidth sinks in the game.
So what we will do is use the currently unused bits.

For example, the x and y positions are 2 octets each. That means 65536 values, but the biggest map ever will not be bigger than 2048 steps. So that means we have 5 bits at the end of x pos, and 5 bits at the end of y pos that are unused.
We also have some unused bits in the rotation field, and we can find even more bits in other places.

For the time being, we do not need more than 10 'public' buffs, so we will use just the x and y pos extra bits. Later on, when we will need more, we'll 'reclaim' other fields.

Everyone who runs a bot in EL should change their code in order to zero the last 5 bits of the x and y position of any entity in it's range. This can be done by doing a logic AND between the position and 0x7FF
Given the fact that those bits are unused anyway, you can implement that change in your bots right now, as there will be no problems prior to the update.

0 Comments:

Post a Comment

<< Home