Atrinik Server 2.5
Data Structures | Typedefs | Functions | Variables
server/skill_util.c File Reference
#include <global.h>

Go to the source code of this file.

Data Structures

struct  _skill_name_table

Typedefs

typedef struct _skill_name_table _skill_name_table

Functions

static int change_skill_to_skill (object *who, object *skl)
static int attack_melee_weapon (object *op, int dir)
static int attack_hth (object *pl, int dir, char *string)
static int do_skill_attack (object *tmp, object *op, char *string)
static void find_skill_exp_name (object *pl, object *exp, int idx)
int find_skill_exp_level (object *pl, int item_skill)
char * find_skill_exp_skillname (int item_skill)
sint64 do_skill (object *op, int dir, const char *params)
sint64 calc_skill_exp (object *who, object *op, int level)
static void init_exp_obj ()
void init_new_exp_system ()
void free_exp_objects ()
void dump_skills ()
int check_skill_known (object *op, int skillnr)
int lookup_skill_by_name (const char *string)
int check_skill_to_fire (object *who)
int check_skill_to_apply (object *who, object *item)
int init_player_exp (object *pl)
void unlink_skill (object *skillop)
void link_player_skills (object *pl)
int link_player_skill (object *pl, object *skillop)
int learn_skill (object *pl, object *scroll, char *name, int skillnr, int scroll_flag)
int use_skill (object *op, char *string)
int change_skill (object *who, int sk_index)
int skill_attack (object *tmp, object *pl, int dir, char *string)
int SK_level (object *op)
objectSK_skill (object *op)
float get_skill_time (object *op, int skillnr)
int check_skill_action_time (object *op, object *skill)

Variables

static objectexp_cat [MAX_EXP_CAT]
static int nrofexpcat = 0
float stat_exp_mult [MAX_STAT+1]
static float lev_exp [MAXLEVEL+1]
static _skill_name_table skill_name_table []
static int item_skill_cs_stat []

Detailed Description

Various skill related functions.

Definition in file skill_util.c.


Typedef Documentation

Skill category table.


Function Documentation

static int attack_hth ( object pl,
int  dir,
char *  string 
) [static]

This handles all hand-to-hand attacks.

Parameters:
plObject attacking.
dirAttack direction.
stringDescribes the attack ("karate-chop", "punch", ...).
Returns:
0 if no attack was done, nonzero otherwise.

Definition at line 1194 of file skill_util.c.

static int attack_melee_weapon ( object op,
int  dir 
) [static]

This handles melee weapon attacks -b.t.

Parameters:
opLiving thing attacking.
dirAttack direction.
Returns:
0 if no attack was done, nonzero otherwise.

Definition at line 1173 of file skill_util.c.

sint64 calc_skill_exp ( object who,
object op,
int  level 
)

Calculates amount of experience can be gained for successfull use of a skill.

Parameters:
whoPlayer/creature that used the skill.
opObject that was 'defeated'.
levelLevel of the skill. If -1, will get level of who's chosen skill.
Returns:
Experience for the skill use.

Definition at line 289 of file skill_util.c.

int change_skill ( object who,
int  sk_index 
)

This changes the object's skill.

Parameters:
whoLiving to change skill for.
sk_indexID of the skill.
Returns:
0 on failure, 1 on success.

Definition at line 1086 of file skill_util.c.

static int change_skill_to_skill ( object who,
object skl 
) [static]

Like change_skill(), but uses skill object instead of looking for the skill number.

Parameters:
whoLiving to change skill for.
sklSkill object.
Returns:
0 on failure, 1 on success.

Definition at line 1134 of file skill_util.c.

int check_skill_action_time ( object op,
object skill 
)

We check the action timer for a skill.

Parameters:
opPlayer.
skillSkill object.
Returns:
1 if the skill action is possible, 0 otherwise.

Definition at line 1440 of file skill_util.c.

int check_skill_known ( object op,
int  skillnr 
)

Check if object knows the specified skill.

Parameters:
opObject we're checking.
skillnrID of the skill.
Returns:
1 if the object knows the skill, 0 otherwise.

Definition at line 510 of file skill_util.c.

int check_skill_to_apply ( object who,
object item 
)

When a player tried to use an object which requires a skill this function is called.

Parameters:
whoPlayer object.
itemThe object to apply.
Returns:
1 if it can be applied, 0 otherwise.

Definition at line 642 of file skill_util.c.

int check_skill_to_fire ( object who)

Check skill for firing.

Parameters:
whoObject.
Returns:
1 on success, 0 on failure.

Definition at line 561 of file skill_util.c.

sint64 do_skill ( object op,
int  dir,
const char *  params 
)

Main skills use function similar in scope to cast_spell().

