called when gaining a level (before u.ulevel gets incremented); also called with u.ulevel==0 during hero initialization or for re-init if hero turns into a "new man/woman/elf/&c" */
| 1077 | also called with u.ulevel==0 during hero initialization or for |
| 1078 | re-init if hero turns into a "new man/woman/elf/&c" */ |
| 1079 | int |
| 1080 | newhp(void) |
| 1081 | { |
| 1082 | int hp, conplus; |
| 1083 | |
| 1084 | if (u.ulevel == 0) { |
| 1085 | /* Initialize hit points */ |
| 1086 | hp = gu.urole.hpadv.infix + gu.urace.hpadv.infix; |
| 1087 | if (gu.urole.hpadv.inrnd > 0) |
| 1088 | hp += rnd(gu.urole.hpadv.inrnd); |
| 1089 | if (gu.urace.hpadv.inrnd > 0) |
| 1090 | hp += rnd(gu.urace.hpadv.inrnd); |
| 1091 | if (svm.moves == 0) { /* initial hero; skip for polyself to new man */ |
| 1092 | /* Initialize alignment stuff */ |
| 1093 | u.ualign.type = aligns[flags.initalign].value; |
| 1094 | u.ualign.record = gu.urole.initrecord; |
| 1095 | } |
| 1096 | /* no Con adjustment for initial hit points */ |
| 1097 | } else { |
| 1098 | if (u.ulevel < gu.urole.xlev) { |
| 1099 | hp = gu.urole.hpadv.lofix + gu.urace.hpadv.lofix; |
| 1100 | if (gu.urole.hpadv.lornd > 0) |
| 1101 | hp += rnd(gu.urole.hpadv.lornd); |
| 1102 | if (gu.urace.hpadv.lornd > 0) |
| 1103 | hp += rnd(gu.urace.hpadv.lornd); |
| 1104 | } else { |
| 1105 | hp = gu.urole.hpadv.hifix + gu.urace.hpadv.hifix; |
| 1106 | if (gu.urole.hpadv.hirnd > 0) |
| 1107 | hp += rnd(gu.urole.hpadv.hirnd); |
| 1108 | if (gu.urace.hpadv.hirnd > 0) |
| 1109 | hp += rnd(gu.urace.hpadv.hirnd); |
| 1110 | } |
| 1111 | if (ACURR(A_CON) <= 3) |
| 1112 | conplus = -2; |
| 1113 | else if (ACURR(A_CON) <= 6) |
| 1114 | conplus = -1; |
| 1115 | else if (ACURR(A_CON) <= 14) |
| 1116 | conplus = 0; |
| 1117 | else if (ACURR(A_CON) <= 16) |
| 1118 | conplus = 1; |
| 1119 | else if (ACURR(A_CON) == 17) |
| 1120 | conplus = 2; |
| 1121 | else if (ACURR(A_CON) == 18) |
| 1122 | conplus = 3; |
| 1123 | else |
| 1124 | conplus = 4; |
| 1125 | hp += conplus; |
| 1126 | } |
| 1127 | if (hp <= 0) |
| 1128 | hp = 1; |
| 1129 | if (u.ulevel < MAXULEV) { |
| 1130 | /* remember increment; future level drain could take it away again */ |
| 1131 | u.uhpinc[u.ulevel] = (xint16) hp; |
| 1132 | } else { |
| 1133 | /* after level 30, throttle hit point gains from extra experience; |
| 1134 | once max reaches 1200, further increments will be just 1 more */ |
| 1135 | char lim = 5 - u.uhpmax / 300; |
| 1136 |
no test coverage detected