MCPcopy Create free account
hub / github.com/NetHack/NetHack / dmgval

Function dmgval

src/weapon.c:215–356  ·  view source on GitHub ↗

* dmgval returns an integer representing the damage bonuses * of "otmp" against the monster. */

Source from the content-addressed store, hash-verified

213 * of "otmp" against the monster.
214 */
215int
216dmgval(struct obj *otmp, struct monst *mon)
217{
218 int tmp = 0, otyp = otmp->otyp;
219 struct permonst *ptr = mon->data;
220 boolean Is_weapon = (otmp->oclass == WEAPON_CLASS || is_weptool(otmp));
221
222 if (otyp == CREAM_PIE)
223 return 0;
224
225 if (bigmonst(ptr)) {
226 if (objects[otyp].oc_wldam)
227 tmp = rnd(objects[otyp].oc_wldam);
228 switch (otyp) {
229 case IRON_CHAIN:
230 case CROSSBOW_BOLT:
231 case MORNING_STAR:
232 case PARTISAN:
233 case RUNESWORD:
234 case ELVEN_BROADSWORD:
235 case BROADSWORD:
236 tmp++;
237 break;
238
239 case FLAIL:
240 case RANSEUR:
241 case VOULGE:
242 tmp += rnd(4);
243 break;
244
245 case ACID_VENOM:
246 case HALBERD:
247 case SPETUM:
248 tmp += rnd(6);
249 break;
250
251 case BATTLE_AXE:
252 case BARDICHE:
253 case TRIDENT:
254 tmp += d(2, 4);
255 break;
256
257 case TSURUGI:
258 case DWARVISH_MATTOCK:
259 case TWO_HANDED_SWORD:
260 tmp += d(2, 6);
261 break;
262 }
263 } else {
264 if (objects[otyp].oc_wsdam)
265 tmp = rnd(objects[otyp].oc_wsdam);
266 switch (otyp) {
267 case IRON_CHAIN:
268 case CROSSBOW_BOLT:
269 case MACE:
270 case SILVER_MACE:
271 case WAR_HAMMER:
272 case FLAIL:

Callers 15

hmon_hitmon_weapon_meleeFunction · 0.85
hmon_hitmon_misc_objFunction · 0.85
shade_missFunction · 0.85
mhitm_ad_physFunction · 0.85
flooreffectsFunction · 0.85
digFunction · 0.85
toss_upFunction · 0.85
trapeffect_arrow_trapFunction · 0.85
trapeffect_dart_trapFunction · 0.85
launch_objFunction · 0.85
thitmFunction · 0.85
boomhitFunction · 0.85

Calls 7

rndFunction · 0.85
dFunction · 0.85
shade_glareFunction · 0.85
mon_hates_blessingsFunction · 0.85
mon_hates_silverFunction · 0.85
artifact_lightFunction · 0.85
spec_dbonFunction · 0.85

Tested by

no test coverage detected