We handle all requests for skill use outside of some combat here. We require a separate routine outside of fire() so as to allow monsters to utilize skills.

Parameters:
opThe object actually using the skill.
dirThe direction in which the skill is used.
paramsString option for the skill.
Returns:
0 on failure of using the skill, non-zero otherwise.

Definition at line 185 of file skill_util.c.

static int do_skill_attack ( object tmp,
object op,
char *  string 
) [static]

We have got an appropriate opponent from either move_player() or skill_attack(). In this part we get on with attacking, take care of messages from the attack and changes in invisible. Returns true if the attack damaged the opponent.

Parameters:
tmpTargetted monster.
opWhat is attacking.
stringDescribes the attack ("karate-chop", "punch", ...).
Returns:
1 if the attack damaged the opponent.

Definition at line 1295 of file skill_util.c.

void dump_skills ( )

Dump debugging information about the skills.

Definition at line 484 of file skill_util.c.

int find_skill_exp_level ( object pl,
int  item_skill 
)

Find and return player skill exp level of given index item_skill using CS_STAT_SKILLEXP_xxx

Parameters:
plPlayer.
item_skillItem skill.
Returns:
Found level, 0 on failure.

Definition at line 146 of file skill_util.c.

static void find_skill_exp_name ( object pl,
object exp,
int  idx 
) [static]

Find and assign the skill experience stuff.

Parameters:
plPlayer.
expExperience object.
idxIndex.

Definition at line 124 of file skill_util.c.

char* find_skill_exp_skillname ( int  item_skill)

Find and return player skill exp level name of given index item_skill.

Parameters:
item_skillThe skill experience category to look for.
Returns:
Name of the skill experience category.

Definition at line 165 of file skill_util.c.

void free_exp_objects ( )

Free all previously initialized experience objects.

Definition at line 466 of file skill_util.c.

float get_skill_time ( object op,
int  skillnr 
)

Returns the amount of time it takes to use a skill.

Parameters:
opPlayer.
skillnrID of the skill to check.
Returns:
Amount of time the skill takes.

Definition at line 1397 of file skill_util.c.

static void init_exp_obj ( ) [static]

This routine looks through all the assembled archetypes for experience objects then copies their values into the exp_cat array.

Definition at line 374 of file skill_util.c.

void init_new_exp_system ( )

Initialize the experience system.

Definition at line 408 of file skill_util.c.

int init_player_exp ( object pl)

Makes various checks and initialization of player experience objects. If things aren't cool then we change them here.

Parameters:
plPlayer.
Returns:
1 on success, 0 on failure.

Definition at line 759 of file skill_util.c.

int learn_skill ( object pl,
object scroll,
char *  name,
int  skillnr,
int  scroll_flag 
)

Player is trying to learn a skill. Success is based on Int.

Parameters:
plPlayer object.
scrollScroll object the player is learning this from, can be NULL.
nameName of the skill to learn.
skillnrID of the skill to learn.
scroll_flagWhether we're learning the skill from a scroll.
Return values:
0Player already knows the skill.
1The player learns the skill.
2Some failure.

Definition at line 942 of file skill_util.c.

int link_player_skill ( object pl,
object skillop 
)

Links a skill to exp object when applied or learned by a player.

Parameters:
plPlayer.
skillopSkill object.
Returns:
1 if it can link, 0 otherwise.

Definition at line 907 of file skill_util.c.

void link_player_skills ( object pl)

Linking skills with experience objects and creating a linked list of skills for later fast access.

Parameters:
plPlayer.

Definition at line 858 of file skill_util.c.

int lookup_skill_by_name ( const char *  string)

Look up a skill by name.

Parameters:
stringName of the skill to look for.
Returns:
ID of the skill if found, -1 otherwise.

Definition at line 529 of file skill_util.c.

int SK_level ( object op)

Get the level of player's chosen skill.

Parameters:
opPlayer.
Returns:
The level of the chosen skill, level of the player if no chosen skill.

Definition at line 1352 of file skill_util.c.

object* SK_skill ( object op)

Get pointer to player's chosen skill object.

Parameters:
opPlayer.
Returns:
Chosen skill object, NULL if no chosen skill.

Definition at line 1380 of file skill_util.c.

int skill_attack ( object tmp,
object pl,
int  dir,
char *  string 
)

Core routine for use when we attack using the skills system. There aren't too many changes from before, basically this is a 'wrapper' for the old attack system. In essence, this code handles all skill-based attacks, ie hth, missile and melee weapons should be treated here. If an opponent is already supplied by move_player(), we move right onto do_skill_attack(), otherwise we find if an appropriate opponent exists.

