Atrinik Server 2.5
Defines | Functions | Variables
server/exp.c File Reference
#include <global.h>

Go to the source code of this file.

Defines

#define MAX_EXPERIENCE   new_levels[MAXLEVEL]
#define MAX_EXP_IN_OBJ   new_levels[MAXLEVEL] / (MAX_EXP_CAT - 1)

Functions

uint64 level_exp (int level, double expmul)
sint64 add_exp (object *op, sint64 exp, int skill_nr, int exact)
void player_lvl_adj (object *who, object *op)
sint64 adjust_exp (object *pl, object *op, sint64 exp)
void apply_death_exp_penalty (object *op)
float calc_level_difference (int who_lvl, int op_lvl)
uint64 calculate_total_exp (object *op)

Variables

uint64 new_levels [MAXLEVEL+2]
_level_color level_color [201]

Detailed Description

Experience management.

Definition in file exp.c.


Define Documentation

#define MAX_EXPERIENCE   new_levels[MAXLEVEL]

Maximum experience.

Definition at line 273 of file exp.c.


Function Documentation

sint64 add_exp ( object op,
sint64  exp,
int  skill_nr,
int  exact 
)

Add experience to player.

Parameters:
opThe player.
expHow much experience to add (or, in case the value being negative, subtract).
skill_nrSkill ID.
exactIf 1, experience gained will not be capped.
Returns:
0 on failure, experience gained on success.

Definition at line 298 of file exp.c.

sint64 adjust_exp ( object pl,
object op,
sint64  exp 
)

Make sure that we don't exceed max or min set on experience.

This function also adjusts skill category experience, and overall player experience based on the skill category that has the most experience.

Parameters:
plPlayer.
opSkill object.
expExperience.
Returns:
0 on failure, experience we added otherwise.

Definition at line 567 of file exp.c.

void apply_death_exp_penalty ( object op)

Applies death experience penalty.

We never lose a level, just percent of the experience we gained for the next level.

Parameters:
opVictim of the penalty. Must not be NULL.

Definition at line 637 of file exp.c.

float calc_level_difference ( int  who_lvl,
int  op_lvl 
)

Calculate level difference.

We will get a bonus or malus value here, unless both levels match.

Yellow does not always mean same level, but in equal range.

Experience multiplication based on target color range:

  • yellow: Between 0.8 and 1.1 (80% - 110%).
  • blue: Between 0.4 and 0.6 (40% - 60%).
  • green: Between 0.25 and 0.3 (25% - 30%).
  • orange: Between 1.2 and 1.4 (120% - 140%).
  • red, purple: 1.4 + 0.1% per level.

If the target is in yellow range, the experience multiplication is between 0.8 and 1.1 (80% - 110%).

If the target is in blue range, the experience

Parameters:
who_lvlPlayer.
op_lvlVictim.
Returns:
Level difference.

Definition at line 733 of file exp.c.

uint64 calculate_total_exp ( object op)

Calculate total experience of player, based on all skills they know.

Parameters:
opPlayer.
Returns:
The total experience.

Definition at line 838 of file exp.c.

uint64 level_exp ( int  level,
double  expmul 
)

Calculates how much experience is needed for a player to become the given level.

Parameters:
levelLevel to become.
expmulExperience multiplicator.
Returns:
The experience needed.
Todo:
Remove, since the param expmul seems to always be passed as '1.0'?

Definition at line 285 of file exp.c.

void player_lvl_adj ( object who,
object op 
)

For the new experience system. We are concerned with whether the player gets more hp, sp and new levels.

Will tell the player about changed levels.

Parameters:
whoPlayer.
opWhat we are checking to gain the level (eg, skill).

Definition at line 388 of file exp.c.


Variable Documentation

Level colors.

Definition at line 67 of file exp.c.

uint64 new_levels[MAXLEVEL+2]
Initial value:
{
    0,          0,          1500,       4000,       8000,
    16000,      32000,      64000,      125000,     250000,
    500000,     1100000,    2300000,    3600000,    5000000,
    6500000,    8100000,    9800000,    11600000,   13500000,
    15500000,   17600000,   19800000,   22100000,   24500000,
    27000000,   29600000,   32300000,   35100000,   38000000,
    41000000,   44100000,   47300000,   50600000,   54000000,
    57500000,   61100000,   64800000,   68600000,   72500000,
    76500000,   80600000,   84800000,   89100000,   93500000,
    98000000,   102600000,  107300000,  112100000,  117000000,
    122000000,  127100000,  132300000,  137600000,  143000000,
    148500000,  154100000,  159800000,  165600000,  171500000,
    177500000,  183600000,  189800000,  196100000,  202500000,
    209000000,  215600000,  222300000,  229100000,  236000000,
    243000000,  250100000,  257300000,  264600000,  272000000,
    280200000,  294800000,  310200000,  326300000,  343200000,
    361000000,  379700000,  399300000,  419900000,  441500000,
    464200000,  488100000,  513100000,  539400000,  567000000,
    596000000,  626400000,  658300000,  691900000,  727100000,
    764100000,  802900000,  843700000,  886500000,  931500000,
    978700000,  1028200000, 1080300000, 1134900000, 1192300000,
    1252500000, 1315800000, 1382200000, 1451900000, 1525100000,
    2100000000ULL, 4200000000ULL, 8400000000ULL, 16800000000ULL, 33600000000ULL,
    67200000000ULL, 134400000000ULL
}

Experience needed for each level.

Around level 11 you need to kill 38 + (2 * (your_level - 11)) yellow monsters with a base exp of 125 to level up.

Definition at line 37 of file exp.c.