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

Function role_init

src/role.c:1979–2117  ·  view source on GitHub ↗

* Special setup modifications here: * * Unfortunately, this is going to have to be done * on each newgame or restore, because you lose the permonst mods * across a save/restore. :-) * * 1 - The Rogue Leader is the Tourist Nemesis. * 2 - Priests start with a random alignment - convert the leader and * guardians here. * 3 - Priests also get their

Source from the content-addressed store, hash-verified

1977 * This code also replaces quest_init().
1978 */
1979void
1980role_init(void)
1981{
1982 int alignmnt;
1983 struct permonst *pm;
1984
1985 /* Strip the role letter out of the player name.
1986 * This is included for backwards compatibility.
1987 */
1988 plnamesuffix();
1989
1990 /* Check for a valid role. Try flags.initrole first. */
1991 if (!validrole(flags.initrole)) {
1992 /* Try the player letter second */
1993 if ((flags.initrole = str2role(svp.pl_character)) < 0)
1994 /* None specified; pick a random role */
1995 flags.initrole = randrole_filtered();
1996 }
1997
1998 /* We now have a valid role index. Copy the role name back. */
1999 /* This should become OBSOLETE */
2000 Strcpy(svp.pl_character, roles[flags.initrole].name.m);
2001 svp.pl_character[PL_CSIZ - 1] = '\0';
2002
2003 /* Check for a valid race */
2004 if (!validrace(flags.initrole, flags.initrace))
2005 flags.initrace = randrace(flags.initrole);
2006
2007 /* Check for a valid gender. If new game, check both initgend
2008 * and female. On restore, assume flags.female is correct. */
2009 if (flags.pantheon == -1) { /* new game */
2010 if (!validgend(flags.initrole, flags.initrace, flags.female))
2011 flags.female = !flags.female;
2012 }
2013 if (!validgend(flags.initrole, flags.initrace, flags.initgend))
2014 /* Note that there is no way to check for an unspecified gender. */
2015 flags.initgend = flags.female;
2016
2017 /* Check for a valid alignment */
2018 if (!validalign(flags.initrole, flags.initrace, flags.initalign))
2019 /* Pick a random alignment */
2020 flags.initalign = randalign(flags.initrole, flags.initrace);
2021 alignmnt = aligns[flags.initalign].value;
2022
2023 /* Initialize gu.urole and gu.urace */
2024 gu.urole = roles[flags.initrole];
2025 gu.urace = races[flags.initrace];
2026
2027 /* Fix up the quest leader */
2028 if (gu.urole.ldrnum != NON_PM) {
2029 pm = &mons[gu.urole.ldrnum];
2030 pm->msound = MS_LEADER;
2031 pm->mflags2 |= (M2_PEACEFUL);
2032 pm->mflags3 |= M3_CLOSE;
2033 pm->maligntyp = alignmnt * 3;
2034 /* if gender is random, we choose it now instead of waiting
2035 until the leader monster is created */
2036 svq.quest_status.ldrgend =

Callers 2

newgameFunction · 0.85
restgamestateFunction · 0.85

Calls 12

plnamesuffixFunction · 0.85
validroleFunction · 0.85
str2roleFunction · 0.85
randrole_filteredFunction · 0.85
validraceFunction · 0.85
randraceFunction · 0.85
validgendFunction · 0.85
validalignFunction · 0.85
randalignFunction · 0.85
rn2Function · 0.85
randroleFunction · 0.85
align_gtitleFunction · 0.85

Tested by

no test coverage detected