Unify anti magic traps
This commit is contained in:
+87
-74
@@ -27,7 +27,7 @@ static int FDECL(trapeffect_level_telep, (struct monst *, struct trap *, unsigne
|
|||||||
static int FDECL(trapeffect_web, (struct monst *, struct trap *, unsigned));
|
static int FDECL(trapeffect_web, (struct monst *, struct trap *, unsigned));
|
||||||
static int FDECL(trapeffect_statue_trap, (struct monst *, struct trap *, unsigned));
|
static int FDECL(trapeffect_statue_trap, (struct monst *, struct trap *, unsigned));
|
||||||
static int FDECL(trapeffect_magic_trap, (struct monst *, struct trap *, unsigned));
|
static int FDECL(trapeffect_magic_trap, (struct monst *, struct trap *, unsigned));
|
||||||
static void FDECL(trapeffect_anti_magic, (struct trap *, unsigned));
|
static int FDECL(trapeffect_anti_magic, (struct monst *, struct trap *, unsigned));
|
||||||
static void FDECL(trapeffect_poly_trap, (struct trap *, unsigned));
|
static void FDECL(trapeffect_poly_trap, (struct trap *, unsigned));
|
||||||
static void FDECL(trapeffect_landmine, (struct trap *, unsigned));
|
static void FDECL(trapeffect_landmine, (struct trap *, unsigned));
|
||||||
static void FDECL(trapeffect_rolling_boulder_trap, (struct trap *, unsigned));
|
static void FDECL(trapeffect_rolling_boulder_trap, (struct trap *, unsigned));
|
||||||
@@ -1954,46 +1954,97 @@ unsigned trflags;
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static int
|
||||||
trapeffect_anti_magic(trap, trflags)
|
trapeffect_anti_magic(mtmp, trap, trflags)
|
||||||
|
struct monst *mtmp;
|
||||||
struct trap *trap;
|
struct trap *trap;
|
||||||
unsigned trflags;
|
unsigned trflags;
|
||||||
{
|
{
|
||||||
seetrap(trap);
|
if (mtmp == &g.youmonst) {
|
||||||
/* hero without magic resistance loses spell energy,
|
seetrap(trap);
|
||||||
hero with magic resistance takes damage instead;
|
/* hero without magic resistance loses spell energy,
|
||||||
possibly non-intuitive but useful for play balance */
|
hero with magic resistance takes damage instead;
|
||||||
if (!Antimagic) {
|
possibly non-intuitive but useful for play balance */
|
||||||
drain_en(rnd(u.ulevel) + 1);
|
if (!Antimagic) {
|
||||||
|
drain_en(rnd(u.ulevel) + 1);
|
||||||
|
} else {
|
||||||
|
struct obj *otmp;
|
||||||
|
int dmgval2 = rnd(4), hp = Upolyd ? u.mh : u.uhp;
|
||||||
|
|
||||||
|
/* Half_XXX_damage has opposite its usual effect (approx)
|
||||||
|
but isn't cumulative if hero has more than one */
|
||||||
|
if (Half_physical_damage || Half_spell_damage)
|
||||||
|
dmgval2 += rnd(4);
|
||||||
|
/* give Magicbane wielder dose of own medicine */
|
||||||
|
if (uwep && uwep->oartifact == ART_MAGICBANE)
|
||||||
|
dmgval2 += rnd(4);
|
||||||
|
/* having an artifact--other than own quest one--which
|
||||||
|
confers magic resistance simply by being carried
|
||||||
|
also increases the effect */
|
||||||
|
for (otmp = g.invent; otmp; otmp = otmp->nobj)
|
||||||
|
if (otmp->oartifact && !is_quest_artifact(otmp)
|
||||||
|
&& defends_when_carried(AD_MAGM, otmp))
|
||||||
|
break;
|
||||||
|
if (otmp)
|
||||||
|
dmgval2 += rnd(4);
|
||||||
|
if (Passes_walls)
|
||||||
|
dmgval2 = (dmgval2 + 3) / 4;
|
||||||
|
|
||||||
|
You_feel((dmgval2 >= hp) ? "unbearably torpid!"
|
||||||
|
: (dmgval2 >= hp / 4) ? "very lethargic."
|
||||||
|
: "sluggish.");
|
||||||
|
/* opposite of magical explosion */
|
||||||
|
losehp(dmgval2, "anti-magic implosion", KILLED_BY_AN);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
struct obj *otmp;
|
boolean trapkilled = FALSE;
|
||||||
int dmgval2 = rnd(4), hp = Upolyd ? u.mh : u.uhp;
|
boolean in_sight = canseemon(mtmp) || (mtmp == u.usteed);
|
||||||
|
boolean see_it = cansee(mtmp->mx, mtmp->my);
|
||||||
|
struct permonst *mptr = mtmp->data;
|
||||||
|
|
||||||
/* Half_XXX_damage has opposite its usual effect (approx)
|
/* similar to hero's case, more or less */
|
||||||
but isn't cumulative if hero has more than one */
|
if (!resists_magm(mtmp)) { /* lose spell energy */
|
||||||
if (Half_physical_damage || Half_spell_damage)
|
if (!mtmp->mcan && (attacktype(mptr, AT_MAGC)
|
||||||
dmgval2 += rnd(4);
|
|| attacktype(mptr, AT_BREA))) {
|
||||||
/* give Magicbane wielder dose of own medicine */
|
mtmp->mspec_used += d(2, 2);
|
||||||
if (uwep && uwep->oartifact == ART_MAGICBANE)
|
if (in_sight) {
|
||||||
dmgval2 += rnd(4);
|
seetrap(trap);
|
||||||
/* having an artifact--other than own quest one--which
|
pline("%s seems lethargic.", Monnam(mtmp));
|
||||||
confers magic resistance simply by being carried
|
}
|
||||||
also increases the effect */
|
}
|
||||||
for (otmp = g.invent; otmp; otmp = otmp->nobj)
|
} else { /* take some damage */
|
||||||
if (otmp->oartifact && !is_quest_artifact(otmp)
|
struct obj *otmp;
|
||||||
&& defends_when_carried(AD_MAGM, otmp))
|
int dmgval2 = rnd(4);
|
||||||
break;
|
|
||||||
if (otmp)
|
|
||||||
dmgval2 += rnd(4);
|
|
||||||
if (Passes_walls)
|
|
||||||
dmgval2 = (dmgval2 + 3) / 4;
|
|
||||||
|
|
||||||
You_feel((dmgval2 >= hp) ? "unbearably torpid!"
|
if ((otmp = MON_WEP(mtmp)) != 0
|
||||||
: (dmgval2 >= hp / 4) ? "very lethargic."
|
&& otmp->oartifact == ART_MAGICBANE)
|
||||||
: "sluggish.");
|
dmgval2 += rnd(4);
|
||||||
/* opposite of magical explosion */
|
for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
|
||||||
losehp(dmgval2, "anti-magic implosion", KILLED_BY_AN);
|
if (otmp->oartifact
|
||||||
|
&& defends_when_carried(AD_MAGM, otmp))
|
||||||
|
break;
|
||||||
|
if (otmp)
|
||||||
|
dmgval2 += rnd(4);
|
||||||
|
if (passes_walls(mptr))
|
||||||
|
dmgval2 = (dmgval2 + 3) / 4;
|
||||||
|
|
||||||
|
if (in_sight)
|
||||||
|
seetrap(trap);
|
||||||
|
mtmp->mhp -= dmgval2;
|
||||||
|
if (DEADMONSTER(mtmp))
|
||||||
|
monkilled(mtmp,
|
||||||
|
in_sight
|
||||||
|
? "compression from an anti-magic field"
|
||||||
|
: (const char *) 0,
|
||||||
|
-AD_MAGM);
|
||||||
|
if (DEADMONSTER(mtmp))
|
||||||
|
trapkilled = TRUE;
|
||||||
|
if (see_it)
|
||||||
|
newsym(trap->tx, trap->ty);
|
||||||
|
}
|
||||||
|
return trapkilled ? 2 : mtmp->mtrapped;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -2248,7 +2299,7 @@ unsigned trflags;
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ANTI_MAGIC:
|
case ANTI_MAGIC:
|
||||||
trapeffect_anti_magic(trap, trflags);
|
(void) trapeffect_anti_magic(&g.youmonst, trap, trflags);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case POLY_TRAP:
|
case POLY_TRAP:
|
||||||
@@ -2951,45 +3002,7 @@ register struct monst *mtmp;
|
|||||||
return trapeffect_statue_trap(mtmp, trap, 0);
|
return trapeffect_statue_trap(mtmp, trap, 0);
|
||||||
break;
|
break;
|
||||||
case ANTI_MAGIC:
|
case ANTI_MAGIC:
|
||||||
/* similar to hero's case, more or less */
|
return trapeffect_anti_magic(mtmp, trap, 0);
|
||||||
if (!resists_magm(mtmp)) { /* lose spell energy */
|
|
||||||
if (!mtmp->mcan && (attacktype(mptr, AT_MAGC)
|
|
||||||
|| attacktype(mptr, AT_BREA))) {
|
|
||||||
mtmp->mspec_used += d(2, 2);
|
|
||||||
if (in_sight) {
|
|
||||||
seetrap(trap);
|
|
||||||
pline("%s seems lethargic.", Monnam(mtmp));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else { /* take some damage */
|
|
||||||
int dmgval2 = rnd(4);
|
|
||||||
|
|
||||||
if ((otmp = MON_WEP(mtmp)) != 0
|
|
||||||
&& otmp->oartifact == ART_MAGICBANE)
|
|
||||||
dmgval2 += rnd(4);
|
|
||||||
for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
|
|
||||||
if (otmp->oartifact
|
|
||||||
&& defends_when_carried(AD_MAGM, otmp))
|
|
||||||
break;
|
|
||||||
if (otmp)
|
|
||||||
dmgval2 += rnd(4);
|
|
||||||
if (passes_walls(mptr))
|
|
||||||
dmgval2 = (dmgval2 + 3) / 4;
|
|
||||||
|
|
||||||
if (in_sight)
|
|
||||||
seetrap(trap);
|
|
||||||
mtmp->mhp -= dmgval2;
|
|
||||||
if (DEADMONSTER(mtmp))
|
|
||||||
monkilled(mtmp,
|
|
||||||
in_sight
|
|
||||||
? "compression from an anti-magic field"
|
|
||||||
: (const char *) 0,
|
|
||||||
-AD_MAGM);
|
|
||||||
if (DEADMONSTER(mtmp))
|
|
||||||
trapkilled = TRUE;
|
|
||||||
if (see_it)
|
|
||||||
newsym(trap->tx, trap->ty);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case LANDMINE:
|
case LANDMINE:
|
||||||
if (rn2(3))
|
if (rn2(3))
|
||||||
|
|||||||
Reference in New Issue
Block a user