Split peaceful responses into separate functions
This commit is contained in:
@@ -20,6 +20,8 @@ static void m_detach(struct monst *, struct permonst *);
|
|||||||
static void set_mon_min_mhpmax(struct monst *, int);
|
static void set_mon_min_mhpmax(struct monst *, int);
|
||||||
static void lifesaved_monster(struct monst *);
|
static void lifesaved_monster(struct monst *);
|
||||||
static boolean ok_to_obliterate(struct monst *);
|
static boolean ok_to_obliterate(struct monst *);
|
||||||
|
static void qst_guardians_respond(void);
|
||||||
|
static void peacefuls_respond(struct monst *);
|
||||||
static void m_restartcham(struct monst *);
|
static void m_restartcham(struct monst *);
|
||||||
static boolean restrap(struct monst *);
|
static boolean restrap(struct monst *);
|
||||||
static int pick_animal(void);
|
static int pick_animal(void);
|
||||||
@@ -3656,60 +3658,10 @@ m_respond(struct monst* mtmp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called whenever the player attacks mtmp; also called in other situations
|
/* how quest guardians respond when you attack the quest leader */
|
||||||
where mtmp gets annoyed at the player. Handles mtmp getting annoyed at the
|
static void
|
||||||
attack and any ramifications that might have. Useful also in situations
|
qst_guardians_respond(void)
|
||||||
where mtmp was already hostile; it checks for situations where the player
|
|
||||||
shouldn't be attacking and any ramifications /that/ might have. */
|
|
||||||
void
|
|
||||||
setmangry(struct monst* mtmp, boolean via_attack)
|
|
||||||
{
|
{
|
||||||
if (via_attack && sengr_at("Elbereth", u.ux, u.uy, TRUE)
|
|
||||||
/* only hypocritical if monster is vulnerable to Elbereth (or
|
|
||||||
peaceful--not vulnerable but attacking it is hypocritical) */
|
|
||||||
&& (onscary(u.ux, u.uy, mtmp) || mtmp->mpeaceful)) {
|
|
||||||
You_feel("like a hypocrite.");
|
|
||||||
/* AIS: Yes, I know alignment penalties and bonuses aren't balanced
|
|
||||||
at the moment. This is about correct relative to other "small"
|
|
||||||
penalties; it should be fairly large, as attacking while standing
|
|
||||||
on an Elbereth means that you're requesting peace and then
|
|
||||||
violating your own request. I know 5 isn't actually large, but
|
|
||||||
it's intentionally larger than the 1s and 2s that are normally
|
|
||||||
given for this sort of thing. */
|
|
||||||
/* reduce to 3 (average) when alignment is already very low */
|
|
||||||
adjalign((u.ualign.record > 5) ? -5 : -rnd(5));
|
|
||||||
|
|
||||||
if (!Blind)
|
|
||||||
pline("The engraving beneath you fades.");
|
|
||||||
del_engr_at(u.ux, u.uy);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* AIS: Should this be in both places, or just in wakeup()? */
|
|
||||||
mtmp->mstrategy &= ~STRAT_WAITMASK;
|
|
||||||
if (!mtmp->mpeaceful)
|
|
||||||
return;
|
|
||||||
/* [FIXME: this logic seems wrong; peaceful humanoids gasp or exclaim
|
|
||||||
when they see you attack a peaceful monster but they just casually
|
|
||||||
look the other way when you attack a pet?] */
|
|
||||||
if (mtmp->mtame)
|
|
||||||
return;
|
|
||||||
mtmp->mpeaceful = 0;
|
|
||||||
if (mtmp->ispriest) {
|
|
||||||
if (p_coaligned(mtmp))
|
|
||||||
adjalign(-5); /* very bad */
|
|
||||||
else
|
|
||||||
adjalign(2);
|
|
||||||
} else
|
|
||||||
adjalign(-1); /* attacking peaceful monsters is bad */
|
|
||||||
if (humanoid(mtmp->data) || mtmp->isshk || mtmp->isgd) {
|
|
||||||
if (couldsee(mtmp->mx, mtmp->my))
|
|
||||||
pline("%s gets angry!", Monnam(mtmp));
|
|
||||||
} else {
|
|
||||||
growl(mtmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* attacking your own quest leader will anger his or her guardians */
|
|
||||||
if (mtmp->data == &mons[quest_info(MS_LEADER)]) {
|
|
||||||
struct monst *mon;
|
struct monst *mon;
|
||||||
struct permonst *q_guardian = &mons[quest_info(MS_GUARDIAN)];
|
struct permonst *q_guardian = &mons[quest_info(MS_GUARDIAN)];
|
||||||
int got_mad = 0;
|
int got_mad = 0;
|
||||||
@@ -3732,10 +3684,12 @@ setmangry(struct monst* mtmp, boolean via_attack)
|
|||||||
pline_The("%s %s to be angry too...",
|
pline_The("%s %s to be angry too...",
|
||||||
who, vtense(who, "appear"));
|
who, vtense(who, "appear"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make other peaceful monsters react */
|
/* how other peacefuls react when you attack monster */
|
||||||
if (!gc.context.mon_moving) {
|
static void
|
||||||
|
peacefuls_respond(struct monst *mtmp)
|
||||||
|
{
|
||||||
struct monst *mon;
|
struct monst *mon;
|
||||||
int mndx = monsndx(mtmp->data);
|
int mndx = monsndx(mtmp->data);
|
||||||
|
|
||||||
@@ -3820,7 +3774,67 @@ setmangry(struct monst* mtmp, boolean via_attack)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Called whenever the player attacks mtmp; also called in other situations
|
||||||
|
where mtmp gets annoyed at the player. Handles mtmp getting annoyed at the
|
||||||
|
attack and any ramifications that might have. Useful also in situations
|
||||||
|
where mtmp was already hostile; it checks for situations where the player
|
||||||
|
shouldn't be attacking and any ramifications /that/ might have. */
|
||||||
|
void
|
||||||
|
setmangry(struct monst* mtmp, boolean via_attack)
|
||||||
|
{
|
||||||
|
if (via_attack && sengr_at("Elbereth", u.ux, u.uy, TRUE)
|
||||||
|
/* only hypocritical if monster is vulnerable to Elbereth (or
|
||||||
|
peaceful--not vulnerable but attacking it is hypocritical) */
|
||||||
|
&& (onscary(u.ux, u.uy, mtmp) || mtmp->mpeaceful)) {
|
||||||
|
You_feel("like a hypocrite.");
|
||||||
|
/* AIS: Yes, I know alignment penalties and bonuses aren't balanced
|
||||||
|
at the moment. This is about correct relative to other "small"
|
||||||
|
penalties; it should be fairly large, as attacking while standing
|
||||||
|
on an Elbereth means that you're requesting peace and then
|
||||||
|
violating your own request. I know 5 isn't actually large, but
|
||||||
|
it's intentionally larger than the 1s and 2s that are normally
|
||||||
|
given for this sort of thing. */
|
||||||
|
/* reduce to 3 (average) when alignment is already very low */
|
||||||
|
adjalign((u.ualign.record > 5) ? -5 : -rnd(5));
|
||||||
|
|
||||||
|
if (!Blind)
|
||||||
|
pline("The engraving beneath you fades.");
|
||||||
|
del_engr_at(u.ux, u.uy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* AIS: Should this be in both places, or just in wakeup()? */
|
||||||
|
mtmp->mstrategy &= ~STRAT_WAITMASK;
|
||||||
|
if (!mtmp->mpeaceful)
|
||||||
|
return;
|
||||||
|
/* [FIXME: this logic seems wrong; peaceful humanoids gasp or exclaim
|
||||||
|
when they see you attack a peaceful monster but they just casually
|
||||||
|
look the other way when you attack a pet?] */
|
||||||
|
if (mtmp->mtame)
|
||||||
|
return;
|
||||||
|
mtmp->mpeaceful = 0;
|
||||||
|
if (mtmp->ispriest) {
|
||||||
|
if (p_coaligned(mtmp))
|
||||||
|
adjalign(-5); /* very bad */
|
||||||
|
else
|
||||||
|
adjalign(2);
|
||||||
|
} else
|
||||||
|
adjalign(-1); /* attacking peaceful monsters is bad */
|
||||||
|
if (humanoid(mtmp->data) || mtmp->isshk || mtmp->isgd) {
|
||||||
|
if (couldsee(mtmp->mx, mtmp->my))
|
||||||
|
pline("%s gets angry!", Monnam(mtmp));
|
||||||
|
} else {
|
||||||
|
growl(mtmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* attacking your own quest leader will anger his or her guardians */
|
||||||
|
if (mtmp->data == &mons[quest_info(MS_LEADER)])
|
||||||
|
qst_guardians_respond();
|
||||||
|
|
||||||
|
/* make other peaceful monsters react */
|
||||||
|
if (!gc.context.mon_moving)
|
||||||
|
peacefuls_respond(mtmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Indicate via message that a monster has awoken. */
|
/* Indicate via message that a monster has awoken. */
|
||||||
|
|||||||
Reference in New Issue
Block a user