summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarshan Shaligram <dshaligram@users.sourceforge.net>2010-01-11 16:13:36 +0530
committerDarshan Shaligram <dshaligram@users.sourceforge.net>2010-01-11 16:13:36 +0530
commit89b4e230ad3bdc806ae058722c70441d49f5d9fe (patch)
treefef3ab5111d75ce5869881542267c9f848e1fe33
parent5871154a2e85ccd38874e88dea22083ced372141 (diff)
downloadcrawl-ref-89b4e230ad3bdc806ae058722c70441d49f5d9fe.tar.gz
crawl-ref-89b4e230ad3bdc806ae058722c70441d49f5d9fe.zip
Amulet of stasis, first cut.
Amulets of stasis blocks: - Teleport self - Blink in all forms - Slowing - Hasting - Paralysis - Petrify - Berserker rage The amulet auto-ids the first time it triggers. The amulet does not affect existing conditions (such as an existing Haste spell or an existing post-berserk Slow).
-rw-r--r--crawl-ref/source/artefact.cc4
-rw-r--r--crawl-ref/source/dat/descript/items.txt9
-rw-r--r--crawl-ref/source/it_use2.cc5
-rw-r--r--crawl-ref/source/item_use.cc43
-rw-r--r--crawl-ref/source/item_use.h5
-rw-r--r--crawl-ref/source/misc.cc9
-rw-r--r--crawl-ref/source/player.cc38
-rw-r--r--crawl-ref/source/player.h2
-rw-r--r--crawl-ref/source/spells1.cc5
-rw-r--r--crawl-ref/source/spells3.cc7
-rw-r--r--crawl-ref/source/xom.cc2
11 files changed, 118 insertions, 11 deletions
diff --git a/crawl-ref/source/artefact.cc b/crawl-ref/source/artefact.cc
index e0bbedf6d1..72288ed158 100644
--- a/crawl-ref/source/artefact.cc
+++ b/crawl-ref/source/artefact.cc
@@ -1809,6 +1809,10 @@ static bool _randart_is_redundant( const item_def &item,
case AMU_INACCURACY:
provides = ARTP_ACCURACY;
break;
+
+ case AMU_STASIS:
+ provides = ARTP_PREVENT_TELEPORTATION;
+ break;
}
if (provides == ARTP_NUM_PROPERTIES)
diff --git a/crawl-ref/source/dat/descript/items.txt b/crawl-ref/source/dat/descript/items.txt
index b0211fad30..eda55ca396 100644
--- a/crawl-ref/source/dat/descript/items.txt
+++ b/crawl-ref/source/dat/descript/items.txt
@@ -71,6 +71,15 @@ wearer. This divine attention makes it easier to please your god, but
your god is also less likely to forgive your transgressions, and the
amulet will drain some of your divine favour when removed.
%%%%
+amulet of stasis
+
+An amulet meticulously constructed with magical wards to block magical
+and physiological effects that would otherwise teleport, slow, haste,
+or paralyse its wearer.
+
+While the amulet is effective against most translocular magic, plane
+shifts such as banishment are beyond its ability to block.
+%%%%
ankus
What mahouts steer their elephants with. It basically resembles a
diff --git a/crawl-ref/source/it_use2.cc b/crawl-ref/source/it_use2.cc
index 49371f2f80..1221daad12 100644
--- a/crawl-ref/source/it_use2.cc
+++ b/crawl-ref/source/it_use2.cc
@@ -61,7 +61,6 @@ bool potion_effect(potion_type pot_eff, int pow, bool drank_it, bool was_known)
switch (pot_eff)
{
case POT_HEALING:
-
inc_hp((5 + random2(7)) / factor, false);
mpr("You feel better.");
@@ -138,8 +137,8 @@ bool potion_effect(potion_type pot_eff, int pow, bool drank_it, bool was_known)
break;
case POT_SPEED:
- haste_player((40 + random2(pow)) / factor);
- did_god_conduct(DID_HASTY, 10, was_known);
+ if (haste_player((40 + random2(pow)) / factor))
+ did_god_conduct(DID_HASTY, 10, was_known);
break;
case POT_MIGHT:
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index ea2dd24dc7..542ed56a20 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -5856,6 +5856,49 @@ bool wearing_slot(int inv_slot)
return (false);
}
+bool item_blocks_teleport(bool permit_id)
+{
+ return (scan_artefacts(ARTP_PREVENT_TELEPORTATION)
+ || stasis_blocks_effect(permit_id, NULL));
+}
+
+bool stasis_blocks_effect(bool identify,
+ const char *msg, int noise,
+ const char *silenced_msg)
+{
+ if (wearing_amulet(AMU_STASIS))
+ {
+ item_def *amulet = you.slot_item(EQ_AMULET);
+
+ if (msg)
+ {
+ const std::string name(amulet? amulet->name(DESC_CAP_YOUR) :
+ "Something");
+ const std::string message =
+ make_stringf(msg, name.c_str());
+
+ if (noise)
+ {
+ if (!noisy(noise, you.pos(), message.c_str())
+ && silenced_msg)
+ {
+ mprf(silenced_msg, name.c_str());
+ }
+ }
+ else
+ {
+ mpr(message.c_str());
+ }
+ }
+
+ // In all cases, the amulet auto-ids if requested.
+ if (amulet && identify)
+ set_ident_type(*amulet, ID_KNOWN_TYPE);
+ return (true);
+ }
+ return (false);
+}
+
#ifdef USE_TILE
// Interactive menu for item drop/use.
diff --git a/crawl-ref/source/item_use.h b/crawl-ref/source/item_use.h
index bba83aa3b4..d264d0fdf6 100644
--- a/crawl-ref/source/item_use.h
+++ b/crawl-ref/source/item_use.h
@@ -116,6 +116,11 @@ void warn_shield_penalties();
bool wearing_slot(int inv_slot);
+bool item_blocks_teleport(bool permit_id);
+bool stasis_blocks_effect(bool identify,
+ const char *msg, int noise = 0,
+ const char *silencedmsg = NULL);
+
#ifdef USE_TILE
void tile_item_use_floor(int idx);
void tile_item_pickup(int idx);
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index f2e27c5174..577221fff8 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -48,6 +48,7 @@
#include "itemname.h"
#include "itemprop.h"
#include "items.h"
+#include "item_use.h"
#include "lev-pand.h"
#include "macro.h"
#include "makeitem.h"
@@ -2698,6 +2699,14 @@ bool go_berserk(bool intentional, bool potion)
if (!you.can_go_berserk(intentional, potion))
return (false);
+ if (stasis_blocks_effect(true,
+ "%s thrums violently and saps your rage.",
+ 3,
+ "%s vibrates violently and saps your rage."))
+ {
+ return (false);
+ }
+
if (Tutorial.tutorial_left)
Tutorial.tut_berserk_counter++;
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index a8c990a854..7163906662 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -35,6 +35,7 @@
#include "itemname.h"
#include "itemprop.h"
#include "items.h"
+#include "item_use.h"
#include "it_use2.h"
#include "kills.h"
#include "macro.h"
@@ -4981,6 +4982,9 @@ bool slow_player(int turns)
if (turns <= 0)
return (false);
+ if (stasis_blocks_effect(true, "%s rumbles.", 20, "%s rumbles."))
+ return (false);
+
// Doubling these values because moving while slowed takes twice the
// usual delay.
turns *= 2;
@@ -5019,12 +5023,18 @@ void dec_slow_player(int delay)
}
}
-void haste_player(int turns)
+bool haste_player(int turns)
{
ASSERT(!crawl_state.arena);
if (turns <= 0)
- return;
+ return (false);
+
+ if (stasis_blocks_effect(true, "%s emits a piercing whistle.", 20,
+ "%s makes your neck tingle."))
+ {
+ return (false);
+ }
// Cutting the nominal turns in half since hasted actions take half the
// usual delay.
@@ -5043,6 +5053,8 @@ void haste_player(int turns)
you.increase_duration(DUR_HASTE, turns, threshold);
did_god_conduct(DID_STIMULANTS, 4 + random2(4));
+
+ return (true);
}
void dec_haste_player(int delay)
@@ -6016,6 +6028,21 @@ bool player::can_go_berserk(bool intentional, bool potion) const
return (false);
}
+ // Stasis, but only for identified amulets; unided amulets will
+ // trigger when the player attempts to activate berserk,
+ // auto-iding at that point, but also killing the berserk and
+ // wasting a turn.
+ if (wearing_amulet(AMU_STASIS, false))
+ {
+ if (verbose)
+ {
+ const item_def *amulet = you.slot_item(EQ_AMULET);
+ mprf("You cannot go berserk with %s on.",
+ amulet? amulet->name(DESC_NOCAP_YOUR).c_str() : "your amulet");
+ }
+ return (false);
+ }
+
if (!intentional && !potion && player_mental_clarity(true))
{
if (verbose)
@@ -6772,6 +6799,10 @@ void player::paralyse(actor *who, int str)
{
ASSERT(!crawl_state.arena);
+ // The shock is too mild to do damage.
+ if (stasis_blocks_effect(true, "%s gives you a mild electric shock."))
+ return;
+
int &paralysis(duration[DUR_PARALYSIS]);
mprf("You %s the ability to move!",
@@ -6789,6 +6820,9 @@ void player::petrify(actor *who, int str)
{
ASSERT(!crawl_state.arena);
+ if (stasis_blocks_effect(true, "%s gives you a mild electric shock."))
+ return;
+
str *= BASELINE_DELAY;
int &petrif(duration[DUR_PETRIFIED]);
diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h
index ca1bb06bc2..81b0fe44d4 100644
--- a/crawl-ref/source/player.h
+++ b/crawl-ref/source/player.h
@@ -771,7 +771,7 @@ void dec_napalm_player(int delay);
bool slow_player(int turns);
void dec_slow_player(int delay);
-void haste_player(int turns);
+bool haste_player(int turns);
void dec_haste_player(int delay);
void dec_disease_player(int delay);
diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc
index 8ece64285d..8fa30ade07 100644
--- a/crawl-ref/source/spells1.cc
+++ b/crawl-ref/source/spells1.cc
@@ -31,6 +31,7 @@
#include "it_use2.h"
#include "itemname.h"
#include "itemprop.h"
+#include "item_use.h"
#include "los.h"
#include "message.h"
#include "misc.h"
@@ -83,7 +84,7 @@ int blink(int pow, bool high_level_controlled_blink, bool wizard_blink)
}
// yes, there is a logic to this ordering {dlb}:
- if (scan_artefacts(ARTP_PREVENT_TELEPORTATION) && !wizard_blink)
+ if (item_blocks_teleport(true) && !wizard_blink)
mpr("You feel a weird sense of stasis.");
else if (you.level_type == LEVEL_ABYSS
&& _abyss_blocks_teleport(high_level_controlled_blink)
@@ -199,7 +200,7 @@ void random_blink(bool allow_partial_control, bool override_abyss)
bool success = false;
coord_def target;
- if (scan_artefacts(ARTP_PREVENT_TELEPORTATION))
+ if (item_blocks_teleport(true))
mpr("You feel a weird sense of stasis.");
else if (you.level_type == LEVEL_ABYSS
&& !override_abyss && !one_chance_in(3))
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc
index 1a30607199..a885e9eb42 100644
--- a/crawl-ref/source/spells3.cc
+++ b/crawl-ref/source/spells3.cc
@@ -34,6 +34,7 @@
#include "itemname.h"
#include "itemprop.h"
#include "items.h"
+#include "item_use.h"
#include "message.h"
#include "misc.h"
#include "mon-behv.h"
@@ -1383,8 +1384,10 @@ bool allow_control_teleport(bool quiet)
void you_teleport(void)
{
- if (scan_artefacts(ARTP_PREVENT_TELEPORTATION))
+ if (item_blocks_teleport(true))
+ {
mpr("You feel a weird sense of stasis.");
+ }
else if (you.duration[DUR_TELEPORT])
{
mpr("You feel strangely stable.");
@@ -1493,7 +1496,7 @@ static bool _teleport_player(bool allow_control, bool new_abyss_area, bool wizar
if (wizard_tele)
is_controlled = true;
- if (scan_artefacts(ARTP_PREVENT_TELEPORTATION) && !wizard_tele)
+ if (item_blocks_teleport(true) && !wizard_tele)
{
mpr("You feel a strange sense of stasis.");
return (false);
diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc
index 323cb9c13e..1ea7e3c76f 100644
--- a/crawl-ref/source/xom.cc
+++ b/crawl-ref/source/xom.cc
@@ -469,7 +469,7 @@ static bool _teleportation_check(const spell_type spell = SPELL_TELEPORT_SELF)
{
case SPELL_BLINK:
case SPELL_TELEPORT_SELF:
- return (!scan_artefacts(ARTP_PREVENT_TELEPORTATION));
+ return (!item_blocks_teleport(false));
default:
return (true);
}