16 Aug, 2006, Sakirious wrote in the 1st comment:
Votes: 0
I've been using grep the past few days to try to find the exact definement of experience, but I seem to have failed todo so. If I might ask, could someone tell me where experience is defined/coded at in the Smaug C-Base?
16 Aug, 2006, Zeno wrote in the 2nd comment:
Votes: 0
What do you mean?

Exp gains? The exp variable?
17 Aug, 2006, Sakirious wrote in the 3rd comment:
Votes: 0
The exp var. I want to dramatically change how exp works, but I can't locate where its coding is.
17 Aug, 2006, Justice wrote in the 4th comment:
Votes: 0
The field exp in struct char_data holds experience.

Example from do_report (player.c):
ch_printf( ch,
"You report: %d/%d hp %d/%d mana %d/%d mv %d xp.\r\n",
ch->hit, ch->max_hit,
ch->mana, ch->max_mana,
ch->move, ch->max_move,
ch->exp );
17 Aug, 2006, Zeno wrote in the 5th comment:
Votes: 0
You can find it in mud.h, in the struct. Although I'm not sure what you mean by "where its coding is".
17 Aug, 2006, Justice wrote in the 6th comment:
Votes: 0
Zeno said:
You can find it in mud.h, in the struct. Although I'm not sure what you mean by "where its coding is".


Yeah, all I did was open mud.h, found the struct, then verified that I had the correct variable by grepping for it and examining where it was used.

Experience is referenced in surprisingly few places. Although that's probably because most things use level directly.
18 Aug, 2006, Sakirious wrote in the 7th comment:
Votes: 0
I see, so what defines how experience is given?
18 Aug, 2006, Zeno wrote in the 8th comment:
Votes: 0
Look for the function called gain_exp, I think. Not sure where it is offhand.
18 Aug, 2006, Conner wrote in the 9th comment:
Votes: 0
The function gain_exp is in update.c, but it's used in fight.c, magic.c, mud_comm.c, skills.c, and dummy declared in mud.h so that it can be used in the rest.

Grep shows it in the following places in my code:
fight.c:      gain_exp( ch, xp_gain );
fight.c: gain_exp( victim, ( exp_level( victim, victim->level ) - victim->exp ) / 2 );
fight.c: gain_exp( gch, xp );
fight.c: gain_exp( ch, 0 - los );
fight.c: gain_exp( ch, 0 - los );
magic.c: gain_exp( victim, 0 - number_range( level / 2, 3 * level / 2 ) );
magic.c: gain_exp( ch, 0 - xp_gain );
magic.c: gain_exp( ch, 0 - xp_gain );
magic.c: gain_exp( ch, 0 - xp_gain );
mud_comm.c: gain_exp( victim, ( exp_level( victim, victim->level ) - victim->exp ) / 2 );
mud.h:void gain_exp args( ( CHAR_DATA * ch, int gain ) );
skills.c: gain_exp( ch, gain );
skills.c: gain_exp( ch, 0 - lose );
skills.c: gain_exp( ch, 0 - lose );
update.c:void gain_exp( CHAR_DATA * ch, int gain )
19 Aug, 2006, Sakirious wrote in the 10th comment:
Votes: 0
Thank you guys, I got it now ;) I can't believe I didn't think to look for gain_exp…I'm an idiot.
19 Aug, 2006, Guest wrote in the 11th comment:
Votes: 0
You'll also want to look for instances of group_gain() and xp_compute() if you really want to dig deep into how experience works and is calculated.
20 Aug, 2006, Sakirious wrote in the 12th comment:
Votes: 0
Ooo… Teh Samson speaks…Nah, just playing, but thank you for the info, it is appreciated. :D
20 Aug, 2006, Justice wrote in the 13th comment:
Votes: 0
If you listen very carefully… you just might hear the mysterious samson speak.
21 Aug, 2006, Conner wrote in the 14th comment:
Votes: 0
BTW, just for reference, grep shows group_gain (in my code) in the following locations:
fight.c:void group_gain args( ( CHAR_DATA * ch, CHAR_DATA * victim ) );
fight.c: group_gain( ch, victim );
fight.c:void group_gain( CHAR_DATA * ch, CHAR_DATA * victim )
mud_prog.c:/* * call in fight.c, group_gain, after (?) the obj_to_room */

and xp_compute in the following locations:
fight.c:int xp_compute args( ( CHAR_DATA * gch, CHAR_DATA * victim ) );
fight.c: xp_gain = ( int )( xp_compute( ch, victim ) * 0.85 * dam ) / victim->max_hit;
fight.c: fight->xp = ( int )xp_compute( ch, victim ) * 0.85;
fight.c: xp = ( int )( xp_compute( gch, victim ) * 0.1765 ) / members;
fight.c:int xp_compute( CHAR_DATA * gch, CHAR_DATA * victim )

so, basically you're really just grabbing a few more spots in fight.c and one in mud_prog.c, not much extra over what you were already looking at. :)
21 Aug, 2006, Darmond wrote in the 15th comment:
Votes: 0
lol I should show my face here more often i could have helped with that as i had done it a month or two ago with my rom code base (i beleve the exp function is relitivly the same just in difernt places) I had to change it so that one could actualy set the EXP gained per mob in medit lol
21 Aug, 2006, Justice wrote in the 16th comment:
Votes: 0
Sounds like how circle handled it.

Was contemplating doing the same on my mud… optionally setting the base exp of a mob in mset.
Been too busy working on crafting to think much on it though.
30 Nov, 2006, cbunting wrote in the 17th comment:
Votes: 0
Hello,
What you are looking for is the xp_compute function in fight.c. I think it's the same on all codebases. I know this is an old post but at least anyone else who may be looking for this will know where to find it. If you want ideas for a generated at load exp system, check out Ackmud 4.3.

Chris
01 Dec, 2006, Omega wrote in the 18th comment:
Votes: 0
in an older mud i did, i went through the act/off/imm/res/vnum tables and added xp-modifiers to them, so that you could add xp/take away xp pending which flags were set on your victim, this was computed in xp_compute, its a good method to create varying xp, figured i'd post this here since a topic on it was going, but yeah, this is how i used to handle xp (there were other things i did aswell like in the spec_table had an xp modifier aswell, so different spec's would affect xp gain)

so, an act_aggressive mob would get +20, and if you gave it spec_dragon ontop of that, it would get an extra +20 to the algorythm, but then, if it had vulnerabilities, it would do stuff like if vuln_weapon, it would have -15, so, making things really vulnerable affected the overall xp output, this made building allot more fun because 1 little flag could offset everthing with the xp-gain.

if that mobile killed lots of people (ie, people died trying to kill it) you would get more xp per kill it had against persons, because the mud would deem it a 'difficult' mobile.

These are all things one can do to create an effective, and fun xp system.

I recommend ensuring that level gets added in, aswell as setting a xp varaible, that sets the 'base' xp, and that you balance it out.
0.0/18