Parameters:
tmpTargetted monster.
plWhat is attacking.
dirAttack direction.
stringDescribes the attack ("karate-chop", "punch", ...).
Returns:
1 if the attack damaged the opponent.

Definition at line 1237 of file skill_util.c.

void unlink_skill ( object skillop)

Removes skill from a player skill list and unlinks the pointer to the exp object.

Parameters:
skillopSkill object.

Definition at line 840 of file skill_util.c.

int use_skill ( object op,
char *  string 
)

Similar to invoke command, it executes the skill in the direction that the user is facing.

Parameters:
opPlayer trying to use a skill.
stringParameter for the skill to use.
Return values:
0Unable to change to the requested skill, or unable to use the skill properly.
1Skill correctly used.

Definition at line 1015 of file skill_util.c.


Variable Documentation

object* exp_cat[MAX_EXP_CAT] [static]

Array of experience objects in the game.

Definition at line 36 of file skill_util.c.

int item_skill_cs_stat[] [static]
Initial value:
{
    0,
    CS_STAT_SKILLEXP_AGILITY,
    CS_STAT_SKILLEXP_PERSONAL,
    CS_STAT_SKILLEXP_MENTAL,
    CS_STAT_SKILLEXP_PHYSIQUE,
    CS_STAT_SKILLEXP_MAGIC,
    CS_STAT_SKILLEXP_WISDOM
}

Definition at line 103 of file skill_util.c.

float lev_exp[MAXLEVEL+1] [static]
Initial value:
{
    0.0f,     1.0f,     1.11f,    1.75f,    3.2f,
    5.5f,     10.0f,    20.0f,    35.25f,   66.1f,
    137.0f,   231.58f,  240.00f,  247.62f,  254.55f,
    260.87f,  266.67f,  272.00f,  276.92f,  281.48f,
    285.71f,  289.66f,  293.33f,  296.77f,  300.00f,
    303.03f,  305.88f,  308.57f,  311.11f,  313.51f,
    315.79f,  317.95f,  320.00f,  321.95f,  323.81f,
    325.58f,  327.27f,  328.89f,  330.43f,  331.91f,
    333.33f,  334.69f,  336.00f,  337.25f,  338.46f,
    339.62f,  340.74f,  341.82f,  342.86f,  343.86f,
    344.83f,  345.76f,  346.67f,  347.54f,  348.39f,
    349.21f,  350.00f,  350.77f,  351.52f,  352.24f,
    352.94f,  353.62f,  354.29f,  354.93f,  355.56f,
    356.16f,  356.76f,  357.33f,  357.89f,  358.44f,
    358.97f,  359.49f,  360.00f,  360.49f,  360.98f,
    361.45f,  361.90f,  362.35f,  362.79f,  365.22f,
    367.64f,  369.04f,  373.44f,  378.84f,  384.22f,
    389.59f,  395.96f,  402.32f,  410.67f,  419.01f,
    429.35f,  440.68f,  452.00f,  465.32f,  479.63f,
    494.93f,  510.23f,  527.52f,  545.81f,  562.09f,
    580.37f,  599.64f,  619.91f,  640.17f,  662.43f,
    685.68f,  709.93f,  773.17f,  852.41f,  932.65f,
    1013.88f, 1104.11f, 1213.35f, 1324.60f, 1431.86f,
    1542.13f
}

Used for calculating experience gained in calc_skill_exp().

Definition at line 54 of file skill_util.c.

int nrofexpcat = 0 [static]

Current number of experience categories in the game.

Definition at line 38 of file skill_util.c.

Initial value:
{
    {"agility", CS_STAT_SKILLEXP_AGILITY},
    {"personality", CS_STAT_SKILLEXP_PERSONAL},
    {"mental", CS_STAT_SKILLEXP_MENTAL},
    {"physique", CS_STAT_SKILLEXP_PHYSIQUE},
    {"magic", CS_STAT_SKILLEXP_MAGIC},
    {"wisdom", CS_STAT_SKILLEXP_WISDOM},
    {"", -1}
}

Array of the skill categories.

Definition at line 92 of file skill_util.c.

float stat_exp_mult[MAX_STAT+1]
Initial value:
{
    0.0f,   0.01f,  0.1f,   0.3f,   0.5f,
    0.6f,   0.7f,   0.8f,   0.85f,  0.9f,
    0.95f,  0.96f,  0.97f,  0.98f,  0.99f,
    1.0f,   1.01f,  1.02f,  1.03f,  1.04f,
    1.05f,  1.07f,  1.09f,  1.12f,  1.15f,
    1.2f,   1.3f,   1.4f,   1.5f,   1.7f,
    2.0f
}

Table for stat modification of exp

Definition at line 41 of file skill_util.c.