From 35914ed1865cac094da3fc1c2591a8541a77d33d Mon Sep 17 00:00:00 2001 From: cohrs Date: Thu, 11 Jul 2002 05:16:27 +0000 Subject: [PATCH] R919 - applying lances Fixes 2 bugs: 1) an impossible() could occur if you applied a lance against a long worm because the code uses thitmonst to do the hitting, but didn't set bhitpos, which is required before calling thitmonst. Add the missing assignment. 2) applying a lance would never mark a knight as a caitiff. Added a new check_caitiff function and called it from the 2 existing checks and in the lance code. --- doc/fixes34.1 | 2 ++ include/extern.h | 1 + src/apply.c | 2 ++ src/dokick.c | 9 +-------- src/uhitm.c | 25 +++++++++++++++++-------- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/doc/fixes34.1 b/doc/fixes34.1 index c1629c293..68b8c24d1 100644 --- a/doc/fixes34.1 +++ b/doc/fixes34.1 @@ -153,6 +153,8 @@ stone to flesh on a statue with contents would lose the contents if a monster was on the same location as the statue steed movement would use your speed if walking step by step kicking a known, unseen monster would sometimes leave behind an extra I symbol +applying a lance against a long worm could cause an impossible +a knight applying a lance did not do a caitiff check Platform- and/or Interface-Specific Fixes diff --git a/include/extern.h b/include/extern.h index 7a5db9434..335c4615e 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1983,6 +1983,7 @@ E void NDECL(u_init); E void FDECL(hurtmarmor,(struct monst *,int)); E boolean FDECL(attack_checks, (struct monst *,struct obj *)); +E void FDECL(check_caitiff, (struct monst *)); E schar FDECL(find_roll_to_hit, (struct monst *)); E boolean FDECL(attack, (struct monst *)); E boolean FDECL(hmon, (struct monst *,struct obj *,int)); diff --git a/src/apply.c b/src/apply.c index 8d9b53bf3..d70b7a2c2 100644 --- a/src/apply.c +++ b/src/apply.c @@ -2367,6 +2367,8 @@ use_pole (obj) if ((mtmp = m_at(cc.x, cc.y)) != (struct monst *)0) { int oldhp = mtmp->mhp; + bhitpos = cc; + check_caitiff(mtmp); (void) thitmonst(mtmp, uwep); /* check the monster's HP because thitmonst() doesn't return * an indication of whether it hit. Not perfect (what if it's a diff --git a/src/dokick.c b/src/dokick.c index ff733cede..52296f51d 100644 --- a/src/dokick.c +++ b/src/dokick.c @@ -61,14 +61,7 @@ register boolean clumsy; if(mon->m_ap_type) seemimic(mon); - /* it is unchivalrous to attack the defenseless or from behind */ - if (Role_if(PM_KNIGHT) && - u.ualign.type == A_LAWFUL && u.ualign.record > -10 && - (!mon->mcanmove || mon->msleeping || - (mon->mflee && !mon->mavenge))) { - You_feel("like a caitiff!"); - adjalign(-1); - } + check_caitiff(mon); /* squeeze some guilt feelings... */ if(mon->mtame) { diff --git a/src/uhitm.c b/src/uhitm.c index b533cb570..84d6f9c0d 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -205,6 +205,22 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */ return(FALSE); } +/* + * It is unchivalrous for a knight to attack the defenseless or from behind. + */ +void +check_caitiff(mtmp) +struct monst *mtmp; +{ + if (Role_if(PM_KNIGHT) && u.ualign.type == A_LAWFUL && + (!mtmp->mcanmove || mtmp->msleeping || + (mtmp->mflee && !mtmp->mavenge)) && + u.ualign.record > -10) { + You("caitiff!"); + adjalign(-1); + } +} + schar find_roll_to_hit(mtmp) register struct monst *mtmp; @@ -215,14 +231,7 @@ register struct monst *mtmp; tmp = 1 + Luck + abon() + find_mac(mtmp) + u.uhitinc + maybe_polyd(youmonst.data->mlevel, u.ulevel); -/* it is unchivalrous to attack the defenseless or from behind */ - if (Role_if(PM_KNIGHT) && u.ualign.type == A_LAWFUL && - (!mtmp->mcanmove || mtmp->msleeping || - (mtmp->mflee && !mtmp->mavenge)) && - u.ualign.record > -10) { - You("caitiff!"); - adjalign(-1); - } + check_caitiff(mtmp); /* attacking peaceful creatures is bad for the samurai's giri */ if (Role_if(PM_SAMURAI) && mtmp->mpeaceful &&