From cfd996c44458c4a6c8796ad73bf5c78a193c4ea4 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Fri, 16 Mar 2007 09:25:17 +0000 Subject: Tweaked unique code to eliminate the confusing arithmetic on MONS enum values. Breaks save compatibility again. Added a unique curse skull. Indulge me. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1044 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/acr.cc | 10 ++-------- crawl-ref/source/beam.cc | 5 ----- crawl-ref/source/dat/splev.des | 13 ++++++++----- crawl-ref/source/describe.cc | 6 +++++- crawl-ref/source/dungeon.cc | 36 +++++++++++++++++++++++++----------- crawl-ref/source/enum.h | 2 ++ crawl-ref/source/externs.h | 10 ++++++---- crawl-ref/source/files.cc | 4 +++- crawl-ref/source/misc.cc | 12 ------------ crawl-ref/source/mon-data.h | 12 ++++++++++++ crawl-ref/source/mon-util.cc | 5 +++++ crawl-ref/source/monplace.cc | 4 ++-- crawl-ref/source/monstuff.cc | 2 +- crawl-ref/source/newgame.cc | 5 +++-- crawl-ref/source/ouch.cc | 2 ++ crawl-ref/source/player.cc | 5 +++++ crawl-ref/source/religion.cc | 34 +++++++++++++++++++++++++++++++++- crawl-ref/source/tags.cc | 22 ++++++++++++---------- crawl-ref/source/view.cc | 3 --- 19 files changed, 126 insertions(+), 66 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 38d0f53351..f92c3747b3 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -2713,14 +2713,8 @@ static bool initialise(void) } } - for (i = 0; i < 50; i++) - { - you.unique_creatures[i] = 0; - you.unique_items[i] = UNIQ_NOT_EXISTS; - } - - for (i = 0; i < NUM_STATUE_TYPES; i++) - you.visible_statue[i] = 0; + you.unique_creatures.init(false); + you.unique_items.init(UNIQ_NOT_EXISTS); // initialize tag system before we try loading anything! tag_init(); diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 032477d7a9..b47c2eb040 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -2655,11 +2655,6 @@ static int affect_wall(struct bolt &beam, int x, int y) mpr("The statue twists and shakes as its substance crumbles away!"); } - if (targ_grid == DNGN_SILVER_STATUE) - you.visible_statue[ STATUE_SILVER ] = 0; - else if (targ_grid == DNGN_ORANGE_CRYSTAL_STATUE) - you.visible_statue[ STATUE_ORANGE_CRYSTAL ] = 0; - beam.obvious_effect = 1; } diff --git a/crawl-ref/source/dat/splev.des b/crawl-ref/source/dat/splev.des index b0778ab487..7183fe696a 100644 --- a/crawl-ref/source/dat/splev.des +++ b/crawl-ref/source/dat/splev.des @@ -329,13 +329,13 @@ xxxxxxxxxxx............................{............................xxxxxxxxxxxx xxxxxxxxxxx.........................................................xxxxxxxxxxxx xxxxxxxxxx...l.l.....................................................xxxxxxxxxxx xxxxxxxxxx..l.l.l.l..................................................xxxxxxxxxxx -xxxxxxxxxx.l.l.l.l.l.................................................xxxxxxxxxxx +xxxxxxxxxx.l.l.l.l.l...................f.............................xxxxxxxxxxx xxxxxxxxx.l.l.l.l.l...................................................xxxxxxxxxx xxxxxxxxxl.l.l.l.l.l..................................................xxxxxxxxxx -xxxxxxxxx.l.l.l.A.l.l.................}1].............................=Axxxxxxxx +xxxxxxxxx.l.l.l.A.l.l..............e..}1]..2..........................=Axxxxxxxx xxxxxxxxxl.l.l.l.l.l.l.................)..............................xxxxxxxxxx xxxxxxxxx.l.l.l.l.l.l.................................................xxxxxxxxxx -xxxxxxxxxx.l.l.l.l.l.l...............................................xxxxxxxxxxx +xxxxxxxxxx.l.l.l.l.l.l.................d.............................xxxxxxxxxxx xxxxxxxxxx..l.l.l.l..................................................xxxxxxxxxxx xxxxxxxxxx.....l.l...................................................xxxxxxxxxxx xxxxxxxxxxx......................[...........(......................xxxxxxxxxxxx @@ -370,8 +370,11 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ENDMAP -MONS: Geryon -MONS: random, random, random, random, random, random +MONS: Geryon, Murray +MONS: random, random, random, random, random + +SHUFFLE: 2def +ITEM: nothing, nothing, nothing ############################################################################# # Dispater's castle - rest of level filled up with plan_4 (irregular city) diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index acb2f2b39f..7038d86cc6 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -5914,7 +5914,7 @@ void describe_monsters(int class_described, unsigned char which_mons) break; case MONS_ROTTING_HULK: - description += "A shambling undead, related to the ghoul."; + description += "A shambling undead creature, related to the ghoul."; break; case MONS_KILLER_KLOWN: @@ -6230,6 +6230,10 @@ void describe_monsters(int class_described, unsigned char which_mons) "glow with an otherworldly radiance."; break; + case MONS_MURRAY: + description += "A demonic skull rolling along the dungeon floor."; + break; + case MONS_PROGRAM_BUG: default: description += "If this monster is a \"program bug\", then it's " diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index 9a45191132..fc437c7c30 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -3882,7 +3882,7 @@ static int builder_by_type(int level_number, char level_type) // Could do spotty_level, but that doesn't always put all paired // stairs reachable from each other which isn't a problem in normal // dungeon but could be in Pandemonium - if (one_chance_in(15)) + if (one_chance_in(4)) { do { @@ -3895,7 +3895,7 @@ static int builder_by_type(int level_number, char level_type) break; } } - while (you.unique_creatures[40 + which_demon] == 1); + while (you.unique_creatures[MONS_MNOLEG + which_demon]); } if (which_demon >= 0) @@ -3904,7 +3904,7 @@ static int builder_by_type(int level_number, char level_type) { "mnoleg", "lom_lobon", "cerebov", "gloorx_vloq" }; - you.unique_creatures[40 + which_demon] = 1; + you.unique_creatures[MONS_MNOLEG + which_demon] = true; const int vault = random_map_for_tag( @@ -4723,6 +4723,26 @@ static bool make_room(int sx,int sy,int ex,int ey,int max_doors, int doorlevel) return true; } //end make_room() +static int pick_unique(int lev) +{ + int which_unique = + ((lev > 19) ? random_range(MONS_LOUISE, MONS_BORIS) : + (lev > 16) ? random_range(MONS_ERICA, MONS_FRANCES) : + (lev > 13) ? random_range(MONS_URUG, MONS_JOZEF) : + (lev > 9) ? random_range(MONS_PSYCHE, MONS_MICHAEL) : + (lev > 7) ? random_range(MONS_BLORK_THE_ORC, MONS_EROLCHA) : + (lev > 3) ? random_range(MONS_IJYB, MONS_EDMUND) : + random_range(MONS_TERENCE, MONS_SIGMUND)); + + if (player_in_branch(BRANCH_VESTIBULE_OF_HELL) + && one_chance_in(7)) + { + which_unique = MONS_MURRAY; + } + + return (which_unique); +} + static void builder_monsters(int level_number, char level_type, int mon_wanted) { int i = 0; @@ -4772,13 +4792,7 @@ static void builder_monsters(int level_number, char level_type, int mon_wanted) break; } - which_unique = ((level_number > 19) ? 20 + random2(11) : - (level_number > 16) ? 13 + random2(10) : - (level_number > 13) ? 9 + random2( 9) : - (level_number > 9) ? 6 + random2( 5) : - (level_number > 7) ? 4 + random2( 4) : - (level_number > 3) ? 2 + random2( 4) - : random2(4)); + which_unique = pick_unique(level_number); } // usually, we'll have quit after a few tries. Make sure we don't @@ -4787,7 +4801,7 @@ static void builder_monsters(int level_number, char level_type, int mon_wanted) break; // note: unique_creatures 40 + used by unique demons - if (place_monster( not_used, 280 + which_unique, level_number, + if (place_monster( not_used, which_unique, level_number, BEH_SLEEP, MHITNOT, false, 1, 1, true, PROX_ANYWHERE, 250, 0, no_monster_zones )) { diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index db03db6da9..9d77b12e49 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -2192,6 +2192,8 @@ enum monster_type // (int) menv[].type MONS_DRACONIAN_ANNIHILATOR, MONS_DRACONIAN_KNIGHT, // 325 MONS_DRACONIAN_SCORCHER, + + MONS_MURRAY, // The Lords of Hell: MONS_GERYON = 340, // 340 diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index b5e419792f..10479c8031 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -108,6 +108,8 @@ public: virtual int id() const = 0; virtual actor_type atype() const = 0; + virtual god_type deity() const = 0; + virtual bool alive() const = 0; virtual coord_def pos() const = 0; @@ -558,8 +560,6 @@ public: int symbol; int colour; - FixedVector< char, NUM_STATUE_TYPES > visible_statue; - char redraw_hit_points; char redraw_magic_points; char redraw_strength; @@ -634,7 +634,7 @@ public: FixedArray item_description; FixedVector unique_items; - FixedVector unique_creatures; + FixedVector unique_creatures; KillMaster kills; @@ -644,7 +644,7 @@ public: FixedVector branch_stairs; - char religion; + god_type religion; unsigned char piety; unsigned char gift_timeout; FixedVector penance; @@ -715,6 +715,7 @@ public: int id() const; actor_type atype() const { return ACT_PLAYER; } + god_type deity() const; bool alive() const; coord_def pos() const; @@ -864,6 +865,7 @@ public: // actor interface int id() const; + god_type deity() const; bool alive() const; coord_def pos() const; bool swimming() const; diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index a45f76a32c..5e73131373 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -94,6 +94,7 @@ void save_level(int level_saved, bool was_a_labyrinth, char where_were_you); #define GHOST_MINOR_VERSION 1 #define LEVEL_MINOR_VERSION 1 +#define YOU_MINOR_VERSION 1 static void redraw_all(void) { @@ -1138,7 +1139,8 @@ void save_game(bool leave_game) if (!charf) end(-1, true, "Unable to open \"%s\" for writing!\n", charFile.c_str()); - write_tagged_file( charf, SAVE_MAJOR_VERSION, 0, TAGTYPE_PLAYER ); + write_tagged_file( charf, SAVE_MAJOR_VERSION, + YOU_MINOR_VERSION, TAGTYPE_PLAYER ); fclose(charf); DO_CHMOD_PRIVATE(charFile.c_str()); diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index f545c5184f..19da6b667e 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -65,8 +65,6 @@ #include "tutorial.h" #include "view.h" -extern FixedVector Visible_Statue; // defined in acr.cc - bool scramble(void); bool trap_item(char base_type, char sub_type, char beam_x, char beam_y); static void dart_trap(bool trap_known, int trapped, struct bolt &pbolt, bool poison); @@ -1877,16 +1875,6 @@ bool i_feel_safe(bool announce) if ( xend >= GXM ) xend = 0; if ( ystart >= GYM ) yend = 0; - /* statue check */ - if (you.visible_statue[STATUE_SILVER] || - you.visible_statue[STATUE_ORANGE_CRYSTAL] ) - { - if (announce) - mprf(MSGCH_WARN, "There are scary statues in view."); - - return (false); - } - if (in_bounds(you.x_pos, you.y_pos) && env.cgrid[you.x_pos][you.y_pos] != EMPTY_CLOUD) { diff --git a/crawl-ref/source/mon-data.h b/crawl-ref/source/mon-data.h index 061bf26777..26c105795d 100644 --- a/crawl-ref/source/mon-data.h +++ b/crawl-ref/source/mon-data.h @@ -4391,4 +4391,16 @@ } , +{ + MONS_MURRAY, 'z', LIGHTRED, "Murray", + M_SPELLCASTER | M_SEE_INVIS | M_EVIL | M_UNIQUE, + MR_RES_ELEC | MR_RES_POISON | MR_RES_HELLFIRE | MR_RES_COLD, + 0, 50, MONS_LICH, MONS_CURSE_SKULL, MH_UNDEAD, MAG_IMMUNE, + { {AT_BITE, AF_PLAIN, 20}, {AT_BITE, AF_PLAIN, 20}, {AT_NONE, AF_PLAIN, 0}, {AT_NONE, AF_PLAIN, 0} }, + { 14, 0, 0, 180 }, + 30, 10, 10, 7, MST_CURSE_SKULL, CE_NOCORPSE, Z_NOZOMBIE, S_MOAN, I_HIGH, + MONUSE_NOTHING, SIZE_TINY +} +, + #endif diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 7ea248d7e3..243b8f03e4 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -2936,6 +2936,11 @@ bool monsters::alive() const return (hit_points > 0 && type != -1); } +god_type monsters::deity() const +{ + return (god); +} + void monsters::hurt(actor *agent, int amount) { if (amount <= 0) diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc index 0057b36025..46dba3c92c 100644 --- a/crawl-ref/source/monplace.cc +++ b/crawl-ref/source/monplace.cc @@ -523,8 +523,8 @@ static int place_monster_aux( int mon_type, char behaviour, int target, // The return of Boris is now handled in monster_die()... // not setting this for Boris here allows for multiple Borises // in the dungeon at the same time. -- bwr - if (mon_type >= MONS_TERENCE && mon_type <= MONS_BORIS) - you.unique_creatures[mon_type - 280] = 1; + if (mons_is_unique(mon_type)) + you.unique_creatures[mon_type] = true; if (extra != 250) menv[id].number = extra; diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 0b1fc60250..bf34d15dc1 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -720,7 +720,7 @@ void monster_die(monsters *monster, char killer, int i, bool silent) // Now that Boris is dead, he's a valid target for monster // creation again. -- bwr - you.unique_creatures[ monster->type - 280 ] = 0; + you.unique_creatures[ monster->type ] = false; } if (killer != KILL_RESET && killer != KILL_DISMISSED) diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc index a2a29570a8..ab6060876a 100644 --- a/crawl-ref/source/newgame.cc +++ b/crawl-ref/source/newgame.cc @@ -3569,7 +3569,7 @@ void give_items_skills() you.skills[SK_INVOCATIONS] = 4; if (Options.priest != GOD_NO_GOD && Options.priest != GOD_RANDOM) - ng_pr = you.religion = Options.priest; + ng_pr = you.religion = static_cast( Options.priest ); else if (Options.random_pick || Options.priest == GOD_RANDOM) { you.religion = coinflip() ? GOD_YREDELEMNUL : GOD_ZIN; @@ -4568,7 +4568,8 @@ void give_items_skills() if (Options.chaos_knight != GOD_NO_GOD && Options.chaos_knight != GOD_RANDOM) { - ng_ck = you.religion = Options.chaos_knight; + ng_ck = you.religion = + static_cast( Options.chaos_knight ); } else if (Options.random_pick || Options.chaos_knight == GOD_RANDOM) { diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc index 945e494e03..9b044de020 100644 --- a/crawl-ref/source/ouch.cc +++ b/crawl-ref/source/ouch.cc @@ -717,6 +717,8 @@ void ouch( int dam, int death_source, char death_type, const char *aux ) return; } break; + default: + break; } // Damage applied here: diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 611ca70bc5..892f09678b 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -5197,3 +5197,8 @@ bool player::has_usable_claws() const || species == SP_TROLL || species == SP_GHOUL)); } + +god_type player::deity() const +{ + return (religion); +} diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index b7dec5523c..8f8679b85f 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -549,6 +549,8 @@ static void do_god_gift() gift = BOOK_DEMONOLOGY; // summoning bks } break; + default: + break; } if (gift != NUM_BOOKS @@ -1247,6 +1249,8 @@ bool did_god_conduct( int thing_done, int level ) penance = level * ((you.religion == GOD_ZIN) ? 2 : 1); ret = true; break; + default: + break; } break; @@ -1271,6 +1275,8 @@ bool did_god_conduct( int thing_done, int level ) penance = level * 3; ret = true; break; + default: + break; } break; @@ -1286,6 +1292,8 @@ bool did_god_conduct( int thing_done, int level ) piety_change = -level; ret = true; break; + default: + break; } break; @@ -1308,6 +1316,9 @@ bool did_god_conduct( int thing_done, int level ) if (random2(level + 10) > 5) piety_change = 1; break; + + default: + break; } break; @@ -1333,6 +1344,9 @@ bool did_god_conduct( int thing_done, int level ) if (random2(level + 18) > 5) piety_change = 1; break; + + default: + break; } break; @@ -1350,6 +1364,9 @@ bool did_god_conduct( int thing_done, int level ) if (random2(level + 18) > 4) piety_change = 1; break; + + default: + break; } break; @@ -1364,6 +1381,9 @@ bool did_god_conduct( int thing_done, int level ) if (random2(level + 18) > 3) piety_change = 1; break; + + default: + break; } break; @@ -1407,6 +1427,9 @@ bool did_god_conduct( int thing_done, int level ) if (random2(level + 18) > 2) piety_change = 1; break; + + default: + break; } break; @@ -1422,6 +1445,8 @@ bool did_god_conduct( int thing_done, int level ) if (random2(level + 10) > 5) piety_change = 1; break; + default: + break; } break; @@ -1440,6 +1465,8 @@ bool did_god_conduct( int thing_done, int level ) if (random2(level + 10) > 5) piety_change = 1; break; + default: + break; } break; @@ -1456,6 +1483,8 @@ bool did_god_conduct( int thing_done, int level ) if (random2(level + 10) > 5) piety_change = 1; break; + default: + break; } break; @@ -1469,6 +1498,8 @@ bool did_god_conduct( int thing_done, int level ) if (random2(level + 10) > 5) piety_change = 1; break; + default: + break; } break; @@ -2540,7 +2571,8 @@ void god_pitch(unsigned char which_god) if (you.religion != GOD_NO_GOD) excommunication(); - you.religion = which_god; //jmf: moved up so god_speaks gives right colour + //jmf: moved up so god_speaks gives right colour + you.religion = static_cast(which_god); you.piety = 15; // to prevent near instant excommunication you.gift_timeout = 0; set_god_ability_slots(); // remove old god's slots, reserve new god's diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc index 351aff12ea..63fe4fc70b 100644 --- a/crawl-ref/source/tags.cc +++ b/crawl-ref/source/tags.cc @@ -886,8 +886,8 @@ static void tag_construct_you_dungeon(struct tagHeader &th) int i,j; // how many unique creatures? - marshallByte(th, 50); - for (j = 0; j < 50; ++j) + marshallShort(th, NUM_MONSTERS); + for (j = 0; j < NUM_MONSTERS; ++j) marshallByte(th,you.unique_creatures[j]); /* unique beasties */ // how many branches? @@ -919,7 +919,7 @@ static void tag_read_you(struct tagHeader &th, char minorVersion) unmarshallString(th, you.your_name, 30); - you.religion = unmarshallByte(th); + you.religion = static_cast(unmarshallByte(th)); you.piety = unmarshallByte(th); you.invis = unmarshallByte(th); you.conf = unmarshallByte(th); @@ -1173,26 +1173,28 @@ static void tag_read_you_items(struct tagHeader &th, char minorVersion) static void tag_read_you_dungeon(struct tagHeader &th) { int i,j; - char count_c; + int count_c; short count_s; // how many unique creatures? - count_c = unmarshallByte(th); + count_c = unmarshallShort(th); + you.unique_creatures.init(false); for (j = 0; j < count_c; ++j) - you.unique_creatures[j] = unmarshallByte(th); + { + const bool created = static_cast(unmarshallByte(th)); + + if (j < NUM_MONSTERS) + you.unique_creatures[j] = created; + } // how many branches? count_c = unmarshallByte(th); for (j = 0; j < count_c; ++j) branches[j].startdepth = unmarshallLong(th); - cprintf("found %d branches\n", (int)count_c); - count_s = unmarshallShort(th); - cprintf("found %d maxlevel\n", (int)count_s); for (i = 0; i < count_s; ++i) { -// cprintf("i = %d\n", i); for (j = 0; j < count_c; ++j) tmp_file_pairs[i][j] = unmarshallBoolean(th); } diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index bf6fc3b1fc..03b1669855 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -3398,9 +3398,6 @@ void viewwindow(bool draw_it, bool do_updates) losight( env.show, grd, you.x_pos, you.y_pos ); // must be done first - for (count_x = 0; count_x < NUM_STATUE_TYPES; count_x++) - you.visible_statue[count_x] = 0; - for (count_x = 0; count_x < 18; count_x++) { for (count_y = 0; count_y < 18; count_y++) -- cgit v1.2.3-54-g00ecf