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

Function expire_gas_cloud

src/region.c:1045–1087  ·  view source on GitHub ↗

* Here is an example of an expire function that may prolong * region life after some mods... */ ARGSUSED*/

Source from the content-addressed store, hash-verified

1043 */
1044/*ARGSUSED*/
1045boolean
1046expire_gas_cloud(genericptr_t p1, genericptr_t p2 UNUSED)
1047{
1048 NhRegion *reg;
1049 int damage, pass;
1050 coordxy x, y;
1051
1052 reg = (NhRegion *) p1;
1053 damage = reg->arg.a_int;
1054
1055 /* If it was a thick cloud, it dissipates a little first */
1056 if (damage >= 5) {
1057 damage /= 2; /* It dissipates, let's do less damage */
1058 reg->arg = cg.zeroany;
1059 reg->arg.a_int = damage;
1060 reg->ttl = 2L; /* Here's the trick : reset ttl */
1061 return FALSE; /* THEN return FALSE, means "still there" */
1062 }
1063
1064 /* The cloud no longer blocks vision. cansee() checks shouldn't be made
1065 until all blocked spots have been unblocked, so we need two passes */
1066 for (pass = 1; pass <= (Blind ? 1 : 2); ++pass) {
1067 for (x = reg->bounding_box.lx; x <= reg->bounding_box.hx; x++) {
1068 for (y = reg->bounding_box.ly; y <= reg->bounding_box.hy; y++) {
1069 if (inside_region(reg, x, y)) {
1070 if (pass == 1) {
1071 if (!does_block(x, y, &levl[x][y]))
1072 unblock_point(x, y);
1073 } else { /* pass==2 */
1074 if (!u.uswallow) {
1075 if (u_at(x, y))
1076 gg.gas_cloud_diss_within = TRUE;
1077 else if (cansee(x, y))
1078 gg.gas_cloud_diss_seen++;
1079 }
1080 }
1081 }
1082 }
1083 }
1084 }
1085
1086 return TRUE; /* OK, it's gone, you can free it! */
1087}
1088
1089/* returns True if p2 is killed by region p1, False otherwise */
1090boolean

Callers

nothing calls this directly

Calls 2

inside_regionFunction · 0.85
unblock_pointFunction · 0.85

Tested by

no test coverage detected