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

Function inside_gas_cloud

src/region.c:1090–1165  ·  view source on GitHub ↗

returns True if p2 is killed by region p1, False otherwise */

Source from the content-addressed store, hash-verified

1088
1089/* returns True if p2 is killed by region p1, False otherwise */
1090boolean
1091inside_gas_cloud(genericptr_t p1, genericptr_t p2)
1092{
1093 NhRegion *reg = (NhRegion *) p1;
1094 struct monst *mtmp = (struct monst *) p2;
1095 struct monst *umon = mtmp ? mtmp : &gy.youmonst;
1096 int dam = reg->arg.a_int;
1097
1098 /*
1099 * Gas clouds can't be targeted at water locations, but they can
1100 * start next to water and spread over it.
1101 */
1102
1103 /* fog clouds maintain gas clouds, even poisonous ones */
1104 if (reg->ttl < 20 && umon && umon->data == &mons[PM_FOG_CLOUD])
1105 reg->ttl += 5;
1106
1107 if (dam < 1)
1108 return FALSE; /* if no damage then there's nothing to do here... */
1109
1110 if (!mtmp) { /* hero is indicated by Null rather than by &youmonst */
1111 if (m_poisongas_ok(&gy.youmonst) == M_POISONGAS_OK)
1112 return FALSE;
1113 if (!Blind) {
1114 Your("%s sting.", makeplural(body_part(EYE)));
1115 make_blinded(1L, FALSE);
1116 }
1117 if (!Poison_resistance) {
1118 pline("%s is burning your %s!", Something,
1119 makeplural(body_part(LUNG)));
1120 You("cough and spit blood!");
1121 wake_nearto(u.ux, u.uy, 2);
1122 dam = Maybe_Half_Phys(rnd(dam) + 5);
1123 if (Half_gas_damage) /* worn towel */
1124 dam = (dam + 1) / 2;
1125 losehp(dam, "gas cloud", KILLED_BY_AN);
1126 monstunseesu(M_SEEN_POISON);
1127 return FALSE;
1128 } else {
1129 You("cough!");
1130 wake_nearto(u.ux, u.uy, 2);
1131 monstseesu(M_SEEN_POISON);
1132 return FALSE;
1133 }
1134 } else { /* A monster is inside the cloud */
1135 mtmp = (struct monst *) p2;
1136
1137 if (m_poisongas_ok(mtmp) != M_POISONGAS_OK) {
1138 if (!is_silent(mtmp->data)) {
1139 if (cansee(mtmp->mx, mtmp->my)
1140 || (distu(mtmp->mx, mtmp->my) < 8))
1141 pline("%s coughs!", Monnam(mtmp));
1142 wake_nearto(mtmp->mx, mtmp->my, 2);
1143 }
1144 if (heros_fault(reg))
1145 setmangry(mtmp, TRUE);
1146 if (haseyes(mtmp->data) && mtmp->mcansee) {
1147 mtmp->mblinded = 1;

Callers

nothing calls this directly

Calls 15

m_poisongas_okFunction · 0.85
YourFunction · 0.85
makepluralFunction · 0.85
body_partFunction · 0.85
make_blindedFunction · 0.85
YouFunction · 0.85
wake_neartoFunction · 0.85
rndFunction · 0.85
losehpFunction · 0.85
monstunseesuFunction · 0.85
monstseesuFunction · 0.85
MonnamFunction · 0.85

Tested by

no test coverage detected