split g into multiple structures
The consolidation of global variables from scattered source
files into decl.c and declared in decl.h was begun in 3.7.0.
Their placement in common files was done for centralized
initialization and potential re-initialization during a
"play again" scenario.
It wasn't really necessary for all of them to be housed in a
single huge structure to meet the "play again" requirement,
and the single huge structure has been a little unwieldy when
it comes to maintenance.
Following this commit, instead of one single extremely large structure
named 'g' to house all of the relocated global variables, they
are distributed into several ga through gz.
To make things easy for the developer, each variable is placed
into the struct corresponding to the starting letter of the variable.
That way, no lookup is required in order to know which struct houses
a particular variable, it is a simple match to the starting letter
for all the centralized global variables.
A global variable named 'amulets', would be found in ga.
ga.amulets
^ ^
A global varable named 'move', would be found in gm.
gm.moves
^ ^
A global variable named 'val_for_n_or_more' would be found in gv.
gv.val_for_n_or_more
^ ^
A global variable named 'youmonst' would be found in gy.
gy.youmonst
^ ^
This commit is contained in:
236
src/mon.c
236
src/mon.c
@@ -32,7 +32,7 @@ static void pacify_guard(struct monst *);
|
||||
|
||||
#define LEVEL_SPECIFIC_NOCORPSE(mdat) \
|
||||
(Is_rogue_level(&u.uz) \
|
||||
|| (g.level.flags.graveyard && is_undead(mdat) && rn2(3)))
|
||||
|| (gl.level.flags.graveyard && is_undead(mdat) && rn2(3)))
|
||||
|
||||
/* A specific combination of x_monnam flags for livelogging. The livelog
|
||||
* shouldn't show that you killed a hallucinatory monster and not what it
|
||||
@@ -99,7 +99,7 @@ sanity_check_single_mon(
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
if (chk_geno && (g.mvitals[mndx].mvflags & G_GENOD) != 0)
|
||||
if (chk_geno && (gm.mvitals[mndx].mvflags & G_GENOD) != 0)
|
||||
impossible("genocided %s in play (%s)",
|
||||
pmname(&mons[mndx], Mgender(mtmp)), msg);
|
||||
if (mtmp->mtame && !mtmp->mpeaceful)
|
||||
@@ -218,7 +218,7 @@ mon_sanity_check(void)
|
||||
if (x != u.ux || y != u.uy)
|
||||
impossible("steed (%s) claims to be at <%d,%d>?",
|
||||
fmt_ptr((genericptr_t) mtmp), x, y);
|
||||
} else if (g.level.monsters[x][y] != mtmp) {
|
||||
} else if (gl.level.monsters[x][y] != mtmp) {
|
||||
impossible("mon (%s) at <%d,%d> is not there!",
|
||||
fmt_ptr((genericptr_t) mtmp), x, y);
|
||||
} else if (mtmp->wormno) {
|
||||
@@ -228,7 +228,7 @@ mon_sanity_check(void)
|
||||
|
||||
for (x = 1; x < COLNO; x++)
|
||||
for (y = 0; y < ROWNO; y++)
|
||||
if ((mtmp = g.level.monsters[x][y]) != 0) {
|
||||
if ((mtmp = gl.level.monsters[x][y]) != 0) {
|
||||
for (m = fmon; m; m = m->nmon)
|
||||
if (m == mtmp)
|
||||
break;
|
||||
@@ -245,7 +245,7 @@ mon_sanity_check(void)
|
||||
mtmp->mx, mtmp->my, x, y);
|
||||
}
|
||||
|
||||
for (mtmp = g.migrating_mons; mtmp; mtmp = mtmp->nmon) {
|
||||
for (mtmp = gm.migrating_mons; mtmp; mtmp = mtmp->nmon) {
|
||||
sanity_check_single_mon(mtmp, FALSE, "migr");
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ int
|
||||
m_poisongas_ok(struct monst* mtmp)
|
||||
{
|
||||
int px, py;
|
||||
boolean is_you = (mtmp == &g.youmonst);
|
||||
boolean is_you = (mtmp == &gy.youmonst);
|
||||
|
||||
/* Non living, non breathing, immune monsters are not concerned */
|
||||
if (nonliving(mtmp->data) || is_vampshifter(mtmp)
|
||||
@@ -480,7 +480,7 @@ pm_to_cham(int mndx)
|
||||
|| is_reviver((mon)->data) \
|
||||
/* normally quest leader will be unique, */ \
|
||||
/* but he or she might have been polymorphed */ \
|
||||
|| (mon)->m_id == g.quest_status.leader_m_id \
|
||||
|| (mon)->m_id == gq.quest_status.leader_m_id \
|
||||
/* special cancellation handling for these */ \
|
||||
|| (dmgtype((mon)->data, AD_SEDU) || dmgtype((mon)->data, AD_SSEX)))
|
||||
|
||||
@@ -653,7 +653,7 @@ make_corpse(struct monst *mtmp, unsigned int corpseflags)
|
||||
return obj;
|
||||
default:
|
||||
default_1:
|
||||
if (g.mvitals[mndx].mvflags & G_NOCORPSE) {
|
||||
if (gm.mvitals[mndx].mvflags & G_NOCORPSE) {
|
||||
return (struct obj *) 0;
|
||||
} else {
|
||||
corpstatflags |= CORPSTAT_INIT;
|
||||
@@ -677,7 +677,7 @@ make_corpse(struct monst *mtmp, unsigned int corpseflags)
|
||||
|
||||
/* if polymorph or undead turning has killed this monster,
|
||||
prevent the same attack beam from hitting its corpse */
|
||||
if (g.context.bypasses)
|
||||
if (gc.context.bypasses)
|
||||
bypass_obj(obj);
|
||||
|
||||
if (has_mgivenname(mtmp))
|
||||
@@ -795,7 +795,7 @@ minliquid_core(struct monst* mtmp)
|
||||
hero to create lava beneath a monster, so the !mon_moving
|
||||
case is not expected to happen (and we haven't made a
|
||||
player-against-monster variation of the message above) */
|
||||
if (g.context.mon_moving)
|
||||
if (gc.context.mon_moving)
|
||||
mondead(mtmp); /* no corpse */
|
||||
else
|
||||
xkilled(mtmp, XKILL_NOMSG);
|
||||
@@ -830,7 +830,7 @@ minliquid_core(struct monst* mtmp)
|
||||
return 0;
|
||||
}
|
||||
if (cansee(mtmp->mx, mtmp->my)) {
|
||||
if (g.context.mon_moving)
|
||||
if (gc.context.mon_moving)
|
||||
pline("%s drowns.", Monnam(mtmp));
|
||||
else
|
||||
/* hero used fire to melt ice that monster was on */
|
||||
@@ -842,7 +842,7 @@ minliquid_core(struct monst* mtmp)
|
||||
pline("%s sinks as %s rushes in and flushes you out.",
|
||||
Monnam(mtmp), hliquid("water"));
|
||||
}
|
||||
if (g.context.mon_moving)
|
||||
if (gc.context.mon_moving)
|
||||
mondied(mtmp); /* ok to leave corpse despite water */
|
||||
else
|
||||
xkilled(mtmp, XKILL_NOMSG);
|
||||
@@ -885,7 +885,7 @@ mcalcmove(
|
||||
else if (mon->mspeed == MFAST)
|
||||
mmove = (4 * mmove + 2) / 3;
|
||||
|
||||
if (mon == u.usteed && u.ugallop && g.context.mv) {
|
||||
if (mon == u.usteed && u.ugallop && gc.context.mv) {
|
||||
/* increase movement by a factor of 1.5; also increase variance of
|
||||
movement speed (if it's naturally 24, we don't want it to always
|
||||
become 36) */
|
||||
@@ -923,7 +923,7 @@ m_calcdistress(struct monst *mtmp)
|
||||
to end up in water or lava; note: when not in liquid they regen,
|
||||
shape-shift, timeout temporary maladies just like other monsters */
|
||||
if (mtmp->data->mmove == 0) {
|
||||
if (g.vision_full_recalc)
|
||||
if (gv.vision_full_recalc)
|
||||
vision_recalc(0);
|
||||
if (minliquid(mtmp))
|
||||
return;
|
||||
@@ -959,10 +959,10 @@ movemon_singlemon(struct monst *mtmp)
|
||||
if (u.utotype
|
||||
#ifdef SAFERHANGUP
|
||||
/* or if the program has lost contact with the user */
|
||||
|| g.program_state.done_hup
|
||||
|| gp.program_state.done_hup
|
||||
#endif
|
||||
) {
|
||||
g.somebody_can_move = FALSE;
|
||||
gs.somebody_can_move = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -974,9 +974,9 @@ movemon_singlemon(struct monst *mtmp)
|
||||
mon->isgd flag so that dmonsfree() will get rid of mon) */
|
||||
if (mtmp->isgd && !mtmp->mx && !(mtmp->mstate & MON_MIGRATING)) {
|
||||
/* parked at <0,0>; eventually isgd should get set to false */
|
||||
if (g.moves > mtmp->mlstmv) {
|
||||
if (gm.moves > mtmp->mlstmv) {
|
||||
(void) gd_move(mtmp);
|
||||
mtmp->mlstmv = g.moves;
|
||||
mtmp->mlstmv = gm.moves;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
@@ -993,13 +993,13 @@ movemon_singlemon(struct monst *mtmp)
|
||||
|
||||
mtmp->movement -= NORMAL_SPEED;
|
||||
if (mtmp->movement >= NORMAL_SPEED)
|
||||
g.somebody_can_move = TRUE;
|
||||
gs.somebody_can_move = TRUE;
|
||||
|
||||
if (g.vision_full_recalc)
|
||||
if (gv.vision_full_recalc)
|
||||
vision_recalc(0); /* vision! */
|
||||
|
||||
/* reset obj bypasses before next monster moves */
|
||||
if (g.context.bypasses)
|
||||
if (gc.context.bypasses)
|
||||
clear_bypasses();
|
||||
clear_splitobjs();
|
||||
if (minliquid(mtmp))
|
||||
@@ -1065,14 +1065,14 @@ movemon_singlemon(struct monst *mtmp)
|
||||
int
|
||||
movemon(void)
|
||||
{
|
||||
g.somebody_can_move = FALSE;
|
||||
gs.somebody_can_move = FALSE;
|
||||
|
||||
iter_mons_safe(movemon_singlemon);
|
||||
|
||||
if (any_light_source())
|
||||
g.vision_full_recalc = 1; /* in case a mon moved with a light source */
|
||||
gv.vision_full_recalc = 1; /* in case a mon moved with a light source */
|
||||
/* reset obj bypasses after last monster has moved */
|
||||
if (g.context.bypasses)
|
||||
if (gc.context.bypasses)
|
||||
clear_bypasses();
|
||||
clear_splitobjs();
|
||||
/* remove dead monsters; dead vault guard will be left at <0,0>
|
||||
@@ -1083,10 +1083,10 @@ movemon(void)
|
||||
if (u.utotype) {
|
||||
deferred_goto();
|
||||
/* changed levels, so these monsters are dormant */
|
||||
g.somebody_can_move = FALSE;
|
||||
gs.somebody_can_move = FALSE;
|
||||
}
|
||||
|
||||
return g.somebody_can_move;
|
||||
return gs.somebody_can_move;
|
||||
}
|
||||
|
||||
/* dispose of contents of an eaten container; used for pets and other mons */
|
||||
@@ -1145,7 +1145,7 @@ meatmetal(struct monst *mtmp)
|
||||
return 0;
|
||||
|
||||
/* Eats topmost metal object if it is there */
|
||||
for (otmp = g.level.objects[mtmp->mx][mtmp->my]; otmp;
|
||||
for (otmp = gl.level.objects[mtmp->mx][mtmp->my]; otmp;
|
||||
otmp = otmp->nexthere) {
|
||||
/* Don't eat indigestible/choking/inappropriate objects */
|
||||
if ((mtmp->data == &mons[PM_RUST_MONSTER] && !is_rustprone(otmp))
|
||||
@@ -1261,7 +1261,7 @@ meatobj(struct monst* mtmp) /* for gelatinous cubes */
|
||||
/* eat organic objects, including cloth and wood, if present;
|
||||
engulf others, except huge rocks and metal attached to player
|
||||
[despite comment at top, doesn't assume that eater is a g-cube] */
|
||||
for (otmp = g.level.objects[mtmp->mx][mtmp->my]; otmp; otmp = otmp2) {
|
||||
for (otmp = gl.level.objects[mtmp->mx][mtmp->my]; otmp; otmp = otmp2) {
|
||||
otmp2 = otmp->nexthere;
|
||||
|
||||
/* avoid special items; once hero picks them up, they'll cease
|
||||
@@ -1603,7 +1603,7 @@ mpickstuff(struct monst *mtmp, const char *str)
|
||||
if (mtmp->isshk && inhishop(mtmp))
|
||||
return FALSE;
|
||||
|
||||
for (otmp = g.level.objects[mtmp->mx][mtmp->my]; otmp; otmp = otmp2) {
|
||||
for (otmp = gl.level.objects[mtmp->mx][mtmp->my]; otmp; otmp = otmp2) {
|
||||
otmp2 = otmp->nexthere;
|
||||
|
||||
/* avoid special items; once hero picks them up, they'll cease
|
||||
@@ -2025,7 +2025,7 @@ mfndpos(
|
||||
}
|
||||
/* Note: ALLOW_SANCT only prevents movement, not
|
||||
attack, into a temple. */
|
||||
if (g.level.flags.has_temple && *in_rooms(nx, ny, TEMPLE)
|
||||
if (gl.level.flags.has_temple && *in_rooms(nx, ny, TEMPLE)
|
||||
&& !*in_rooms(x, y, TEMPLE)
|
||||
&& in_your_sanctuary((struct monst *) 0, nx, ny)) {
|
||||
if (!(flag & ALLOW_SANCT))
|
||||
@@ -2219,8 +2219,8 @@ replmon(struct monst *mtmp, struct monst *mtmp2)
|
||||
}
|
||||
mtmp->minvent = 0;
|
||||
/* before relmon(mtmp), because it could clear polearm.hitmon */
|
||||
if (g.context.polearm.hitmon == mtmp)
|
||||
g.context.polearm.hitmon = mtmp2;
|
||||
if (gc.context.polearm.hitmon == mtmp)
|
||||
gc.context.polearm.hitmon = mtmp2;
|
||||
|
||||
/* remove the old monster from the map and from `fmon' list */
|
||||
relmon(mtmp, (struct monst **) 0);
|
||||
@@ -2255,7 +2255,7 @@ replmon(struct monst *mtmp, struct monst *mtmp2)
|
||||
void
|
||||
relmon(
|
||||
struct monst *mon,
|
||||
struct monst **monst_list) /* &g.migrating_mons or &g.mydogs or null */
|
||||
struct monst **monst_list) /* &gm.migrating_mons or &gm.mydogs or null */
|
||||
{
|
||||
if (!fmon)
|
||||
panic("relmon: no fmon available.");
|
||||
@@ -2279,7 +2279,7 @@ relmon(
|
||||
}
|
||||
|
||||
if (monst_list) {
|
||||
/* insert into g.mydogs or g.migrating_mons */
|
||||
/* insert into gm.mydogs or gm.migrating_mons */
|
||||
mon->nmon = *monst_list;
|
||||
*monst_list = mon;
|
||||
} else {
|
||||
@@ -2375,14 +2375,14 @@ static void
|
||||
mon_leaving_level(struct monst *mon)
|
||||
{
|
||||
coordxy mx = mon->mx, my = mon->my;
|
||||
boolean onmap = (isok(mx, my) && g.level.monsters[mx][my] == mon);
|
||||
boolean onmap = (isok(mx, my) && gl.level.monsters[mx][my] == mon);
|
||||
|
||||
/* to prevent an infinite relobj-flooreffects-hmon-killed loop */
|
||||
mon->mtrapped = 0;
|
||||
unstuck(mon); /* mon is not swallowing or holding you nor held by you */
|
||||
|
||||
/* vault guard might be at <0,0> */
|
||||
if (onmap || mon == g.level.monsters[0][0]) {
|
||||
if (onmap || mon == gl.level.monsters[0][0]) {
|
||||
if (mon->wormno)
|
||||
remove_worm(mon);
|
||||
else
|
||||
@@ -2404,8 +2404,8 @@ mon_leaving_level(struct monst *mon)
|
||||
newsym(mx, my);
|
||||
}
|
||||
/* if mon is a remembered target, forget it since it isn't here anymore */
|
||||
if (mon == g.context.polearm.hitmon)
|
||||
g.context.polearm.hitmon = (struct monst *) 0;
|
||||
if (mon == gc.context.polearm.hitmon)
|
||||
gc.context.polearm.hitmon = (struct monst *) 0;
|
||||
}
|
||||
|
||||
/* 'mtmp' is going away; remove effects of mtmp from other data structures */
|
||||
@@ -2445,7 +2445,7 @@ m_detach(
|
||||
}
|
||||
if (mtmp->data->msound == MS_LEADER)
|
||||
leaddead();
|
||||
if (mtmp->m_id == g.stealmid)
|
||||
if (mtmp->m_id == gs.stealmid)
|
||||
thiefdead();
|
||||
/* release (drop onto map) all objects carried by mtmp; assumes that
|
||||
mtmp->mx,my contains the appropriate location */
|
||||
@@ -2529,7 +2529,7 @@ lifesaved_monster(struct monst* mtmp)
|
||||
/* equip replacement amulet, if any, on next move */
|
||||
check_gear_next_turn(mtmp);
|
||||
|
||||
surviver = !(g.mvitals[monsndx(mtmp->data)].mvflags & G_GENOD);
|
||||
surviver = !(gm.mvitals[monsndx(mtmp->data)].mvflags & G_GENOD);
|
||||
mtmp->mcanmove = 1;
|
||||
mtmp->mfrozen = 0;
|
||||
if (mtmp->mtame && !mtmp->isminion) {
|
||||
@@ -2570,14 +2570,14 @@ mondead(struct monst *mtmp)
|
||||
/* this only happens if shapeshifted */
|
||||
mndx = mtmp->cham;
|
||||
if (mndx >= LOW_PM && mndx != monsndx(mtmp->data)
|
||||
&& !(g.mvitals[mndx].mvflags & G_GENOD)) {
|
||||
&& !(gm.mvitals[mndx].mvflags & G_GENOD)) {
|
||||
coord new_xy;
|
||||
char buf[BUFSZ];
|
||||
/* alternate message phrasing for some monster types */
|
||||
boolean spec_mon = (nonliving(mtmp->data)
|
||||
|| noncorporeal(mtmp->data)
|
||||
|| amorphous(mtmp->data)),
|
||||
spec_death = (g.disintegested /* disintegrated/digested */
|
||||
spec_death = (gd.disintegested /* disintegrated/digested */
|
||||
|| noncorporeal(mtmp->data)
|
||||
|| amorphous(mtmp->data));
|
||||
coordxy x = mtmp->mx, y = mtmp->my;
|
||||
@@ -2620,7 +2620,7 @@ mondead(struct monst *mtmp)
|
||||
x_monnam(mtmp, ARTICLE_A, (char *) 0,
|
||||
(SUPPRESS_NAME | SUPPRESS_IT
|
||||
| SUPPRESS_INVISIBLE), FALSE));
|
||||
g.vamp_rise_msg = TRUE;
|
||||
gv.vamp_rise_msg = TRUE;
|
||||
}
|
||||
newsym(x, y);
|
||||
return;
|
||||
@@ -2653,7 +2653,7 @@ mondead(struct monst *mtmp)
|
||||
set_mon_data(mtmp, &mons[PM_HUMAN_WERERAT]);
|
||||
|
||||
/*
|
||||
* g.mvitals[].died does double duty as total number of dead monsters
|
||||
* gm.mvitals[].died does double duty as total number of dead monsters
|
||||
* and as experience factor for the player killing more monsters.
|
||||
* this means that a dragon dying by other means reduces the
|
||||
* experience the player gets for killing a dragon directly; this
|
||||
@@ -2663,16 +2663,16 @@ mondead(struct monst *mtmp)
|
||||
* for rings of conflict and such.
|
||||
*/
|
||||
mndx = monsndx(mtmp->data);
|
||||
if (g.mvitals[mndx].died < 255)
|
||||
g.mvitals[mndx].died++;
|
||||
if (gm.mvitals[mndx].died < 255)
|
||||
gm.mvitals[mndx].died++;
|
||||
|
||||
/* if it's a (possibly polymorphed) quest leader, mark him as dead */
|
||||
if (mtmp->m_id == g.quest_status.leader_m_id)
|
||||
g.quest_status.leader_is_dead = TRUE;
|
||||
if (mtmp->m_id == gq.quest_status.leader_m_id)
|
||||
gq.quest_status.leader_is_dead = TRUE;
|
||||
#ifdef MAIL_STRUCTURES
|
||||
/* if the mail daemon dies, no more mail delivery. -3. */
|
||||
if (mndx == PM_MAIL_DAEMON)
|
||||
g.mvitals[mndx].mvflags |= G_GENOD;
|
||||
gm.mvitals[mndx].mvflags |= G_GENOD;
|
||||
#endif
|
||||
|
||||
if (mtmp->data->mlet == S_KOP) {
|
||||
@@ -2700,7 +2700,7 @@ mondead(struct monst *mtmp)
|
||||
nemdead();
|
||||
#endif
|
||||
|
||||
if (mndx == PM_MEDUSA && g.mvitals[mndx].died == 1) {
|
||||
if (mndx == PM_MEDUSA && gm.mvitals[mndx].died == 1) {
|
||||
record_achievement(ACH_MEDU); /* also generates a livelog event */
|
||||
} else if (unique_corpstat(mtmp->data)) {
|
||||
/*
|
||||
@@ -2711,7 +2711,7 @@ mondead(struct monst *mtmp)
|
||||
* unique within each game but unfortunately for this potential
|
||||
* usage their kill count is lumped together in a group total.
|
||||
*/
|
||||
int howmany = g.mvitals[mndx].died;
|
||||
int howmany = gm.mvitals[mndx].died;
|
||||
|
||||
/* killing a unique more than once doesn't get logged every time;
|
||||
the Wizard and the Riders can be killed more than once
|
||||
@@ -2772,11 +2772,11 @@ corpse_chance(
|
||||
else
|
||||
tmp = 0;
|
||||
if (was_swallowed && magr) {
|
||||
if (magr == &g.youmonst) {
|
||||
if (magr == &gy.youmonst) {
|
||||
There("is an explosion in your %s!", body_part(STOMACH));
|
||||
Sprintf(g.killer.name, "%s explosion",
|
||||
Sprintf(gk.killer.name, "%s explosion",
|
||||
s_suffix(pmname(mdat, Mgender(mon))));
|
||||
losehp(Maybe_Half_Phys(tmp), g.killer.name, KILLED_BY_AN);
|
||||
losehp(Maybe_Half_Phys(tmp), gk.killer.name, KILLED_BY_AN);
|
||||
} else {
|
||||
You_hear("an explosion.");
|
||||
magr->mhp -= tmp;
|
||||
@@ -2960,9 +2960,9 @@ monkilled(
|
||||
rot completely are described as "falling to pieces" so they do
|
||||
leave a corpse (which means staves for wood golem, leather armor for
|
||||
leather golem, iron chains for iron golem, not a regular corpse) */
|
||||
g.disintegested = (how == AD_DGST || how == -AD_RBRE
|
||||
gd.disintegested = (how == AD_DGST || how == -AD_RBRE
|
||||
|| (how == AD_FIRE && completelyburns(mptr)));
|
||||
if (g.disintegested)
|
||||
if (gd.disintegested)
|
||||
mondead(mdef); /* never leaves a corpse */
|
||||
else
|
||||
mondied(mdef); /* calls mondead() and maybe leaves a corpse */
|
||||
@@ -2991,7 +2991,7 @@ set_ustuck(struct monst *mtmp)
|
||||
mon_nam(mtmp), mdistu(mtmp));
|
||||
}
|
||||
|
||||
g.context.botl = 1;
|
||||
gc.context.botl = 1;
|
||||
u.ustuck = mtmp;
|
||||
if (!u.ustuck) {
|
||||
u.uswallow = 0;
|
||||
@@ -3015,7 +3015,7 @@ unstuck(struct monst *mtmp)
|
||||
u.uy = mtmp->my;
|
||||
if (Punished && uchain->where != OBJ_FLOOR)
|
||||
placebc();
|
||||
g.vision_full_recalc = 1;
|
||||
gv.vision_full_recalc = 1;
|
||||
docrt();
|
||||
}
|
||||
|
||||
@@ -3088,37 +3088,37 @@ xkilled(
|
||||
if (mtmp->mtame && !mtmp->isminion)
|
||||
EDOG(mtmp)->killed_by_u = 1;
|
||||
|
||||
if (wasinside && g.thrownobj && g.thrownobj != uball
|
||||
if (wasinside && gt.thrownobj && gt.thrownobj != uball
|
||||
/* don't give to mon if missile is going to be destroyed */
|
||||
&& g.thrownobj->oclass != POTION_CLASS
|
||||
&& gt.thrownobj->oclass != POTION_CLASS
|
||||
/* don't give to mon if missile is going to return to hero */
|
||||
&& g.thrownobj != (struct obj *) iflags.returning_missile) {
|
||||
&& gt.thrownobj != (struct obj *) iflags.returning_missile) {
|
||||
/* thrown object has killed hero's engulfer; add it to mon's
|
||||
inventory now so that it will be placed with mon's other
|
||||
stuff prior to lookhere/autopickup when hero is expelled
|
||||
below (as a side-effect, this missile has immunity from
|
||||
being consumed [for this shot/throw only]) */
|
||||
mpickobj(mtmp, g.thrownobj);
|
||||
mpickobj(mtmp, gt.thrownobj);
|
||||
/* let throwing code know that missile has been disposed of */
|
||||
g.thrownobj = 0;
|
||||
gt.thrownobj = 0;
|
||||
}
|
||||
|
||||
g.vamp_rise_msg = FALSE; /* might get set in mondead(); checked below */
|
||||
g.disintegested = nocorpse; /* alternate vamp_rise mesg needed if true */
|
||||
gv.vamp_rise_msg = FALSE; /* might get set in mondead(); checked below */
|
||||
gd.disintegested = nocorpse; /* alternate vamp_rise mesg needed if true */
|
||||
/* dispose of monster and make cadaver */
|
||||
if (g.stoned)
|
||||
if (gs.stoned)
|
||||
monstone(mtmp);
|
||||
else
|
||||
mondead(mtmp);
|
||||
g.disintegested = FALSE; /* reset */
|
||||
gd.disintegested = FALSE; /* reset */
|
||||
|
||||
if (!DEADMONSTER(mtmp)) { /* monster lifesaved */
|
||||
/* Cannot put the non-visible lifesaving message in
|
||||
* lifesaved_monster() since the message appears only when _you_
|
||||
* kill it (as opposed to visible lifesaving which always appears).
|
||||
*/
|
||||
g.stoned = FALSE;
|
||||
if (!cansee(x, y) && !g.vamp_rise_msg)
|
||||
gs.stoned = FALSE;
|
||||
if (!cansee(x, y) && !gv.vamp_rise_msg)
|
||||
pline("Maybe not...");
|
||||
return;
|
||||
}
|
||||
@@ -3129,8 +3129,8 @@ xkilled(
|
||||
mdat = mtmp->data; /* note: mondead can change mtmp->data */
|
||||
mndx = monsndx(mdat);
|
||||
|
||||
if (g.stoned) {
|
||||
g.stoned = FALSE;
|
||||
if (gs.stoned) {
|
||||
gs.stoned = FALSE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@@ -3147,7 +3147,7 @@ xkilled(
|
||||
int otyp;
|
||||
|
||||
/* illogical but traditional "treasure drop" */
|
||||
if (!rn2(6) && !(g.mvitals[mndx].mvflags & G_NOCORPSE)
|
||||
if (!rn2(6) && !(gm.mvitals[mndx].mvflags & G_NOCORPSE)
|
||||
/* no extra item from swallower or steed */
|
||||
&& (x != u.ux || y != u.uy)
|
||||
/* no extra item from kops--too easy to abuse */
|
||||
@@ -3171,12 +3171,12 @@ xkilled(
|
||||
}
|
||||
/* corpse--none if hero was inside the monster */
|
||||
if (!wasinside && corpse_chance(mtmp, (struct monst *) 0, FALSE)) {
|
||||
g.zombify = (!g.thrownobj && !g.stoned && !uwep
|
||||
&& zombie_maker(&g.youmonst)
|
||||
gz.zombify = (!gt.thrownobj && !gs.stoned && !uwep
|
||||
&& zombie_maker(&gy.youmonst)
|
||||
&& zombie_form(mtmp->data) != NON_PM);
|
||||
cadaver = make_corpse(mtmp, burycorpse ? CORPSTAT_BURIED
|
||||
: CORPSTAT_NONE);
|
||||
g.zombify = FALSE; /* reset */
|
||||
gz.zombify = FALSE; /* reset */
|
||||
if (burycorpse && cadaver && cansee(x, y) && !mtmp->minvis
|
||||
&& cadaver->where == OBJ_BURIED && !nomsg) {
|
||||
pline("%s corpse ends up buried.", s_suffix(Monnam(mtmp)));
|
||||
@@ -3208,19 +3208,19 @@ xkilled(
|
||||
}
|
||||
|
||||
/* give experience points */
|
||||
tmp = experience(mtmp, (int) g.mvitals[mndx].died);
|
||||
tmp = experience(mtmp, (int) gm.mvitals[mndx].died);
|
||||
more_experienced(tmp, 0);
|
||||
newexplevel(); /* will decide if you go up */
|
||||
|
||||
/* adjust alignment points */
|
||||
if (mtmp->m_id == g.quest_status.leader_m_id) { /* REAL BAD! */
|
||||
if (mtmp->m_id == gq.quest_status.leader_m_id) { /* REAL BAD! */
|
||||
adjalign(-(u.ualign.record + (int) ALIGNLIM / 2));
|
||||
u.ugangr += 7; /* instantly become "extremely" angry */
|
||||
change_luck(-20);
|
||||
pline("That was %sa bad idea...",
|
||||
u.uevent.qcompleted ? "probably " : "");
|
||||
} else if (mdat->msound == MS_NEMESIS) { /* Real good! */
|
||||
if (!g.quest_status.killed_leader)
|
||||
if (!gq.quest_status.killed_leader)
|
||||
adjalign((int) (ALIGNLIM / 4));
|
||||
} else if (mdat->msound == MS_GUARDIAN) { /* Bad */
|
||||
adjalign(-(int) (ALIGNLIM / 8));
|
||||
@@ -3289,7 +3289,7 @@ vamp_stone(struct monst *mtmp)
|
||||
|
||||
/* this only happens if shapeshifted */
|
||||
if (mndx >= LOW_PM && mndx != monsndx(mtmp->data)
|
||||
&& !(g.mvitals[mndx].mvflags & G_GENOD)) {
|
||||
&& !(gm.mvitals[mndx].mvflags & G_GENOD)) {
|
||||
char buf[BUFSZ];
|
||||
|
||||
/* construct a format string before transformation */
|
||||
@@ -3400,10 +3400,10 @@ elemental_clog(struct monst *mon)
|
||||
|
||||
if (In_endgame(&u.uz)) {
|
||||
m1 = m2 = m3 = m4 = m5 = zm = (struct monst *) 0;
|
||||
if (!msgmv || (g.moves - msgmv) > 200L) {
|
||||
if (!msgmv || (gm.moves - msgmv) > 200L) {
|
||||
if (!msgmv || rn2(2))
|
||||
You_feel("besieged.");
|
||||
msgmv = g.moves;
|
||||
msgmv = gm.moves;
|
||||
}
|
||||
/*
|
||||
* m1 an elemental from another plane.
|
||||
@@ -3701,7 +3701,7 @@ setmangry(struct monst* mtmp, boolean via_attack)
|
||||
}
|
||||
|
||||
/* make other peaceful monsters react */
|
||||
if (!g.context.mon_moving) {
|
||||
if (!gc.context.mon_moving) {
|
||||
struct monst *mon;
|
||||
int mndx = monsndx(mtmp->data);
|
||||
|
||||
@@ -3810,7 +3810,7 @@ wakeup(struct monst* mtmp, boolean via_attack)
|
||||
have to lose his disguise */
|
||||
if (M_AP_TYPE(mtmp) != M_AP_MONSTER)
|
||||
seemimic(mtmp);
|
||||
} else if (g.context.forcefight && !g.context.mon_moving
|
||||
} else if (gc.context.forcefight && !gc.context.mon_moving
|
||||
&& mtmp->mundetected) {
|
||||
mtmp->mundetected = 0;
|
||||
newsym(mtmp->mx, mtmp->my);
|
||||
@@ -3843,11 +3843,11 @@ wake_nearto(coordxy x, coordxy y, int distance)
|
||||
mtmp->msleeping = 0; /* wake indeterminate sleep */
|
||||
if (!(mtmp->data->geno & G_UNIQ))
|
||||
mtmp->mstrategy &= ~STRAT_WAITMASK; /* wake 'meditation' */
|
||||
if (g.context.mon_moving)
|
||||
if (gc.context.mon_moving)
|
||||
continue;
|
||||
if (mtmp->mtame) {
|
||||
if (!mtmp->isminion)
|
||||
EDOG(mtmp)->whistletime = g.moves;
|
||||
EDOG(mtmp)->whistletime = gm.moves;
|
||||
/* Fix up a pet who is stuck "fleeing" its master */
|
||||
mon_track_clear(mtmp);
|
||||
}
|
||||
@@ -4068,7 +4068,7 @@ maybe_unhide_at(coordxy x, coordxy y)
|
||||
if (OBJ_AT(x, y))
|
||||
return;
|
||||
if ((mtmp = m_at(x, y)) == 0 && u_at(x, y))
|
||||
mtmp = &g.youmonst;
|
||||
mtmp = &gy.youmonst;
|
||||
if (mtmp && mtmp->mundetected && hides_under(mtmp->data))
|
||||
(void) hideunder(mtmp);
|
||||
}
|
||||
@@ -4078,7 +4078,7 @@ boolean
|
||||
hideunder(struct monst *mtmp)
|
||||
{
|
||||
struct trap *t;
|
||||
boolean oldundetctd, undetected = FALSE, is_u = (mtmp == &g.youmonst);
|
||||
boolean oldundetctd, undetected = FALSE, is_u = (mtmp == &gy.youmonst);
|
||||
coordxy x = is_u ? u.ux : mtmp->mx, y = is_u ? u.uy : mtmp->my;
|
||||
|
||||
if (mtmp == u.ustuck) {
|
||||
@@ -4090,14 +4090,14 @@ hideunder(struct monst *mtmp)
|
||||
} else if (mtmp->data->mlet == S_EEL) {
|
||||
undetected = (is_pool(x, y) && !Is_waterlevel(&u.uz));
|
||||
} else if (hides_under(mtmp->data) && OBJ_AT(x, y)) {
|
||||
struct obj *otmp = g.level.objects[x][y];
|
||||
struct obj *otmp = gl.level.objects[x][y];
|
||||
|
||||
/* most monsters won't hide under cockatrice corpse but they
|
||||
can hide under a pile containing more than just such corpses */
|
||||
while (otmp && otmp->otyp == CORPSE
|
||||
&& touch_petrifies(&mons[otmp->corpsenm]))
|
||||
otmp = otmp->nexthere;
|
||||
if (otmp != 0 || ((mtmp == &g.youmonst) ? Stone_resistance
|
||||
if (otmp != 0 || ((mtmp == &gy.youmonst) ? Stone_resistance
|
||||
: resists_ston(mtmp)))
|
||||
undetected = TRUE;
|
||||
}
|
||||
@@ -4123,16 +4123,16 @@ hide_monst(struct monst* mon)
|
||||
if ((is_hider(mon->data) || hider_under)
|
||||
&& !(mon->mundetected || M_AP_TYPE(mon))) {
|
||||
coordxy x = mon->mx, y = mon->my;
|
||||
char save_viz = g.viz_array[y][x];
|
||||
char save_viz = gv.viz_array[y][x];
|
||||
|
||||
/* override vision, forcing hero to be unable to see monster's spot */
|
||||
g.viz_array[y][x] &= ~(IN_SIGHT | COULD_SEE);
|
||||
gv.viz_array[y][x] &= ~(IN_SIGHT | COULD_SEE);
|
||||
if (is_hider(mon->data))
|
||||
(void) restrap(mon);
|
||||
/* try again if mimic missed its 1/3 chance to hide */
|
||||
if (mon->data->mlet == S_MIMIC && !M_AP_TYPE(mon))
|
||||
(void) restrap(mon);
|
||||
g.viz_array[y][x] = save_viz;
|
||||
gv.viz_array[y][x] = save_viz;
|
||||
if (hider_under)
|
||||
(void) hideunder(mon);
|
||||
}
|
||||
@@ -4152,14 +4152,14 @@ mon_animal_list(boolean construct)
|
||||
animal_temp[n++] = i;
|
||||
/* if (n == 0) animal_temp[n++] = NON_PM; */
|
||||
|
||||
g.animal_list = (short *) alloc(n * sizeof *g.animal_list);
|
||||
(void) memcpy((genericptr_t) g.animal_list, (genericptr_t) animal_temp,
|
||||
n * sizeof *g.animal_list);
|
||||
g.animal_list_count = n;
|
||||
ga.animal_list = (short *) alloc(n * sizeof *ga.animal_list);
|
||||
(void) memcpy((genericptr_t) ga.animal_list, (genericptr_t) animal_temp,
|
||||
n * sizeof *ga.animal_list);
|
||||
ga.animal_list_count = n;
|
||||
} else { /* release */
|
||||
if (g.animal_list)
|
||||
free((genericptr_t) g.animal_list), g.animal_list = 0;
|
||||
g.animal_list_count = 0;
|
||||
if (ga.animal_list)
|
||||
free((genericptr_t) ga.animal_list), ga.animal_list = 0;
|
||||
ga.animal_list_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4168,15 +4168,15 @@ pick_animal(void)
|
||||
{
|
||||
int res;
|
||||
|
||||
if (!g.animal_list)
|
||||
if (!ga.animal_list)
|
||||
mon_animal_list(TRUE);
|
||||
|
||||
res = g.animal_list[rn2(g.animal_list_count)];
|
||||
res = ga.animal_list[rn2(ga.animal_list_count)];
|
||||
/* rogue level should use monsters represented by uppercase letters
|
||||
only, but since chameleons aren't generated there (not uppercase!)
|
||||
we don't perform a lot of retries */
|
||||
if (Is_rogue_level(&u.uz) && !isupper((uchar) mons[res].mlet))
|
||||
res = g.animal_list[rn2(g.animal_list_count)];
|
||||
res = ga.animal_list[rn2(ga.animal_list_count)];
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -4274,7 +4274,7 @@ pickvampshape(struct monst* mon)
|
||||
break;
|
||||
}
|
||||
|
||||
if (g.mvitals[mndx].mvflags & G_GENOD)
|
||||
if (gm.mvitals[mndx].mvflags & G_GENOD)
|
||||
return mon->cham;
|
||||
|
||||
return mndx;
|
||||
@@ -4285,7 +4285,7 @@ static boolean
|
||||
isspecmon(struct monst* mon)
|
||||
{
|
||||
return (mon->isshk || mon->ispriest || mon->isgd
|
||||
|| mon->m_id == g.quest_status.leader_m_id);
|
||||
|| mon->m_id == gq.quest_status.leader_m_id);
|
||||
}
|
||||
|
||||
/* restrict certain special monsters (shopkeepers, aligned priests,
|
||||
@@ -4393,7 +4393,7 @@ select_newcham_form(struct monst* mon)
|
||||
} else if (!rn2(3)) { /* quest guardians */
|
||||
mndx = rn1(PM_APPRENTICE - PM_STUDENT + 1, PM_STUDENT);
|
||||
/* avoid own role's guardian */
|
||||
if (mndx == g.urole.guardnum)
|
||||
if (mndx == gu.urole.guardnum)
|
||||
mndx = NON_PM;
|
||||
} else { /* general humanoids */
|
||||
tryct = 5;
|
||||
@@ -4526,7 +4526,7 @@ accept_newcham_form(struct monst *mon, int mndx)
|
||||
if (mndx == NON_PM)
|
||||
return 0;
|
||||
mdat = &mons[mndx];
|
||||
if ((g.mvitals[mndx].mvflags & G_GENOD) != 0)
|
||||
if ((gm.mvitals[mndx].mvflags & G_GENOD) != 0)
|
||||
return 0;
|
||||
if (is_placeholder(mdat))
|
||||
return 0;
|
||||
@@ -4624,7 +4624,7 @@ newcham(
|
||||
} while (--tryct > 0);
|
||||
if (!tryct)
|
||||
return 0;
|
||||
} else if (g.mvitals[monsndx(mdat)].mvflags & G_GENOD)
|
||||
} else if (gm.mvitals[monsndx(mdat)].mvflags & G_GENOD)
|
||||
return 0; /* passed in mdat is genocided */
|
||||
|
||||
if (mdat == olddata)
|
||||
@@ -4726,7 +4726,7 @@ newcham(
|
||||
/* update swallow glyphs for new monster */
|
||||
swallowed(0);
|
||||
}
|
||||
} else if (!sticks(mdat) && !sticks(g.youmonst.data))
|
||||
} else if (!sticks(mdat) && !sticks(gy.youmonst.data))
|
||||
unstuck(mtmp);
|
||||
}
|
||||
|
||||
@@ -4762,7 +4762,7 @@ newcham(
|
||||
mon_break_armor(mtmp, polyspot);
|
||||
if (!(mtmp->misc_worn_check & W_ARMG))
|
||||
mselftouch(mtmp, "No longer petrify-resistant, ",
|
||||
!g.context.mon_moving);
|
||||
!gc.context.mon_moving);
|
||||
check_gear_next_turn(mtmp);
|
||||
|
||||
/* This ought to re-test can_carry() on each item in the inventory
|
||||
@@ -4856,8 +4856,8 @@ dead_species(int m_idx, boolean egg)
|
||||
* overpopulation does not kill eggs.
|
||||
*/
|
||||
alt_idx = egg ? big_to_little(m_idx) : m_idx;
|
||||
return (boolean) ((g.mvitals[m_idx].mvflags & G_GENOD) != 0
|
||||
|| (g.mvitals[alt_idx].mvflags & G_GENOD) != 0);
|
||||
return (boolean) ((gm.mvitals[m_idx].mvflags & G_GENOD) != 0
|
||||
|| (gm.mvitals[alt_idx].mvflags & G_GENOD) != 0);
|
||||
}
|
||||
|
||||
/* kill off any eggs of genocided monsters */
|
||||
@@ -4915,8 +4915,8 @@ kill_genocided_monsters(void)
|
||||
continue;
|
||||
mndx = monsndx(mtmp->data);
|
||||
kill_cham = (mtmp->cham >= LOW_PM
|
||||
&& (g.mvitals[mtmp->cham].mvflags & G_GENOD));
|
||||
if ((g.mvitals[mndx].mvflags & G_GENOD) || kill_cham) {
|
||||
&& (gm.mvitals[mtmp->cham].mvflags & G_GENOD));
|
||||
if ((gm.mvitals[mndx].mvflags & G_GENOD) || kill_cham) {
|
||||
if (mtmp->cham >= LOW_PM && !kill_cham)
|
||||
(void) newcham(mtmp, (struct permonst *) 0, NC_SHOW_MSG);
|
||||
else
|
||||
@@ -4926,10 +4926,10 @@ kill_genocided_monsters(void)
|
||||
kill_eggs(mtmp->minvent);
|
||||
}
|
||||
|
||||
kill_eggs(g.invent);
|
||||
kill_eggs(gi.invent);
|
||||
kill_eggs(fobj);
|
||||
kill_eggs(g.migrating_objs);
|
||||
kill_eggs(g.level.buriedobjlist);
|
||||
kill_eggs(gm.migrating_objs);
|
||||
kill_eggs(gl.level.buriedobjlist);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -5058,7 +5058,7 @@ usmellmon(struct permonst* mdat)
|
||||
boolean msg_given = FALSE;
|
||||
|
||||
if (mdat) {
|
||||
if (!olfaction(g.youmonst.data))
|
||||
if (!olfaction(gy.youmonst.data))
|
||||
return FALSE;
|
||||
mndx = monsndx(mdat);
|
||||
switch (mndx) {
|
||||
@@ -5153,7 +5153,7 @@ usmellmon(struct permonst* mdat)
|
||||
msg_given = TRUE;
|
||||
break;
|
||||
case S_ORC:
|
||||
if (maybe_polyd(is_orc(g.youmonst.data), Race_if(PM_ORC)))
|
||||
if (maybe_polyd(is_orc(gy.youmonst.data), Race_if(PM_ORC)))
|
||||
You("notice an attractive smell.");
|
||||
else
|
||||
pline("A foul stench makes you feel a little nauseated.");
|
||||
|
||||
Reference in New Issue
Block a user