From 3846460d200480f3af4c345c4137f9bbee818b24 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Mon, 31 Mar 2008 19:09:19 +0000 Subject: Give monsters better natural regeneration increasing with HD. Monsters will still never heal more than 1 hp per turn. Increase royal jelly movement speed, hp and attack damage. The royal jelly now spits out high-level jellies when it takes a high-damage hit of any kind. No experience for the expelled jellies, given that they're technically part of the royal jelly, and the royal jelly already gives a heap of xp. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3985 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/monplace.cc | 82 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 3 deletions(-) (limited to 'crawl-ref/source/monplace.cc') diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc index efea2a6e94..e0aa3b0d3d 100644 --- a/crawl-ref/source/monplace.cc +++ b/crawl-ref/source/monplace.cc @@ -1579,6 +1579,84 @@ int mons_place( int mon_type, beh_type behaviour, int target, bool summoned, return (mid); } // end mons_place() +static dungeon_feature_type _monster_habitat_feature(int mtype) +{ + return ((mtype == RANDOM_MONSTER) ? DNGN_FLOOR + : habitat2grid( mons_habitat_by_type(mtype) )); +} + +class newmons_square_find : public travel_pathfind +{ +private: + dungeon_feature_type grid_wanted; + coord_def start; + int maxdistance; + + int best_distance; + int nfound; +public: + // Terrain that we can't spawn on, but that we can skip through. + std::set passable; +public: + newmons_square_find(dungeon_feature_type grdw, + const coord_def &pos, + int maxdist = 0) + : grid_wanted(grdw), start(pos), maxdistance(maxdist), + best_distance(0), nfound(0) + { + } + + coord_def pathfind() + { + set_floodseed(start); + return travel_pathfind::pathfind(RMODE_EXPLORE); + } + + bool path_flood(const coord_def &c, const coord_def &dc) + { + if (best_distance && traveled_distance > best_distance) + return (true); + + if (!in_bounds(dc) + || (maxdistance > 0 && traveled_distance > maxdistance)) + { + return (false); + } + if (!grid_compatible(grid_wanted, grd(dc), true)) + { + if (passable.find(grd(dc)) != passable.end()) + good_square(dc); + return (false); + } + if (mgrd(dc) == NON_MONSTER && dc != you.pos() + && one_chance_in(++nfound)) + { + greedy_dist = traveled_distance; + greedy_place = dc; + best_distance = traveled_distance; + } + else + { + good_square(dc); + } + return (false); + } +}; + +/* + * Finds a square for a monster of the given class, pathfinding + * through only contiguous squares of habitable terrain. + */ +coord_def find_newmons_square_contiguous(monster_type mons_class, + const coord_def &start, + int distance) +{ + newmons_square_find nmfind(_monster_habitat_feature(mons_class), + start, distance); + const coord_def p = nmfind.pathfind(); + return (in_bounds(p)? p : coord_def(-1, -1)); +} + coord_def find_newmons_square(int mons_class, int x, int y) { FixedVector < char, 2 > empty; @@ -1590,9 +1668,7 @@ coord_def find_newmons_square(int mons_class, int x, int y) if (mons_class == WANDERING_MONSTER) mons_class = RANDOM_MONSTER; - dungeon_feature_type spcw = - ((mons_class == RANDOM_MONSTER) ? DNGN_FLOOR - : habitat2grid( mons_habitat_by_type(mons_class) )); + const dungeon_feature_type spcw = _monster_habitat_feature(mons_class); // Might be better if we chose a space and tried to match the monster // to it in the case of RANDOM_MONSTER, that way if the target square -- cgit v1.2.3-54-g00ecf