Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ PowerLevel Mod (Not DBZ)
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Malti
USA (55 posts) Bio
|
| Date
| Thu 04 May 2006 05:21 PM (UTC) |
| Message
| I want to have a mod that allows Imms to use the command powerlevel <on/off> <num> to make the exp players recieve multiplyed times num. I know this can be somewhat dangerous, but I still want to do it and I want it to apply to the whole game. The part I am struggling with is where to put the bit and num? Should they go into mud.h? if so, where?
Also, what would I need to change in this function?
void gain_exp( CHAR_DATA * ch, int gain )
{
double modgain;
if( IS_NPC( ch ) || ch->level >= LEVEL_AVATAR )
return;
/*
* Bonus for deadly lowbies
*/
modgain = gain;
if( modgain > 0 && IS_PKILL( ch ) && ch->level < 17 )
{
if( ch->level <= 6 )
{
send_to_char( "The Favor of Gravoc fosters your learning.\n\r", ch );
modgain *= 2;
}
if( ch->level <= 10 && ch->level >= 7 )
{
send_to_char( "The Hand of Gravoc hastens your learning.\n\r", ch );
modgain *= 1.75;
}
if( ch->level <= 13 && ch->level >= 11 )
{
send_to_char( "The Cunning of Gravoc succors your learning.\n\r", ch );
modgain *= 1.5;
}
if( ch->level <= 16 && ch->level >= 14 )
{
send_to_char( "The Patronage of Gravoc reinforces your learning.\n\r", ch );
modgain *= 1.25;
}
}
/*
* per-race experience multipliers
*/
modgain *= ( race_table[ch->race]->exp_multiplier / 100.0 );
/*
* Deadly exp loss floor is exp floor of level
*/
if( IS_PKILL( ch ) && modgain < 0 )
{
if( ch->exp + modgain < exp_level( ch, ch->level ) )
{
modgain = exp_level( ch, ch->level ) - ch->exp;
send_to_char( "Gravoc's Pandect protects your insight.\n\r", ch );
}
}
/*
* xp cap to prevent any one event from giving enuf xp to
*/
/*
* gain more than one level - FB
*/
modgain = UMIN( modgain, exp_level( ch, ch->level + 2 ) - exp_level( ch, ch->level + 1 ) );
ch->exp = UMAX( 0, ch->exp + ( int )modgain );
if( NOT_AUTHED( ch ) && ch->exp >= exp_level( ch, ch->level + 1 ) )
{
send_to_char( "You can not ascend to a higher level until you are authorized.\n\r", ch );
ch->exp = ( exp_level( ch, ( ch->level + 1 ) ) - 1 );
return;
}
while( ch->level < LEVEL_AVATAR && ch->exp >= exp_level( ch, ch->level + 1 ) )
{
set_char_color( AT_WHITE + AT_BLINK, ch );
ch->level += 1;
ch_printf( ch, "You have now obtained experience level %d!\n\r", ch->level );
advance_level( ch );
}
return;
}
| | Top |
|
| Posted by
| David Haley
USA (3,881 posts) Bio
|
| Date
| Reply #1 on Thu 04 May 2006 07:05 PM (UTC) |
| Message
| You'd want to modify the function so that it multiplies the value modgain by your modifier before passing the gain through the capping function (that 'umin' part).
As for where to put the flag and the value, just look at how other integers are declared in mud.h. You'd want to do something very similar; but an 'extern int exp_mod' (or whatever) in there, and then in a C source file somewhere, declare a global 'int exp_mod' and that's all there is to it. (Same for the flag). |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | | Top |
|
| Posted by
| Malti
USA (55 posts) Bio
|
| Date
| Reply #2 on Fri 05 May 2006 02:09 AM (UTC) |
| Message
| I added this in mud.h
extern int exp_mod;
extern bool exp_mod_flag;
and I added this in db.c
int exp_mod;
bool exp_mod_flag;
and this to the gain_exp func
/*
* per-race experience multipliers
*/
modgain *= ( race_table[ch->race]->exp_multiplier / 100.0 );
if(exp_mod_flag)
modgain *= exp_mod;
/*
* Deadly exp loss floor is exp floor of level
*/
if( IS_PKILL( ch ) && modgain < 0 )
{
Now I am confused on how i add the command to set the bool to true or false..Where would I put such a function and what else would i need to add with the function to make it work
| | Top |
|
| Posted by
| Malti
USA (55 posts) Bio
|
| Date
| Reply #3 on Fri 05 May 2006 02:57 AM (UTC) |
| Message
| So I figured there was no harm in trying so I went ahead and tried to write everything. I wrote this, added the DEFINE_DO_FUN stuff in mud.h, and added it to the table in table.c. Eveything compiles, but the only problem is that is seems to have no effect when i activate the command. A lowbie was getting 3 exp points on the one mob and when i activated the command to add 10 exp it didn't multiply it. Hopefully someone will be able to help :\.
void do_powerlevel( CHAR_DATA * ch, char *argument )
{
char arg1[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
set_char_color( AT_IMMORT, ch );
smash_tilde( argument );
argument = one_argument( argument, arg1 );
argument = one_argument( argument, arg2 );
if( arg1[0] == '\0' )
{
if( get_trust( ch ) > LEVEL_SUB_IMPLEM )
{
send_to_char( "Syntax: powerlevel <0/1> <Multiplyer>\n\r", ch );
}
return;
}
if( arg1[0] == '1')
{
if( exp_mod_flag == FALSE )
{
if( is_number(arg2) && (atoi(arg2) > 1))
{
exp_mod = atoi(arg2);
exp_mod_flag = TRUE;
send_to_char( "Powerleveling activated.", ch );
}
else
{
exp_mod = 2;
exp_mod_flag = TRUE;
send_to_char( "Powerleveling activated.", ch );
}
}
else
{
send_to_char( "Powerleveling is already activated.", ch );
}
}
else
{
exp_mod = 1;
exp_mod_flag = FALSE;
send_to_char( "Powerleveling dectivated.", ch );
}
}
| | Top |
|
| Posted by
| David Haley
USA (3,881 posts) Bio
|
| Date
| Reply #4 on Fri 05 May 2006 05:42 AM (UTC) |
| Message
| Your function looks right, generally speaking. One thing is that in db.c you actually want to initialize those values to something, like 1 and false. So you'd write:int exp_mod = 1;
bool exp_mod_flag = false;
As for why the multiplier isn't working, I'd suggest logging the exp gain before multiplication and then the gain afterwards, in addition to the multiplier in effect at that time. That will help you see if something is actually happening; keep in mind that exp gains can be affected by several things including how often you have killed a particular mob. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
17,657 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top