I gave the ability for the player to set stats based on a pool of available points. I will post it up here and maybe it will help you get your code together.
You could edit this slightly and save a bit array of flags for answers to questions and assign stats at the end based on all the flags they have set.
added the following to interpreter.c in their appropriate places. I also added tmpint and selection (both integers) to the descriptor struct in structs.h. I removed classes in my mud so this is right after choosing sex.. for you it could be after choosing class or race depending on if you put races in. You also have to add this CON to structs.h.
Code:
/* CLASS WAS ASSIGNED HERE */
if (d->olc) {
free(d->olc);
d->olc = NULL;
}
if (GET_PFILEPOS(d->character) < 0)
GET_PFILEPOS(d->character) = create_entry(GET_PC_NAME(d->character));
/* Now GET_NAME() will work properly. */
init_char(d->character);
d->tmpint = 15;
vitals_menu(d);
STATE(d) = CON_VITALSMENU;
break;
case CON_VITALSMENU:
switch (*arg) {
case 'v':
case 'V':
d->selection = 0;
write_to_output(d, "What do you want your vision to be? (5-20) : ");
STATE(d) = CON_EDITVITALS;
break;
case 'i':
case 'I':
d->selection = 1;
write_to_output(d, "What do you want your invincibility to be? (5-20) : ");
STATE(d) = CON_EDITVITALS;
break;
case 't':
case 'T':
d->selection = 2;
write_to_output(d, "What do you want your technology to be? (5-20) : ");
STATE(d) = CON_EDITVITALS;
break;
case 'a':
case 'A':
d->selection = 3;
write_to_output(d, "What do you want your agility to be? (5-20) : ");
STATE(d) = CON_EDITVITALS;
break;
case 'l':
case 'L':
d->selection = 4;
write_to_output(d, "What do you want your luck to be? (5-20) : ");
STATE(d) = CON_EDITVITALS;
break;
case 's':
case 'S':
d->selection = 5;
write_to_output(d, "What do you want your strength to be? (5-20) : ");
STATE(d) = CON_EDITVITALS;
break;
case 'q':
case 'Q':
if (d->tmpint == 0) {
d->tmpint = 0;
d->selection = 0;
save_char(d->character);
save_player_index();
write_to_output(d, "%s\r\n*** PRESS RETURN TO ENTER BODY: ", motd);
STATE(d) = CON_RMOTD;
/* make sure the last log is updated correctly. */
GET_PREF(d->character)= rand_number(1, 128000);
GET_HOST(d->character)= strdup(d->host);
mudlog(NRM, LVL_GOD, TRUE, "%s [%s] new player.", GET_NAME(d->character), d->host);
/* Add to the list of 'recent' players (since last reboot) */
if (AddRecentPlayer(GET_NAME(d->character), d->host, TRUE, FALSE) == FALSE)
{
mudlog(BRF, MAX(LVL_IMMORT, GET_INVIS_LEV(d->character)), TRUE, "Failure to AddRecentPlayer (returned FALSE).");
}
break;
} else {
vitals_menu(d);
write_to_output(d, "You can't quit until you assign all points\r\n");
write_to_output(d, "What stat do you wish to edit? : ");
return;
}
break;
default:
write_to_output(d, "Invalid Choice...\r\n"
"What stat do you wish to edit? : ");
return;
}
return;
case CON_EDITVITALS:
if (isdigit(*arg)){
num = atoi(arg);
if (d->selection == 0) {
stat_was = d->character->real_abils.vis;
stat = LIMIT(num, 5, 20);
if (stat > stat_was) {
i = d->tmpint - (stat - stat_was);
if (i < 0)
stat = stat + i;
}
d->character->real_abils.vis = stat;
if (stat > stat_was)
d->tmpint = d->tmpint - (stat - stat_was);
else
d->tmpint = d->tmpint + (stat_was - stat);
} else if (d->selection == 1) {
stat_was = d->character->real_abils.inv;
stat = LIMIT(num, 5, 20);
if (stat > stat_was) {
i = d->tmpint - (stat - stat_was);
if (i < 0)
stat = stat + i;
}
d->character->real_abils.inv = stat;
if (stat > stat_was)
d->tmpint = d->tmpint - (stat - stat_was);
else
d->tmpint = d->tmpint + (stat_was - stat);
} else if (d->selection == 2) {
stat_was = d->character->real_abils.tec;
stat = LIMIT(num, 5, 20);
if (stat > stat_was) {
i = d->tmpint - (stat - stat_was);
if (i < 0)
stat = stat + i;
}
d->character->real_abils.tec = stat;
if (stat > stat_was)
d->tmpint = d->tmpint - (stat - stat_was);
else
d->tmpint = d->tmpint + (stat_was - stat);
} else if (d->selection == 3) {
stat_was = d->character->real_abils.agi;
stat = LIMIT(num, 5, 20);
if (stat > stat_was) {
i = d->tmpint - (stat - stat_was);
if (i < 0)
stat = stat + i;
}
d->character->real_abils.agi = stat;
if (stat > stat_was)
d->tmpint = d->tmpint - (stat - stat_was);
else
d->tmpint = d->tmpint + (stat_was - stat);
} else if (d->selection == 4) {
stat_was = d->character->real_abils.luc;
stat = LIMIT(num, 5, 20);
if (stat > stat_was) {
i = d->tmpint - (stat - stat_was);
if (i < 0)
stat = stat + i;
}
d->character->real_abils.luc = stat;
if (stat > stat_was)
d->tmpint = d->tmpint - (stat - stat_was);
else
d->tmpint = d->tmpint + (stat_was - stat);
} else if (d->selection == 5) {
stat_was = d->character->real_abils.str;
stat = LIMIT(num, 5, 20);
if (stat > stat_was) {
i = d->tmpint - (stat - stat_was);
if (i < 0)
stat = stat + i;
}
d->character->real_abils.str = stat;
if (stat > stat_was)
d->tmpint = d->tmpint - (stat - stat_was);
else
d->tmpint = d->tmpint + (stat_was - stat);
}
} else {
vitals_menu(d);
write_to_output(d, "You entered an invalid argument.\r\n");
write_to_output(d, "What stat do you wish to edit? : ");
STATE(d) = CON_VITALSMENU;
break;
}
vitals_menu(d);
STATE(d) = CON_VITALSMENU;
break;
added this to class.c and included the prototype in class.h
void vitals_menu(struct descriptor_data *d)
{
write_to_output(d, "\r\n\r\n|=============================================================================|\r\n"
"| \tRCognizance Recycler\tn |\r\n"
"| Module ID: VITALS (Very Intelligent Teratogen Allocation Lligase System) |\r\n"
"|=============================================================================|\r\n"
"| [V : %2d] - Vision: How well you perceive the environment and other people |\r\n"
"| EXAMPLES: GUNS BOWS SNEAKING INFRAVISION TRACKING ETC... |\r\n"
"| [I : %2d] - Invincibility: How much damage you can take |\r\n"
"| EXAMPLES: HEALTH GAINS/HEALING/REGEN, DAMAGE MITIGATION, ETC... |\r\n"
"| [T : %2d] - Technology: Proficiency with using technology |\r\n"
"| EXAMPLES: FIREBALLS, CLOAKING, TELEPORTING, CRAFTING, ETC... |\r\n"
"| [A : %2d] - Agility: How quickly you can react, how long before winded |\r\n"
"| EXAMPLES: BLOCKING, SNEAKING, BACKSTAB, ACTION REGEN, ETC... |\r\n"
"| [L : %2d] - Luck: How favorable chance based rolls are |\r\n"
"| EXAMPLES: BONUS TO CRITIAL HITS, ACCURACY, CRAFTING, ETC... |\r\n"
"| [S : %2d] - Strength: Raw physical damage |\r\n"
"| EXAMPLES: UNARMED COMBAT, MELEE, CARRY WEIGHT, ETC... |\r\n"
"| Q) Accept current values, create body, and transfer Cognizance |\r\n"
"|=============================================================================|\r\n"
"| You have %2d more points to distribute. |\r\n"
"| You may set a stat to be anywhere in the 5-20 range. |\r\n"
"| Statistics in the game range from 3-50 for all players and NPC(s) |\r\n"
"| Your currently allowed in-game stat range is 3-25. |\r\n"
"|=============================================================================|\r\n",
d->character->real_abils.vis, d->character->real_abils.inv, d->character->real_abils.tec,
d->character->real_abils.agi, d->character->real_abils.luc, d->character->real_abils.str,
d->tmpint);
write_to_output(d, "\r\nWhat stat do you wish to edit? : ");
}