home · contact · privacy
Server, plugin: Abort command_worldactive checks as early as possible.
[plomrogue] / server / decrement_lifepoints.py
1 # This file is part of PlomRogue. PlomRogue is licensed under the GPL version 3
2 # or any later version. For details on its copyright, license, and warranties,
3 # see the file NOTICE in the root directory of the PlomRogue source package.
4
5
6 def decrement_lifepoints(t):
7     """Decrement t's lifepoints by 1, and if to zero, corpse it.
8
9     If t is the player avatar, only blank its fovmap, so that the client may
10     still display memory data. On non-player things, erase fovmap and memory.
11     Dying actors drop all their things.
12     """
13     from server.config.world_data import world_db
14     from server.io import log
15     t["T_LIFEPOINTS"] -= 1
16     if 0 == t["T_LIFEPOINTS"]:
17         for id in t["T_CARRIES"]:
18             t["T_CARRIES"].remove(id)
19             world_db["Things"][id]["T_POSY"] = t["T_POSY"]
20             world_db["Things"][id]["T_POSX"] = t["T_POSX"]
21             world_db["Things"][id]["carried"] = False
22         t["T_TYPE"] = world_db["ThingTypes"][t["T_TYPE"]]["TT_CORPSE_ID"]
23         if world_db["Things"][0] == t:
24             t["fovmap"] = bytearray(b' ' * (world_db["MAP_LENGTH"] ** 2))
25             log("You die.")
26             log("See README on how to start over.")
27         else:
28             t["fovmap"] = False
29             t["T_MEMMAP"] = False
30             t["T_MEMDEPTHMAP"] = False
31             t["T_MEMTHING"] = []