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

Function drain_weapon_skill

src/weapon.c:1475–1514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1473}
1474
1475void
1476drain_weapon_skill(int n) /* number of skills to drain */
1477{
1478 int skill;
1479 int i;
1480 int curradv;
1481 int prevadv;
1482 int tmpskills[P_NUM_SKILLS];
1483
1484 (void) memset((genericptr_t) tmpskills, 0, sizeof(tmpskills));
1485
1486 while (--n >= 0) {
1487 if (u.skills_advanced) {
1488 /* Pick a random skill, deleting it from the list. */
1489 i = rn2(u.skills_advanced);
1490 skill = u.skill_record[i];
1491 tmpskills[skill] = 1;
1492 for (; i < u.skills_advanced - 1; i++) {
1493 u.skill_record[i] = u.skill_record[i + 1];
1494 }
1495 u.skills_advanced--;
1496 if (P_SKILL(skill) <= P_UNSKILLED)
1497 panic("drain_weapon_skill (%d)", skill);
1498 P_SKILL(skill)--; /* drop skill one level */
1499 /* refund slots used for skill */
1500 u.weapon_slots += slots_required(skill);
1501 /* drain skill training to a value appropriate for new level */
1502 curradv = practice_needed_to_advance(P_SKILL(skill));
1503 prevadv = practice_needed_to_advance(P_SKILL(skill) - 1);
1504 if (P_ADVANCE(skill) >= curradv)
1505 P_ADVANCE(skill) = prevadv + rn2(curradv - prevadv);
1506 }
1507 }
1508
1509 for (skill = 0; skill < P_NUM_SKILLS; skill++)
1510 if (tmpskills[skill]) {
1511 You("forget %syour training in %s.",
1512 P_SKILL(skill) >= P_BASIC ? "some of " : "", P_NAME(skill));
1513 }
1514}
1515
1516int
1517weapon_type(struct obj *obj)

Callers 2

mhitm_ad_drinFunction · 0.85
forgetFunction · 0.85

Calls 4

rn2Function · 0.85
slots_requiredFunction · 0.85
YouFunction · 0.85
panicFunction · 0.50

Tested by

no test coverage detected