Unify code for cure self spell
This commit is contained in:
34
src/mcastu.c
34
src/mcastu.c
@@ -38,6 +38,7 @@ enum mcast_cleric_spells {
|
|||||||
STATIC_DCL void FDECL(cursetxt, (struct monst *, BOOLEAN_P));
|
STATIC_DCL void FDECL(cursetxt, (struct monst *, BOOLEAN_P));
|
||||||
STATIC_DCL int FDECL(choose_magic_spell, (int));
|
STATIC_DCL int FDECL(choose_magic_spell, (int));
|
||||||
STATIC_DCL int FDECL(choose_clerical_spell, (int));
|
STATIC_DCL int FDECL(choose_clerical_spell, (int));
|
||||||
|
STATIC_DCL int FDECL(m_cure_self, (struct monst *, int));
|
||||||
STATIC_DCL void FDECL(cast_wizard_spell, (struct monst *, int, int));
|
STATIC_DCL void FDECL(cast_wizard_spell, (struct monst *, int, int));
|
||||||
STATIC_DCL void FDECL(cast_cleric_spell, (struct monst *, int, int));
|
STATIC_DCL void FDECL(cast_cleric_spell, (struct monst *, int, int));
|
||||||
STATIC_DCL boolean FDECL(is_undirected_spell, (unsigned int, int));
|
STATIC_DCL boolean FDECL(is_undirected_spell, (unsigned int, int));
|
||||||
@@ -336,6 +337,21 @@ boolean foundyou;
|
|||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC_OVL int
|
||||||
|
m_cure_self(mtmp, dmg)
|
||||||
|
struct monst *mtmp;
|
||||||
|
{
|
||||||
|
if (mtmp->mhp < mtmp->mhpmax) {
|
||||||
|
if (canseemon(mtmp))
|
||||||
|
pline("%s looks better.", Monnam(mtmp));
|
||||||
|
/* note: player healing does 6d4; this used to do 1d8 */
|
||||||
|
if ((mtmp->mhp += d(3, 6)) > mtmp->mhpmax)
|
||||||
|
mtmp->mhp = mtmp->mhpmax;
|
||||||
|
dmg = 0;
|
||||||
|
}
|
||||||
|
return dmg;
|
||||||
|
}
|
||||||
|
|
||||||
/* monster wizard and cleric spellcasting functions */
|
/* monster wizard and cleric spellcasting functions */
|
||||||
/*
|
/*
|
||||||
If dmg is zero, then the monster is not casting at you.
|
If dmg is zero, then the monster is not casting at you.
|
||||||
@@ -474,14 +490,7 @@ int spellnum;
|
|||||||
dmg = 0;
|
dmg = 0;
|
||||||
break;
|
break;
|
||||||
case MGC_CURE_SELF:
|
case MGC_CURE_SELF:
|
||||||
if (mtmp->mhp < mtmp->mhpmax) {
|
dmg = m_cure_self(mtmp, dmg);
|
||||||
if (canseemon(mtmp))
|
|
||||||
pline("%s looks better.", Monnam(mtmp));
|
|
||||||
/* note: player healing does 6d4; this used to do 1d8 */
|
|
||||||
if ((mtmp->mhp += d(3, 6)) > mtmp->mhpmax)
|
|
||||||
mtmp->mhp = mtmp->mhpmax;
|
|
||||||
dmg = 0;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case MGC_PSI_BOLT:
|
case MGC_PSI_BOLT:
|
||||||
/* prior to 3.4.0 Antimagic was setting the damage to 1--this
|
/* prior to 3.4.0 Antimagic was setting the damage to 1--this
|
||||||
@@ -695,14 +704,7 @@ int spellnum;
|
|||||||
dmg = 0;
|
dmg = 0;
|
||||||
break;
|
break;
|
||||||
case CLC_CURE_SELF:
|
case CLC_CURE_SELF:
|
||||||
if (mtmp->mhp < mtmp->mhpmax) {
|
dmg = m_cure_self(mtmp, dmg);
|
||||||
if (canseemon(mtmp))
|
|
||||||
pline("%s looks better.", Monnam(mtmp));
|
|
||||||
/* note: player healing does 6d4; this used to do 1d8 */
|
|
||||||
if ((mtmp->mhp += d(3, 6)) > mtmp->mhpmax)
|
|
||||||
mtmp->mhp = mtmp->mhpmax;
|
|
||||||
dmg = 0;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case CLC_OPEN_WOUNDS:
|
case CLC_OPEN_WOUNDS:
|
||||||
if (Antimagic) {
|
if (Antimagic) {
|
||||||
|
|||||||
Reference in New Issue
Block a user