if (ch->level == LEVEL_HERO)
ch->level += 0;
ch->pcdata->sublevel += 1;
if(ch->level == LEVEL_HERO)
ch->pcdata->sublevel++;
int level;
+ int sublevel;
fprintf( fp, "Level %d\n", ch->level );
+ fprintf( fp, "Sublevel %d\n", ch->sublevel );
KEY( "Security", ch->pcdata->security, fread_number( fp ) ); /* OLC */
+ KEY( "Sublevel", ch->sublevel, fread_number( fp ) );
void gain_exp( CHAR_DATA *ch, int gain )
{
if ( IS_NPC(ch) || ch->level >= LEVEL_IMMORTAL )
return;
ch->exp = UMAX( exp_per_level(ch,ch->pcdata->exp_lvl), ch->exp + gain );
while ( ch->level < LEVEL_IMMORTAL && ch->exp >=
exp_per_level(ch,ch->pcdata->exp_lvl) * (ch->level+1))
{
send_to_char( "{MYou raise a level!!{x ", ch );
if (ch->level < LEVEL_HERO)
ch->level += 1;
return;
if (ch->level == LEVEL_HERO)
ch->sublevel ++;
return;
advance_level( ch );
save_char_obj(ch);
}
return;
}
void do_advance( CHAR_DATA *ch, char *argument )
{
char buf[MAX_STRING_LENGTH];
char arg1[MAX_INPUT_LENGTH];
bool sublevel = FALSE;
CHAR_DATA *victim;
int level;
int iLevel;
argument = one_argument( argument, arg1 );
if( arg1[0] == '\0' || argument[0] == '\0' )
{
send_to_char( "Syntax: advance <char> <level>\n\r", ch );
return;
}
if ( ( victim = get_char_world( ch, arg1 ) ) == NULL )
{
send_to_char( "That player is not here.\n\r", ch);
return;
}
if ( IS_NPC(victim) )
{
send_to_char( "Not on NPC's.\n\r", ch );
return;
}
if( victim->sublevel )
{
argument = one_argument( argument, arg1 );
if( argument[0] == '\0' || !is_number( argument )
|| ( str_cmp( arg1, "level" ) && str_cmp( arg1, "sublevel" ) ) )
{
send_to_char( "For chars that are heros/lords, please specify level or sublevel.\n\r", ch );
return;
}
if( !str_cmp( arg1, "sublevel" ) )
sublevel = TRUE;
}
if( !is_number( argument ) )
{
send_to_char( "Usage: advance <character> [sublevel|level] <level>\n\r", ch );
return;
}
level = atoi( argument );
if( level <= 0 || level > LEVEL_HERO )
{
sprintf( buf, "Advance within range 1 to %d.\n\r", LEVEL_HERO );
send_to_char(buf,ch);
return;
}
if( victim->sublevel && ( level > victim->level
|| ( sublevel && level <= victim->sublevel ) ) )
{
send_to_char(
"For hero or lords, you may only demote them to a\n\r"
"lower level, or promote them sublevels.\n\r", ch );
return;
}
/*
* Lower level:
* Reset to level 1.
* Then raise again.
* Currently, an imp can lower another imp.
* – Swiftest
*/
if( !sublevel && level <= victim->level )
{
int temp_prac;
int temp_train;
send_to_char( "Lowering a player's level!\n\r", ch );
send_to_char( "**** OOOOHHHHHHHHHH NNNNOOOO ****\n\r", victim );
temp_prac = victim->practice;
temp_train = victim->train;
victim->level = 1;
victim->sublevel = 0;
victim->exp = exp_per_level(victim,victim->pcdata->exp_lvl);
victim->max_hit = 20;
victim->max_mana = 100;
victim->max_move = 100;
victim->hit = victim->max_hit;
victim->mana = victim->max_mana;
victim->move = victim->max_move;
advance_level( victim );
victim->practice = temp_prac;
victim->train = temp_train;
}
else
{
send_to_char( "Raising a player's level!\n\r", ch );
send_to_char( "**** OOOOHHHHHHHHHH YYYYEEEESSS ****\n\r", victim );
}
if( victim->sublevel > 0 )
{
for( iLevel = victim->sublevel; iLevel < level; iLevel++ )
{
victim->sublevel += 1;
advance_level( victim );
}
}
else
{
for( iLevel = victim->level; iLevel < level; iLevel++ )
{
victim->level += 1;
advance_level( victim );
}
}
sprintf(buf,"You are now level %d.\n\r",victim->level);
send_to_char(buf,victim);
victim->exp = exp_per_level(victim,victim->pcdata->exp_lvl)
* UMAX( 1, victim->level );
victim->trust = 0;
save_char_obj(victim);
return;
}
void gain_exp( CHAR_DATA *ch, int gain )
{
if ( IS_NPC(ch) || ch->level >= LEVEL_IMMORTAL )
return;
ch->exp = UMAX( exp_per_level(ch,ch->pcdata->exp_lvl), ch->exp + gain );
while ( ch->level < LEVEL_IMMORTAL && ch->exp >=
exp_per_level(ch,ch->pcdata->exp_lvl) * (ch->level+1))
{
send_to_char( "{MYou raise a level!!{x ", ch );
if (ch->level < LEVEL_HERO)
ch->level += 1;
return;
if (ch->level == LEVEL_HERO)
ch->sublevel ++;
return;
advance_level( ch );
save_char_obj(ch);
}
return;
}
void gain_exp( CHAR_DATA *ch, int gain )
{
char Info[MAX_INPUT_LENGTH];
int i;
if( IS_NPC( ch ) || ch->level >= LEVEL_HERO )
return;
ch->exp -= UMIN( get_tnl( ch ) * 2, gain );
while( ch->level < LEVEL_HERO && ch->exp <= 0 )
{
ch->exp += get_tnl( ch );
if( ch->sublevel )
{
ch->sublevel++;
if( ch->sublevel > ch->level )
{
ch->sublevel = 0;
ch->level++;
else
{
ch->level++;
if( ch->level == 51 )
do_help( ch, "GRATS_HERO" );
}
advance_level( ch, FALSE );
}
while( ch->level == LEVEL_HERO && ch->exp <= 0 )
{
ch->exp += get_tnl( ch );
if( ch->sublevel < 1000 )
ch->sublevel++;
if( ch->exp > 0 )
advance_level( ch, FALSE );
else
advance_level( ch, TRUE );
}
return;
}
if( ch->sublevel )
{
ch->sublevel++;
if( ch->sublevel > ch->level )
{
ch->sublevel = 0;
ch->level++;
else
{
ch->level++;
if( ch->level == 51 )
do_help( ch, "GRATS_HERO" );
}
if( ch->sublevel )
{
ch->sublevel++;
if( ch->sublevel > ch->level )
{
ch->sublevel = 0;
ch->level++;
else
{
ch->level++;
if( ch->level == 51 )
do_help( ch, "GRATS_HERO" );
}
if( ch->sublevel )
{
ch->sublevel++;
if( ch->sublevel > ch->level )
{
ch->sublevel = 0;
ch->level++;
}
}
else
{
ch->level++;
if( ch->level == 51 )
do_help( ch, "GRATS_HERO" );
}
void gain_exp( CHAR_DATA *ch, int gain )
{
char Info[MAX_INPUT_LENGTH];
int i;
if( IS_NPC( ch ) || ch->level >= LEVEL_HERO )
return;
ch->exp -= UMIN( get_tnl( ch ) * 2, gain );
while( ch->level < LEVEL_HERO && ch->exp <= 0 )
{
ch->exp += get_tnl( ch );
if( ch->sublevel )
{
ch->sublevel++;
if( ch->sublevel > ch->level )
{
ch->sublevel = 0;
ch->level++;
}
else
{
ch->level++;
if( ch->level == 51 )
do_help( ch, "GRATS_HERO" );
}
advance_level( ch, FALSE );
}
}
while( ch->level == LEVEL_HERO && ch->exp <= 0 )
{
ch->exp += get_tnl( ch );
if( ch->sublevel < 1000 )
ch->sublevel++;
if( ch->exp > 0 )
advance_level( ch, FALSE );
else
advance_level( ch, TRUE );
}
return;
}
I've redone some code and idea multiple times and I've been close to achieving what I want but I just can't get it 100% right.
A mud I used to play has sublevels and this is where I had gotten the idea. However, I've been trying to do this without having to use a remort system or multiclassing.
General breakdown of levels:
Mortal Level 1 - 50 (Also show on Mortal Who)
Hero Level 51, Sublevel (001) - Sublevel (999) if wanted to go that high.
So basicly, once the player reaches level 51, they go on leveling but instead of raising the actual levels, they just advance in sublevels instead. But I thought this would be rather simple but I seem to be missing something.
In pc_data in merc.h, I have int sublevel;
In save.c, I put the sublevel code in fread_char and fwrite_char.
Now in update.c, gain_exp I have this
The thing is, is that once the char reaches level hero, I don't want to add to the level anymore, I want to add to the sublevel instead. I eventually plan on adding in a lord level with will have additional sublevels but so far, the code above seems to work but instead of the char gaining level 51 with +1 sublevel, you'll see it show Level 51 and the sublevel jumps to 304 or something instead of starting at one.
Any ideas?
Thanks for your time,
Chris