From 5b096f16cf685678b6ceb622c60de77f4b90b689 Mon Sep 17 00:00:00 2001 From: haranp Date: Sat, 23 Jun 2007 21:42:00 +0000 Subject: Added more logic to Stealth and Portal cards. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1631 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/acr.cc | 8 ++++ crawl-ref/source/decks.cc | 20 +++++----- crawl-ref/source/enum.h | 1 + crawl-ref/source/externs.h | 1 - crawl-ref/source/mutation.cc | 20 +++++----- crawl-ref/source/player.cc | 3 ++ crawl-ref/source/tags.cc | 87 +++++++++++++++++++++++++------------------- 7 files changed, 80 insertions(+), 60 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 4cafa0a2f7..731427fb98 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -1869,6 +1869,14 @@ static void decrement_durations() you.duration[DUR_TELEPORT] = 0; } + if (you.duration[DUR_STEALTH] > 1) + you.duration[DUR_STEALTH]--; + else if (you.duration[DUR_STEALTH] == 1) + { + mpr("You feel less stealthy.", MSGCH_DURATION); + you.duration[DUR_STEALTH] = 0; + } + if (you.duration[DUR_CONTROL_TELEPORT] > 1) { you.duration[DUR_CONTROL_TELEPORT]--; diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc index 0444fabd69..75f2d74bb1 100644 --- a/crawl-ref/source/decks.cc +++ b/crawl-ref/source/decks.cc @@ -12,7 +12,6 @@ #include "AppHdr.h" #include "decks.h" -#include #include #include "externs.h" @@ -470,15 +469,12 @@ static void portal_card(int power, deck_rarity_type rarity) const bool was_controlled = player_control_teleport(); if ( controlled && !was_controlled ) - you.duration[DUR_CONTROL_TELEPORT] = 1; + you.duration[DUR_CONTROL_TELEPORT] = 6; // long enough to kick in if ( instant ) you_teleport_now( true ); else you_teleport(); - - if ( controlled && !was_controlled ) - you.duration[DUR_CONTROL_TELEPORT] = 0; } static void warp_card(int power, deck_rarity_type rarity) @@ -591,7 +587,7 @@ static void minefield_card(int power, deck_rarity_type rarity) { for ( int dy = -radius; dy <= radius; ++dy ) { - if ( dx * dx + dy*dy > radius*radius + 1 ) + if ( dx*dx + dy*dy > radius*radius + 1 ) continue; if ( dx == 0 && dy == 0 ) continue; @@ -613,8 +609,6 @@ static void damaging_card( card_type card, int power, deck_rarity_type rarity ) { dist target; bolt beam; - - zap_type ztype; switch ( card ) { @@ -661,7 +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 ) - you.duration[DUR_SLAYING] = random2(power/6); + you.duration[DUR_SLAYING] = random2(power/6) + 1; else if ( power_level == 1 ) go_berserk(false); else if ( power_level == 0 ) @@ -729,7 +723,7 @@ static void helm_card(int power, deck_rarity_type rarity) if ( random2(4-i) < num_resists ) { // Add a temporary resist - you.duration[possible_resists[i]] += random2(power/7); + you.duration[possible_resists[i]] += random2(power/7) + 1; msg::stream << "You feel resistant to " << resist_names[i] << '.' << std::endl; --num_resists; @@ -766,10 +760,14 @@ static void blade_card(int power, deck_rarity_type rarity) static void shadow_card(int power, deck_rarity_type rarity) { const int power_level = get_power_level(power, rarity); + if ( power_level >= 1 ) { - // XXX add a stealth attribute here + mpr( you.duration[DUR_STEALTH] ? "You feel more catlike." : + "You feel stealthy."); + you.duration[DUR_STEALTH] += random2(power/4) + 1; } + potion_effect(POT_INVISIBILITY, random2(power/4)); } diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 4117c06801..8eca15f3b8 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -1191,6 +1191,7 @@ enum duration_type DUR_RESIST_FIRE, DUR_RESIST_COLD, DUR_SLAYING, + DUR_STEALTH, NUM_DURATIONS }; diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index aeb1c2025f..07457b8d12 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -1186,7 +1186,6 @@ struct crawl_environment FixedVector< trap_struct, MAX_TRAPS > trap; // trap list FixedVector< int, 20 > mons_alloc; - int trap_known; double elapsed_time; // used during level load // Number of turns the player has spent on this level. diff --git a/crawl-ref/source/mutation.cc b/crawl-ref/source/mutation.cc index 281f3f0d4f..360dfe99cb 100644 --- a/crawl-ref/source/mutation.cc +++ b/crawl-ref/source/mutation.cc @@ -280,13 +280,13 @@ const char *mutation_descrip[][3] = { "You are mostly covered in smooth nacreous scales (AC + 3).", "You are completely covered in smooth nacreous scales (AC + 5)."}, - {"You are partially covered in ridged grey scales (AC + 2, dex - 1).", - "You are mostly covered in ridged grey scales (AC + 4, dex - 1).", - "You are completely covered in ridged grey scales (AC + 6, dex - 2)."}, + {"You are partially covered in ridged grey scales (AC + 2, Dex -1).", + "You are mostly covered in ridged grey scales (AC + 4, Dex -1).", + "You are completely covered in ridged grey scales (AC + 6, Dex -2)."}, - {"You are partially covered in metallic scales (AC + 3, dex - 2).", - "You are mostly covered in metallic scales (AC + 7, dex - 3).", - "You are completely covered in metallic scales (AC + 10, dex - 4)."}, + {"You are partially covered in metallic scales (AC + 3, Dex -2).", + "You are mostly covered in metallic scales (AC + 7, Dex -3).", + "You are completely covered in metallic scales (AC + 10, Dex -4)."}, {"You are partially covered in black scales (AC + 1).", "You are mostly covered in black scales (AC + 3).", @@ -297,8 +297,8 @@ const char *mutation_descrip[][3] = { "You are completely covered in white scales (AC + 5)."}, {"You are partially covered in yellow scales (AC + 2).", - "You are mostly covered in yellow scales (AC + 4, dex - 1).", - "You are completely covered in yellow scales (AC + 6, dex - 2)."}, + "You are mostly covered in yellow scales (AC + 4, Dex -1).", + "You are completely covered in yellow scales (AC + 6, Dex -2)."}, {"You are partially covered in brown scales (AC + 2).", "You are mostly covered in brown scales (AC + 4).", @@ -327,8 +327,8 @@ const char *mutation_descrip[][3] = { "You are completely covered in indigo scales (AC + 5)."}, {"You are partially covered in knobbly red scales (AC + 2).", - "You are mostly covered in knobbly red scales (AC + 5, dex - 1).", - "You are completely covered in knobbly red scales (AC + 7, dex - 2)."}, + "You are mostly covered in knobbly red scales (AC + 5, Dex -1).", + "You are completely covered in knobbly red scales (AC + 7, Dex -2)."}, {"You are partially covered in iridescent scales (AC + 1).", "You are mostly covered in iridescent scales (AC + 2).", diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 635ac234c8..356228f36b 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -2906,6 +2906,9 @@ int check_stealth(void) stealth += 20; } + if ( you.duration[DUR_STEALTH] ) + stealth += 80; + stealth += scan_randarts( RAP_STEALTH ); if (player_is_levitating()) diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc index 0049611f7d..2986016cc5 100644 --- a/crawl-ref/source/tags.cc +++ b/crawl-ref/source/tags.cc @@ -58,6 +58,7 @@ #include #include #include // for memcpy +#include #ifdef UNIX #include @@ -127,6 +128,13 @@ static void unmarshall_monster(tagHeader &th, monsters &m); static void marshall_item(tagHeader &th, const item_def &item); static void unmarshall_item(tagHeader &th, item_def &item); +template +static void marshall_iterator(struct tagHeader &th, T_iter beg, T_iter end, + void (*T_marshall)(struct tagHeader&, const T&)); +template +static void unmarshall_vector(struct tagHeader& th, std::vector& vec, + T (*T_unmarshall)(struct tagHeader&)); + // provide a wrapper for file writing, just in case. int write2(FILE * file, const char *buffer, unsigned int count) { @@ -227,6 +235,28 @@ void marshallMap(struct tagHeader &th, const std::map& data, } } +template +static void marshall_iterator(struct tagHeader &th, T_iter beg, T_iter end, + void (*T_marshall)(struct tagHeader&, const T&)) +{ + marshallLong(th, std::distance(beg, end)); + while ( beg != end ) + { + T_marshall(th, *beg); + ++beg; + } +} + +template +static void unmarshall_vector(struct tagHeader& th, std::vector& vec, + T (*T_unmarshall)(struct tagHeader&)) +{ + vec.clear(); + const long num_to_read = unmarshallLong(th); + for ( long i = 0; i < num_to_read; ++i ) + vec.push_back( T_unmarshall(th) ); +} + void marshall_level_id( tagHeader& th, const level_id& id ) { marshallByte(th, id.branch ); @@ -1033,7 +1063,6 @@ static void tag_read_you(struct tagHeader &th, char minorVersion) you.skills[j] = unmarshallByte(th); you.practise_skill[j] = unmarshallByte(th); you.skill_points[j] = unmarshallLong(th); - you.skill_order[j] = unmarshallByte(th); } @@ -1101,7 +1130,6 @@ static void tag_read_you_items(struct tagHeader &th, char minorVersion) count_c = unmarshallByte(th); for (i = 0; i < count_c; ++i) { - you.inv[i].orig_monnum = you.inv[i].orig_place = 0; you.inv[i].base_type = static_cast(unmarshallByte(th)); you.inv[i].sub_type = (unsigned char) unmarshallByte(th); @@ -1110,14 +1138,10 @@ static void tag_read_you_items(struct tagHeader &th, char minorVersion) you.inv[i].colour = (unsigned char) unmarshallByte(th); you.inv[i].flags = (unsigned long) unmarshallLong(th); you.inv[i].quantity = unmarshallShort(th); - you.inv[i].plus2 = unmarshallShort(th); - + you.inv[i].plus2 = unmarshallShort(th); you.inv[i].orig_place = unmarshallShort(th); you.inv[i].orig_monnum = unmarshallShort(th); - - char insstring[80]; - unmarshallString(th, insstring, 80); - you.inv[i].inscription = std::string(insstring); + you.inv[i].inscription = unmarshallString(th, 80); // these never need to be saved for items in the inventory -- bwr you.inv[i].x = -1; @@ -1339,23 +1363,17 @@ static void unmarshall_item(tagHeader &th, item_def &item) unmarshallShort(th); // igrd[item.x][item.y] -- unused item.slot = unmarshallByte(th); - item.inscription.clear(); item.orig_place = unmarshallShort(th); - item.orig_monnum = unmarshallShort(th); - - char insstring[80]; - unmarshallString(th, insstring, 80); - item.inscription = std::string(insstring); + item.orig_monnum = unmarshallShort(th); + item.inscription = unmarshallString(th, 80); } static void tag_construct_level_items(struct tagHeader &th) { - int i; - // how many traps? marshallShort(th, MAX_TRAPS); - for (i = 0; i < MAX_TRAPS; ++i) + for (int i = 0; i < MAX_TRAPS; ++i) { marshallByte(th, env.trap[i].type); marshallByte(th, env.trap[i].x); @@ -1364,7 +1382,7 @@ static void tag_construct_level_items(struct tagHeader &th) // how many items? marshallShort(th, MAX_ITEMS); - for (i = 0; i < MAX_ITEMS; ++i) + for (int i = 0; i < MAX_ITEMS; ++i) marshall_item(th, mitm[i]); } @@ -1460,22 +1478,18 @@ void tag_construct_level_attitude(struct tagHeader &th) static void tag_read_level( struct tagHeader &th, char minorVersion ) { - int i,j; - int gx, gy; - - env.elapsed_time = (double)unmarshallFloat(th); - + env.elapsed_time = unmarshallFloat(th); // map grids // how many X? - gx = unmarshallShort(th); + const int gx = unmarshallShort(th); // how many Y? - gy = unmarshallShort(th); + const int gy = unmarshallShort(th); env.turns_on_level = unmarshallLong(th); - for (i = 0; i < gx; i++) + for (int i = 0; i < gx; i++) { - for (j = 0; j < gy; j++) + for (int j = 0; j < gy; j++) { grd[i][j] = static_cast( @@ -1493,8 +1507,8 @@ static void tag_read_level( struct tagHeader &th, char minorVersion ) env.cloud_no = unmarshallShort(th); // how many clouds? - gx = unmarshallShort(th); - for (i = 0; i < gx; i++) + const int num_clouds = unmarshallShort(th); + for (int i = 0; i < num_clouds; i++) { env.cloud[i].x = unmarshallByte(th); env.cloud[i].y = unmarshallByte(th); @@ -1504,8 +1518,8 @@ static void tag_read_level( struct tagHeader &th, char minorVersion ) } // how many shops? - gx = unmarshallByte(th); - for (i = 0; i < gx; i++) + const int num_shops = unmarshallByte(th); + for (int i = 0; i < num_shops; i++) { env.shop[i].keeper_name[0] = unmarshallByte(th); env.shop[i].keeper_name[1] = unmarshallByte(th); @@ -1520,12 +1534,9 @@ static void tag_read_level( struct tagHeader &th, char minorVersion ) static void tag_read_level_items(struct tagHeader &th, char minorVersion) { - int i; - int count; - // how many traps? - count = unmarshallShort(th); - for (i = 0; i < count; ++i) + const int trap_count = unmarshallShort(th); + for (int i = 0; i < trap_count; ++i) { env.trap[i].type = static_cast( @@ -1535,8 +1546,8 @@ static void tag_read_level_items(struct tagHeader &th, char minorVersion) } // how many items? - count = unmarshallShort(th); - for (i = 0; i < count; ++i) + const int item_count = unmarshallShort(th); + for (int i = 0; i < item_count; ++i) unmarshall_item(th, mitm[i]); } -- cgit v1.2.3-54-g00ecf