Skip to content

Commit

Permalink
[FOURK] Implement race-based (and inventory-based) skill cap adjustme…
Browse files Browse the repository at this point in the history
…nts.

 * Any weapon you get in starting inventory will have a skill cap
   no less than basic.  (Your starting skill was already being
   raised to basic.  This prevents you from being above your max.)

 * Dwarves can now always get to at least skilled in pick-axe,
   and can get to expert if a human of the same role would be
   able to get to skilled.

 * Gnomes can always get to skilled in crossbow and aklys and can
   go two skill ranks higher than a human of the same role, up to
   a maximum of expert (crossbow) or master (club).

 * Orcs can get at least skilled in scimitar and two ranks higher
   than a human of the same role up to a maximum of master.

 * Elves can always get at least basic skill in bows, regardless
   of their role, and can get to skilled if a human of the same
   role could get to basic. TODO: consider raising max to Master

---=== ALSO ===---

Fix bugs in the race-based skill cap augmentation.

There were two bugs here, one in the player's favor and one against.

The count wasn't being respected, so the cap was always being bumped
to the maximum.

However, the game was ignoring the maximum if it had previously
been zero.  Raising the current skill level to unskilled if it
was previously restricted fixes this.
  • Loading branch information
tsadok authored and yrmvgh committed Nov 14, 2017
1 parent 9a58d72 commit 05dd4b7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
30 changes: 25 additions & 5 deletions libnethack/src/u_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ static void role_ini_inv(const struct trobj *, short nocreate[4]);
static void race_ini_inv(const struct trobj *, short nocreate[4]);
static void knows_object(int);
static void knows_class(char);
static void augment_skill_cap(int skill, int augment, int minimum, int maximum);
static boolean restricted_spell_discipline(int);

#define UNDEF_TYP 0
Expand Down Expand Up @@ -241,9 +242,10 @@ static const struct trobj Booze[] = {
};
/* Gnomes start with an assortment of tools */
static const struct trobj Bits_bobs[] = {
{AKLYS, 0, WEAPON_CLASS, 1, UNDEF_BLESS},
{POT_OIL, 0, POTION_CLASS, 1, 0},
{LEASH, 0, TOOL_CLASS, 1, 0},
{FORTUNE_COOKIE, 0, FOOD_CLASS, 1, 0},
{CARROT, 0, FOOD_CLASS, 1, 0},
{TALLOW_CANDLE, 0, TOOL_CLASS, 1, 0},
{WAX_CANDLE, 0, TOOL_CLASS, 1, 0},
{0, 0, 0, 0, 0}
Expand Down Expand Up @@ -601,23 +603,35 @@ u_init(microseconds birthday)
for (i = 0; i <= MAXSPELL; i++)
spl_book[i].sp_id = NO_SPELL;
update_supernatural_abilities();

u.ublesscnt = 300; /* no prayers just yet */
u.ualignbase[A_CURRENT] = u.ualignbase[A_ORIGINAL] = u.ualign.type =
aligns[u.initalign].value;
u.ulycn = NON_PM;

u.ubirthday = birthday;

/* For now, everyone starts out with a night vision range of 1. */
u.nv_range = 1;
u.next_attr_check = 600; /* arbitrary initial setting */

u.delayed_killers.genocide = u.delayed_killers.illness =
u.delayed_killers.stoning = u.delayed_killers.sliming =
u.delayed_killers.zombie = NULL;
}

/* Raise the player character's skill cap for a particular skill. */
void
augment_skill_cap(int skill, int augment, int minimum, int maximum)
{
int count = 0;
if (P_SKILL(skill) == P_ISRESTRICTED)
P_SKILL(skill) = P_BASIC;
while (count++ < augment && P_MAX_SKILL(skill) < maximum)
P_MAX_SKILL(skill) = P_MAX_SKILL(skill) + 1;
if (P_MAX_SKILL(skill) < minimum)
P_MAX_SKILL(skill) = minimum;
}


void
u_init_inv_skills(void)
Expand Down Expand Up @@ -782,6 +796,7 @@ u_init_inv_skills(void)
knows_object(ELVEN_SHIELD);
knows_object(ELVEN_BOOTS);
knows_object(ELVEN_CLOAK);
augment_skill_cap(P_BOW, 1, P_BASIC, P_SKILLED);
break;
}
case PM_DWARF:
Expand All @@ -796,6 +811,7 @@ u_init_inv_skills(void)
knows_object(DWARVISH_MITHRIL_COAT);
knows_object(DWARVISH_CLOAK);
knows_object(DWARVISH_ROUNDSHIELD);
augment_skill_cap(P_PICK_AXE, 1, P_SKILLED, P_EXPERT);
break;

case PM_GNOME:
Expand All @@ -805,6 +821,9 @@ u_init_inv_skills(void)
/*and they live in search of diamonds*/
knows_object(TOUCHSTONE);
knows_object(DIAMOND);

augment_skill_cap(P_CROSSBOW, 2, P_SKILLED, P_EXPERT);
augment_skill_cap(P_CLUB, 1, P_SKILLED, P_MASTER);
break;

case PM_ORC:
Expand All @@ -823,6 +842,7 @@ u_init_inv_skills(void)
knows_object(ORCISH_SHIELD);
knows_object(URUK_HAI_SHIELD);
knows_object(ORCISH_CLOAK);
augment_skill_cap(P_SCIMITAR, 2, P_SKILLED, P_MASTER);
break;

default: /* impossible */
Expand Down
8 changes: 5 additions & 3 deletions libnethack/src/weapon.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/
/* Last modified by Fredrik Ljungdahl, 2017-11-06 */
/* Last modified by Yer mivvaggah, 2017-11-13 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */

Expand Down Expand Up @@ -1482,8 +1482,10 @@ skill_init(const struct def_skill *class_skill)
if (obj->otyp == TOUCHSTONE || obj->otyp == LUCKSTONE)
continue;
skill = weapon_type(obj);
if (skill != P_NONE)
P_SKILL(skill) = P_BASIC;
if (skill != P_NONE) {
P_MAX_SKILL(skill) = P_BASIC;
P_SKILL(skill) = P_BASIC;
}
}

/* set skills for magic */
Expand Down

0 comments on commit 05dd4b7

Please sign in to comment.