magicbane groundwork
To fix Magicbane's message sequencing, its code needs to be redone
substantially. These changes make that easier.
cancel_monst() let caller know whether cancellation succeeds
resist() give artifact weapons a resistance attack rating
vtense() handle monster names and "you" as subjects; checking against
object names and descriptions pointed out a couple of other
words that would have ended up being miscategorized.
This commit is contained in:
@@ -2322,8 +2322,8 @@ E int FDECL(zappable, (struct obj *));
|
||||
E void FDECL(zapnodir, (struct obj *));
|
||||
E int NDECL(dozap);
|
||||
E int FDECL(zapyourself, (struct obj *,BOOLEAN_P));
|
||||
E void FDECL(cancel_monst, (struct monst *,struct obj *,
|
||||
BOOLEAN_P,BOOLEAN_P,BOOLEAN_P));
|
||||
E boolean FDECL(cancel_monst, (struct monst *,struct obj *,
|
||||
BOOLEAN_P,BOOLEAN_P,BOOLEAN_P));
|
||||
E void FDECL(weffects, (struct obj *));
|
||||
E int NDECL(spell_damage_bonus);
|
||||
E const char *FDECL(exclam, (int force));
|
||||
|
||||
35
src/objnam.c
35
src/objnam.c
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)objnam.c 3.4 2002/09/21 */
|
||||
/* SCCS Id: @(#)objnam.c 3.4 2003/02/08 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -1029,6 +1029,19 @@ register const char *verb;
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* various singular words that vtense would otherwise categorize as plural */
|
||||
static const char * const special_subjs[] = {
|
||||
"erinys",
|
||||
"manes", /* this one is ambiguous */
|
||||
"Cyclops",
|
||||
"Hippocrates",
|
||||
"Pelias",
|
||||
"aklys",
|
||||
"amnesia",
|
||||
"paralysis",
|
||||
0
|
||||
};
|
||||
|
||||
/* return form of the verb (input plural) for present tense 3rd person subj */
|
||||
char *
|
||||
vtense(subj, verb)
|
||||
@@ -1037,8 +1050,8 @@ register const char *verb;
|
||||
{
|
||||
char *buf = nextobuf();
|
||||
int len;
|
||||
const char *spot;
|
||||
const char *sp;
|
||||
const char *sp, *spot;
|
||||
const char * const *spec;
|
||||
|
||||
/*
|
||||
* verb is given in plural (without trailing s). Return as input
|
||||
@@ -1054,6 +1067,7 @@ register const char *verb;
|
||||
spot = (const char *)0;
|
||||
for (sp = subj; (sp = index(sp, ' ')) != 0; ++sp) {
|
||||
if (!strncmp(sp, " of ", 4) ||
|
||||
!strncmp(sp, " from ", 6) ||
|
||||
!strncmp(sp, " called ", 8) ||
|
||||
!strncmp(sp, " named ", 7) ||
|
||||
!strncmp(sp, " labeled ", 9)) {
|
||||
@@ -1061,7 +1075,7 @@ register const char *verb;
|
||||
break;
|
||||
}
|
||||
}
|
||||
len = strlen(subj);
|
||||
len = (int) strlen(subj);
|
||||
if (!spot) spot = subj + len - 1;
|
||||
|
||||
/*
|
||||
@@ -1074,11 +1088,20 @@ register const char *verb;
|
||||
((spot - subj) >= 3 && !strncmp(spot-3, "feet", 4)) ||
|
||||
((spot - subj) >= 2 && !strncmp(spot-1, "ia", 2)) ||
|
||||
((spot - subj) >= 2 && !strncmp(spot-1, "ae", 2))) {
|
||||
Strcpy(buf, verb);
|
||||
return buf;
|
||||
/* check for special cases to avoid false matches */
|
||||
len = (int)(spot - subj) + 1;
|
||||
for (spec = special_subjs; *spec; spec++)
|
||||
if (!strncmpi(*spec, subj, len)) goto sing;
|
||||
|
||||
return strcpy(buf, verb);
|
||||
}
|
||||
/*
|
||||
* 2nd person singular behaves as if plural.
|
||||
*/
|
||||
if (!strcmpi(subj, "you")) return strcpy(buf, verb);
|
||||
}
|
||||
|
||||
sing:
|
||||
len = strlen(verb);
|
||||
spot = verb + len - 1;
|
||||
|
||||
|
||||
16
src/zap.c
16
src/zap.c
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)zap.c 3.4 2003/01/08 */
|
||||
/* SCCS Id: @(#)zap.c 3.4 2003/02/08 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -202,7 +202,7 @@ struct obj *otmp;
|
||||
break;
|
||||
case WAN_CANCELLATION:
|
||||
case SPE_CANCELLATION:
|
||||
cancel_monst(mtmp, otmp, TRUE, TRUE, FALSE);
|
||||
(void) cancel_monst(mtmp, otmp, TRUE, TRUE, FALSE);
|
||||
break;
|
||||
case WAN_TELEPORTATION:
|
||||
case SPE_TELEPORT_AWAY:
|
||||
@@ -1956,7 +1956,7 @@ boolean ordinary;
|
||||
|
||||
case WAN_CANCELLATION:
|
||||
case SPE_CANCELLATION:
|
||||
cancel_monst(&youmonst, obj, TRUE, FALSE, TRUE);
|
||||
(void) cancel_monst(&youmonst, obj, TRUE, FALSE, TRUE);
|
||||
break;
|
||||
|
||||
case SPE_DRAIN_LIFE:
|
||||
@@ -2203,7 +2203,7 @@ struct obj *obj; /* wand or spell */
|
||||
* effect is too strong. currently non-hero monsters do not zap
|
||||
* themselves with cancellation.
|
||||
*/
|
||||
void
|
||||
boolean
|
||||
cancel_monst(mdef, obj, youattack, allow_cancel_kill, self_cancel)
|
||||
register struct monst *mdef;
|
||||
register struct obj *obj;
|
||||
@@ -2216,7 +2216,7 @@ boolean youattack, allow_cancel_kill, self_cancel;
|
||||
|
||||
if (youdefend ? (!youattack && Antimagic)
|
||||
: resist(mdef, obj->oclass, 0, NOTELL))
|
||||
return; /* resisted cancellation */
|
||||
return FALSE; /* resisted cancellation */
|
||||
|
||||
if (self_cancel) { /* 1st cancel inventory */
|
||||
struct obj *otmp;
|
||||
@@ -2259,6 +2259,7 @@ boolean youattack, allow_cancel_kill, self_cancel;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* you've zapped an immediate type wand up or down */
|
||||
@@ -4010,11 +4011,12 @@ int damage, tell;
|
||||
/* attack level */
|
||||
switch (oclass) {
|
||||
case WAND_CLASS: alev = 12; break;
|
||||
case TOOL_CLASS: alev = 10; break;
|
||||
case TOOL_CLASS: alev = 10; break; /* instrument */
|
||||
case WEAPON_CLASS: alev = 10; break; /* artifact */
|
||||
case SCROLL_CLASS: alev = 9; break;
|
||||
case POTION_CLASS: alev = 6; break;
|
||||
case RING_CLASS: alev = 5; break;
|
||||
default: alev = u.ulevel; break; /* spell */
|
||||
default: alev = u.ulevel; break; /* spell */
|
||||
}
|
||||
/* defense level */
|
||||
dlev = (int)mtmp->m_lev;
|
||||
|
||||
Reference in New Issue
Block a user