]> granicus.if.org Git - nethack/commitdiff
Remember position of monster you hit with polearm
authorPasi Kallinen <paxed@alt.org>
Fri, 27 Mar 2015 21:29:30 +0000 (23:29 +0200)
committerPasi Kallinen <paxed@alt.org>
Fri, 27 Mar 2015 21:34:13 +0000 (23:34 +0200)
If you hit a monster with a polearm, following polearm applications
will try to automatically suggest the monster's position

doc/fixes35.0
include/context.h
include/patchlevel.h
src/apply.c
src/do.c
src/mon.c
src/restore.c
src/save.c

index 6b59f340fcf56c395f33e0816af5284ec773ec69..601be2ee0a73416697b1ff787a28dcfa3dcc24ee 100644 (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
        act as menu accelerators, toggleable via "menu_objsyms" option
 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
index ebfe1ada7fd4786ef6249b2d903acd3bf46c73a2..7a73344afde873dd13fbf39a7890503d1823c3dd 100644 (file)
@@ -73,6 +73,11 @@ struct warntype_info {
        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 {
        unsigned ident;         /* social security number for each monster */
        unsigned no_of_wizards; /* 0, 1 or 2 (wizard and his shadow) */
@@ -103,6 +108,7 @@ struct context_info {
        struct book_info spbook;
        struct takeoff_info takeoff;
        struct warntype_info warntype;
+       struct polearm_info polearm;
 };
 
 extern NEARDATA struct context_info context;
index eab90e89fd59822291b62e9c2f2f87394733fb51..1b0ebf24159886ca6af159e97785853a3493a7f0 100644 (file)
@@ -14,7 +14,7 @@
  * Incrementing EDITLEVEL can be used to force invalidation of old bones
  * and save files.
  */
-#define EDITLEVEL      58
+#define EDITLEVEL      59
 
 #define COPYRIGHT_BANNER_A \
 "NetHack, Copyright 1985-2015"
index fd3193fb34b0800287b150fd7c02e2b40bf6b856..185ca80ad7f36aa94fd38e28dce44612ba60504c 100644 (file)
@@ -2539,6 +2539,7 @@ use_pole(obj)
        int res = 0, typ, max_range, min_range, glyph;
        coord cc;
        struct monst *mtmp;
+       struct monst *hitm = context.polearm.hitmon;
 
        /* Are you allowed to use the pole? */
        if (u.uswallow) {
@@ -2553,8 +2554,13 @@ use_pole(obj)
 
        /* Prompt for a location */
        pline(where_to_hit);
-       cc.x = u.ux;
-       cc.y = u.uy;
+       if (hitm && !DEADMONSTER(hitm) && cansee(hitm->mx, hitm->my)) {
+           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)
            return res; /* ESC; uses turn iff polearm became wielded */
 
@@ -2596,11 +2602,13 @@ use_pole(obj)
            return res;
        }
 
+       context.polearm.hitmon = NULL;
        /* Attack the monster there */
        bhitpos = cc;
        if ((mtmp = m_at(bhitpos.x, bhitpos.y)) != (struct monst *)0) {
            if (attack_checks(mtmp, uwep)) return res;
            if (overexertion()) return 1; /* burn nutrition; maybe pass out */
+           context.polearm.hitmon = mtmp;
            check_caitiff(mtmp);
            notonhead = (bhitpos.x != mtmp->mx || bhitpos.y != mtmp->my);
            (void) thitmonst(mtmp, uwep);
index b387752d64a1b5566b4fd9eef9e27274a439806e..c690ad4faffde67d9f8d5a367cc40270200f7071 100644 (file)
--- a/src/do.c
+++ b/src/do.c
@@ -1402,6 +1402,7 @@ boolean at_stairs, falling, portal;
        /* assume this will always return TRUE when changing level */
        (void) in_out_region(u.ux, u.uy);
        (void) pickup(1);
+       context.polearm.hitmon = NULL;
 }
 
 STATIC_OVL void
index d9bc63d6d0005a435b45100ea541d2b4bcbaabd7..607845e7abf2782726f760cee7006452b429640d 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -1237,6 +1237,8 @@ dmonsfree()
     for (mtmp = &fmon; *mtmp;) {
        freetmp = *mtmp;
        if (freetmp->mhp <= 0 && !freetmp->isgd) {
+           if (freetmp == context.polearm.hitmon)
+               context.polearm.hitmon = NULL;
            *mtmp = freetmp->nmon;
            dealloc_monst(freetmp);
            count++;
index 4e4502b53e2060bc73d430abcbeab932c98137da..be1126be853c08f3cb8b2a866cc13cfa5c32d1fb 100644 (file)
@@ -446,6 +446,10 @@ boolean ghostly;
                if (mtmp->isshk) restshk(mtmp, ghostly);
                if (mtmp->ispriest) restpriest(mtmp, ghostly);
 
+               if (!ghostly) {
+                   if (mtmp->m_id == context.polearm.m_id)
+                       context.polearm.hitmon = mtmp;
+               }
                mtmp2 = mtmp;
        }
        if(first && mtmp2->nmon){
index f94b1857c0b65331319199f32e3bc0bddecb8feb..4a4363e9ecb28f6466cc3a13bf423de2adfecd7d 100644 (file)
@@ -1124,8 +1124,13 @@ register struct monst *mtmp;
            }
            if (mtmp->minvent)
                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);
+           }
            mtmp = mtmp2;
        }
        if (perform_bwrite(mode))