summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Cline <zelgadis@sourceforge.net>2009-11-07 21:05:59 -0800
committerMatthew Cline <zelgadis@sourceforge.net>2009-11-07 21:05:59 -0800
commitee4d8d69cdded564187651f879b618a4fc2538f9 (patch)
treeb33f77d91b9d665b93567bcff6e24c6df1b191b6
parent5f88766c2ade9a2061cc477ef7d2cef4fb4af547 (diff)
downloadcrawl-ref-ee4d8d69cdded564187651f879b618a4fc2538f9.tar.gz
crawl-ref-ee4d8d69cdded564187651f879b618a4fc2538f9.zip
Different launchers make different amount of noise
-rw-r--r--crawl-ref/source/item_use.cc60
-rw-r--r--crawl-ref/source/item_use.h2
-rw-r--r--crawl-ref/source/mon-act.cc1
3 files changed, 59 insertions, 4 deletions
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index 28b8c33d3f..79a4a68779 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -2229,6 +2229,59 @@ void _merge_ammo_in_inventory(int slot)
}
}
+void throw_noise(actor* act, const bolt &pbolt, const item_def &ammo)
+{
+ const item_def* launcher = act->weapon();
+
+ if (launcher == NULL)
+ return;
+
+ ASSERT(launcher->base_type == OBJ_WEAPONS);
+
+ if (is_launched(act, launcher, ammo) != LRET_LAUNCHED)
+ return;
+
+ // Throwing and blowguns are silent...
+ int level = 0;
+ const char* msg = NULL;
+
+ switch(launcher->sub_type)
+ {
+ case WPN_BLOWGUN:
+ return;
+
+ case WPN_SLING:
+ level = 1;
+ msg = "You hear a whirring sound.";
+ break;
+ case WPN_HAND_CROSSBOW:
+ level = 3;
+ msg = "You hear a small twanging sound.";
+ break;
+ case WPN_BOW:
+ level = 5;
+ msg = "You hear a twanging sound.";
+ break;
+ case WPN_LONGBOW:
+ level = 6;
+ msg = "You hear a loud twanging sound.";
+ break;
+ case WPN_CROSSBOW:
+ level = 7;
+ msg = "You hear a thunk.";
+ break;
+
+ default:
+ DEBUGSTR("Invalid launcher '%s'",
+ launcher->name(DESC_PLAIN).c_str());
+ return;
+ }
+ if (act->atype() == ACT_PLAYER || you.can_see(act))
+ msg = NULL;
+
+ noisy(level, act->pos(), msg, act->mindex());
+}
+
// throw_it - currently handles player throwing only. Monster
// throwing is handled in mon-act:_mons_throw()
// Note: If teleport is true, assume that pbolt is already set up,
@@ -3016,11 +3069,10 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus,
canned_msg(MSG_EMPTY_HANDED);
}
- // Throwing and blowguns are silent...
- if (projected == LRET_LAUNCHED && lnchType != WPN_BLOWGUN)
- noisy(6, you.pos());
+ throw_noise(&you, pbolt, thrown);
- // ...but any monster nearby can see that something has been thrown.
+ // ...any monster nearby can see that something has been thrown, even
+ // if it didn't make any noise.
alert_nearby_monsters();
if (ammo_ided)
diff --git a/crawl-ref/source/item_use.h b/crawl-ref/source/item_use.h
index cc8522b76a..8df61d07b6 100644
--- a/crawl-ref/source/item_use.h
+++ b/crawl-ref/source/item_use.h
@@ -99,6 +99,8 @@ bool enchant_armour(int &ac_change, bool quiet, item_def &arm);
bool setup_missile_beam(const actor *actor, bolt &beam, item_def &item,
std::string &ammo_name, bool &returning);
+void throw_noise(actor* act, const bolt &pbolt, const item_def &ammo);
+
bool throw_it(bolt &pbolt, int throw_2, bool teleport = false,
int acc_bonus = 0, dist *target = NULL);
diff --git a/crawl-ref/source/mon-act.cc b/crawl-ref/source/mon-act.cc
index 2547054527..aaf47240cd 100644
--- a/crawl-ref/source/mon-act.cc
+++ b/crawl-ref/source/mon-act.cc
@@ -1336,6 +1336,7 @@ static bool _mons_throw(struct monsters *monster, struct bolt &pbolt,
set_ident_flags(mitm[hand_used], ISFLAG_KNOW_TYPE);
}
}
+ throw_noise(monster, pbolt, item);
// [dshaligram] When changing bolt names here, you must edit
// hiscores.cc (scorefile_entry::terse_missile_cause()) to match.