Remember position of monster you hit with polearm

If you hit a monster with a polearm, following polearm applications
will try to automatically suggest the monster's position
This commit is contained in:
Pasi Kallinen
2015-03-27 23:34:13 +02:00
parent 5c87641985
commit 5bb4a02ffe
8 changed files with 31 additions and 4 deletions
+1
View File
@@ -886,6 +886,7 @@ after object loss through polyshudder don't get left hiding under nothing
show object symbols in menu headings in menus where those object symbols show object symbols in menu headings in menus where those object symbols
act as menu accelerators, toggleable via "menu_objsyms" option act as menu accelerators, toggleable via "menu_objsyms" option
show t-shirt text at end of game inventory disclose show t-shirt text at end of game inventory disclose
hitting with a polearm remembers the position of the last monster you hit
Platform- and/or Interface-Specific Fixes Platform- and/or Interface-Specific Fixes
+6
View File
@@ -73,6 +73,11 @@ struct warntype_info {
short speciesidx; /* index of above in mons[] (for save/restore) */ short speciesidx; /* index of above in mons[] (for save/restore) */
}; };
struct polearm_info {
struct monst *hitmon; /* the monster we tried to hit last */
unsigned m_id; /* monster id of hitmon, in save file */
};
struct context_info { struct context_info {
unsigned ident; /* social security number for each monster */ unsigned ident; /* social security number for each monster */
unsigned no_of_wizards; /* 0, 1 or 2 (wizard and his shadow) */ unsigned no_of_wizards; /* 0, 1 or 2 (wizard and his shadow) */
@@ -103,6 +108,7 @@ struct context_info {
struct book_info spbook; struct book_info spbook;
struct takeoff_info takeoff; struct takeoff_info takeoff;
struct warntype_info warntype; struct warntype_info warntype;
struct polearm_info polearm;
}; };
extern NEARDATA struct context_info context; extern NEARDATA struct context_info context;
+1 -1
View File
@@ -14,7 +14,7 @@
* Incrementing EDITLEVEL can be used to force invalidation of old bones * Incrementing EDITLEVEL can be used to force invalidation of old bones
* and save files. * and save files.
*/ */
#define EDITLEVEL 58 #define EDITLEVEL 59
#define COPYRIGHT_BANNER_A \ #define COPYRIGHT_BANNER_A \
"NetHack, Copyright 1985-2015" "NetHack, Copyright 1985-2015"
+10 -2
View File
@@ -2539,6 +2539,7 @@ use_pole(obj)
int res = 0, typ, max_range, min_range, glyph; int res = 0, typ, max_range, min_range, glyph;
coord cc; coord cc;
struct monst *mtmp; struct monst *mtmp;
struct monst *hitm = context.polearm.hitmon;
/* Are you allowed to use the pole? */ /* Are you allowed to use the pole? */
if (u.uswallow) { if (u.uswallow) {
@@ -2553,8 +2554,13 @@ use_pole(obj)
/* Prompt for a location */ /* Prompt for a location */
pline(where_to_hit); pline(where_to_hit);
cc.x = u.ux; if (hitm && !DEADMONSTER(hitm) && cansee(hitm->mx, hitm->my)) {
cc.y = u.uy; cc.x = hitm->mx;
cc.y = hitm->my;
} else {
cc.x = u.ux;
cc.y = u.uy;
}
if (getpos(&cc, TRUE, "the spot to hit") < 0) if (getpos(&cc, TRUE, "the spot to hit") < 0)
return res; /* ESC; uses turn iff polearm became wielded */ return res; /* ESC; uses turn iff polearm became wielded */
@@ -2596,11 +2602,13 @@ use_pole(obj)
return res; return res;
} }
context.polearm.hitmon = NULL;
/* Attack the monster there */ /* Attack the monster there */
bhitpos = cc; bhitpos = cc;
if ((mtmp = m_at(bhitpos.x, bhitpos.y)) != (struct monst *)0) { if ((mtmp = m_at(bhitpos.x, bhitpos.y)) != (struct monst *)0) {
if (attack_checks(mtmp, uwep)) return res; if (attack_checks(mtmp, uwep)) return res;
if (overexertion()) return 1; /* burn nutrition; maybe pass out */ if (overexertion()) return 1; /* burn nutrition; maybe pass out */
context.polearm.hitmon = mtmp;
check_caitiff(mtmp); check_caitiff(mtmp);
notonhead = (bhitpos.x != mtmp->mx || bhitpos.y != mtmp->my); notonhead = (bhitpos.x != mtmp->mx || bhitpos.y != mtmp->my);
(void) thitmonst(mtmp, uwep); (void) thitmonst(mtmp, uwep);
+1
View File
@@ -1402,6 +1402,7 @@ boolean at_stairs, falling, portal;
/* assume this will always return TRUE when changing level */ /* assume this will always return TRUE when changing level */
(void) in_out_region(u.ux, u.uy); (void) in_out_region(u.ux, u.uy);
(void) pickup(1); (void) pickup(1);
context.polearm.hitmon = NULL;
} }
STATIC_OVL void STATIC_OVL void
+2
View File
@@ -1237,6 +1237,8 @@ dmonsfree()
for (mtmp = &fmon; *mtmp;) { for (mtmp = &fmon; *mtmp;) {
freetmp = *mtmp; freetmp = *mtmp;
if (freetmp->mhp <= 0 && !freetmp->isgd) { if (freetmp->mhp <= 0 && !freetmp->isgd) {
if (freetmp == context.polearm.hitmon)
context.polearm.hitmon = NULL;
*mtmp = freetmp->nmon; *mtmp = freetmp->nmon;
dealloc_monst(freetmp); dealloc_monst(freetmp);
count++; count++;
+4
View File
@@ -446,6 +446,10 @@ boolean ghostly;
if (mtmp->isshk) restshk(mtmp, ghostly); if (mtmp->isshk) restshk(mtmp, ghostly);
if (mtmp->ispriest) restpriest(mtmp, ghostly); if (mtmp->ispriest) restpriest(mtmp, ghostly);
if (!ghostly) {
if (mtmp->m_id == context.polearm.m_id)
context.polearm.hitmon = mtmp;
}
mtmp2 = mtmp; mtmp2 = mtmp;
} }
if(first && mtmp2->nmon){ if(first && mtmp2->nmon){
+6 -1
View File
@@ -1124,8 +1124,13 @@ register struct monst *mtmp;
} }
if (mtmp->minvent) if (mtmp->minvent)
saveobjchn(fd,mtmp->minvent,mode); saveobjchn(fd,mtmp->minvent,mode);
if (release_data(mode)) if (release_data(mode)) {
if (mtmp == context.polearm.hitmon) {
context.polearm.m_id = mtmp->m_id;
context.polearm.hitmon = NULL;
}
dealloc_monst(mtmp); dealloc_monst(mtmp);
}
mtmp = mtmp2; mtmp = mtmp2;
} }
if (perform_bwrite(mode)) if (perform_bwrite(mode))