Buzz macros and related stuff

Add macros to convert AD_foo, WAN_foo, and SPE_foo to relative values
for passing to BZ_U_foo and BZ_M_foo macros.

Change some return values in monster spellcasting function from
magic numbers to MM_MISS or MM_HIT.

Make buzzmu consider hero resistances - previously the
monster with innate zapping ray (Angels and Asmodeus) would
just keep doing that attack, but they will now just curse if
it saw the hero resist the attack.
This commit is contained in:
Pasi Kallinen
2022-07-19 15:14:55 +03:00
parent 0bca93be87
commit d713c1826b
11 changed files with 58 additions and 38 deletions
+18 -23
View File
@@ -210,20 +210,20 @@ castmu(register struct monst *mtmp,
if (foundyou)
impossible(
"spellcasting monster found you and doesn't know it?");
return 0;
return MM_MISS;
}
break;
}
} while (--cnt > 0
&& spell_would_be_useless(mtmp, mattk->adtyp, spellnum));
if (cnt == 0)
return 0;
return MM_MISS;
}
/* monster unable to cast spells? */
if (mtmp->mcan || mtmp->mspec_used || !ml) {
cursetxt(mtmp, is_undirected_spell(mattk->adtyp, spellnum));
return 0;
return MM_MISS;
}
if (mattk->adtyp == AD_SPEL || mattk->adtyp == AD_CLRC) {
@@ -241,14 +241,14 @@ castmu(register struct monst *mtmp,
canseemon(mtmp) ? Monnam(mtmp) : "Something",
is_waterwall(mtmp->mux,mtmp->muy) ? "empty water"
: "thin air");
return 0;
return MM_MISS;
}
nomul(0);
if (rn2(ml * 10) < (mtmp->mconf ? 100 : 20)) { /* fumbled attack */
if (canseemon(mtmp) && !Deaf)
pline_The("air crackles around %s.", mon_nam(mtmp));
return 0;
return MM_MISS;
}
if (canspotmon(mtmp) || !is_undirected_spell(mattk->adtyp, spellnum)) {
pline("%s casts a spell%s!",
@@ -274,7 +274,7 @@ castmu(register struct monst *mtmp,
impossible(
"%s casting non-hand-to-hand version of hand-to-hand spell %d?",
Monnam(mtmp), mattk->adtyp);
return 0;
return MM_MISS;
}
} else if (mattk->damd)
dmg = d((int) ((ml / 2) + mattk->damn), (int) mattk->damd);
@@ -283,7 +283,7 @@ castmu(register struct monst *mtmp,
if (Half_spell_damage)
dmg = (dmg + 1) / 2;
ret = 1;
ret = MM_HIT;
switch (mattk->adtyp) {
case AD_FIRE:
pline("You're enveloped in flames.");
@@ -850,34 +850,29 @@ spell_would_be_useless(struct monst *mtmp, unsigned int adtyp, int spellnum)
return FALSE;
}
/* convert 1..10 to 0..9; add 10 for second group (spell casting) */
#define ad_to_typ(k) (10 + (int) k - 1)
/* monster uses spell (ranged) */
int
buzzmu(register struct monst *mtmp, register struct attack *mattk)
{
/* don't print constant stream of curse messages for 'normal'
spellcasting monsters at range */
if (mattk->adtyp > AD_SPC2)
return 0;
if (!BZ_VALID_ADTYP(mattk->adtyp))
return MM_MISS;
if (mtmp->mcan) {
if (mtmp->mcan || m_seenres(mtmp, cvt_adtyp_to_mseenres(mattk->adtyp))) {
cursetxt(mtmp, FALSE);
return 0;
return MM_MISS;
}
if (lined_up(mtmp) && rn2(3)) {
nomul(0);
if (mattk->adtyp && (mattk->adtyp < 11)) { /* no cf unsigned >0 */
if (canseemon(mtmp))
pline("%s zaps you with a %s!", Monnam(mtmp),
flash_str(ad_to_typ(mattk->adtyp), FALSE));
buzz(-ad_to_typ(mattk->adtyp), (int) mattk->damn, mtmp->mx,
mtmp->my, sgn(g.tbx), sgn(g.tby));
} else
impossible("Monster spell %d cast", mattk->adtyp - 1);
if (canseemon(mtmp))
pline("%s zaps you with a %s!", Monnam(mtmp),
flash_str(BZ_OFS_AD(mattk->adtyp), FALSE));
buzz(BZ_M_SPELL(BZ_OFS_AD(mattk->adtyp)), (int) mattk->damn, mtmp->mx,
mtmp->my, sgn(g.tbx), sgn(g.tby));
return MM_HIT;
}
return 1;
return MM_MISS;
}
/*mcastu.c*/
+1 -1
View File
@@ -720,7 +720,7 @@ dochug(register struct monst* mtmp)
for (a = &mdat->mattk[0]; a < &mdat->mattk[NATTK]; a++) {
if (a->aatyp == AT_MAGC
&& (a->adtyp == AD_SPEL || a->adtyp == AD_CLRC)) {
if (castmu(mtmp, a, FALSE, FALSE)) {
if ((castmu(mtmp, a, FALSE, FALSE) & MM_HIT)) {
tmp = MMOVE_DONE; /* bypass m_move() */
break;
}
+3 -3
View File
@@ -886,7 +886,7 @@ breathwep_name(int typ)
if (Hallucination)
return rnd_hallublast();
return breathwep[typ - 1];
return breathwep[BZ_OFS_AD(typ)];
}
/* monster breathes at monster (ranged) */
@@ -915,12 +915,12 @@ breamm(struct monst* mtmp, struct attack* mattk, struct monst* mtarg)
return MM_HIT;
if (!mtmp->mspec_used && rn2(3)) {
if ((typ >= AD_MAGM) && (typ <= AD_ACID)) {
if (BZ_VALID_ADTYP(typ)) {
boolean utarget = (mtarg == &g.youmonst);
if (canseemon(mtmp))
pline("%s breathes %s!",
Monnam(mtmp), breathwep_name(typ));
dobuzz((int) (-20 - (typ - 1)), (int) mattk->damn,
dobuzz(BZ_M_BREATH(BZ_OFS_AD(typ)), (int) mattk->damn,
mtmp->mx, mtmp->my, sgn(g.tbx), sgn(g.tby), utarget);
nomul(0);
/* breath runs out sometimes. Also, give monster some
+2 -2
View File
@@ -1565,7 +1565,7 @@ use_offensive(struct monst* mtmp)
if (oseen)
makeknown(otmp->otyp);
g.m_using = TRUE;
buzz((int) (-30 - (otmp->otyp - WAN_MAGIC_MISSILE)),
buzz(BZ_M_WAND(BZ_OFS_WAN(otmp->otyp)),
(otmp->otyp == WAN_MAGIC_MISSILE) ? 2 : 6, mtmp->mx, mtmp->my,
sgn(mtmp->mux - mtmp->mx), sgn(mtmp->muy - mtmp->my));
g.m_using = FALSE;
@@ -1574,7 +1574,7 @@ use_offensive(struct monst* mtmp)
case MUSE_FROST_HORN:
mplayhorn(mtmp, otmp, FALSE);
g.m_using = TRUE;
buzz(-30 - ((otmp->otyp == FROST_HORN) ? AD_COLD - 1 : AD_FIRE - 1),
buzz(BZ_M_WAND(BZ_OFS_AD((otmp->otyp == FROST_HORN) ? AD_COLD : AD_FIRE)),
rn1(6, 6), mtmp->mx, mtmp->my, sgn(mtmp->mux - mtmp->mx),
sgn(mtmp->muy - mtmp->my));
g.m_using = FALSE;
+2 -2
View File
@@ -599,11 +599,11 @@ do_improvisation(struct obj* instr)
losehp(damage, buf, KILLED_BY); /* fire or frost damage */
}
} else {
int type = (instr->otyp == FROST_HORN) ? AD_COLD - 1 : AD_FIRE - 1;
int type = BZ_OFS_AD((instr->otyp == FROST_HORN) ? AD_COLD : AD_FIRE);
if (!Blind)
pline("A %s blasts out of the horn!", flash_str(type, FALSE));
buzz(type, rn1(6, 6), u.ux, u.uy, u.dx, u.dy);
ubuzz(BZ_U_WAND(type), rn1(6, 6));
}
makeknown(instr->otyp);
break;
+1 -2
View File
@@ -1252,8 +1252,7 @@ dobreathe(void)
else if (!u.dx && !u.dy && !u.dz)
ubreatheu(mattk);
else
buzz((int) (20 + mattk->adtyp - 1), (int) mattk->damn, u.ux, u.uy,
u.dx, u.dy);
ubuzz(BZ_U_BREATH(BZ_OFS_AD(mattk->adtyp)), (int) mattk->damn);
return ECMD_TIME;
}
+1 -1
View File
@@ -809,7 +809,7 @@ ghod_hitsu(struct monst *priest)
break;
}
buzz(-10 - (AD_ELEC - 1), 6, x, y, sgn(g.tbx),
buzz(BZ_M_SPELL(BZ_OFS_AD(AD_ELEC)), 6, x, y, sgn(g.tbx),
sgn(g.tby)); /* bolt of lightning */
exercise(A_WIS, FALSE);
}
+8 -4
View File
@@ -3235,11 +3235,9 @@ weffects(struct obj *obj)
if (otyp == WAN_DIGGING || otyp == SPE_DIG)
zap_dig();
else if (otyp >= SPE_MAGIC_MISSILE && otyp <= SPE_FINGER_OF_DEATH)
buzz(otyp - SPE_MAGIC_MISSILE + 10, u.ulevel / 2 + 1, u.ux, u.uy,
u.dx, u.dy);
ubuzz(BZ_U_SPELL(BZ_OFS_SPE(otyp)), u.ulevel / 2 + 1);
else if (otyp >= WAN_MAGIC_MISSILE && otyp <= WAN_LIGHTNING)
buzz(otyp - WAN_MAGIC_MISSILE,
(otyp == WAN_MAGIC_MISSILE) ? 2 : 6, u.ux, u.uy, u.dx, u.dy);
ubuzz(BZ_U_WAND(BZ_OFS_WAN(otyp)), (otyp == WAN_MAGIC_MISSILE) ? 2 : 6);
else
impossible("weffects: unexpected spell or wand");
disclose = TRUE;
@@ -4254,6 +4252,12 @@ disintegrate_mon(struct monst *mon,
xkilled(mon, XKILL_NOMSG | XKILL_NOCORPSE);
}
void
ubuzz(int type, int nd)
{
dobuzz(type, nd, u.ux, u.uy, u.dx, u.dy, TRUE);
}
void
buzz(int type, int nd, coordxy sx, coordxy sy, int dx, int dy)
{