07 Dec, 2013, Grieffels wrote in the 1st comment:
Votes: 0
Hey everyone, I have a few questions and was wondering if I could get a hand.
I'm currently adding levels to each skill in the game. I have the functions setup correctly
to level up the skills as they hit 100% but past that im note sure. I seem to be having
an of how to actually pull which level it is. Here is the code I put into place.

old save.c
——————————————————————
for (sn = 0; sn < MAX_SKILL; sn++)
{
if (skill_table[sn].name != NULL && ch->pcdata->learned[sn] > 0)
{
fprintf (fp, "Sk %d '%s'\n",
ch->pcdata->learned[sn], skill_table[sn].name);
}
}
——————————————————————-
if (!str_cmp (word, "Skill") || !str_cmp (word, "Sk"))
{
int sn;
int value;
char *temp;
value = fread_number (fp);
temp = fread_word (fp);
sn = skill_lookup (temp);
/* sn = skill_lookup( fread_word( fp ) ); */

if (sn < 0)
{
fprintf (stderr, "%s", temp);
bug ("Fread_char: unknown skill. ", 0);
}
else
ch->pcdata->learned[sn] = value;
fMatch = TRUE;
}

/* NEW save.c */
for (sn = 0; sn < MAX_SKILL; sn++)
{
if (skill_table[sn].name != NULL && ch->pcdata->learned[sn] > 0)
{
fprintf (fp, "Sk %d '%s' %d\n",
ch->pcdata->learned[sn], skill_table[sn].name,ch->pcdata->skill_level[sn]);
// Should ch->pcdata->skill_level[sn] be pulling for MAX_SKILL or should it do something
//else? My reasoning was to have it pull for each skill that you have.
}
}

The other portion of old save.c above I havent modified and when I tried, I kept crashing my game.
else
ch->pcdata->learned[sn] = value;
fMatch = TRUE;
// How should I setup ch->pcdata->skill_level within this portion of the code?

}

=================================
merc.h
in the pc_data structure
I added int skill_level[MAX_SKILL]; under int learned[MAX_SKILL];

Should MAX_SKILL on skill level be set to MAX_SKILL_LEVEL which is 100?

Also, using the skills command in rom, I cant get it to print the correct number
from the pfile of the skill level.

ADDED minutes later:
After messing with it I have it fixed.

in save.c I left it the same except for the portion of code which has int value, value = fread_number(fp);

I added int svalue; svalue = fread_number(fp); and at the bottom where learned[sn] = value; I added skill_level[sn] = svalue; and all is well.
11 Dec, 2013, Vigud wrote in the 2nd comment:
Votes: 0
I suggest posting the output of diff -u old.c new.c to a paste site to use that as a reference the next time you have a problem like this one.
0.0/2