Refined version based on the unfinished and unpublished source code of Reign of the Undead 2.1