From 3389c0212619bb62f354edeb9d6530e9f6160f90 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Wed, 2 Nov 2005 05:49:18 +0000 Subject: [PATCH] guardian angel Move the guardian angel creation and removal code to minion.c. --- include/extern.h | 2 ++ src/do.c | 56 +++------------------------------ src/dogmove.c | 18 ++--------- src/minion.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 90 insertions(+), 68 deletions(-) diff --git a/include/extern.h b/include/extern.h index 13616d872..caf08669d 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1033,6 +1033,8 @@ E int FDECL(dlord, (ALIGNTYP_P)); E int NDECL(llord); E int FDECL(ndemon, (ALIGNTYP_P)); E int NDECL(lminion); +E void FDECL(lose_guardian_angel, (struct monst *)); +E void NDECL(gain_guardian_angel); /* ### mklev.c ### */ diff --git a/src/do.c b/src/do.c index ce6752140..4986b1747 100644 --- a/src/do.c +++ b/src/do.c @@ -1405,64 +1405,18 @@ STATIC_OVL void final_level() { struct monst *mtmp; - struct obj *otmp; - coord mm; - int i; /* reset monster hostility relative to player */ - for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) - if (!DEADMONSTER(mtmp)) reset_hostility(mtmp); + for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { + if (DEADMONSTER(mtmp)) continue; + reset_hostility(mtmp); + } /* create some player-monsters */ create_mplayers(rn1(4, 3), TRUE); /* create a guardian angel next to player, if worthy */ - if (Conflict) { - pline( - "A voice booms: \"Thy desire for conflict shall be fulfilled!\""); - for (i = rnd(4); i > 0; --i) { - mm.x = u.ux; - mm.y = u.uy; - if (enexto(&mm, mm.x, mm.y, &mons[PM_ANGEL])) - (void) mk_roamer(&mons[PM_ANGEL], u.ualign.type, - mm.x, mm.y, FALSE); - } - - } else if (u.ualign.record > 8) { /* fervent */ - pline("A voice whispers: \"Thou hast been worthy of me!\""); - mm.x = u.ux; - mm.y = u.uy; - if (enexto(&mm, mm.x, mm.y, &mons[PM_ANGEL])) { - if ((mtmp = mk_roamer(&mons[PM_ANGEL], u.ualign.type, - mm.x, mm.y, TRUE)) != 0) { - if (!Blind) - pline("An angel appears near you."); - else - You_feel("the presence of a friendly angel near you."); - /* guardian angel -- the one case mtame doesn't - * imply an edog structure, so we don't want to - * call tamedog(). - */ - mtmp->mtame = 10; - /* make him strong enough vs. endgame foes */ - mtmp->m_lev = rn1(8,15); - mtmp->mhp = mtmp->mhpmax = - d((int)mtmp->m_lev,10) + 30 + rnd(30); - if ((otmp = select_hwep(mtmp)) == 0) { - otmp = mksobj(SILVER_SABER, FALSE, FALSE); - if (mpickobj(mtmp, otmp)) - panic("merged weapon?"); - } - bless(otmp); - if (otmp->spe < 4) otmp->spe += rnd(4); - if ((otmp = which_armor(mtmp, W_ARMS)) == 0 || - otmp->otyp != SHIELD_OF_REFLECTION) { - (void) mongets(mtmp, AMULET_OF_REFLECTION); - m_dowear(mtmp, TRUE); - } - } - } - } + gain_guardian_angel(); } static char *dfr_pre_msg = 0, /* pline() before level change */ diff --git a/src/dogmove.c b/src/dogmove.c index b6139f5c2..f779f345c 100644 --- a/src/dogmove.c +++ b/src/dogmove.c @@ -629,25 +629,11 @@ register int after; /* this is extra fast monster movement */ if (Conflict && !resist(mtmp, RING_CLASS, 0, 0)) { allowflags |= ALLOW_U; if (!has_edog) { - coord mm; /* Guardian angel refuses to be conflicted; rather, * it disappears, angrily, and sends in some nasties */ - if (canspotmon(mtmp)) { - pline("%s rebukes you, saying:", Monnam(mtmp)); - verbalize("Since you desire conflict, have some more!"); - } - mongone(mtmp); - i = rnd(4); - while(i--) { - mm.x = u.ux; - mm.y = u.uy; - if(enexto(&mm, mm.x, mm.y, &mons[PM_ANGEL])) - (void) mk_roamer(&mons[PM_ANGEL], u.ualign.type, - mm.x, mm.y, FALSE); - } - return(2); - + lose_guardian_angel(mtmp); + return 2; /* current monster is gone */ } } if (!Conflict && !mtmp->mconf && diff --git a/src/minion.c b/src/minion.c index 6576d6c16..9cb15926d 100644 --- a/src/minion.c +++ b/src/minion.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)minion.c 3.5 2004/12/20 */ +/* SCCS Id: @(#)minion.c 3.5 2005/11/01 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -321,4 +321,84 @@ aligntyp atyp; return NON_PM; } +/* guardian angel has been affected by conflict so is abandoning hero */ +void +lose_guardian_angel(mon) +struct monst *mon; /* if null, angel hasn't been created yet */ +{ + coord mm; + int i; + + if (mon) { + if (canspotmon(mon)) { + if (!Deaf) { + pline("%s rebukes you, saying:", Monnam(mon)); + verbalize("Since you desire conflict, have some more!"); + } else { + pline("%s vanishes!", Monnam(mon)); + } + } + mongone(mon); + } + /* create 1 to 4 hostile angels to replace the lost guardian */ + for (i = rnd(4); i > 0; --i) { + mm.x = u.ux; + mm.y = u.uy; + if (enexto(&mm, mm.x, mm.y, &mons[PM_ANGEL])) + (void) mk_roamer(&mons[PM_ANGEL], u.ualign.type, + mm.x, mm.y, FALSE); + } +} + +/* just entered the Astral Plane; receive tame guardian angel if worthy */ +void +gain_guardian_angel() +{ + struct monst *mtmp; + struct obj *otmp; + coord mm; + + Hear_again(); /* attempt to cure any deafness now (divine + message will be heard even if that fails) */ + if (Conflict) { + pline("A voice booms:"); + verbalize("Thy desire for conflict shall be fulfilled!"); + /* send in some hostile angels instead */ + lose_guardian_angel((struct monst *)0); + } else if (u.ualign.record > 8) { /* fervent */ + pline("A voice whispers:"); + verbalize("Thou hast been worthy of me!"); + mm.x = u.ux; + mm.y = u.uy; + if (enexto(&mm, mm.x, mm.y, &mons[PM_ANGEL]) && + (mtmp = mk_roamer(&mons[PM_ANGEL], u.ualign.type, + mm.x, mm.y, TRUE)) != 0) { + if (!Blind) + pline("An angel appears near you."); + else + You_feel("the presence of a friendly angel near you."); + /* guardian angel -- the one case mtame doesn't + * imply an edog structure, so we don't want to + * call tamedog(). + */ + mtmp->mtame = 10; + /* make him strong enough vs. endgame foes */ + mtmp->m_lev = rn1(8,15); + mtmp->mhp = mtmp->mhpmax = d((int)mtmp->m_lev,10) + 30 + rnd(30); + if ((otmp = select_hwep(mtmp)) == 0) { + otmp = mksobj(SILVER_SABER, FALSE, FALSE); + if (mpickobj(mtmp, otmp)) + panic("merged weapon?"); + } + bless(otmp); + if (otmp->spe < 4) otmp->spe += rnd(4); + if ((otmp = which_armor(mtmp, W_ARMS)) == 0 || + otmp->otyp != SHIELD_OF_REFLECTION) { + (void) mongets(mtmp, AMULET_OF_REFLECTION); + m_dowear(mtmp, TRUE); + } + } + } +} + /*minion.c*/ -- 2.40.0