MCPcopy Create free account
hub / github.com/NetHack/NetHack / set_uasmon

Function set_uasmon

src/polyself.c:37–127  ·  view source on GitHub ↗

update the gy.youmonst.data structure pointer and intrinsics */

Source from the content-addressed store, hash-verified

35
36/* update the gy.youmonst.data structure pointer and intrinsics */
37void
38set_uasmon(void)
39{
40 struct permonst *mdat = &mons[u.umonnum];
41 boolean was_vampshifter = valid_vampshiftform(gy.youmonst.cham, u.umonnum);
42
43 set_mon_data(&gy.youmonst, mdat);
44 gy.youmonst.m_id = 1;
45
46 if (Protection_from_shape_changers)
47 gy.youmonst.cham = NON_PM;
48 else if (is_vampire(gy.youmonst.data))
49 gy.youmonst.cham = gy.youmonst.mnum;
50 /* assume hero-as-chameleon/doppelganger/sandestin doesn't change shape */
51 else if (!was_vampshifter)
52 gy.youmonst.cham = NON_PM;
53 u.mcham = gy.youmonst.cham; /* for save/restore since youmonst isn't */
54
55#define PROPSET(PropIndx, ON) \
56 do { \
57 if (ON) \
58 u.uprops[PropIndx].intrinsic |= FROMFORM; \
59 else \
60 u.uprops[PropIndx].intrinsic &= ~FROMFORM; \
61 } while (0)
62#define resist_from_form(MRtyp) ((gy.youmonst.data->mresists & (MRtyp)) != 0)
63
64 PROPSET(FIRE_RES, resist_from_form(MR_FIRE));
65 PROPSET(COLD_RES, resist_from_form( MR_COLD));
66 PROPSET(SLEEP_RES, resist_from_form(MR_SLEEP));
67 PROPSET(DISINT_RES, resist_from_form(MR_DISINT));
68 PROPSET(SHOCK_RES, resist_from_form(MR_ELEC));
69 PROPSET(POISON_RES, resist_from_form(MR_POISON));
70 PROPSET(ACID_RES, resist_from_form(MR_ACID));
71 PROPSET(STONE_RES, resist_from_form(MR_STONE));
72 {
73 /* resists_drli() takes wielded weapon into account; suppress it */
74 struct obj *save_uwep = uwep;
75
76 uwep = 0;
77 PROPSET(DRAIN_RES, resists_drli(&gy.youmonst));
78 uwep = save_uwep;
79 }
80 /* resists_magm() takes wielded, worn, and carried equipment into
81 into account; cheat and duplicate its monster-specific part */
82 PROPSET(ANTIMAGIC, (dmgtype(mdat, AD_MAGM)
83 || mdat == &mons[PM_BABY_GRAY_DRAGON]
84 || dmgtype(mdat, AD_RBRE)));
85 PROPSET(SICK_RES, (mdat->mlet == S_FUNGUS || mdat == &mons[PM_GHOUL]));
86
87 PROPSET(STUNNED, (mdat == &mons[PM_STALKER] || is_bat(mdat)));
88 PROPSET(HALLUC_RES, dmgtype(mdat, AD_HALU));
89 PROPSET(SEE_INVIS, perceives(mdat));
90 PROPSET(TELEPAT, telepathic(mdat));
91 /* note that Infravision uses mons[race] rather than usual mons[role] */
92 PROPSET(INFRAVISION, infravision(Upolyd ? mdat : &mons[gu.urace.mnum]));
93 PROPSET(INVIS, pm_invisible(mdat));
94 PROPSET(TELEPORT, can_teleport(mdat));

Callers 7

allmain.cFile · 0.85
set_ulycnFunction · 0.85
restgamestateFunction · 0.85
polymanFunction · 0.85
change_sexFunction · 0.85
polymonFunction · 0.85
u_init_miscFunction · 0.85

Calls 8

valid_vampshiftformFunction · 0.85
set_mon_dataFunction · 0.85
resists_drliFunction · 0.85
dmgtypeFunction · 0.85
dmgtype_fromattackFunction · 0.85
float_vs_flightFunction · 0.85
polysenseFunction · 0.85
status_initializeFunction · 0.85

Tested by

no test coverage detected