set up a new monster's initial level and hit points; used by newcham() as well as by makemon() */
| 1009 | /* set up a new monster's initial level and hit points; |
| 1010 | used by newcham() as well as by makemon() */ |
| 1011 | void |
| 1012 | newmonhp(struct monst *mon, int mndx) |
| 1013 | { |
| 1014 | struct permonst *ptr = &mons[mndx]; |
| 1015 | int basehp = 0; |
| 1016 | |
| 1017 | mon->m_lev = adj_lev(ptr); |
| 1018 | if (is_golem(ptr)) { |
| 1019 | /* golems have a fixed amount of HP, varying by golem type */ |
| 1020 | mon->mhpmax = mon->mhp = golemhp(mndx); |
| 1021 | } else if (is_rider(ptr)) { |
| 1022 | /* we want low HP, but a high mlevel so they can attack well */ |
| 1023 | basehp = 10; /* minimum is 1 per false (weaker) level */ |
| 1024 | mon->mhpmax = mon->mhp = d(basehp, 8); |
| 1025 | } else if (ptr->mlevel > 49) { |
| 1026 | /* "special" fixed hp monster |
| 1027 | * the hit points are encoded in the mlevel in a somewhat strange |
| 1028 | * way to fit in the 50..127 positive range of a signed character |
| 1029 | * above the 1..49 that indicate "normal" monster levels */ |
| 1030 | mon->mhpmax = mon->mhp = 2 * (ptr->mlevel - 6); |
| 1031 | mon->m_lev = mon->mhp / 4; /* approximation */ |
| 1032 | } else if (ptr->mlet == S_DRAGON && mndx >= PM_GRAY_DRAGON) { |
| 1033 | /* adult dragons; N*(4+rnd(4)) before endgame, N*8 once there */ |
| 1034 | basehp = (int) mon->m_lev; /* not really applicable; isolates cast */ |
| 1035 | mon->mhpmax = mon->mhp = In_endgame(&u.uz) ? (8 * basehp) |
| 1036 | : (4 * basehp + d(basehp, 4)); |
| 1037 | } else if (!mon->m_lev) { |
| 1038 | basehp = 1; /* minimum is 1, increased to 2 below */ |
| 1039 | mon->mhpmax = mon->mhp = rnd(4); |
| 1040 | } else { |
| 1041 | basehp = (int) mon->m_lev; /* minimum possible is one per level */ |
| 1042 | mon->mhpmax = mon->mhp = d(basehp, 8); |
| 1043 | if (is_home_elemental(ptr)) |
| 1044 | mon->mhpmax = (mon->mhp *= 3); /* leave 'basehp' as-is */ |
| 1045 | } |
| 1046 | |
| 1047 | /* if d(X,8) rolled a 1 all X times, give a boost; |
| 1048 | most beneficial for level 0 and level 1 monsters, making mhpmax |
| 1049 | and starting mhp always be at least 2 */ |
| 1050 | if (mon->mhpmax == basehp) { |
| 1051 | mon->mhpmax += 1; |
| 1052 | mon->mhp = mon->mhpmax; |
| 1053 | } |
| 1054 | } |
| 1055 | |
| 1056 | static const struct mextra zeromextra = DUMMY; |
| 1057 |