MCPcopy Index your code
hub / github.com/NetHack/NetHack / level_difficulty

Function level_difficulty

src/dungeon.c:2026–2084  ·  view source on GitHub ↗

use instead of depth() wherever a degree of difficulty is made * dependent on the location in the dungeon (eg. monster creation). */

Source from the content-addressed store, hash-verified

2024 * dependent on the location in the dungeon (eg. monster creation).
2025 */
2026xint16
2027level_difficulty(void)
2028{
2029 xint16 res;
2030
2031 if (In_endgame(&u.uz)) {
2032 res = depth(&sanctum_level) + u.ulevel / 2;
2033 } else if (u.uhave.amulet) {
2034 res = deepest_lev_reached(FALSE);
2035 } else {
2036 res = depth(&u.uz);
2037 /* depth() is the number of elevation units (levels) below
2038 the theoretical surface; in a builds-up branch, that value
2039 ends up making the harder to reach levels be treated as if
2040 they were easier; adjust for the extra effort involved in
2041 going down to the entrance and then up to the location */
2042 if (builds_up(&u.uz))
2043 res += 2 * (svd.dungeons[u.uz.dnum].entry_lev - u.uz.dlevel + 1);
2044 /*
2045 * 'Proof' by example: suppose the entrance to sokoban is
2046 * on dungeon level 9, leading up to bottom sokoban level
2047 * of 8 [entry_lev]. When the hero is on sokoban level 8
2048 * [uz.dlevel], depth() yields eight but he has ventured
2049 * one level beyond 9, so difficulty depth should be 10:
2050 * 8 + 2 * (8 - 8 + 1) => 10.
2051 * Going up to 7, depth is 7 but hero will be two beyond 9:
2052 * 7 + 2 * (8 - 7 + 1) => 11.
2053 * When he goes up to level 6, three levels beyond 9:
2054 * 6 + 2 * (8 - 6 + 1) => 12.
2055 * And the top level of sokoban at 5, four levels beyond 9:
2056 * 5 + 2 * (8 - 5 + 1) => 13.
2057 * The same applies to Vlad's Tower, although the increment
2058 * there is inconsequential compared to overall depth.
2059 */
2060#if 0
2061 /*
2062 * The inside of the Wizard's Tower is also effectively a
2063 * builds-up area, reached from a portal an arbitrary distance
2064 * below rather than stairs 1 level beneath the entry level.
2065 */
2066 else if (On_W_tower_level(&u.uz) && In_W_tower(some_X, some_Y, &u.uz))
2067 res += (fakewiz1.dlevel - u.uz.dlevel);
2068 /*
2069 * Handling this properly would need more information here:
2070 * an inside/outside flag, or coordinates to calculate it.
2071 * Unfortunately level difficulty may be wanted before
2072 * coordinates have been chosen so simply extending this
2073 * routine to take extra arguments is not sufficient to cope.
2074 * The difference beyond naive depth-from-surface is small
2075 * relative to the overall depth, so just ignore complications
2076 * posed by W_tower.
2077 */
2078#endif /*0*/
2079 }
2080 /* ring of aggravate monster */
2081 if (EAggravate_monster)
2082 res = res > 25 ? 50 : res * 2;
2083 return res;

Callers 15

mk_zoo_thronemonFunction · 0.85
fill_zooFunction · 0.85
mkundeadFunction · 0.85
morguemonFunction · 0.85
antholemonFunction · 0.85
courtmonFunction · 0.85
squadmonFunction · 0.85
goto_levelFunction · 0.85
nhl_level_difficultyFunction · 0.85
mkbox_cntsFunction · 0.85
mksobj_initFunction · 0.85
mkgoldFunction · 0.85

Calls 4

depthFunction · 0.85
deepest_lev_reachedFunction · 0.85
builds_upFunction · 0.85
In_W_towerFunction · 0.85

Tested by

no test coverage detected