Skip to content
This repository
Browse code

Make Tartarus drain experience over time, restore lost experience whe…

…n returning from the branch.
  • Loading branch information...
commit 0b0dabbd95bccc252be074f232d34955377c2fff 1 parent c349644
dtsund authored June 16, 2012
7  crawl-ref/source/effects.cc
@@ -2212,6 +2212,13 @@ void handle_time()
2212 2212
     // Nasty things happen to people who spend too long in Hell.
2213 2213
     if (player_in_hell() && coinflip())
2214 2214
         _hell_effects();
  2215
+    
  2216
+    // In particular, Tartarus slowly drains your experience...
  2217
+    if(you.where_are_you == BRANCH_TARTARUS)
  2218
+    {
  2219
+        you.experience = you.experience * 49 / 50;
  2220
+        level_change();
  2221
+    }
2215 2222
 
2216 2223
     // Adjust the player's stats if s/he's diseased. Stats used to slowly
2217 2224
     // recover over time, but now they don't.
2  crawl-ref/source/player.h
@@ -66,6 +66,8 @@ class player : public actor
66 66
   uint8_t hit_points_regeneration;
67 67
   uint8_t magic_points_regeneration;
68 68
   unsigned int experience;
  69
+  unsigned int undrained_experience; //Experience immediately before entering Tartarus.
  70
+                                     //Will be restored on exit.
69 71
   int experience_level;
70 72
   int gold;
71 73
   int zigs_completed, zig_max;
25  crawl-ref/source/stairs.cc
@@ -692,6 +692,17 @@ void up_stairs(dungeon_feature_type force_stair,
692 692
     {
693 693
         mprf("Welcome back to %s!",
694 694
              branches[you.where_are_you].longname);
  695
+        
  696
+        //When leaving Tartarus, restore lost experience.
  697
+        if(old_level.branch == BRANCH_TARTARUS)
  698
+        {
  699
+            if(you.experience < you.undrained_experience)
  700
+            {
  701
+                mpr("You sigh with relief as your memories come flooding back.");
  702
+                you.experience = you.undrained_experience;
  703
+                level_change();
  704
+            }
  705
+        }
695 706
     }
696 707
 
697 708
     const coord_def stair_pos = you.pos();
@@ -1166,6 +1177,20 @@ void down_stairs(dungeon_feature_type force_stair,
1166 1177
             mpr(branches[you.where_are_you].entry_message);
1167 1178
         else
1168 1179
             mprf("Welcome to %s!", branches[you.where_are_you].longname);
  1180
+            
  1181
+        //Handle the just-entered-Tartarus stuff here.
  1182
+        if(you.where_are_you == BRANCH_TARTARUS)
  1183
+        {
  1184
+            mpr("You shudder as the unholy atmosphere begins claiming your memories...");
  1185
+            you.undrained_experience = you.experience;
  1186
+            
  1187
+            //This will almost never happen in practice.
  1188
+            if(you.experience_level == 1)
  1189
+                you.experience = 0;
  1190
+            else
  1191
+                you.experience = exp_needed(you.experience_level) - 1;
  1192
+            level_change();
  1193
+        }
1169 1194
     }
1170 1195
 
1171 1196
     if (stair_find == DNGN_ENTER_HELL)
3  crawl-ref/source/tag-version.h
@@ -13,7 +13,8 @@ enum tag_minor_version
13 13
     TAG_MINOR_LUA_COLOUR_ENUM,     // Require enums for Lua colours.
14 14
     TAG_MINOR_GOLDIFIED_RUNES,     // Runes are undroppable and don't take space.
15 15
     TAG_MINOR_MONS_THREAT_LEVEL,   // Save threat level in monster_info.
16  
-    TAG_MINOR_STAIR_FOLLOW,        // Monsters follow you more dynamically, Brogue-style
  16
+    TAG_MINOR_STAIR_FOLLOW,        // Monsters follow you more dynamically, Brogue-style.
  17
+    TAG_MINOR_TAR_DRAINING,        // Tartarus drains your experience.
17 18
 
18 19
     NUM_TAG_MINORS,
19 20
     TAG_MINOR_VERSION = NUM_TAG_MINORS - 1
7  crawl-ref/source/tags.cc
@@ -1076,6 +1076,7 @@ static void tag_construct_you(writer &th)
1076 1076
 
1077 1077
     marshallShort(th, you.hit_points_regeneration * 100);
1078 1078
     marshallInt(th, you.experience);
  1079
+    marshallInt(th, you.undrained_experience);
1079 1080
     marshallInt(th, you.gold);
1080 1081
 
1081 1082
     marshallInt(th, you.exp_available);
@@ -1721,6 +1722,12 @@ static void tag_read_you(reader &th)
1721 1722
 
1722 1723
     you.hit_points_regeneration   = unmarshallShort(th) / 100;
1723 1724
     you.experience                = unmarshallInt(th);
  1725
+
  1726
+    if(th.getMinorVersion() >= TAG_MINOR_TAR_DRAINING)
  1727
+        you.undrained_experience  = unmarshallInt(th);
  1728
+    else
  1729
+        you.undrained_experience = you.experience;
  1730
+
1724 1731
     you.gold                      = unmarshallInt(th);
1725 1732
     you.exp_available             = unmarshallInt(th);
1726 1733
     

0 notes on commit 0b0dabb

Please sign in to comment.
Something went wrong with that request. Please try again.