GSoC Week 1: Die Hard (Or Not!)
GSoC official coding period began this week. I worked on what happens when a player dies in-game this week. The github project card can be found here.
In the normal gameplay mode of Terasology, when a player dies, you are shown a death screen with the reason of your death. You disappear from the game play area. However, we are aiming at fast-paced capture-the-flag type gameplay for Light and Shadow. We want the player to teleport back to its team’s base and health should be refilled to 100%.
I initially struggled to get this right without breaking other systems. A player’s death is indicated to the client through the
PlayerDeath Event. This is send from a system which handles destruction of the entities by capturing
BeforeDestroy Event. I created a new method with higher priority to capture and consume the
BeforeDestroy Event. Now I use two other events
CharacterTeleport to refill the dead player’s health and send it back to its base.
PR: Respawn and heal player on death #82
Next task was to empty the inventory of the dead player. However, we can’t delect the player’s
MagicStaff weapon since it is given only once to the players. This task was quite straight forward. I just iterated through the inventory and if the item was not the
MagicStaff, I dropped the all the items in the corresponding inventory slot.
PR: Handle inventory on death #83
Now we move on to resetting the game once one of the team wins. We need to clear the gameplay region and take players to their respective bases. This will be followed by addition of StatSystem to store the various game statistics like kills, deaths, etc.