|
From: <gi...@cr...> - 2011-08-31 12:40:12
|
via fb4d66978b117d32b0bcea4229ec7c7d834a06a8 (commit)
from 81c39c2b82440da64acdbeb1aaec15b88355fbcf (commit)
-----------------------------------------------------------------------
commit fb4d66978b117d32b0bcea4229ec7c7d834a06a8
Author: Adam Borowski <kil...@an...>
Date: Wed Aug 31 14:38:26 2011 +0200
Grow more webs as time passes.
-----------------------------------------------------------------------
Summary of changes:
crawl-ref/source/dungeon.cc | 48 +-----------------------------------------
crawl-ref/source/effects.cc | 3 ++
crawl-ref/source/traps.cc | 46 +++++++++++++++++++++++++++++++++++++++++
crawl-ref/source/traps.h | 1 +
4 files changed, 52 insertions(+), 46 deletions(-)
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index 8fa53ee..7909a6a 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -2911,50 +2911,6 @@ static bool _shaft_is_in_corridor(const coord_def& c)
return (false);
}
-static void _place_webs(int num)
-{
- int slot = 0;
- for (int j = 0; j < num; j++)
- {
- for (;; slot++)
- {
- if (slot >= MAX_TRAPS)
- return;
- if (env.trap[++slot].type == TRAP_UNASSIGNED)
- break;
- };
- trap_def& ts(env.trap[slot]);
-
- int tries;
- // TODO: reuse this logic to place new traps at regular intervals (out of LOS)
- for (tries = 0; tries < 200; ++tries)
- {
- ts.pos.x = random2(GXM);
- ts.pos.y = random2(GYM);
- if (in_bounds(ts.pos)
- && grd(ts.pos) == DNGN_FLOOR
- && !map_masked(ts.pos, MMT_NO_TRAP))
- {
- // Calculate weight
- int weight = 0;
- for (adjacent_iterator ai(ts.pos); ai; ++ai)
- if (feat_is_solid(grd(*ai)))
- weight++;
- if (one_chance_in(10 - weight))
- break;
- }
- }
-
- if (tries >= 200)
- break;
-
- ts.type = TRAP_WEB;
- grd(ts.pos) = DNGN_UNDISCOVERED_TRAP;
- env.tgrid(ts.pos) = slot;
- ts.prepare_ammo();
- }
-}
-
static void _place_traps(int level_number)
{
const int num_traps = num_traps_for_place(level_number);
@@ -3010,9 +2966,9 @@ static void _place_traps(int level_number)
}
if (player_in_branch(BRANCH_SPIDER_NEST))
- _place_webs(400 - num_traps) / 2);
+ place_webs((400 - num_traps) / 2);
else if (player_in_branch(BRANCH_CRYPT))
- _place_webs(random2(20));
+ place_webs(random2(20));
}
static void _dgn_place_feature_at_random_floor_square(dungeon_feature_type feat,
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index d407c10..b40bd43 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -2402,6 +2402,9 @@ void handle_time()
if (you.religion == GOD_JIYVA && one_chance_in(25))
jiyva_eat_offlevel_items();
+
+ if (player_in_branch(BRANCH_SPIDER_NEST) && coinflip())
+ place_webs(random2(10));
}
// Move monsters around to fake them walking around while player was
diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc
index 0a8dd76..900689c 100644
--- a/crawl-ref/source/traps.cc
+++ b/crawl-ref/source/traps.cc
@@ -20,6 +20,7 @@
#include "delay.h"
#include "describe.h"
#include "directn.h"
+#include "dungeon.h"
#include "exercise.h"
#include "map_knowledge.h"
#include "itemname.h"
@@ -1991,3 +1992,48 @@ int count_traps(trap_type ttyp)
num++;
return num;
}
+
+void place_webs(int num)
+{
+ int slot = 0;
+ for (int j = 0; j < num; j++)
+ {
+ for (;; slot++)
+ {
+ if (slot >= MAX_TRAPS)
+ return;
+ if (env.trap[++slot].type == TRAP_UNASSIGNED)
+ break;
+ };
+ trap_def& ts(env.trap[slot]);
+
+ int tries;
+ // this is hardly ever enough to place many webs, most of the time
+ // it will fail prematurely. Which is fine.
+ for (tries = 0; tries < 200; ++tries)
+ {
+ ts.pos.x = random2(GXM);
+ ts.pos.y = random2(GYM);
+ if (in_bounds(ts.pos)
+ && grd(ts.pos) == DNGN_FLOOR
+ && !map_masked(ts.pos, MMT_NO_TRAP))
+ {
+ // Calculate weight
+ int weight = 0;
+ for (adjacent_iterator ai(ts.pos); ai; ++ai)
+ if (feat_is_solid(grd(*ai)))
+ weight++;
+ if (one_chance_in(10 - weight))
+ break;
+ }
+ }
+
+ if (tries >= 200)
+ break;
+
+ ts.type = TRAP_WEB;
+ grd(ts.pos) = DNGN_UNDISCOVERED_TRAP;
+ env.tgrid(ts.pos) = slot;
+ ts.prepare_ammo();
+ }
+}
diff --git a/crawl-ref/source/traps.h b/crawl-ref/source/traps.h
index 468b281..55bf0a5 100644
--- a/crawl-ref/source/traps.h
+++ b/crawl-ref/source/traps.h
@@ -47,4 +47,5 @@ trap_type random_trap_for_place(int level_number = -1,
const level_id &place = level_id::current());
int count_traps(trap_type ttyp);
+void place_webs(int num);
#endif
--
Dungeon Crawl Stone Soup
|