until save/restore.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1371 c06c8d41-db1a-0410-9941-cceddc491573
6LT6USGJOTDMRJGXLAN2NSZXK2GKWEXDKKUV6SVV7ZC6WI6EKMDQC
YLQG4LJO36VGGVGMUWKVWM73HK76IVBK6GALSYIRCIIRY6SZRMIQC
YCL3W2PFE6ILTGBFODCSXNPDIA46KVSZP2TI7HDMYAOEJT65RIEAC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC
77H4BWWPPGLM3PLZH4QTAJRXIZTSDVNCOKZE223I437FN2UJ34RQC
SDLKLUNFGVKDS55DDJZCBAVIB7NL3RRYPTACAY65SCUQKV6APFSAC
QDTVLBRGHDTRUVT7I3O72K6TMOYAUSAJBZUHGOEFU2RKJNUPWZSQC
5OVWAD2MGK2NT6Q546KW7HZHELVDBBRC2CQX6VZMZF2YVRC7CPVAC
5UVDIVD4NSXA52U4QMQIVST3GSZJ2A2YZK3RUEXKPM43YVQ7LI5AC
RGWUYJO74FDGTH22CYSHBKFDGJ4S76WTLIULKPXA4QT5ZCNOB4LQC
SGR2P5BGJIJHVSSQYQHWS4ORLVHQBZTDES3D4BFC6SVAQXSKENNQC
for (int i = 0; i < MAX_NUM_GODS; i++)
{
penance[i] = 0;
worshipped[i] = 0;
num_gifts[i] = 0;
}
penance.init(0);
worshipped.init(0);
num_gifts.init(0);
for (int i = 0; i < 52; i++)
{
spell_letter_table[i] = -1;
ability_letter_table[i] = ABIL_NON_ABILITY;
}
for (int i = 0; i < 100; i++)
mutation[i] = 0;
spell_letter_table.init(-1);
ability_letter_table.init(ABIL_NON_ABILITY);
for (int i = 0; i < 50; i++)
{
skills[i] = 0;
skill_points[i] = 0;
skill_order[i] = MAX_SKILL_ORDER;
practise_skill[i] = 1;
}
skills.init(0);
skill_points.init(0);
skill_order.init(MAX_SKILL_ORDER);
practise_skill.init(true);
//jmf: NEW ASSERTS: we ought to do a *lot* of these
ASSERT(NUM_SPELLS < SPELL_NO_SPELL);
ASSERT(NUM_JOBS < JOB_UNKNOWN);
ASSERT(NUM_ATTRIBUTES >= 30);
you.item_description[IDESC_POTIONS][POT_PORRIDGE] =
PDESCQ(PDQ_GLUGGY, PDC_WHITE);
strncpy(you.your_name, Options.player_name.c_str(), kNameLen);
you.your_name[kNameLen - 1] = 0;
}
// We really should only loop until NUM_WANDS, etc., here
for (int j = 0; j < you.item_description.height(); j++)
{
// Don't override predefines
if (you.item_description[i][j] != 255)
continue;
// copy name into you.your_name if set from environment --
// note that you.your_name could already be set from init.txt
// this, clearly, will overwrite such information {dlb}
if (SysEnv.crawl_name)
{
strncpy( you.your_name, SysEnv.crawl_name, kNameLen );
you.your_name[ kNameLen - 1 ] = 0;
}
switch (i)
{
case IDESC_WANDS: // wands
you.item_description[i][j] = random2( 16 * 12 );
if (coinflip())
you.item_description[i][j] %= 12;
break;
openingScreen();
enter_player_name(true);
case IDESC_POTIONS: // potions
you.item_description[i][j] = random_potion_description();
break;
case IDESC_SCROLLS: // scrolls
case IDESC_SCROLLS_II:
you.item_description[i][j] = random2(151);
break;
case IDESC_RINGS: // rings
you.item_description[i][j] = random2( 13 * 13 );
if (coinflip())
you.item_description[i][j] %= 13;
break;
}
bool is_ok = true;
if (you.your_name[0] != 0)
{
if (check_saved_game())
{
textcolor( BROWN );
cprintf( EOL "Welcome back, " );
textcolor( YELLOW );
cprintf( "%s!", you.your_name );
textcolor( LIGHTGREY );
// test whether we've used this description before
// don't have p < j because some are preassigned
for (int p = 0; p < you.item_description.height(); p++)
{
if ( p == j )
continue;
while (choose_race() && !choose_class());
item.base_type = OBJ_FOOD;
if (you.species == SP_HILL_ORC || you.species == SP_KOBOLD ||
you.species == SP_OGRE || you.species == SP_TROLL)
item.sub_type = FOOD_MEAT_RATION;
else
item.sub_type = FOOD_BREAD_RATION;
char spec_buff[80];
strncpy(spec_buff,
species_name(you.species, you.experience_level), 80);
snprintf( info, INFO_SIZE, "You are a%s %s %s." EOL,
(is_vowel( spec_buff[0] )) ? "n" : "", spec_buff,
you.class_name );
cprintf( info );
enter_player_name(false);
you.had_book[subtype] = true;
if (check_saved_game())
{
cprintf(EOL "Do you really want to overwrite your old game?");
char c = getch();
if (!(c == 'Y' || c == 'y'))
// one for all, all for one
if (subtype == BOOK_MINOR_MAGIC_I ||
subtype == BOOK_MINOR_MAGIC_II ||
subtype == BOOK_MINOR_MAGIC_III)
textcolor( BROWN );
cprintf(EOL EOL "Welcome back, ");
textcolor( YELLOW );
cprintf("%s!", you.your_name);
textcolor( LIGHTGREY );
you.had_book[BOOK_MINOR_MAGIC_I] = true;
you.had_book[BOOK_MINOR_MAGIC_II] = true;
you.had_book[BOOK_MINOR_MAGIC_III] = true;
}
static void racialise_starting_equipment()
{
for (int i = 0; i < ENDOFPACK; i++)
{
if (is_valid_item(you.inv[i]))
{
// don't change object type modifier unless it starts plain
if ((you.inv[i].base_type == OBJ_ARMOUR ||
you.inv[i].base_type == OBJ_WEAPONS ||
you.inv[i].base_type == OBJ_MISSILES)
&& get_equip_race(you.inv[i]) == ISFLAG_NO_RACE )
{
// now add appropriate species type mod
switch (you.species)
{
case SP_ELF:
case SP_HIGH_ELF:
case SP_GREY_ELF:
case SP_DEEP_ELF:
case SP_SLUDGE_ELF:
set_equip_race( you.inv[i], ISFLAG_ELVEN );
break;
you.is_undead = ((you.species == SP_MUMMY) ? US_UNDEAD :
(you.species == SP_GHOUL) ? US_HUNGRY_DEAD : US_ALIVE);
// Characters are actually granted skill points, not skill levels.
// Here we take racial aptitudes into account in determining final
// skill levels.
static void reassess_starting_skills()
{
for (int i = 0; i < NUM_SKILLS; i++)
{
if (!you.skills[i])
continue;
// before we get into the inventory init, set light radius based
// on species vision. currently, all species see out to 8 squares.
you.normal_vision = 8;
you.current_vision = 8;
// Grant the amount of skill points required for a human
const int points = skill_exp_needed( you.skills[i] + 1 );
you.skill_points[i] = (points * species_skills(i, SP_HUMAN))/100 + 1;
// randomly boost stats a number of times based on species
// - should be a function {dlb}
unsigned char points_left = (you.species == SP_DEMIGOD
|| you.species == SP_DEMONSPAWN) ? 15 : 8;
for (int lvl = 1; lvl <= 8; lvl++)
{
if (you.skill_points[i] > (skill_exp_needed(lvl+1) * sp_diff)/100)
you.skills[i] = lvl;
else
break;
}
}
}
// these need to be set above using functions!!! {dlb}
you.max_dex = you.dex;
you.max_strength = you.strength;
you.max_intel = you.intel;
bool new_game(void)
{
//jmf: NEW ASSERTS: we ought to do a *lot* of these
ASSERT(NUM_SPELLS < SPELL_NO_SPELL);
ASSERT(NUM_JOBS < JOB_UNKNOWN);
ASSERT(NUM_ATTRIBUTES >= 30);
for (i = 0; i < ENDOFPACK; i++)
{
if (!you.inv[i].quantity)
{
you.inv[i].quantity = 1;
if (you.species == SP_SPRIGGAN)
{
you.inv[i].base_type = OBJ_POTIONS;
you.inv[i].sub_type = POT_PORRIDGE;
}
else
{
you.inv[i].base_type = OBJ_FOOD;
you.inv[i].sub_type = FOOD_BREAD_RATION;
}
strncpy(you.your_name, Options.player_name.c_str(), kNameLen);
you.your_name[kNameLen - 1] = 0;
}
break;
}
}
// copy name into you.your_name if set from environment --
// note that you.your_name could already be set from init.txt
// this, clearly, will overwrite such information {dlb}
if (SysEnv.crawl_name)
{
strncpy( you.your_name, SysEnv.crawl_name, kNameLen );
you.your_name[ kNameLen - 1 ] = 0;
if (you.inv[i].base_type == OBJ_BOOKS)
{
you.had_book[you.inv[i].sub_type] = 1;
if (you.inv[i].sub_type == BOOK_MINOR_MAGIC_I
|| you.inv[i].sub_type == BOOK_MINOR_MAGIC_II
|| you.inv[i].sub_type == BOOK_MINOR_MAGIC_III)
{
you.had_book[BOOK_MINOR_MAGIC_I] = 1;
you.had_book[BOOK_MINOR_MAGIC_II] = 1;
you.had_book[BOOK_MINOR_MAGIC_III] = 1;
}
if (you.inv[i].sub_type == BOOK_CONJURATIONS_I
|| you.inv[i].sub_type == BOOK_CONJURATIONS_II)
{
you.had_book[BOOK_CONJURATIONS_I] = 1;
you.had_book[BOOK_CONJURATIONS_II] = 1;
}
}
// don't change object type modifier unless it starts plain
if (you.inv[i].base_type <= OBJ_ARMOUR
&& get_equip_race(you.inv[i]) == 0 ) // == DARM_PLAIN
{
// now add appropriate species type mod:
switch (you.species)
{
case SP_ELF:
case SP_HIGH_ELF:
case SP_GREY_ELF:
case SP_DEEP_ELF:
case SP_SLUDGE_ELF:
set_equip_race( you.inv[i], ISFLAG_ELVEN );
break;
textcolor( BROWN );
cprintf( EOL "Welcome back, " );
textcolor( YELLOW );
cprintf( "%s!", you.your_name );
textcolor( LIGHTGREY );
case SP_HILL_DWARF:
case SP_MOUNTAIN_DWARF:
set_equip_race( you.inv[i], ISFLAG_DWARVEN );
break;
case SP_HILL_ORC:
set_equip_race( you.inv[i], ISFLAG_ORCISH );
break;
}
}
save_player_name();
return (false);
you.item_description[IDESC_POTIONS][POT_WATER] =
PDESCS(PDC_CLEAR);
int passout;
for (i = 0; i < 4; i++)
// new: pick name _after_ race and class choices
if (you.your_name[0] == 0)
switch (i)
{
case IDESC_WANDS: // wands
you.item_description[i][j] = random2( 16 * 12 );
if (coinflip())
you.item_description[i][j] %= 12;
break;
snprintf( info, INFO_SIZE, "You are a%s %s %s." EOL,
(is_vowel( spec_buff[0] )) ? "n" : "", spec_buff,
you.class_name );
case IDESC_RINGS: // rings
you.item_description[i][j] = random2( 13 * 13 );
if (coinflip())
you.item_description[i][j] %= 13;
break;
}
if (check_saved_game())
{
cprintf(EOL "Do you really want to overwrite your old game?");
char c = getch();
if (!(c == 'Y' || c == 'y'))
{
textcolor( BROWN );
cprintf(EOL EOL "Welcome back, ");
textcolor( YELLOW );
cprintf("%s!", you.your_name);
textcolor( LIGHTGREY );
if (i == SK_SPELLCASTING)
you.skill_points[i] = (points * 130) / 100 + 1;
else if (i == SK_INVOCATIONS || i == SK_EVOCATIONS)
you.skill_points[i] = (points * 75) / 100 + 1;
you.is_undead = ((you.species == SP_MUMMY) ? US_UNDEAD :
(you.species == SP_GHOUL) ? US_HUNGRY_DEAD : US_ALIVE);
// before we get into the inventory init, set light radius based
// on species vision. currently, all species see out to 8 squares.
you.normal_vision = 8;
you.current_vision = 8;
jobs_stat_init( you.char_class );
give_last_paycheck( you.char_class );
assign_remaining_stats((you.species == SP_DEMIGOD ||
you.species == SP_DEMONSPAWN) ? 15 : 8);
// this function depends on stats being finalized
give_items_skills();
give_species_bonus_hp();
give_species_bonus_mp();
// these need to be set above using functions!!! {dlb}
you.max_dex = you.dex;
you.max_strength = you.strength;
you.max_intel = you.intel;
for (int lvl = 0; lvl < MAX_LEVELS; lvl++)
{
for (int dng = 0; dng < NUM_BRANCHES; dng++)
{
tmp_file_pairs[lvl][dng] = false;
}
}
tmp_file_pairs.init(false);