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

Function spell_backfire

src/spell.c:1180–1217  ·  view source on GitHub ↗

attempting to cast a forgotten spell will cause disorientation */

Source from the content-addressed store, hash-verified

1178
1179/* attempting to cast a forgotten spell will cause disorientation */
1180staticfn void
1181spell_backfire(int spell)
1182{
1183 long duration = (long) ((spellev(spell) + 1) * 3), /* 6..24 */
1184 old_stun = (HStun & TIMEOUT), old_conf = (HConfusion & TIMEOUT);
1185
1186 /* Prior to 3.4.1, only effect was confusion; it still predominates.
1187 *
1188 * 3.6.0: this used to override pre-existing confusion duration
1189 * (cases 0..8) and pre-existing stun duration (cases 4..9);
1190 * increase them instead. (Hero can no longer cast spells while
1191 * Stunned, so the potential increment to stun duration here is
1192 * just hypothetical.)
1193 */
1194 switch (rn2(10)) {
1195 case 0:
1196 case 1:
1197 case 2:
1198 case 3:
1199 make_confused(old_conf + duration, FALSE); /* 40% */
1200 break;
1201 case 4:
1202 case 5:
1203 case 6:
1204 make_confused(old_conf + 2L * duration / 3L, FALSE); /* 30% */
1205 make_stunned(old_stun + duration / 3L, FALSE);
1206 break;
1207 case 7:
1208 case 8:
1209 make_stunned(old_stun + 2L * duration / 3L, FALSE); /* 20% */
1210 make_confused(old_conf + duration / 3L, FALSE);
1211 break;
1212 case 9:
1213 make_stunned(old_stun + duration, FALSE); /* 10% */
1214 break;
1215 }
1216 return;
1217}
1218
1219staticfn boolean
1220spelleffects_check(int spell, int *res, int *energy)

Callers 1

spelleffects_checkFunction · 0.85

Calls 3

rn2Function · 0.85
make_confusedFunction · 0.85
make_stunnedFunction · 0.85

Tested by

no test coverage detected