summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-11-30 11:04:07 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-11-30 11:04:07 +0000
commitbdcd305d09236d064dfd0dd695dd4f4a0f205030 (patch)
tree86ff506b5b47f1e6560f6686d130c06338c50554
parentf6a1d5082c4ae9853ded65581030b86f5c7991fb (diff)
downloadcrawl-ref-bdcd305d09236d064dfd0dd695dd4f4a0f205030.tar.gz
crawl-ref-bdcd305d09236d064dfd0dd695dd4f4a0f205030.zip
Added Sage card, which boosts skill training.
[Side note: rm saves/ * is a bad idea.] git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2945 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/acr.cc1
-rw-r--r--crawl-ref/source/decks.cc44
-rw-r--r--crawl-ref/source/decks.h1
-rw-r--r--crawl-ref/source/defines.h2
-rw-r--r--crawl-ref/source/enum.h1
-rw-r--r--crawl-ref/source/externs.h4
-rw-r--r--crawl-ref/source/output.cc23
-rw-r--r--crawl-ref/source/player.cc18
-rw-r--r--crawl-ref/source/skills.cc4
-rw-r--r--crawl-ref/source/spells1.cc2
10 files changed, 90 insertions, 10 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index e061525409..ebe51b8677 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -2499,6 +2499,7 @@ static void decrement_durations()
6, coinflip(),
"Your unholy channel is weakening.");
+ decrement_a_duration(DUR_SAGE, "You feel less studious.");
decrement_a_duration(DUR_STEALTH, "You feel less stealthy.");
decrement_a_duration(DUR_RESIST_FIRE, "Your fire resistance expires.");
decrement_a_duration(DUR_RESIST_COLD, "Your cold resistance expires.");
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc
index 89fa8a9e9e..30b5fb703d 100644
--- a/crawl-ref/source/decks.cc
+++ b/crawl-ref/source/decks.cc
@@ -36,6 +36,7 @@
#include "output.h"
#include "player.h"
#include "religion.h"
+#include "skills2.h"
#include "spells1.h"
#include "spells2.h"
#include "spells3.h"
@@ -133,6 +134,7 @@ const deck_archetype deck_of_wonders[] = {
{ CARD_EXPERIENCE, {5, 5, 5} },
{ CARD_WILD_MAGIC, {5, 5, 5} },
{ CARD_HELIX, {5, 5, 5} },
+ { CARD_SAGE, {5, 5, 5} },
END_OF_DECK
};
@@ -264,6 +266,7 @@ const char* card_name(card_type card)
case CARD_SHUFFLE: return "Shuffle";
case CARD_EXPERIENCE: return "Experience";
case CARD_HELIX: return "the Helix";
+ case CARD_SAGE: return "the Sage";
case CARD_DOWSING: return "Dowsing";
case CARD_TROWEL: return "the Trowel";
case CARD_MINEFIELD: return "the Minefield";
@@ -1945,6 +1948,46 @@ static void helix_card(int power, deck_rarity_type rarity)
mpr("You feel transcendent for a moment.");
}
+static void sage_card(int power, deck_rarity_type rarity)
+{
+ const int power_level = get_power_level(power, rarity);
+ int c; // how much to weight your skills
+ if ( power_level == 0 )
+ c = 0;
+ else if ( power_level == 1 )
+ c = random2(10) + 1;
+ else
+ c = 10;
+
+ // FIXME: yet another reproduction of random_choose_weighted
+ // Ah for Python:
+ // skill = random_choice([x*(40-x)*c/10 for x in skill_levels])
+ int totalweight = 0;
+ int result = -1;
+ for (int i = 0; i < NUM_SKILLS; ++i )
+ {
+ if ( you.skills[i] < MAX_SKILL_LEVEL )
+ {
+ const int curweight = 1 + you.skills[i] * (40-you.skills[i]) * c;
+ totalweight += curweight;
+ if ( random2(totalweight) < curweight )
+ result = i;
+ }
+ }
+
+ if ( result == -1 )
+ {
+ mpr("You feel omnipotent."); // all skills maxed
+ }
+ else
+ {
+ you.duration[DUR_SAGE] = random2(1800) + 200;
+ you.sage_bonus_skill = static_cast<skill_type>(result);
+ you.sage_bonus_degree = power / 25;
+ mprf(MSGCH_PLAIN, "You feel studious about %s.", skill_name(result));
+ }
+}
+
static void glass_card(int power, deck_rarity_type rarity)
{
const int power_level = get_power_level(power, rarity);
@@ -2339,6 +2382,7 @@ bool card_effect(card_type which_card, deck_rarity_type rarity,
case CARD_SHUFFLE: shuffle_card(power, rarity); break;
case CARD_EXPERIENCE: potion_effect(POT_EXPERIENCE, power/4); break;
case CARD_HELIX: helix_card(power, rarity); break;
+ case CARD_SAGE: sage_card(power, rarity); break;
case CARD_GLASS: glass_card(power, rarity); break;
case CARD_DOWSING: dowsing_card(power, rarity); break;
case CARD_MINEFIELD: minefield_card(power, rarity); break;
diff --git a/crawl-ref/source/decks.h b/crawl-ref/source/decks.h
index 68c6390b2a..79f7a3536c 100644
--- a/crawl-ref/source/decks.h
+++ b/crawl-ref/source/decks.h
@@ -96,6 +96,7 @@ enum card_type
CARD_EXPERIENCE,
CARD_WILD_MAGIC,
+ CARD_SAGE, // skill training
CARD_HELIX, // remove one *bad* mutation
CARD_GLASS, // make walls transparent
diff --git a/crawl-ref/source/defines.h b/crawl-ref/source/defines.h
index b396283eb0..b5455f2df0 100644
--- a/crawl-ref/source/defines.h
+++ b/crawl-ref/source/defines.h
@@ -142,6 +142,8 @@ const int LABYRINTH_BORDER = 12;
// Yes, I know we have 32-bit ints now.
#define DEBUG_COOKIE 32767
+#define MAX_SKILL_LEVEL 27
+
#define MIN_HIT_MISS_PERCENTAGE 5
// grids that monsters can see
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h
index 12b7cdf79d..918da756b5 100644
--- a/crawl-ref/source/enum.h
+++ b/crawl-ref/source/enum.h
@@ -1036,6 +1036,7 @@ enum duration_type
DUR_STEALTH,
DUR_MAGIC_SHIELD,
DUR_SLEEP,
+ DUR_SAGE,
NUM_DURATIONS
};
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index 8f0ae5144a..6d9ab7909c 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -638,6 +638,10 @@ public:
FixedVector<bool, 50> practise_skill;
FixedVector<unsigned int, 50> skill_points;
FixedVector<unsigned char, 50> skill_order;
+
+ skill_type sage_bonus_skill; // if Sage is in effect, which skill it affects
+ int sage_bonus_degree; // how much bonus XP to give in that skill
+
int skill_cost_level;
int total_skill_points;
int exp_available;
diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc
index 792bf67d41..7a0e129133 100644
--- a/crawl-ref/source/output.cc
+++ b/crawl-ref/source/output.cc
@@ -485,7 +485,7 @@ void print_stats(void)
}
else
{
- dur_colour( BLUE, (you.duration[DUR_LEVITATION] <= 10 && !perm) );
+ dur_colour(BLUE, (you.duration[DUR_LEVITATION] <= 10 && !perm));
cprintf( "Lev " );
}
}
@@ -506,16 +506,22 @@ void print_stats(void)
// In that case, it should be probably be GREEN, and we'd have
// to check to see if the player does have a breath weapon. -- bwr
if (you.duration[DUR_BREATH_WEAPON] &&
- wherex() < get_number_of_cols() - 4)
+ wherex() < get_number_of_cols() - 5)
{
textcolor( YELLOW ); // no warning
- cprintf( "BWpn" );
+ cprintf( "BWpn " );
}
- if (you.duration[DUR_BARGAIN] && wherex() < get_number_of_cols() - 4)
+ if (you.duration[DUR_BARGAIN] && wherex() < get_number_of_cols() - 5)
{
dur_colour( BLUE, (you.duration[DUR_BARGAIN] <= 15) );
- cprintf( "Brgn" );
+ cprintf( "Brgn " );
+ }
+
+ if (you.duration[DUR_SAGE] && wherex() < get_number_of_cols() - 5)
+ {
+ dur_colour( BLUE, (you.duration[DUR_SAGE] <= 15) );
+ cprintf( "Sage " );
}
textcolor( LIGHTGREY );
@@ -1386,6 +1392,13 @@ std::string status_mut_abilities()
// DUR_STEALTHY handled in stealth printout
+ if (you.duration[DUR_SAGE])
+ {
+ text += "studying ";
+ text += skill_name(you.sage_bonus_skill);
+ text += ", ";
+ }
+
if (you.duration[DUR_MAGIC_SHIELD])
text += "shielded, ";
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 358b2ebee9..f38d9cc6a5 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -2656,8 +2656,8 @@ void gain_exp( unsigned int exp_gained, unsigned int* actual_gain,
if (player_equip_ego_type( EQ_BODY_ARMOUR, SPARM_ARCHMAGI ))
exp_gained = div_rand_round( exp_gained, 4 );
- unsigned long old_exp = you.experience;
- int old_avail = you.exp_available;
+ const unsigned long old_exp = you.experience;
+ const int old_avail = you.exp_available;
#if DEBUG_DIAGNOSTICS
mprf(MSGCH_DIAGNOSTICS, "gain_exp: %d", exp_gained );
@@ -2668,12 +2668,23 @@ void gain_exp( unsigned int exp_gained, unsigned int* actual_gain,
else
you.experience += exp_gained;
+ if (you.duration[DUR_SAGE])
+ {
+ // Bonus skill training from Sage.
+ you.exp_available =
+ (exp_gained * you.sage_bonus_degree) / 100 + exp_gained / 2;
+ exercise(you.sage_bonus_skill, 20);
+ you.exp_available = old_avail;
+ exp_gained /= 2;
+ }
+
if (you.exp_available + exp_gained > 20000)
you.exp_available = 20000;
else
you.exp_available += exp_gained;
level_change();
+
// increase tutorial time-out now that it's actually
// become useful for a longer time
if (Options.tutorial_left && you.experience_level == 7)
@@ -3482,6 +3493,9 @@ void display_char_status()
else if (you.burden_state == BS_OVERLOADED)
mpr("You are overloaded with stuff.");
+ if (you.duration[DUR_SAGE])
+ mprf("You are studying %s.", skill_name(you.sage_bonus_skill));
+
if (you.duration[DUR_BREATH_WEAPON])
mpr( "You are short of breath." );
diff --git a/crawl-ref/source/skills.cc b/crawl-ref/source/skills.cc
index af9dd22cee..9f7a5eb2a1 100644
--- a/crawl-ref/source/skills.cc
+++ b/crawl-ref/source/skills.cc
@@ -389,7 +389,7 @@ static int exercise2( int exsk )
if (you.exp_available < 0)
you.exp_available = 0;
- you.redraw_experience = 1;
+ you.redraw_experience = true;
/*
New (LH): debugging bit: when you exercise a skill, displays the skill
@@ -457,7 +457,7 @@ static int exercise2( int exsk )
|| exsk == SK_ICE_MAGIC || exsk == SK_EARTH_MAGIC
|| you.duration[ DUR_TRANSFORMATION ] > 0)
{
- you.redraw_armour_class = 1;
+ you.redraw_armour_class = true;
}
const unsigned char best = best_skill( SK_FIGHTING,
diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc
index 247e12f8d6..2e8b7acb26 100644
--- a/crawl-ref/source/spells1.cc
+++ b/crawl-ref/source/spells1.cc
@@ -783,7 +783,7 @@ void antimagic()
DUR_FORESCRY, DUR_SEE_INVISIBLE, DUR_WEAPON_BRAND, DUR_SILENCE,
DUR_CONDENSATION_SHIELD, DUR_STONESKIN, DUR_BARGAIN,
DUR_INSULATION, DUR_RESIST_POISON, DUR_RESIST_FIRE, DUR_RESIST_COLD,
- DUR_SLAYING, DUR_STEALTH, DUR_MAGIC_SHIELD
+ DUR_SLAYING, DUR_STEALTH, DUR_MAGIC_SHIELD, DUR_SAGE
};
if (you.duration[DUR_LEVITATION] > 2 && you.duration[DUR_LEVITATION] < 100)