Skip to content

Commit

Permalink
Make Tartarus drain experience over time, restore lost experience whe…
Browse files Browse the repository at this point in the history
…n returning from the branch.
  • Loading branch information
dtsund committed Jun 16, 2012
1 parent c349644 commit 0b0dabb
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
7 changes: 7 additions & 0 deletions crawl-ref/source/effects.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2212,6 +2212,13 @@ void handle_time()
// Nasty things happen to people who spend too long in Hell.
if (player_in_hell() && coinflip())
_hell_effects();

// In particular, Tartarus slowly drains your experience...
if(you.where_are_you == BRANCH_TARTARUS)
{
you.experience = you.experience * 49 / 50;
level_change();
}

// Adjust the player's stats if s/he's diseased. Stats used to slowly
// recover over time, but now they don't.
Expand Down
2 changes: 2 additions & 0 deletions crawl-ref/source/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class player : public actor
uint8_t hit_points_regeneration;
uint8_t magic_points_regeneration;
unsigned int experience;
unsigned int undrained_experience; //Experience immediately before entering Tartarus.
//Will be restored on exit.
int experience_level;
int gold;
int zigs_completed, zig_max;
Expand Down
25 changes: 25 additions & 0 deletions crawl-ref/source/stairs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,17 @@ void up_stairs(dungeon_feature_type force_stair,
{
mprf("Welcome back to %s!",
branches[you.where_are_you].longname);

//When leaving Tartarus, restore lost experience.
if(old_level.branch == BRANCH_TARTARUS)
{
if(you.experience < you.undrained_experience)
{
mpr("You sigh with relief as your memories come flooding back.");
you.experience = you.undrained_experience;
level_change();
}
}
}

const coord_def stair_pos = you.pos();
Expand Down Expand Up @@ -1166,6 +1177,20 @@ void down_stairs(dungeon_feature_type force_stair,
mpr(branches[you.where_are_you].entry_message);
else
mprf("Welcome to %s!", branches[you.where_are_you].longname);

//Handle the just-entered-Tartarus stuff here.
if(you.where_are_you == BRANCH_TARTARUS)
{
mpr("You shudder as the unholy atmosphere begins claiming your memories...");
you.undrained_experience = you.experience;

//This will almost never happen in practice.
if(you.experience_level == 1)
you.experience = 0;
else
you.experience = exp_needed(you.experience_level) - 1;
level_change();
}
}

if (stair_find == DNGN_ENTER_HELL)
Expand Down
3 changes: 2 additions & 1 deletion crawl-ref/source/tag-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ enum tag_minor_version
TAG_MINOR_LUA_COLOUR_ENUM, // Require enums for Lua colours.
TAG_MINOR_GOLDIFIED_RUNES, // Runes are undroppable and don't take space.
TAG_MINOR_MONS_THREAT_LEVEL, // Save threat level in monster_info.
TAG_MINOR_STAIR_FOLLOW, // Monsters follow you more dynamically, Brogue-style
TAG_MINOR_STAIR_FOLLOW, // Monsters follow you more dynamically, Brogue-style.
TAG_MINOR_TAR_DRAINING, // Tartarus drains your experience.

NUM_TAG_MINORS,
TAG_MINOR_VERSION = NUM_TAG_MINORS - 1
Expand Down
7 changes: 7 additions & 0 deletions crawl-ref/source/tags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,7 @@ static void tag_construct_you(writer &th)

marshallShort(th, you.hit_points_regeneration * 100);
marshallInt(th, you.experience);
marshallInt(th, you.undrained_experience);
marshallInt(th, you.gold);

marshallInt(th, you.exp_available);
Expand Down Expand Up @@ -1721,6 +1722,12 @@ static void tag_read_you(reader &th)

you.hit_points_regeneration = unmarshallShort(th) / 100;
you.experience = unmarshallInt(th);

if(th.getMinorVersion() >= TAG_MINOR_TAR_DRAINING)
you.undrained_experience = unmarshallInt(th);
else
you.undrained_experience = you.experience;

you.gold = unmarshallInt(th);
you.exp_available = unmarshallInt(th);

Expand Down

0 comments on commit 0b0dabb

Please sign in to comment.