Skip to content

Commit 087f562

Browse files
committed
Fix: allow spear traps to be disarmed.
Calling this a fix due to an issue encountered in Mines' End, where the buried chest that has the magic key could also have a trap spawn on top of its location. All other traps can be removed through various means without too much effort, except for spear traps. A spear trap forming on top of the buried chest made it almost impossible to dig up the chest. Disarming a spear trap has a chance to produce one spear (type of spear is random). Pulled this code from Hack'EM (slightly modified).
1 parent 0040220 commit 087f562

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

doc/evilhack-changelog.md

+2
Original file line numberDiff line numberDiff line change
@@ -3341,3 +3341,5 @@ The following changes to date are:
33413341
- Fix: a couple cases of bracers preventing wielding bimanual weapons
33423342
- Restore auto-suppression of some dangerous attacks
33433343
- Fix: crash when examining discoveries with '`' in certain cases
3344+
- Fix: allow spear traps to be disarmed
3345+

src/trap.c

+39
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ STATIC_DCL int FDECL(try_disarm, (struct trap *, BOOLEAN_P));
2727
STATIC_DCL void FDECL(reward_untrap, (struct trap *, struct monst *));
2828
STATIC_DCL int FDECL(disarm_holdingtrap, (struct trap *));
2929
STATIC_DCL int FDECL(disarm_landmine, (struct trap *));
30+
STATIC_DCL int FDECL(disarm_spear_trap, (struct trap *));
3031
STATIC_DCL int FDECL(disarm_squeaky_board, (struct trap *));
3132
STATIC_DCL int FDECL(disarm_shooting_trap, (struct trap *, int));
3233
STATIC_DCL void FDECL(clear_conjoined_pits, (struct trap *));
@@ -4976,6 +4977,42 @@ struct trap *ttmp;
49764977
return 1;
49774978
}
49784979

4980+
STATIC_OVL int
4981+
disarm_spear_trap(ttmp)
4982+
struct trap *ttmp;
4983+
{
4984+
int fails = try_disarm(ttmp, FALSE);
4985+
4986+
if (fails < 2)
4987+
return fails;
4988+
You("disarm %s spear trap.", the_your[ttmp->madeby_u]);
4989+
4990+
if (rnl(10) > 5) {
4991+
switch (rn2(5)) {
4992+
case 0:
4993+
cnv_trap_obj(SPEAR, 1, ttmp, FALSE);
4994+
break;
4995+
case 1:
4996+
cnv_trap_obj(ELVEN_SPEAR, 1, ttmp, FALSE);
4997+
break;
4998+
case 2:
4999+
cnv_trap_obj(ORCISH_SPEAR, 1, ttmp, FALSE);
5000+
break;
5001+
case 3:
5002+
cnv_trap_obj(DWARVISH_SPEAR, 1, ttmp, FALSE);
5003+
break;
5004+
case 4:
5005+
cnv_trap_obj(DARK_ELVEN_SPEAR, 1, ttmp, FALSE);
5006+
break;
5007+
}
5008+
} else {
5009+
pline_The("spear breaks!");
5010+
deltrap(ttmp);
5011+
newsym(u.ux + u.dx, u.uy + u.dy);
5012+
}
5013+
return 1;
5014+
}
5015+
49795016
/* getobj will filter down to cans of grease and known potions of oil */
49805017
static NEARDATA const char oil[] = { ALL_CLASSES, TOOL_CLASS, POTION_CLASS,
49815018
0 };
@@ -5260,6 +5297,8 @@ boolean force;
52605297
return disarm_shooting_trap(ttmp, ARROW);
52615298
case BOLT_TRAP:
52625299
return disarm_shooting_trap(ttmp, CROSSBOW_BOLT);
5300+
case SPEAR_TRAP:
5301+
return disarm_spear_trap(ttmp);
52635302
case PIT:
52645303
case SPIKED_PIT:
52655304
if (here) {

0 commit comments

Comments
 (0)