27 Dec, 2012, Rarva.Riendf wrote in the 21st comment:
Votes: 0
as an example

in fwrite
fprintf(fp, "AMod %d %d %d %d %d %d\n", ch->mod_stat[STAT_STR], ch->mod_stat[STAT_INT], ch->mod_stat[STAT_WIS],
ch->mod_stat[STAT_DEX], ch->mod_stat[STAT_CON], ch->mod_stat[STAT_CHA]); //and yeah I shoudl rewrite this to use a loop so I can add stats, guess I forgot…

in fread
if ( !str_cmp(word, "AMod")) {
int stat;
for (stat = 0;stat < MAX_STATS;stat ++)
ch->mod_stat[stat] = fread_number(fp);
fMatch = TRUE;
break;
}
27 Dec, 2012, Scandum wrote in the 22nd comment:
Votes: 0
Rarva.Riendf said:
Wont work, you wrote multiple value from a table so you need to read multiple values.

It'll work as the AKEY macro reads two values.
28 Dec, 2012, Sharmair wrote in the 23rd comment:
Votes: 0
Scandum said:
Rarva.Riendf said:
Wont work, you wrote multiple value from a table so you need to read multiple values.

It'll work as the AKEY macro reads two values.

Maybe you should have mentioned the workings of your nonstandard AKEY macro in your post
so as not to confuse all the coders that will be using this thread as a guide to how to do things.
But it is still unlikely to work reliably if the skills are changed between when the player logs out
and back on again as you are saving the skill numbers. Skill numbers, like rnums in Diku can
change depending on the data set and should not be saved. Either the slot number or the
name should be saved and a skill number lookup done on load to get the current skill number.
28 Dec, 2012, Scandum wrote in the 24th comment:
Votes: 0
Sharmair said:
Maybe you should have mentioned the workings of your nonstandard AKEY macro in your post
so as not to confuse all the coders that will be using this thread as a guide to how to do things.

Not a bad idea.

#define AKEY( literal, field, value ) \
{ \
if (!strcmp(word, literal)) \
{ \
cnt = value; \
field[cnt] = value; \
fMatch = TRUE; \
break; \
} \
}


Sharmair said:
But it is still unlikely to work reliably if the skills are changed between when the player logs out
and back on again as you are saving the skill numbers. Skill numbers, like rnums in Diku can
change depending on the data set and should not be saved. Either the slot number or the
name should be saved and a skill number lookup done on load to get the current skill number.

Lola (codebase in question here) had slot support stripped out as it's rather slow with large skill tables. So I guess you'd be looking at:

for (sn = 0 ; sn < MAX_SKILL ; sn++)
{
if (ch->cooldown[sn] > 0)
{
fprintf(fp, "Cooldown %d '%s'\n", ch->cooldown[sn], skill_table[sn].name);
}
}


And for reading:

if (!strcmp(word, "Cooldown"))
{
int sn, value;

value = fread_number(fp);
sn = skill_lookup(fread_word(fp));

if (sn < 0)
{
log_string("fread_char: unknown cooldown skill.");
}
else
{
ch->cooldown[sn] = value;
}
}
29 Dec, 2012, jurdendurden wrote in the 25th comment:
Votes: 0
I actually wrote a snippet for this a couple of years back, you could take a look at it, since it appears to be written in some form of rom as well. Here is the link: Cooldown Snippet
29 Dec, 2012, khyldes wrote in the 26th comment:
Votes: 0
jurdendurden said:
I actually wrote a snippet for this a couple of years back, you could take a look at it, since it appears to be written in some form of rom as well. Here is the link: Cooldown Snippet


Yeah your cooldown snippet is where I started with this. It works well within ROM, but I'm porting it over to Lola, which just a bit different.
29 Dec, 2012, jurdendurden wrote in the 27th comment:
Votes: 0
Ahh gotcha. Thought that code looked a bit familiar :)
20.0/27