summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-23 09:53:35 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-23 09:53:35 +0000
commitf99e05e0fe9978367c71ed097e18cbac86998c81 (patch)
tree49f6374d513f5344d33ec220c10a80730becc2a2 /crawl-ref
parent639bda974405b152b7655657a8a4af441888d74c (diff)
downloadcrawl-ref-f99e05e0fe9978367c71ed097e18cbac86998c81.tar.gz
crawl-ref-f99e05e0fe9978367c71ed097e18cbac86998c81.zip
Some more card implementations (resists in Helm, demon summoning.)
More type-safety. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1624 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/acr.cc42
-rw-r--r--crawl-ref/source/decks.cc97
-rw-r--r--crawl-ref/source/defines.h2
-rw-r--r--crawl-ref/source/enum.h29
-rw-r--r--crawl-ref/source/externs.h6
-rw-r--r--crawl-ref/source/it_use3.cc8
-rw-r--r--crawl-ref/source/monplace.cc12
-rw-r--r--crawl-ref/source/monplace.h8
-rw-r--r--crawl-ref/source/monstuff.cc2
-rw-r--r--crawl-ref/source/player.cc10
-rw-r--r--crawl-ref/source/spells1.cc92
-rw-r--r--crawl-ref/source/spells1.h2
-rw-r--r--crawl-ref/source/spells2.cc16
-rw-r--r--crawl-ref/source/spells2.h9
-rw-r--r--crawl-ref/source/spells4.cc8
-rw-r--r--crawl-ref/source/spl-cast.cc24
-rw-r--r--crawl-ref/source/tags.cc6
17 files changed, 216 insertions, 157 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index 9f01b74414..7c8e4a1276 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -1886,6 +1886,38 @@ static void decrement_durations()
you.duration[DUR_CONTROL_TELEPORT] = 0;
}
+ if (you.duration[DUR_RESIST_FIRE] > 1)
+ {
+ you.duration[DUR_RESIST_FIRE]--;
+ if (you.duration[DUR_RESIST_FIRE] == 6)
+ {
+ mpr("Your fire resistance is about to expire.", MSGCH_DURATION);
+ if (coinflip())
+ you.duration[DUR_RESIST_FIRE]--;
+ }
+ }
+ else if (you.duration[DUR_RESIST_FIRE] == 1)
+ {
+ mpr("Your fire resistance expires.", MSGCH_DURATION);
+ you.duration[DUR_RESIST_FIRE] = 0;
+ }
+
+ if (you.duration[DUR_RESIST_COLD] > 1)
+ {
+ you.duration[DUR_RESIST_COLD]--;
+ if (you.duration[DUR_RESIST_COLD] == 6)
+ {
+ mpr("Your cold resistance is about to expire.", MSGCH_DURATION);
+ if (coinflip())
+ you.duration[DUR_RESIST_COLD]--;
+ }
+ }
+ else if (you.duration[DUR_RESIST_COLD] == 1)
+ {
+ mpr("Your cold resistance expires.", MSGCH_DURATION);
+ you.duration[DUR_RESIST_COLD] = 0;
+ }
+
if (you.duration[DUR_RESIST_POISON] > 1)
{
you.duration[DUR_RESIST_POISON]--;
@@ -1902,6 +1934,16 @@ static void decrement_durations()
you.duration[DUR_RESIST_POISON] = 0;
}
+ if (you.duration[DUR_SLAYING] > 1)
+ {
+ you.duration[DUR_SLAYING]--;
+ }
+ else if (you.duration[DUR_SLAYING] == 1)
+ {
+ mpr("You feel less lethal.", MSGCH_DURATION);
+ you.duration[DUR_SLAYING] = 0;
+ }
+
if (you.duration[DUR_DEATH_CHANNEL] > 1)
{
you.duration[DUR_DEATH_CHANNEL]--;
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc
index 5fc7aac932..d01e518c28 100644
--- a/crawl-ref/source/decks.cc
+++ b/crawl-ref/source/decks.cc
@@ -82,7 +82,7 @@ DEFVEC(deck_of_summoning);
static card_type a_deck_of_wonders[] = {
CARD_POTION, CARD_FOCUS, CARD_SHUFFLE,
- CARD_EXPERIENCE, CARD_WILD_MAGIC, CARD_GENETIC_ENGINEER
+ CARD_EXPERIENCE, CARD_WILD_MAGIC, CARD_HELIX
};
DEFVEC(deck_of_wonders);
@@ -132,7 +132,7 @@ const char* card_name(card_type card)
case CARD_FOCUS: return "Focus";
case CARD_SHUFFLE: return "Shuffle";
case CARD_EXPERIENCE: return "Experience";
- case CARD_GENETIC_ENGINEER: return "Genetics";
+ case CARD_HELIX: return "the Helix";
case CARD_DOWSING: return "Dowsing";
case CARD_TROWEL: return "the Trowel";
case CARD_MINEFIELD: return "the Minefield";
@@ -577,6 +577,32 @@ static void warpwright_card(int power, deck_rarity_type rarity)
}
}
+static void minefield_card(int power, deck_rarity_type rarity)
+{
+ const int power_level = get_power_level(power, rarity);
+ const int radius = power_level * 2 + 2;
+ for ( int dx = -radius; dx <= radius; ++dx )
+ {
+ for ( int dy = -radius; dy <= radius; ++dy )
+ {
+ if ( dx * dx + dy*dy > radius*radius + 1 )
+ continue;
+ if ( dx == 0 && dy == 0 )
+ continue;
+
+ const int rx = you.x_pos + dx;
+ const int ry = you.y_pos + dy;
+ if ( !in_bounds(rx, ry) )
+ continue;
+ if ( grd[rx][ry] == DNGN_FLOOR && trap_at_xy(rx,ry) == -1 &&
+ one_chance_in(4 - power_level) )
+ {
+ place_specific_trap(rx, ry, TRAP_RANDOM);
+ }
+ }
+ }
+}
+
static void damaging_card( card_type card, int power, deck_rarity_type rarity )
{
dist target;
@@ -629,9 +655,7 @@ static void battle_lust_card(int power, deck_rarity_type rarity)
{
const int power_level = get_power_level(power, rarity);
if ( power_level >= 2 )
- {
- // temporary ring of slaying effect XXX
- }
+ you.duration[DUR_SLAYING] = random2(power/6);
else if ( power_level == 1 )
go_berserk(false);
else if ( power_level == 0 )
@@ -644,8 +668,10 @@ static void metamorphosis_card(int power, deck_rarity_type rarity)
transformation_type trans;
if ( power_level >= 2 )
trans = (coinflip() ? TRAN_DRAGON : TRAN_LICH);
- else
+ else if ( power_level == 1 )
trans = (coinflip() ? TRAN_STATUE : TRAN_BLADE_HANDS);
+ else
+ trans = (coinflip() ? TRAN_SPIDER : TRAN_ICE_BEAST);
transform(random2(power/4), trans);
}
@@ -681,8 +707,33 @@ static void helm_card(int power, deck_rarity_type rarity)
cast_forescry( random2(power/4) );
if ( do_stoneskin )
cast_stoneskin( random2(power/4) );
+ if ( num_resists )
+ {
+ const duration_type possible_resists[4] = {
+ DUR_RESIST_POISON, DUR_INSULATION,
+ DUR_RESIST_FIRE, DUR_RESIST_COLD
+ };
+ const char* resist_names[4] = {
+ "poison", "electricity", "fire", "cold"
+ };
+ for ( int i = 0; i < 4 && num_resists; ++i )
+ {
+ // if there are n left, of which we need to choose
+ // k, we have chance k/n of selecting the next item.
+ if ( random2(4-i) < num_resists )
+ {
+ // Add a temporary resist
+ you.duration[possible_resists[i]] += random2(power/7);
+ msg::stream << "You feel resistant to " << resist_names[i]
+ << '.' << std::endl;
+ --num_resists;
+ if ( num_resists == 0 )
+ break;
+ }
+ }
+ }
- // XXX XXX FIXME handle do_shield, do_resist
+ // XXX XXX FIXME handle do_shield
}
// Do one of: vorpalise, sure blade, dancing weapon
@@ -776,7 +827,7 @@ static void shuffle_card(int power, deck_rarity_type rarity)
return;
}
-static void genetic_engineer_card(int power, deck_rarity_type rarity)
+static void helix_card(int power, deck_rarity_type rarity)
{
mutation_type bad_mutations[] = {
MUT_FAST_METABOLISM, MUT_WEAK, MUT_DOPEY, MUT_CLUMSY,
@@ -823,12 +874,6 @@ static void trowel_card(int power, deck_rarity_type rarity)
return;
}
-static void minefield_card(int power, deck_rarity_type rarity)
-{
- // not implemented yet
- return;
-}
-
static void genie_card(int power, deck_rarity_type rarity)
{
if ( coinflip() )
@@ -867,6 +912,19 @@ static void curse_card(int power, deck_rarity_type rarity)
}
}
+static void summon_demon_card(int power, deck_rarity_type rarity)
+{
+ const int power_level = get_power_level(power, rarity);
+ demon_class_type dct;
+ if ( power_level >= 2 )
+ dct = DEMON_GREATER;
+ else if ( power_level == 1 )
+ dct = DEMON_COMMON;
+ else
+ dct = DEMON_LESSER;
+ create_monster( dct, power/50, BEH_FRIENDLY, you.x_pos, you.y_pos,
+ MHITYOU, 250 );
+}
static int card_power(deck_rarity_type rarity)
{
@@ -918,7 +976,7 @@ void card_effect(card_type which_card, deck_rarity_type rarity)
case CARD_FOCUS: focus_card(power, rarity); break;
case CARD_SHUFFLE: shuffle_card(power, rarity); break;
case CARD_EXPERIENCE: potion_effect(POT_EXPERIENCE, power/4); break;
- case CARD_GENETIC_ENGINEER: genetic_engineer_card(power, rarity); break;
+ case CARD_HELIX: helix_card(power, rarity); break;
case CARD_DOWSING: dowsing_card(power, rarity); break;
case CARD_TROWEL: trowel_card(power, rarity); break;
case CARD_MINEFIELD: minefield_card(power, rarity); break;
@@ -928,6 +986,7 @@ void card_effect(card_type which_card, deck_rarity_type rarity)
case CARD_TOMB: entomb(); break;
case CARD_WRAITH: drain_exp(); lose_level(); break;
case CARD_WRATH: godly_wrath(); break;
+ case CARD_SUMMON_DEMON: summon_demon_card(power, rarity); break;
case CARD_SPADE:
mpr("Sorry, this card is not yet available.");
@@ -954,16 +1013,8 @@ void card_effect(card_type which_card, deck_rarity_type rarity)
break;
case CARD_SUMMON_ANIMAL: break;
- case CARD_SUMMON_DEMON: break;
case CARD_SUMMON_WEAPON: break;
case CARD_SUMMON_ANY: break;
-
-
- /* if (create_monster( summon_any_demon( DEMON_LESSER ), 6,
- BEH_HOSTILE, you.x_pos, you.y_pos,
- MHITYOU, 250 ) != -1)
- */
-
case CARD_XOM: xom_acts(5 + random2(power/10)); break;
case CARD_FAMINE:
diff --git a/crawl-ref/source/defines.h b/crawl-ref/source/defines.h
index 3690f49573..a3e2b3b63f 100644
--- a/crawl-ref/source/defines.h
+++ b/crawl-ref/source/defines.h
@@ -118,7 +118,7 @@
#define VIEW_MIN_HEIGHT 17
// max traps per level
-#define MAX_TRAPS 30
+#define MAX_TRAPS 100
// max shops per level
#define MAX_SHOPS 5
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h
index 9003eb173e..618fecb07b 100644
--- a/crawl-ref/source/enum.h
+++ b/crawl-ref/source/enum.h
@@ -514,7 +514,7 @@ enum card_type
CARD_EXPERIENCE,
CARD_WILD_MAGIC,
- CARD_GENETIC_ENGINEER, // remove one *bad* mutation
+ CARD_HELIX, // remove one *bad* mutation
CARD_MAP, // magic mapping
CARD_DOWSING, // detect SD/traps/items/monsters
@@ -1147,32 +1147,35 @@ enum dungeon_feature_type
enum duration_type
{
- DUR_LIQUID_FLAMES, // 0
+ DUR_LIQUID_FLAMES, // 0
DUR_ICY_ARMOUR,
DUR_REPEL_MISSILES,
DUR_PRAYER,
DUR_REGENERATION,
- DUR_SWIFTNESS, // 5
- DUR_INSULATION,
+ DUR_SWIFTNESS, // 5
DUR_STONEMAIL,
DUR_CONTROLLED_FLIGHT,
DUR_TELEPORT,
- DUR_CONTROL_TELEPORT, // 10
- DUR_RESIST_POISON,
- DUR_BREATH_WEAPON,
+ DUR_CONTROL_TELEPORT,
+ DUR_BREATH_WEAPON, // 10
DUR_TRANSFORMATION,
DUR_DEATH_CHANNEL,
- DUR_DEFLECT_MISSILES, // 15
+ DUR_DEFLECT_MISSILES,
DUR_FORESCRY,
- DUR_SEE_INVISIBLE,
+ DUR_SEE_INVISIBLE, // 15
DUR_WEAPON_BRAND, // general "branding" spell counter
DUR_SILENCE,
- DUR_GLAMOUR, // 20
+ DUR_GLAMOUR,
DUR_CONDENSATION_SHIELD,
- DUR_STONESKIN,
+ DUR_STONESKIN, // 20
DUR_REPEL_UNDEAD,
DUR_GOURMAND,
- DUR_BARGAIN, // 25
+ DUR_BARGAIN,
+ DUR_INSULATION,
+ DUR_RESIST_POISON, // 25
+ DUR_RESIST_FIRE,
+ DUR_RESIST_COLD,
+ DUR_SLAYING,
NUM_DURATIONS = 30 // must be at least 30
};
@@ -1180,7 +1183,7 @@ enum duration_type
// MUST match the order in initfile.cc or breakage results.
enum element_type
{
- EC_FIRE = 32, // fiery colours (must be first and > higest colour)
+ EC_FIRE = 32, // fiery colours (must be first and > highest colour)
EC_ICE, // icy colours
EC_EARTH, // earthy colours
EC_ELECTRICITY, // electrical side of air
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index 303bef9abc..25c0f33397 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -619,7 +619,7 @@ public:
char special_wield;
char deaths_door;
- char fire_shield;
+ int fire_shield;
double elapsed_time; // total amount of elapsed time in the game
@@ -994,8 +994,8 @@ public:
unsigned char target_y;
FixedVector<int, 8> inv;
monster_spells spells;
- unsigned char attitude; // from MONS_ATTITUDE
- unsigned int behaviour;
+ mon_attitude_type attitude;
+ beh_type behaviour;
unsigned int foe;
mon_enchant_list enchantments;
unsigned long flags; // bitfield of boolean flags
diff --git a/crawl-ref/source/it_use3.cc b/crawl-ref/source/it_use3.cc
index d96d9c66b1..456e05019f 100644
--- a/crawl-ref/source/it_use3.cc
+++ b/crawl-ref/source/it_use3.cc
@@ -674,7 +674,7 @@ bool evoke_wielded( void )
static bool efreet_flask(void)
{
- const int behaviour = ((you.skills[SK_EVOCATIONS] > random2(20))
+ const beh_type behaviour = ((you.skills[SK_EVOCATIONS] > random2(20))
? BEH_FRIENDLY : BEH_HOSTILE);
mpr("You open the flask...");
@@ -943,7 +943,7 @@ void skill_manual(char sc_read_2)
xom_is_stimulated(14);
} // end skill_manual()
-static bool box_of_beasts(void)
+static bool box_of_beasts()
{
int beasty = MONS_PROGRAM_BUG; // error trapping {dlb}
int temp_rand = 0; // probability determination {dlb}
@@ -968,8 +968,8 @@ static bool box_of_beasts(void)
(temp_rand == 9) ? MONS_BROWN_SNAKE
: MONS_GIANT_LIZARD);
- int beh = (one_chance_in(you.skills[SK_EVOCATIONS] + 5) ? BEH_HOSTILE
- : BEH_FRIENDLY);
+ beh_type beh = (one_chance_in(you.skills[SK_EVOCATIONS] + 5)
+ ? BEH_HOSTILE : BEH_FRIENDLY);
if (create_monster( beasty, 2 + random2(4), beh,
you.x_pos, you.y_pos, MHITYOU, 250 ) != -1)
diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc
index 955e7776c4..35149b333a 100644
--- a/crawl-ref/source/monplace.cc
+++ b/crawl-ref/source/monplace.cc
@@ -38,7 +38,7 @@
static int band_member(band_type band, int power);
static band_type choose_band( int mon_type, int power, int &band_size );
-static int place_monster_aux(int mon_type, char behaviour, int target,
+static int place_monster_aux(int mon_type, beh_type behaviour, int target,
int px, int py, int power, int extra, bool first_band_member,
int dur = 0);
@@ -141,7 +141,7 @@ static bool need_moderate_ood(int lev_mons)
&& one_chance_in(50));
}
-bool place_monster(int &id, int mon_type, int power, char behaviour,
+bool place_monster(int &id, int mon_type, int power, beh_type behaviour,
int target, bool summoned, int px, int py, bool allow_bands,
proximity_type proximity, int extra, int dur,
const dgn_region_list &forbidden)
@@ -445,7 +445,7 @@ bool place_monster(int &id, int mon_type, int power, char behaviour,
return (true);
}
-static int place_monster_aux( int mon_type, char behaviour, int target,
+static int place_monster_aux( int mon_type, beh_type behaviour, int target,
int px, int py, int power, int extra,
bool first_band_member, int dur )
{
@@ -1165,7 +1165,7 @@ static int ood_limit() {
return Options.ood_interesting;
}
-void mark_interesting_monst(struct monsters* monster, char behaviour)
+void mark_interesting_monst(struct monsters* monster, beh_type behaviour)
{
bool interesting = false;
@@ -1202,7 +1202,7 @@ void mark_interesting_monst(struct monsters* monster, char behaviour)
// PUBLIC FUNCTION -- mons_place().
-int mons_place( int mon_type, char behaviour, int target, bool summoned,
+int mons_place( int mon_type, beh_type behaviour, int target, bool summoned,
int px, int py, int level_type, proximity_type proximity,
int extra, int dur, bool permit_bands )
{
@@ -1351,7 +1351,7 @@ bool player_angers_monster(monsters *creation)
return (false);
}
-int create_monster( int cls, int dur, int beha, int cr_x, int cr_y,
+int create_monster( int cls, int dur, beh_type beha, int cr_x, int cr_y,
int hitting, int zsec, bool permit_bands,
bool force_place, bool force_behaviour )
{
diff --git a/crawl-ref/source/monplace.h b/crawl-ref/source/monplace.h
index 786ce7ac8b..04eff7f9db 100644
--- a/crawl-ref/source/monplace.h
+++ b/crawl-ref/source/monplace.h
@@ -37,7 +37,7 @@
* 2 = don't place the monster near the player
* 3 = place the monster near stairs (regardless of player pos)
* *********************************************************************** */
-int mons_place( int mon_type, char behaviour, int target, bool summoned,
+int mons_place( int mon_type, beh_type behaviour, int target, bool summoned,
int px, int py, int level_type = LEVEL_DUNGEON,
proximity_type proximity = PROX_ANYWHERE, int extra = 250,
int dur = 0, bool permit_bands = false );
@@ -48,7 +48,7 @@ int mons_place( int mon_type, char behaviour, int target, bool summoned,
* items - monstuff - mstuff2 - religion - spell - spells -
* spells2 - spells3 - spells4
* *********************************************************************** */
-int create_monster( int cls, int dur, int beha, int cr_x, int cr_y,
+int create_monster( int cls, int dur, beh_type beha, int cr_x, int cr_y,
int hitting, int zsec, bool permit_bands = false,
bool force_place = false, bool force_behaviour = false );
@@ -78,7 +78,7 @@ int summon_any_demon( demon_class_type demon_class );
* mons_place(). If you need to put a monster somewhere, use mons_place().
* Summoned creatures can be created with create_monster().
* *********************************************************************** */
-bool place_monster( int &id, int mon_type, int power, char behaviour,
+bool place_monster( int &id, int mon_type, int power, beh_type behaviour,
int target, bool summoned, int px, int py, bool allow_bands,
proximity_type proximity = PROX_ANYWHERE, int extra = 250,
int dur = 0,
@@ -90,7 +90,7 @@ monster_type rand_dragon( dragon_class_type type );
* called from: monplace monstuff
* *********************************************************************** */
void mark_interesting_monst(struct monsters* monster,
- char behaviour = BEH_SLEEP);
+ beh_type behaviour = BEH_SLEEP);
bool grid_compatible(int grid_wanted, int actual_grid, bool generation = false);
bool monster_habitable_grid(int monster_class, int actual_grid,
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index c7522ccf0a..cec3a9c299 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -1626,7 +1626,7 @@ static void handle_behaviour(monsters *mon)
}
// track changes to state; attitude never changes here.
- unsigned int new_beh = mon->behaviour;
+ beh_type new_beh = mon->behaviour;
unsigned int new_foe = mon->foe;
// take care of monster state changes
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 676a064cbb..940c0cc90b 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -887,6 +887,10 @@ int player_res_fire(bool calc_unid)
if (you.species == SP_MUMMY)
rf--;
+ // spells:
+ if (you.duration[DUR_RESIST_FIRE] > 0)
+ rf++;
+
// mutations:
rf += you.mutation[MUT_HEAT_RESISTANCE];
@@ -944,6 +948,10 @@ int player_res_cold(bool calc_unid)
// randart weapons:
rc += scan_randarts(RAP_COLD, calc_unid);
+ // spells:
+ if (you.duration[DUR_RESIST_COLD] > 0)
+ rc++;
+
// mutations:
rc += you.mutation[MUT_COLD_RESISTANCE];
@@ -3694,6 +3702,8 @@ int slaying_bonus(char which_affected)
ret += scan_randarts(RAP_DAMAGE);
}
+ ret += std::min(you.duration[DUR_SLAYING] / 13, 6);
+
return (ret);
} // end slaying_bonus()
diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc
index 536260e79a..62412a9ce7 100644
--- a/crawl-ref/source/spells1.cc
+++ b/crawl-ref/source/spells1.cc
@@ -688,83 +688,31 @@ void abjuration(int pow)
// that's why we reduce levitation to 2, so that the player has a chance
// to stop insta-death... sure the others could lead to death, but that's
// not as direct as falling into deep water) -- bwr
-void antimagic( void )
+void antimagic()
{
- if (you.haste)
- you.haste = 1;
-
- if (you.slow)
- you.slow = 1;
-
- if (you.paralysis)
- you.paralysis = 1;
-
- if (you.conf)
- you.conf = 1;
-
- if (you.might)
- you.might = 1;
-
+ int* direct_list[] = {
+ &you.haste, &you.slow, &you.paralysis, &you.conf,
+ &you.might, &you.invis, &you.fire_shield
+ };
+
+ duration_type dur_list[] = {
+ DUR_WEAPON_BRAND, DUR_ICY_ARMOUR, DUR_REPEL_MISSILES, DUR_REGENERATION,
+ DUR_DEFLECT_MISSILES, DUR_SWIFTNESS, DUR_INSULATION, DUR_STONEMAIL,
+ DUR_CONTROLLED_FLIGHT, DUR_CONTROL_TELEPORT, DUR_RESIST_POISON,
+ DUR_RESIST_FIRE, DUR_RESIST_COLD, DUR_TRANSFORMATION, DUR_STONESKIN,
+ DUR_FORESCRY, DUR_SEE_INVISIBLE, DUR_SILENCE, DUR_CONDENSATION_SHIELD
+ };
+
if (you.levitation > 2)
you.levitation = 2;
- if (you.invis)
- you.invis = 1;
-
- if (you.duration[DUR_WEAPON_BRAND])
- you.duration[DUR_WEAPON_BRAND] = 1;
-
- if (you.duration[DUR_ICY_ARMOUR])
- you.duration[DUR_ICY_ARMOUR] = 1;
-
- if (you.duration[DUR_REPEL_MISSILES])
- you.duration[DUR_REPEL_MISSILES] = 1;
-
- if (you.duration[DUR_REGENERATION])
- you.duration[DUR_REGENERATION] = 1;
-
- if (you.duration[DUR_DEFLECT_MISSILES])
- you.duration[DUR_DEFLECT_MISSILES] = 1;
-
- if (you.fire_shield)
- you.fire_shield = 1;
-
- if (you.duration[DUR_SWIFTNESS])
- you.duration[DUR_SWIFTNESS] = 1;
-
- if (you.duration[DUR_INSULATION])
- you.duration[DUR_INSULATION] = 1;
-
- if (you.duration[DUR_STONEMAIL])
- you.duration[DUR_STONEMAIL] = 1;
-
- if (you.duration[DUR_CONTROLLED_FLIGHT])
- you.duration[DUR_CONTROLLED_FLIGHT] = 1;
-
- if (you.duration[DUR_CONTROL_TELEPORT])
- you.duration[DUR_CONTROL_TELEPORT] = 1;
-
- if (you.duration[DUR_RESIST_POISON])
- you.duration[DUR_RESIST_POISON] = 1;
+ for ( unsigned int i = 0; i < ARRAYSIZE(direct_list); ++i )
+ if ( *(direct_list[i]) > 1 )
+ *(direct_list[i]) = 1;
- if (you.duration[DUR_TRANSFORMATION])
- you.duration[DUR_TRANSFORMATION] = 1;
-
- //jmf: added following
- if (you.duration[DUR_STONESKIN])
- you.duration[DUR_STONESKIN] = 1;
-
- if (you.duration[DUR_FORESCRY])
- you.duration[DUR_FORESCRY] = 1;
-
- if (you.duration[DUR_SEE_INVISIBLE])
- you.duration[DUR_SEE_INVISIBLE] = 1;
-
- if (you.duration[DUR_SILENCE])
- you.duration[DUR_SILENCE] = 1;
-
- if (you.duration[DUR_CONDENSATION_SHIELD])
- you.duration[DUR_CONDENSATION_SHIELD] = 1;
+ for ( unsigned int i = 0; i < ARRAYSIZE(dur_list); ++i )
+ if ( you.duration[dur_list[i]] > 1 )
+ you.duration[dur_list[i]] = 1;
contaminate_player( -1 * (1+random2(5)));
} // end antimagic()
diff --git a/crawl-ref/source/spells1.h b/crawl-ref/source/spells1.h
index 77e32371dd..e1f333b07a 100644
--- a/crawl-ref/source/spells1.h
+++ b/crawl-ref/source/spells1.h
@@ -110,7 +110,7 @@ void stone_scales(int pow);
/* ***********************************************************************
* called from: religion
* *********************************************************************** */
-void antimagic(void);
+void antimagic();
// last updated 24may2000 {dlb}
/* ***********************************************************************
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc
index 8bd05d4bc1..bb3427da8f 100644
--- a/crawl-ref/source/spells2.cc
+++ b/crawl-ref/source/spells2.cc
@@ -48,8 +48,8 @@
#include "stuff.h"
#include "view.h"
-int raise_corpse( int corps, int corx, int cory, int corps_beh,
- int corps_hit, int actual );
+static int raise_corpse( int corps, int corx, int cory, beh_type corps_beh,
+ int corps_hit, int actual );
unsigned char detect_traps( int pow )
{
@@ -287,7 +287,7 @@ int corpse_rot(int power)
return 0;
} // end corpse_rot()
-int animate_dead( int power, int corps_beh, int corps_hit, int actual )
+int animate_dead( int power, beh_type corps_beh, int corps_hit, int actual )
{
UNUSED( power );
@@ -360,7 +360,7 @@ int animate_dead( int power, int corps_beh, int corps_hit, int actual )
return number_raised;
} // end animate_dead()
-int animate_a_corpse( int axps, int ayps, int corps_beh, int corps_hit,
+int animate_a_corpse( int axps, int ayps, beh_type corps_beh, int corps_hit,
int class_allowed )
{
if (igrd[axps][ayps] == NON_ITEM)
@@ -388,7 +388,7 @@ int animate_a_corpse( int axps, int ayps, int corps_beh, int corps_hit,
} // end animate_a_corpse()
int raise_corpse( int corps, int corx, int cory,
- int corps_beh, int corps_hit, int actual )
+ beh_type corps_beh, int corps_hit, int actual )
{
int returnVal = 1;
@@ -421,7 +421,7 @@ int raise_corpse( int corps, int corx, int cory,
return returnVal;
} // end raise_corpse()
-void cast_twisted(int power, int corps_beh, int corps_hit)
+void cast_twisted(int power, beh_type corps_beh, int corps_hit)
{
int total_mass = 0;
int num_corpses = 0;
@@ -1344,7 +1344,7 @@ void summon_scorpions(int pow)
void summon_ice_beast_etc(int pow, int ibc, bool divine_gift)
{
int numsc = cap_int(2 + (random2(pow) / 4), 6);
- int beha = divine_gift? BEH_GOD_GIFT : BEH_FRIENDLY;
+ beh_type beha = divine_gift? BEH_GOD_GIFT : BEH_FRIENDLY;
switch (ibc)
{
@@ -1445,7 +1445,7 @@ bool summon_swarm( int pow, bool unfriendly, bool god_gift )
break;
} // end switch
- int behaviour = BEH_HOSTILE; // default to unfriendly
+ beh_type behaviour = BEH_HOSTILE; // default to unfriendly
// Note: friendly, non-god_gift means spell.
if (god_gift)
diff --git a/crawl-ref/source/spells2.h b/crawl-ref/source/spells2.h
index d982c3e997..61bd654853 100644
--- a/crawl-ref/source/spells2.h
+++ b/crawl-ref/source/spells2.h
@@ -13,6 +13,8 @@
#ifndef SPELLS2_H
#define SPELLS2_H
+#include "enum.h"
+
// last updated 24may2000 {dlb}
/* ***********************************************************************
@@ -25,14 +27,15 @@ bool brand_weapon(int which_brand, int power);
/* ***********************************************************************
* called from: ability - spell
* *********************************************************************** */
-int animate_a_corpse(int axps, int ayps, int corps_beh, int corps_hit, int class_allowed);
+int animate_a_corpse(int axps, int ayps, beh_type corps_beh,
+ int corps_hit, int class_allowed);
// last updated 24may2000 {dlb}
/* ***********************************************************************
* called from: ability - it_use3 - monstuff - mstuff2 - spell
* *********************************************************************** */
-int animate_dead(int power, int corps_beh, int corps_hit, int actual);
+int animate_dead(int power, beh_type corps_beh, int corps_hit, int actual);
// last updated 24may2000 {dlb}
@@ -103,7 +106,7 @@ void cast_toxic_radiance(void);
/* ***********************************************************************
* called from: spell
* *********************************************************************** */
-void cast_twisted(int power, int corps_beh, int corps_hit);
+void cast_twisted(int power, beh_type corps_beh, int corps_hit);
// last updated 24may2000 {dlb}
diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc
index fa521f1d35..6a3fccf2f3 100644
--- a/crawl-ref/source/spells4.cc
+++ b/crawl-ref/source/spells4.cc
@@ -663,7 +663,7 @@ void cast_summon_large_mammal(int pow)
void cast_sticks_to_snakes(int pow)
{
- int mon, i, behaviour;
+ int mon;
int how_many = 0;
int max = 1 + random2( 1 + you.skills[SK_TRANSMIGRATION] ) / 4;
int dur = cap_int(3 + random2(pow) / 20, 5);
@@ -676,8 +676,8 @@ void cast_sticks_to_snakes(int pow)
return;
}
- behaviour = item_cursed( you.inv[ weapon ] ) ? BEH_HOSTILE
- : BEH_FRIENDLY;
+ const beh_type behaviour = item_cursed( you.inv[ weapon ] )
+ ? BEH_HOSTILE : BEH_FRIENDLY;
if ((you.inv[ weapon ].base_type == OBJ_MISSILES
&& (you.inv[ weapon ].sub_type == MI_ARROW)))
@@ -685,7 +685,7 @@ void cast_sticks_to_snakes(int pow)
if (you.inv[ weapon ].quantity < max)
max = you.inv[ weapon ].quantity;
- for (i = 0; i <= max; i++)
+ for (int i = 0; i <= max; i++)
{
if (pow > 50 || (pow > 25 && one_chance_in(3))
|| (get_ammo_brand(you.inv[weapon]) == SPMSL_POISONED
diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc
index 8096b5c40b..e3d7357851 100644
--- a/crawl-ref/source/spl-cast.cc
+++ b/crawl-ref/source/spl-cast.cc
@@ -799,8 +799,6 @@ static bool spell_is_uncastable(spell_type spell)
// the casting.
spret_type your_spells( spell_type spc2, int powc, bool allow_fail )
{
- int dem_hor = 0;
- int dem_hor2 = 0;
struct dist spd;
struct bolt beam;
@@ -1390,24 +1388,28 @@ spret_type your_spells( spell_type spc2, int powc, bool allow_fail )
case SPELL_DEMONIC_HORDE:
mpr("You open a gate to Pandemonium!");
- dem_hor2 = 3 + random2(5);
- for (dem_hor = 0; dem_hor < 4 + dem_hor2; dem_hor++)
{
- summon_ice_beast_etc(powc, summon_any_demon(DEMON_LESSER));
+ const int num = 7 + random2(5);
+ for (int i = 0; i < num; ++i)
+ {
+ summon_ice_beast_etc(powc, summon_any_demon(DEMON_LESSER));
+ }
}
break;
case SPELL_SUMMON_GREATER_DEMON:
mpr("You open a gate to Pandemonium!");
- dem_hor = ((random2(powc) <= 5) ? BEH_HOSTILE : BEH_CHARMED);
-
- if (dem_hor == BEH_CHARMED)
- mpr("You don't feel so good about this...");
+ {
+ const beh_type dem_beh = ((random2(powc) <= 5)
+ ? BEH_HOSTILE : BEH_CHARMED);
- create_monster( summon_any_demon(DEMON_GREATER), 5, dem_hor,
- you.x_pos, you.y_pos, MHITYOU, 250 );
+ if (dem_beh == BEH_CHARMED)
+ mpr("You don't feel so good about this...");
+ create_monster( summon_any_demon(DEMON_GREATER), 5, dem_beh,
+ you.x_pos, you.y_pos, MHITYOU, 250 );
+ }
break;
case SPELL_CORPSE_ROT:
diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc
index cfd339d5f6..274fed6dbb 100644
--- a/crawl-ref/source/tags.cc
+++ b/crawl-ref/source/tags.cc
@@ -1591,7 +1591,7 @@ static void unmarshall_monster(tagHeader &th, monsters &m)
m.speed = unmarshallByte(th);
// Avoid sign extension when loading files (Elethiomel's hang)
m.speed_increment = (unsigned char) unmarshallByte(th);
- m.behaviour = unmarshallByte(th);
+ m.behaviour = static_cast<beh_type>(unmarshallByte(th));
m.x = unmarshallByte(th);
m.y = unmarshallByte(th);
m.target_x = unmarshallByte(th);
@@ -1658,7 +1658,7 @@ void tag_read_level_attitude(struct tagHeader &th)
for (i = 0; i < count; i++)
{
- menv[i].attitude = unmarshallByte(th);
+ menv[i].attitude = static_cast<mon_attitude_type>(unmarshallByte(th));
menv[i].foe = unmarshallShort(th);
}
}
@@ -1709,7 +1709,7 @@ void tag_missing_level_attitude()
}
menv[i].attitude = (isFriendly)?ATT_FRIENDLY : ATT_HOSTILE;
- menv[i].behaviour = new_beh;
+ menv[i].behaviour = static_cast<beh_type>(new_beh);
menv[i].foe_memory = 0;
}
}