Crossfire Server, Trunk  R20513
Functions | Variables
exp.c File Reference

Experience management. More...

#include "global.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for exp.c:

Go to the source code of this file.

Functions

void dump_experience (void)
 Dump the experience table, then calls exit() - useful in terms of debugging to make sure the format of the exp_table is correct. More...
 
void free_experience (void)
 Frees experience-related memory. More...
 
int has_ability (const object *ob)
 Checks whether object has innate abilities (spell/spellbook in inventory). More...
 
void init_experience (void)
 This loads the experience table from the exp_table file. More...
 
int64_t new_exp (const object *ob)
 Alternative way to calculate experience based on the ability of a monster. More...
 

Variables

static const float exp_att_mult [NROFATTACKS]
 
static const float exp_prot_mult [NROFATTACKS]
 
int64_tlevels
 Number of levels for which we have experience. More...
 

Detailed Description

Experience management.

reading data from files and such.

Definition in file exp.c.

Function Documentation

void dump_experience ( void  )

Dump the experience table, then calls exit() - useful in terms of debugging to make sure the format of the exp_table is correct.

Definition at line 249 of file exp.c.

References FMT64, levels, logfile, Settings::max_level, and settings.

void free_experience ( void  )

Frees experience-related memory.

Definition at line 261 of file exp.c.

References FREE_AND_CLEAR, and levels.

Referenced by free_globals().

Here is the caller graph for this function:

int has_ability ( const object ob)

Checks whether object has innate abilities (spell/spellbook in inventory).

Returns
1 if monster has any innate abilities, 0 else

Definition at line 153 of file exp.c.

References object_find_by_type(), SPELL, and SPELLBOOK.

Referenced by new_exp().

Here is the call graph for this function:

Here is the caller graph for this function:

void init_experience ( void  )

This loads the experience table from the exp_table file.

This tends to exit on any errors, since it populates the table as it goes along, so if there are errors, the table is likely in an inconsistent state.

Note
will call exit() if file is invalid or not found.

Definition at line 167 of file exp.c.

References atoll, Settings::confdir, FMT64, levels, llevDebug, llevError, LOG(), MAX_BUF, Settings::max_level, settings, snprintf, and strncasecmp().

Referenced by init_library(), and setup().

Here is the call graph for this function:

Here is the caller graph for this function:

int64_t new_exp ( const object ob)

Alternative way to calculate experience based on the ability of a monster.

It's far from perfect, and doesn't consider everything which can be considered, thus it's only used in debugging. this is only used with one of the dumpflags, and not anyplace in the code.

Parameters
obobject for which to return experience
Returns
experience computed from object's properties.

Definition at line 100 of file exp.c.

References liv::ac, obj::attacktype, liv::Con, liv::dam, exp_att_mult, exp_prot_mult, FABS, FALSE, FLAG_CAST_SPELL, FLAG_HITBACK, FLAG_NO_MAGIC, FLAG_REFL_MISSILE, FLAG_REFL_SPELL, FLAG_SEE_INVISIBLE, FLAG_SPLITTING, FLAG_STAND_STILL, FLAG_USE_BOW, FLAG_USE_RANGE, FLAG_USE_SCROLL, has_ability(), MAX, liv::maxhp, liv::maxsp, MIN, NROFATTACKS, QUERY_FLAG, obj::resist, obj::speed, obj::stats, and liv::wc.

Referenced by print_monsters().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

const float exp_att_mult[NROFATTACKS]
static
Initial value:
= {
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.4,
1.5,
0.0,
0.1,
0.3,
0.1,
0.3,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.5,
0.1,
0.2,
0.0,
0.5,
0.2,
}

Definition at line 28 of file exp.c.

Referenced by new_exp().

const float exp_prot_mult[NROFATTACKS]
static
Initial value:
= {
0.4,
0.5,
0.1,
0.1,
0.1,
0.1,
0.1,
0.1,
0.1,
0.1,
0.1,
0.0,
0.1,
0.1,
0.1,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.1,
0.0,
0.0,
0.0,
0.1,
}

Definition at line 57 of file exp.c.

Referenced by new_exp().

int64_t* levels