summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/abl-show.cc19
-rw-r--r--crawl-ref/source/decks.cc33
-rw-r--r--crawl-ref/source/food.cc4
-rw-r--r--crawl-ref/source/it_use2.cc18
-rw-r--r--crawl-ref/source/item_use.cc3
-rw-r--r--crawl-ref/source/player.cc38
-rw-r--r--crawl-ref/source/player.h7
-rw-r--r--crawl-ref/source/spells1.cc70
-rw-r--r--crawl-ref/source/spells2.cc8
-rw-r--r--crawl-ref/source/spells3.cc14
-rw-r--r--crawl-ref/source/spells4.cc46
-rw-r--r--crawl-ref/source/transfor.cc7
12 files changed, 114 insertions, 153 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc
index 8680f76495..7c38f70b67 100644
--- a/crawl-ref/source/abl-show.cc
+++ b/crawl-ref/source/abl-show.cc
@@ -1316,7 +1316,7 @@ static bool _do_ability(const ability_def& abil)
else
{
zapping(ZAP_SPIT_POISON, pow, beam);
- you.duration[DUR_BREATH_WEAPON] = (3 + random2(5)) * BASELINE_DELAY;
+ you.set_duration(DUR_BREATH_WEAPON, 3 + random2(5) );
}
break;
}
@@ -1421,10 +1421,8 @@ static bool _do_ability(const ability_def& abil)
if (abil.ability != ABIL_SPIT_ACID)
{
- you.duration[DUR_BREATH_WEAPON] =
- 3 + random2(4) + random2(30 - you.experience_level) / 2;
-
- you.duration[DUR_BREATH_WEAPON] *= BASELINE_DELAY;
+ you.increase_duration(DUR_BREATH_WEAPON,
+ 3 + random2(4) + random2(30 - you.experience_level) / 2);
if (abil.ability == ABIL_BREATHE_STEAM)
you.duration[DUR_BREATH_WEAPON] /= 2;
@@ -1546,7 +1544,7 @@ static bool _do_ability(const ability_def& abil)
case ABIL_END_TRANSFORMATION:
mpr("You feel almost normal.");
- you.duration[DUR_TRANSFORMATION] = 2 * BASELINE_DELAY;
+ you.set_duration(DUR_TRANSFORMATION, 2);
break;
// INVOCATIONS:
@@ -2025,12 +2023,9 @@ static bool _do_ability(const ability_def& abil)
}
mprf(MSGCH_DURATION, "A thick mucus forms on %s.", msg.c_str());
- int addition = you.skills[SK_INVOCATIONS] * 3 / 2 + 3;
-
- you.duration[DUR_SLIMIFY] += addition * BASELINE_DELAY;
-
- if (you.duration[DUR_SLIMIFY] > 100 * BASELINE_DELAY)
- you.duration[DUR_SLIMIFY] = 100 * BASELINE_DELAY;
+ you.increase_duration(DUR_SLIMIFY,
+ you.skills[SK_INVOCATIONS] * 3 / 2 + 3,
+ 100);
exercise(SK_INVOCATIONS, 3 + random2(5));
break;
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc
index 0fbdd0611e..47785496c7 100644
--- a/crawl-ref/source/decks.cc
+++ b/crawl-ref/source/decks.cc
@@ -1389,13 +1389,14 @@ static void _portal_card(int power, deck_rarity_type rarity)
controlled = true;
}
- int threshold = 6 * BASELINE_DELAY;
+ int threshold = 6;
const bool was_controlled = player_control_teleport();
const bool short_control = (you.duration[DUR_CONTROL_TELEPORT] > 0
- && you.duration[DUR_CONTROL_TELEPORT] < threshold);
+ && you.duration[DUR_CONTROL_TELEPORT]
+ < threshold * BASELINE_DELAY);
if (controlled && (!was_controlled || short_control))
- you.duration[DUR_CONTROL_TELEPORT] = threshold; // Long enough to kick in.
+ you.set_duration(DUR_CONTROL_TELEPORT, threshold); // Long enough to kick in.
if (instant)
you_teleport_now( true );
@@ -1736,13 +1737,13 @@ static void _battle_lust_card(int power, deck_rarity_type rarity)
const int power_level = get_power_level(power, rarity);
if (power_level >= 2)
{
- you.duration[DUR_SLAYING] = (random2(power/6) + 1) * BASELINE_DELAY;
- mpr("You feel deadly.");
+ you.set_duration(DUR_SLAYING, random2(power/6) + 1,
+ 0, "You feel deadly.");
}
else if (power_level == 1)
{
- you.duration[DUR_BUILDING_RAGE] = 1 * BASELINE_DELAY;
- mpr("You feel your rage building.");
+ you.set_duration(DUR_BUILDING_RAGE, 1,
+ 0, "You feel your rage building.");
}
else if (power_level == 0)
potion_effect(POT_MIGHT, random2(power/4));
@@ -1821,8 +1822,7 @@ static void _helm_card(int power, deck_rarity_type rarity)
if (x_chance_in_y(num_resists, 4-i))
{
// Add a temporary resistance.
- int duration = (random2(power/7) + 1) * BASELINE_DELAY;
- you.duration[possible_resists[i]] += duration;
+ you.increase_duration(possible_resists[i], random2(power/7) +1);
msg::stream << "You feel resistant to " << resist_names[i]
<< '.' << std::endl;
--num_resists;
@@ -1880,9 +1880,7 @@ static void _shadow_card(int power, deck_rarity_type rarity)
{
mpr(you.duration[DUR_STEALTH] ? "You feel more catlike."
: "You feel stealthy.");
- int duration = (random2(power/4) + 1 ) * BASELINE_DELAY;
-
- you.duration[DUR_STEALTH] += duration;
+ you.increase_duration(DUR_STEALTH, random2(power/4) + 1);
}
potion_effect(POT_INVISIBILITY, random2(power/4));
@@ -2212,8 +2210,7 @@ static void _sage_card(int power, deck_rarity_type rarity)
mpr("You feel omnipotent."); // All skills maxed.
else
{
- you.duration[DUR_SAGE] = random2(1800) + 200;
- you.duration[DUR_SAGE] *= BASELINE_DELAY;
+ you.set_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));
@@ -2329,8 +2326,8 @@ static void _dowsing_card(int power, deck_rarity_type rarity)
detect_traps( random2(power/4) );
if (things_to_do[2])
{
- mpr("You feel telepathic!");
- you.duration[DUR_TELEPATHY] = random2(power/4) * BASELINE_DELAY;
+ you.set_duration(DUR_TELEPATHY, random2(power/4), 0,
+ "You feel telepathic!");
}
}
@@ -2924,8 +2921,8 @@ bool card_effect(card_type which_card, deck_rarity_type rarity,
break;
case CARD_BARGAIN:
- you.duration[DUR_BARGAIN] += (random2(power) + random2(power) + 2)
- * BASELINE_DELAY;
+ you.increase_duration(DUR_BARGAIN,
+ random2(power) + random2(power) + 2);
break;
case CARD_MAP:
diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc
index ed5061be01..2338a85098 100644
--- a/crawl-ref/source/food.cc
+++ b/crawl-ref/source/food.cc
@@ -929,7 +929,7 @@ bool food_change(bool suppress_message)
{
mpr("Your blood-deprived body can't sustain your "
"transformation much longer.", MSGCH_DURATION);
- you.duration[DUR_TRANSFORMATION] = 2 * BASELINE_DELAY;
+ you.set_duration(DUR_TRANSFORMATION, 2);
}
}
else if (player_in_bat_form()
@@ -940,7 +940,7 @@ bool food_change(bool suppress_message)
"much longer.", MSGCH_WARN);
// Give more time because suddenly stopping flying can be fatal.
- you.duration[DUR_TRANSFORMATION] = 5 * BASELINE_DELAY;
+ you.set_duration(DUR_TRANSFORMATION, 5);
}
else if (newstate == HS_ENGORGED && is_vampire_feeding()) // Alive
{
diff --git a/crawl-ref/source/it_use2.cc b/crawl-ref/source/it_use2.cc
index 547b418c3a..a9c630671c 100644
--- a/crawl-ref/source/it_use2.cc
+++ b/crawl-ref/source/it_use2.cc
@@ -328,12 +328,10 @@ bool potion_effect(potion_type pot_eff, int pow, bool drank_it, bool was_known)
// Now multiple invisiblity casts aren't as good. -- bwr
if (!you.duration[DUR_INVIS])
- you.duration[DUR_INVIS] = (15 + random2(pow)) * BASELINE_DELAY;
+ you.set_duration(DUR_INVIS, 15 + random2(pow), 100);
else
- you.duration[DUR_INVIS] += random2(pow) * BASELINE_DELAY;
+ you.increase_duration(DUR_INVIS, random2(pow), 100);
- if (you.duration[DUR_INVIS] > 100 * BASELINE_DELAY)
- you.duration[DUR_INVIS] = 100 * BASELINE_DELAY;
break;
case POT_PORRIDGE: // oatmeal - always gluggy white/grey?
@@ -445,14 +443,10 @@ bool potion_effect(potion_type pot_eff, int pow, bool drank_it, bool was_known)
case POT_RESISTANCE:
mpr("You feel protected.", MSGCH_DURATION);
- you.duration[DUR_RESIST_FIRE] +=
- (random2(pow) + 35) * BASELINE_DELAY / factor;
- you.duration[DUR_RESIST_COLD] +=
- (random2(pow) + 35) * BASELINE_DELAY / factor;
- you.duration[DUR_RESIST_POISON] +=
- (random2(pow) + 35) * BASELINE_DELAY / factor;
- you.duration[DUR_INSULATION] +=
- (random2(pow) + 35) * BASELINE_DELAY/ factor;
+ you.increase_duration(DUR_RESIST_FIRE, (random2(pow) + 35) / factor);
+ you.increase_duration(DUR_RESIST_COLD, (random2(pow) + 35) / factor);
+ you.increase_duration(DUR_RESIST_POISON, (random2(pow) + 35) / factor);
+ you.increase_duration(DUR_INSULATION, (random2(pow) + 35) / factor);
// Just one point of contamination. These potions are really rare,
// and contamination is nastier.
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index 71093e334d..5ab49f1123 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -5125,8 +5125,7 @@ static void _vulnerability_scroll()
}
}
- you.duration[DUR_LOWERED_MR] = 40 * BASELINE_DELAY;
- mpr("Magic dampens around you!");
+ you.set_duration(DUR_LOWERED_MR, 40, 0, "Magic dampens around you!");
}
void read_scroll(int slot)
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 2ebd63236c..a36799c8f8 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -4718,10 +4718,7 @@ bool confuse_player(int amount, bool resistable)
}
const int old_value = you.duration[DUR_CONF];
- you.duration[DUR_CONF] += amount * BASELINE_DELAY;
-
- if (you.duration[DUR_CONF] > 40 * BASELINE_DELAY)
- you.duration[DUR_CONF] = 40 * BASELINE_DELAY;
+ you.increase_duration(DUR_CONF, amount, 40);
if (you.duration[DUR_CONF] > old_value)
{
@@ -4887,10 +4884,7 @@ bool napalm_player(int amount)
return (false);
const int old_value = you.duration[DUR_LIQUID_FLAMES];
- you.duration[DUR_LIQUID_FLAMES] += amount * BASELINE_DELAY;
-
- if (you.duration[DUR_LIQUID_FLAMES] > 100 * BASELINE_DELAY)
- you.duration[DUR_LIQUID_FLAMES] = 100 * BASELINE_DELAY;
+ you.increase_duration(DUR_LIQUID_FLAMES, amount, 100);
if (you.duration[DUR_LIQUID_FLAMES] > old_value)
mpr("You are covered in liquid flames!", MSGCH_WARN);
@@ -7017,8 +7011,7 @@ void player::hibernate(int)
viewwindow(false);
// Do this *after* redrawing the view, or viewwindow() will no-op.
- duration[DUR_SLEEP] = 3 + random2avg(5, 2);
- duration[DUR_SLEEP] *= BASELINE_DELAY;
+ set_duration(DUR_SLEEP, 3 + random2avg(5, 2));
}
void player::put_to_sleep(int power)
@@ -7035,8 +7028,7 @@ void player::put_to_sleep(int power)
viewwindow(false);
// As above, do this after redraw.
- duration[DUR_SLEEP] = 5 + random2avg(power / 10, 5);
- duration[DUR_SLEEP] *= BASELINE_DELAY;
+ set_duration(DUR_SLEEP, 5 + random2avg(power/10, 5));
}
void player::awake()
@@ -7348,3 +7340,25 @@ void player::set_gold(int amount)
shopping_list.gold_changed(old_gold, gold);
}
}
+
+void player::increase_duration(duration_type dur, int turns, int cap,
+ const char* msg)
+{
+ if (msg)
+ mpr(msg);
+ cap *= BASELINE_DELAY;
+
+ you.duration[dur] += turns * BASELINE_DELAY;
+ if (cap && you.duration[dur] > cap)
+ you.duration[dur] = cap;
+}
+
+void player::set_duration(duration_type dur, int turns,
+ int cap, const char * msg)
+{
+ you.duration[dur] = 0;
+ increase_duration(dur, turns, cap, msg);
+}
+
+
+
diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h
index c435b9d608..79ed2c1ed2 100644
--- a/crawl-ref/source/player.h
+++ b/crawl-ref/source/player.h
@@ -526,6 +526,13 @@ public:
void del_gold(int delta);
void set_gold(int amount);
+ void increase_duration(duration_type dur, int turns, int cap = 0,
+ const char* msg = NULL);
+ void set_duration(duration_type dur, int turns, int cap = 0,
+ const char *msg = NULL);
+
+
+
protected:
void _removed_beholder();
bool _possible_beholder(const monsters *mon) const;
diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc
index c96e950c10..dccf3a4516 100644
--- a/crawl-ref/source/spells1.cc
+++ b/crawl-ref/source/spells1.cc
@@ -1271,10 +1271,9 @@ void extension(int pow)
mpr("Your ring of flames roars with new vigour!");
}
- if ( !(you.duration[DUR_WEAPON_BRAND] < 1
- || you.duration[DUR_WEAPON_BRAND] > 80 * BASELINE_DELAY) )
+ if ( !you.duration[DUR_WEAPON_BRAND] < 1)
{
- you.duration[DUR_WEAPON_BRAND] += (5 + random2(8)) * BASELINE_DELAY;
+ you.increase_duration(DUR_WEAPON_BRAND, 5 + random2(8), 80);
}
if (you.duration[DUR_SWIFTNESS])
@@ -1300,9 +1299,8 @@ void extension(int pow)
|| you.attribute[ATTR_TRANSFORMATION] != TRAN_BAT))
{
mpr("Your transformation has been extended.");
- you.duration[DUR_TRANSFORMATION] += random2(pow) * BASELINE_DELAY;
- if (you.duration[DUR_TRANSFORMATION] > 100 * BASELINE_DELAY)
- you.duration[DUR_TRANSFORMATION] = 100 * BASELINE_DELAY;
+ you.increase_duration(DUR_TRANSFORMATION, random2(pow), 100,
+ "Your transformation has been extended.");
// Give a warning if it won't last long enough for the
// timeout messages.
@@ -1329,18 +1327,6 @@ void extension(int pow)
contaminate_player( contamination, true );
}
-static void _increase_duration(duration_type dur, int amount, int cap,
- const char* msg)
-{
- if (msg)
- mpr(msg);
- cap *= BASELINE_DELAY;
-
- you.duration[dur] += amount * BASELINE_DELAY;
- if (you.duration[dur] > cap)
- you.duration[dur] = cap;
-}
-
void ice_armour(int pow, bool extending)
{
if (!player_light_armour())
@@ -1371,8 +1357,8 @@ void ice_armour(int pow, bool extending)
you.redraw_armour_class = true;
}
- _increase_duration(DUR_ICY_ARMOUR, 20 + random2(pow) + random2(pow), 50,
- NULL);
+ you.increase_duration(DUR_ICY_ARMOUR, 20 + random2(pow) + random2(pow), 50,
+ NULL);
}
void stone_scales(int pow)
@@ -1396,21 +1382,21 @@ void stone_scales(int pow)
you.redraw_armour_class = true;
}
- _increase_duration(DUR_STONEMAIL, 20 + random2(pow) + random2(pow), 100,
- NULL);
+ you.increase_duration(DUR_STONEMAIL, 20 + random2(pow) + random2(pow), 100,
+ NULL);
burden_change();
}
void missile_prot(int pow)
{
- _increase_duration(DUR_REPEL_MISSILES, 8 + roll_dice( 2, pow ), 100,
- "You feel protected from missiles.");
+ you.increase_duration(DUR_REPEL_MISSILES, 8 + roll_dice( 2, pow ), 100,
+ "You feel protected from missiles.");
}
void deflection(int pow)
{
- _increase_duration(DUR_DEFLECT_MISSILES, 15 + random2(pow), 100,
- "You feel very safe from missiles.");
+ you.increase_duration(DUR_DEFLECT_MISSILES, 15 + random2(pow), 100,
+ "You feel very safe from missiles.");
}
void remove_regen(bool divine_ability)
@@ -1426,8 +1412,8 @@ void remove_regen(bool divine_ability)
void cast_regen(int pow, bool divine_ability)
{
- _increase_duration(DUR_REGENERATION, 5 + roll_dice(2, pow / 3 + 1), 100,
- "Your skin crawls.");
+ you.increase_duration(DUR_REGENERATION, 5 + roll_dice(2, pow / 3 + 1), 100,
+ "Your skin crawls.");
if (divine_ability)
{
@@ -1457,8 +1443,8 @@ void cast_swiftness(int power)
// [dshaligram] Removed the on-your-feet bit. Sounds odd when
// you're levitating, for instance.
- _increase_duration(DUR_SWIFTNESS, 20 + random2(power), 100,
- "You feel quick.");
+ you.increase_duration(DUR_SWIFTNESS, 20 + random2(power), 100,
+ "You feel quick.");
did_god_conduct(DID_HASTY, 8, true);
}
@@ -1494,20 +1480,20 @@ void cast_fly(int power)
void cast_insulation(int power)
{
- _increase_duration(DUR_INSULATION, 10 + random2(power), 100,
- "You feel insulated.");
+ you.increase_duration(DUR_INSULATION, 10 + random2(power), 100,
+ "You feel insulated.");
}
void cast_resist_poison(int power)
{
- _increase_duration(DUR_RESIST_POISON, 10 + random2(power), 100,
- "You feel resistant to poison.");
+ you.increase_duration(DUR_RESIST_POISON, 10 + random2(power), 100,
+ "You feel resistant to poison.");
}
void cast_teleport_control(int power)
{
- _increase_duration(DUR_CONTROL_TELEPORT, 10 + random2(power), 50,
- "You feel in control.");
+ you.increase_duration(DUR_CONTROL_TELEPORT, 10 + random2(power), 50,
+ "You feel in control.");
}
void cast_ring_of_flames(int power)
@@ -1518,9 +1504,9 @@ void cast_ring_of_flames(int power)
mpr("Your spell sizzles in the rain.");
return;
}
- _increase_duration(DUR_FIRE_SHIELD,
- 5 + (power / 10) + (random2(power) / 5), 50,
- "The air around you leaps into flame!");
+ you.increase_duration(DUR_FIRE_SHIELD,
+ 5 + (power / 10) + (random2(power) / 5), 50,
+ "The air around you leaps into flame!");
manage_fire_shield();
}
@@ -1530,7 +1516,8 @@ void cast_confusing_touch(int power)
<< (you.duration[DUR_CONFUSING_TOUCH] ? "brighter" : "red")
<< "." << std::endl;
- _increase_duration(DUR_CONFUSING_TOUCH, 5 + (random2(power) / 5), 50, NULL);
+ you.increase_duration(DUR_CONFUSING_TOUCH, 5 + (random2(power) / 5),
+ 50, NULL);
}
@@ -1552,7 +1539,8 @@ bool cast_sure_blade(int power)
else if (you.duration[DUR_SURE_BLADE] < 25)
mpr("Your bond becomes stronger.");
- _increase_duration(DUR_SURE_BLADE, 8 + (random2(power) / 10), 25, NULL);
+ you.increase_duration(DUR_SURE_BLADE, 8 + (random2(power) / 10),
+ 25, NULL);
success = true;
}
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc
index 649c516bf0..21e67164f8 100644
--- a/crawl-ref/source/spells2.cc
+++ b/crawl-ref/source/spells2.cc
@@ -366,12 +366,8 @@ bool brand_weapon(brand_type which_brand, int power)
else
mprf("%s flashes.", weapon.name(DESC_CAP_YOUR).c_str());
- const int dur_change = duration_affected + roll_dice(2, power);
-
- you.duration[DUR_WEAPON_BRAND] += dur_change * BASELINE_DELAY;
-
- if (you.duration[DUR_WEAPON_BRAND] > 50 * BASELINE_DELAY)
- you.duration[DUR_WEAPON_BRAND] = 50 * BASELINE_DELAY;
+ you.increase_duration(DUR_WEAPON_BRAND,
+ duration_affected + roll_dice(2, power), 50);
return (true);
}
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc
index 639e7dfa06..89bfa68c43 100644
--- a/crawl-ref/source/spells3.cc
+++ b/crawl-ref/source/spells3.cc
@@ -1353,12 +1353,7 @@ bool cast_death_channel(int pow, god_type god)
mpr("Malign forces permeate your being, awaiting release.");
- int addition = 15 + random2(1 + (pow / 3));
- addition *= BASELINE_DELAY;
- you.duration[DUR_DEATH_CHANNEL] += addition;
-
- if (you.duration[DUR_DEATH_CHANNEL] > 100 * BASELINE_DELAY)
- you.duration[DUR_DEATH_CHANNEL] = 100 * BASELINE_DELAY;
+ you.increase_duration(DUR_DEATH_CHANNEL, 15 + random2(1 + pow/3), 100);
if (god != GOD_NO_GOD)
you.attribute[ATTR_DIVINE_DEATH_CHANNEL] = static_cast<int>(god);
@@ -1396,14 +1391,15 @@ void you_teleport(void)
{
mpr("You feel strangely unstable.");
- you.duration[DUR_TELEPORT] = 3 + random2(3);
+ int teleport_delay = 3 + random2(3);
+
if (you.level_type == LEVEL_ABYSS && !one_chance_in(5))
{
mpr("You have a feeling this translocation may take a while to kick in...");
- you.duration[DUR_TELEPORT] += 5 + random2(10);
+ teleport_delay += 5 + random2(10);
}
- you.duration[DUR_TELEPORT] *= BASELINE_DELAY;
+ you.set_duration(DUR_TELEPORT, teleport_delay);
}
}
diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc
index 6ca84a2a82..47eda3c4ab 100644
--- a/crawl-ref/source/spells4.cc
+++ b/crawl-ref/source/spells4.cc
@@ -340,11 +340,7 @@ void cast_phase_shift(int pow)
else
mpr("Your feel the material plane grow further away.");
- you.duration[DUR_PHASE_SHIFT] += (5 + random2(pow)) * BASELINE_DELAY;
-
- if (you.duration[DUR_PHASE_SHIFT] > 30 * BASELINE_DELAY)
- you.duration[DUR_PHASE_SHIFT] = 30 * BASELINE_DELAY;
-
+ you.increase_duration(DUR_PHASE_SHIFT, 5 + random2(pow), 30);
you.redraw_evasion = true;
}
@@ -363,13 +359,8 @@ void cast_see_invisible(int pow)
autotoggle_autopickup(false);
}
- int duration = 10 + random2(2 + (pow / 2));
-
// No message if you already are under the spell.
- you.duration[DUR_SEE_INVISIBLE] += duration * BASELINE_DELAY;
-
- if (you.duration[DUR_SEE_INVISIBLE] > 100 * BASELINE_DELAY)
- you.duration[DUR_SEE_INVISIBLE] = 100 * BASELINE_DELAY;
+ you.increase_duration(DUR_SEE_INVISIBLE, 10 + random2(2 + pow/2), 100);
}
// The description idea was okay, but this spell just isn't that exciting.
@@ -613,12 +604,11 @@ void cast_ignite_poison(int pow)
you.weapon()->name(DESC_CAP_YOUR).c_str());
you.wield_change = true;
- int increase = (1 + you.duration[DUR_WEAPON_BRAND]/2)
- * BASELINE_DELAY;
- you.duration[DUR_WEAPON_BRAND] += increase;
- if (you.duration[DUR_WEAPON_BRAND] > 80 * BASELINE_DELAY)
- you.duration[DUR_WEAPON_BRAND] = 80 * BASELINE_DELAY;
+ int increase = 1 + you.duration[DUR_WEAPON_BRAND]
+ /(2 * BASELINE_DELAY);
+
+ you.increase_duration(DUR_WEAPON_BRAND, increase, 80);
}
}
@@ -760,12 +750,7 @@ void cast_silence(int pow)
you.attribute[ATTR_WAS_SILENCED] = 1;
- int value = 10 + random2avg( pow, 2 );
- value *= BASELINE_DELAY;
- you.duration[DUR_SILENCE] += value;
-
- if (you.duration[DUR_SILENCE] > 100 * BASELINE_DELAY)
- you.duration[DUR_SILENCE] = 100 * BASELINE_DELAY;
+ you.increase_duration(DUR_SILENCE, 10 + random2avg(pow,2), 100);
if (you.beheld())
{
@@ -1914,19 +1899,16 @@ void cast_condensation_shield(int pow)
if (you.duration[DUR_CONDENSATION_SHIELD] > 0)
{
mpr("The disc of vapour around you crackles some more.");
- int addition = (5 + roll_dice(2, 3)) * BASELINE_DELAY;
- you.duration[DUR_CONDENSATION_SHIELD] += addition;
+ you.increase_duration(DUR_CONDENSATION_SHIELD,
+ 5 + roll_dice(2,3), 30);
}
else
{
mpr("A crackling disc of dense vapour forms in the air!");
- int delay = (10 + roll_dice(2, pow / 5)) * BASELINE_DELAY;
- you.duration[DUR_CONDENSATION_SHIELD] = 10 + roll_dice(2, pow / 5);
+ you.increase_duration(DUR_CONDENSATION_SHIELD,
+ 10 + roll_dice(2, pow / 5), 30);
you.redraw_armour_class = true;
}
-
- if (you.duration[DUR_CONDENSATION_SHIELD] > 30 * BASELINE_DELAY)
- you.duration[DUR_CONDENSATION_SHIELD] = 30 * BASELINE_DELAY;
}
}
@@ -2079,11 +2061,7 @@ void cast_stoneskin(int pow)
you.redraw_armour_class = true;
}
- int addition = (10 + random2(pow) + random2(pow)) * BASELINE_DELAY;
- you.duration[DUR_STONESKIN] += addition;
-
- if (you.duration[DUR_STONESKIN] > 50 * BASELINE_DELAY)
- you.duration[DUR_STONESKIN] = 50 * BASELINE_DELAY;
+ you.increase_duration(DUR_STONESKIN, 10 + random2(pow) + random2(pow), 50);
}
bool do_slow_monster(monsters* mon, kill_category whose_kill)
diff --git a/crawl-ref/source/transfor.cc b/crawl-ref/source/transfor.cc
index ae5f5e1221..c81574ef0d 100644
--- a/crawl-ref/source/transfor.cc
+++ b/crawl-ref/source/transfor.cc
@@ -559,10 +559,7 @@ bool transform(int pow, transformation_type which_trans, bool force,
mpr("You feel you'll be a pig longer.");
else
mpr("You extend your transformation's duration.");
- you.duration[DUR_TRANSFORMATION] += random2(pow) * BASELINE_DELAY;
-
- if (you.duration[DUR_TRANSFORMATION] > 100 * BASELINE_DELAY)
- you.duration[DUR_TRANSFORMATION] = 100 * BASELINE_DELAY;
+ you.increase_duration(DUR_TRANSFORMATION, random2(pow), 100);
return (true);
}
@@ -756,7 +753,7 @@ bool transform(int pow, transformation_type which_trans, bool force,
// Update your status.
you.attribute[ATTR_TRANSFORMATION] = which_trans;
- you.duration[DUR_TRANSFORMATION] = dur * BASELINE_DELAY;
+ you.set_duration(DUR_TRANSFORMATION, dur);
you.symbol = symbol;
you.colour = colour;