From 41f78a696154902ae7baa22e116d39b6d321fc62 Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Tue, 21 Jul 2009 17:53:49 +0000 Subject: Make fish on dry land (due to Feawn's Sunlight power) flop about and lose hit points until back in water, using ENCH_AQUATIC_LAND. (Bug 2824663) Also fix tiles compilation (patch 2824632) and add DATA_DIR_PATH to tiled icons (patch 2824635). Both patches (and some more) by Trent W. Buck. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10364 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/docs/crawl.6 | 4 +-- crawl-ref/source/AppHdr.h | 2 ++ crawl-ref/source/command.cc | 4 +-- crawl-ref/source/debug.cc | 4 +-- crawl-ref/source/enum.h | 7 ++--- crawl-ref/source/fight.cc | 5 ++-- crawl-ref/source/files.cc | 2 ++ crawl-ref/source/misc.cc | 7 +++-- crawl-ref/source/mon-util.cc | 38 ++++++++++++++++++++++++--- crawl-ref/source/monstuff.cc | 50 +++++++++++++++++++++++++++++++++--- crawl-ref/source/player.cc | 2 +- crawl-ref/source/rltiles/dc-misc.txt | 2 +- crawl-ref/source/spells2.cc | 30 +++++++++++++--------- crawl-ref/source/spells3.cc | 43 +++++++++++++++++-------------- crawl-ref/source/tilesdl.cc | 9 +++++-- 15 files changed, 155 insertions(+), 54 deletions(-) diff --git a/crawl-ref/docs/crawl.6 b/crawl-ref/docs/crawl.6 index 846a2e5e8c..c029c0ed64 100644 --- a/crawl-ref/docs/crawl.6 +++ b/crawl-ref/docs/crawl.6 @@ -1,11 +1,11 @@ .TH CRAWL 6 .SH NAME -crawl - play the roguelike game of crawl +crawl \- play the roguelike game of crawl .SH SYNOPSIS .BR crawl [options] .PP -Use the "-help" option to get a list of command line options and their descriptions. +Use the "\-help" option to get a list of command line options and their descriptions. .SH DESCRIPTION Crawl is a fun game in the grand tradition of games like Rogue, Hack, and Moria. Your objective is to travel deep into a subterranean cave complex and diff --git a/crawl-ref/source/AppHdr.h b/crawl-ref/source/AppHdr.h index f417f201ab..3c91b2ef07 100644 --- a/crawl-ref/source/AppHdr.h +++ b/crawl-ref/source/AppHdr.h @@ -112,7 +112,9 @@ #define USE_MORE_SECURE_SEED // Use POSIX regular expressions + #ifndef REGEX_PCRE #define REGEX_POSIX + #endif // If you have libpcre, you can use that instead of POSIX regexes - // uncomment the line below and add -lpcre to your makefile. diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index 5524e29522..76e8ac5479 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -1663,8 +1663,8 @@ static bool _find_description(bool &again, std::string& error_inout) else { error_inout = "No matching "; - error_inout += type; - error_inout += "s."; + error_inout += pluralise(type); + error_inout += "."; } return (false); } diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index 5758a05bc3..1d983b8072 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -6605,10 +6605,10 @@ void do_crash_dump() fprintf(file, "dlua stack:" EOL); print_dlua_stack(); - // Lastly try to dump the Lua persistant data and the contents of the Lua + // Lastly try to dump the Lua persistent data and the contents of the Lua // markers, since actually running Lua code has the greatest chance of // crashing. - fprintf(file, "Lua persistant data:" EOL); + fprintf(file, "Lua persistent data:" EOL); fprintf(file, "<<<<<<<<<<<<<<<<<<<<<<" EOL); _debug_dump_lua_persist(file); fprintf(file, ">>>>>>>>>>>>>>>>>>>>>>" EOL EOL); diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 4d942ddb2d..e168b64b5e 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -1252,18 +1252,19 @@ enum enchant_type ENCH_SLEEPY, // Monster can't wake until this wears off. ENCH_FATIGUE, // Post-berserk fatigue. ENCH_HELD, // Caught in a net. - ENCH_BATTLE_FRENZY, // 25 -- Monster is in a battle frenzy + ENCH_BATTLE_FRENZY, // 25 -- Monster is in a battle frenzy ENCH_NEUTRAL, ENCH_PETRIFYING, ENCH_PETRIFIED, ENCH_LOWERED_MR, - ENCH_SOUL_RIPE, + ENCH_SOUL_RIPE, // 30 ENCH_SLOWLY_DYING, ENCH_EATS_ITEMS, + ENCH_AQUATIC_LAND, // Water monsters lose hp while on land. // Update enchantment names in mon-util.cc when adding or removing // enchantments. - NUM_ENCHANTMENTS + NUM_ENCHANTMENTS // 34 }; enum enchant_retval diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 1802e37ac2..4c53fc9b84 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -3519,9 +3519,10 @@ void melee_attack::player_apply_staff_damage() break; default: - mpr("You're wielding some staff I've never heard of! (fight.cc)"); + mpr("You're wielding some staff I've never heard of! (fight.cc)", + MSGCH_ERROR); break; - } // end switch + } if (special_damage > 0) { diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index 2d0a20f7e4..1b22578dd1 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -461,8 +461,10 @@ void assert_read_safe_path(const std::string &path) throw (std::string) throw make_stringf("\"%s\" is an absolute path.", path.c_str()); if (path.find("..") != std::string::npos) + { throw make_stringf("\"%s\" contains \"..\" sequences.", path.c_str()); + } #endif // Path is okay. diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 5c98c97a4e..aabdcea2a9 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -1473,7 +1473,7 @@ static void set_entry_cause(entry_cause_type default_cause, } } -static int runes_in_pack() +static int runes_in_pack(std::vector &runes) { int num_runes = 0; @@ -1484,6 +1484,8 @@ static int runes_in_pack() && you.inv[i].sub_type == MISC_RUNE_OF_ZOT) { num_runes += you.inv[i].quantity; + for (int q = 1; runes.size() < 3 && q < you.inv[i].quantity; ++q) + runes.push_back(you.inv[i].plus); } } @@ -2123,7 +2125,8 @@ void down_stairs( int old_level, dungeon_feature_type force_stair, if (stair_find == DNGN_ENTER_ZOT && !you.opened_zot) { - const int num_runes = runes_in_pack(); + std::vector runes; + const int num_runes = runes_in_pack(runes); if (num_runes < NUMBER_OF_RUNES_NEEDED) { diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index fc5de18c16..a47e025a88 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -7261,6 +7261,27 @@ void monsters::apply_enchantment(const mon_enchant &me) decay_enchantment(me, false); break; + case ENCH_AQUATIC_LAND: + // Aquatic monsters lose hit points every turn they spend on dry land. + ASSERT(mons_habitat(this) == HT_WATER + && !grid_is_watery( grd(pos()) )); + + // Zombies don't take damage from flopping about on land. + if (mons_is_zombified(this)) + break; + + // We don't have a reasonable agent to give. + // Don't clean up the monster in order to credit properly. + hurt(NULL, 1 + random2(5), BEAM_NONE, false); + + // Credit the kill. + if (hit_points < 1) + { + monster_die(this, me.killer(), me.kill_agent()); + break; + } + break; + case ENCH_HELD: { if (mons_is_stationary(this) || mons_cannot_act(this) @@ -7900,7 +7921,18 @@ void monsters::apply_location_effects(const coord_def &oldpos) if (oldpos != pos()) dungeon_events.fire_position_event(DET_MONSTER_MOVED, pos()); - // monsters stepping on traps: + if (alive() && has_ench(ENCH_AQUATIC_LAND)) + { + if (!grid_is_watery( grd(pos()) )) + simple_monster_message(this, " flops around on dry land!"); + else if (!grid_is_watery( grd(oldpos) )) + { + simple_monster_message(this, " dives back into the water!"); + del_ench(ENCH_AQUATIC_LAND); + } + } + + // Monsters stepping on traps: trap_def* ptrap = find_trap(pos()); if (ptrap) ptrap->trigger(*this); @@ -8055,7 +8087,7 @@ int monsters::action_energy(energy_use_type et) const // (HT_AMPHIBIOUS_LAND, such as hydras) and those that // favour water (HT_AMPHIBIOUS_WATER, such as merfolk), but // that's something we can think about. - if (mons_class_amphibious(type)) + if (mons_amphibious(this)) return div_rand_round(mu.swim * 7, 10); else return mu.swim; @@ -8279,7 +8311,7 @@ static const char *enchant_names[] = "gloshifter", "shifter", "tp", "wary", "submerged", "short-lived", "paralysis", "sick", "sleep", "fatigue", "held", "blood-lust", "neutral", "petrifying", "petrified", "magic-vulnerable", - "soul-ripe", "decay", "hungry", "bug" + "soul-ripe", "decay", "hungry", "flopping", "bug" }; static const char *_mons_enchantment_name(enchant_type ench) diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index bf3c5b2276..530e768313 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -3963,8 +3963,8 @@ static void _check_wander_target(monsters *mon, bool isPacified = false, if (!can_move) { - can_move = (mons_amphibious(mon)) - ? DNGN_DEEP_WATER : DNGN_SHALLOW_WATER; + can_move = (mons_amphibious(mon) ? DNGN_DEEP_WATER + : DNGN_SHALLOW_WATER); } if (mon->is_travelling()) @@ -8624,7 +8624,7 @@ static bool _monster_move(monsters *monster) if (monster->type == MONS_TRAPDOOR_SPIDER) { if (mons_is_submerged(monster)) - return (false); + return (false); // Trapdoor spiders hide if they can't see their foe. // (Note that friendly trapdoor spiders will thus hide even @@ -8683,6 +8683,50 @@ static bool _monster_move(monsters *monster) return (false); } + // If a water monster is currently flopping around on land, it cannot + // really control where it wants to move, though there's a 50% chance + // of flopping into an adjacent water grid. + if (monster->has_ench(ENCH_AQUATIC_LAND)) + { + std::vector adj_water; + std::vector adj_move; + for (adjacent_iterator ai(monster->pos()); ai; ++ai) + { + if (!grid_is_solid(*ai)) + { + adj_move.push_back(*ai); + if (grid_is_watery(grd(*ai))) + adj_water.push_back(*ai); + } + } + if (adj_move.empty()) + { + simple_monster_message(monster, " flops around on dry land!"); + return (false); + } + + std::vector moves = adj_water; + if (adj_water.empty() || coinflip()) + moves = adj_move; + + coord_def newpos = monster->pos(); + int count = 0; + for (unsigned int i = 0; i < moves.size(); ++i) + if (one_chance_in(++count)) + newpos = moves[i]; + + const monsters *mon2 = monster_at(newpos); + if (newpos == you.pos() && mons_wont_attack(monster) + || (mon2 && mons_wont_attack(monster) == mons_wont_attack(mon2))) + { + + simple_monster_message(monster, " flops around on dry land!"); + return (false); + } + + return _do_move_monster(monster, newpos - monster->pos()); + } + // Let's not even bother with this if mmov is zero. if (mmov.origin()) return (false); diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index b4d8ab8131..a1889aee42 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -1950,7 +1950,7 @@ int player_prot_life(bool calc_unid, bool temp, bool items) return (pl); } -// New player movement speed system... allows for a bit more that +// New player movement speed system... allows for a bit more than // "player runs fast" and "player walks slow" in that the speed is // actually calculated (allowing for centaurs to get a bonus from // swiftness and other such things). Levels of the mutation now diff --git a/crawl-ref/source/rltiles/dc-misc.txt b/crawl-ref/source/rltiles/dc-misc.txt index becfc2e769..95cdeeb603 100644 --- a/crawl-ref/source/rltiles/dc-misc.txt +++ b/crawl-ref/source/rltiles/dc-misc.txt @@ -39,7 +39,7 @@ unseen_monster UNSEEN_CORPSE %corpse 0 %back none dc-dngn/altars/dngn_altar UNSEEN_ALTAR -dc-dngn/dngn_entrance UNSEEN_ENTRANCE +dc-dngn/gateways/dngn_entrance UNSEEN_ENTRANCE %back none mask_deep_water MASK_DEEP_WATER diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index 4c151456e9..878c17a84c 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -1808,7 +1808,6 @@ int create_plant(coord_def & target) bool sunlight() { - int c_size = 5; int x_offset[] = {-1, 0, 0, 0, 1}; int y_offset[] = { 0,-1, 0, 1, 0}; @@ -1872,19 +1871,22 @@ bool sunlight() evap_count++; } - monsters *monster_vic = monster_at(target); + monsters *mons = monster_at(target); - // Pop submerged status (this may be a little too nice - // because it will affect trapdoor spiders, not just fish). - if (monster_vic) - monster_vic->del_ench(ENCH_SUBMERGED); + // Pop submerged status. + if (mons && mons_habitat(mons) == HT_WATER) + { + mons->del_ench(ENCH_SUBMERGED); + if (ftype == DNGN_FLOOR) + mons->add_ench(mon_enchant(ENCH_AQUATIC_LAND, 0, KC_YOU)); + } if (victim) { - if (!monster_vic) + if (!mons) you.backlight(); else - backlight_monsters(target,1,0); + backlight_monsters(target, 1, 0); } else if (one_chance_in(100) && ftype >= DNGN_FLOOR_MIN @@ -2150,10 +2152,8 @@ bool plant_ring_from_fruit() // Returns the number of plants/fungus created int rain(coord_def & target) { - radius_iterator rad(target, LOS_RADIUS, true, true, true); - int spawned_count = 0; - for (; rad; ++rad) + for (radius_iterator rad(target, LOS_RADIUS, true, true, true); rad; ++rad) { // Adjusting the shape of the rainfall slightly to make it look nicer. // I want a threshold of 2.5 on the euclidean distance so a threshold @@ -2197,6 +2197,10 @@ int rain(coord_def & target) grd(*rad) = DNGN_SHALLOW_WATER; // Remove blood stains as well env.map(*rad).property &= ~(FPROP_BLOODY); + + monsters *mon = monster_at(*rad); + if (mon && mon->has_ench(ENCH_AQUATIC_LAND)) + mon->del_ench(ENCH_AQUATIC_LAND); } // We can also turn shallow water into deep water, but we're just going // to skip cases where there is something on the shallow water. @@ -2342,9 +2346,11 @@ bool evolve_flora() coord_def target_square = current_plant->pos(); // Remove the original plant. + // XXX: Why do we destroy the old and create a new plant + // rather than simply upgrade the old plant? monster_die(current_plant, KILL_MISC, NON_MONSTER, true); - monster_type new_species; + monster_type new_species = MONS_PLANT; switch (base_species) { case MONS_PLANT: diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index 6f238654ad..3a815e32e8 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -815,7 +815,7 @@ void equip_undead(const coord_def &a, int corps, int monster, int monnum) default: continue; - } // switch + } // Two different items going into the same slot indicate that // this and further items weren't equipment the monster died @@ -825,10 +825,10 @@ void equip_undead(const coord_def &a, int corps, int monster, int monnum) unwind_var save_speedinc(mon->speed_increment); mon->pickup_item(mitm[objl], false, true); - } // while + } } -static bool _raise_remains(const coord_def &a, int corps, beh_type beha, +static bool _raise_remains(const coord_def &pos, int corps, beh_type beha, unsigned short hitting, god_type god, bool actual, int* mon_index) { @@ -851,45 +851,50 @@ static bool _raise_remains(const coord_def &a, int corps, beh_type beha, // Headless hydras cannot be raised, sorry. if (zombie_type == MONS_HYDRA && number == 0) + { + if (see_grid(pos)) + { + mpr("The zero-headed hydra corpse sways and immediately " + "collapses!"); + } return (false); + } monster_type mon = MONS_PROGRAM_BUG; if (item.sub_type == CORPSE_BODY) { - mon = (mons_zombie_size(item.plus) == Z_SMALL) ? - MONS_ZOMBIE_SMALL : MONS_ZOMBIE_LARGE; + mon = (mons_zombie_size(item.plus) == Z_SMALL) ? MONS_ZOMBIE_SMALL + : MONS_ZOMBIE_LARGE; } else { - mon = (mons_zombie_size(item.plus) == Z_SMALL) ? - MONS_SKELETON_SMALL : MONS_SKELETON_LARGE; + mon = (mons_zombie_size(item.plus) == Z_SMALL) ? MONS_SKELETON_SMALL + : MONS_SKELETON_LARGE; } - const int monster = create_monster( + int monster = create_monster( mgen_data(mon, beha, - 0, 0, a, hitting, + 0, 0, pos, hitting, 0, god, zombie_type, number)); if (mon_index != NULL) *mon_index = monster; - if (monster != -1) - { - const int monnum = item.orig_monnum - 1; + if (monster == -1) + return (false); - if (is_named_corpse(item)) - name_zombie(&menv[monster], monnum, get_corpse_name(item)); + const int monnum = item.orig_monnum - 1; - equip_undead(a, corps, monster, monnum); + if (is_named_corpse(item)) + name_zombie(&menv[monster], monnum, get_corpse_name(item)); - destroy_item(corps); + equip_undead(pos, corps, monster, monnum); - return (true); - } + destroy_item(corps); - return (false); + return (true); } // Note that quiet will *not* suppress the message about a corpse diff --git a/crawl-ref/source/tilesdl.cc b/crawl-ref/source/tilesdl.cc index 11bdc6b964..c84fcd9c30 100644 --- a/crawl-ref/source/tilesdl.cc +++ b/crawl-ref/source/tilesdl.cc @@ -232,11 +232,16 @@ bool TilesFramework::initialise() SDL_EnableUNICODE(true); SDL_WM_SetCaption(CRAWL " " VERSION, CRAWL); + const char *icon_name = +#ifdef DATA_DIR_PATH + DATA_DIR_PATH +#endif #ifdef WIN32TILES - const char *icon_name = "dat/tiles/stone_soup_icon-win32.png"; + "dat/tiles/stone_soup_icon-win32.png"; #else - const char *icon_name = "dat/tiles/stone_soup_icon-32x32.png"; + "dat/tiles/stone_soup_icon-32x32.png"; #endif + SDL_Surface *icon = IMG_Load(icon_name); if (!icon) { -- cgit v1.2.3-54-g00ecf