Atrinik Server  4.0
Functions | Variables
skill_util.c File Reference
#include <global.h>
#include <toolkit/string.h>
#include <plugin.h>
#include <arch.h>
#include <player.h>
#include <object.h>
#include <exp.h>

Go to the source code of this file.


static int do_skill_attack (object *tmp, object *op, char *string)
int64_t do_skill (object *op, int dir, const char *params)
int64_t calc_skill_exp (object *who, object *op, int level)
void init_new_exp_system (void)
int check_skill_to_fire (object *op, object *weapon)
void link_player_skills (object *pl)
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 stat_exp_mult [MAX_STAT+1]
static float lev_exp [MAXLEVEL+1]

Detailed Description

Various skill related functions.

Definition in file skill_util.c.

Function Documentation

int64_t calc_skill_exp ( object who,
object op,
int  level 

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

whoWho used the skill. Cannot be NULL, and must be a player.
opObject that was 'defeated'.
levelLevel of the skill. If -1, will get level of who's chosen skill.
Experience for the skill use.

Definition at line 158 of file skill_util.c.

int change_skill ( object who,
int  sk_index 

This changes the object's skill.

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

Definition at line 340 of file skill_util.c.

int check_skill_to_fire ( object op,
object weapon 

Check skill for firing.

opWho is firing.
weaponWeapon that is being fired.
1 on success, 0 on failure.

Definition at line 252 of file skill_util.c.

int64_t 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.

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

Definition at line 99 of file skill_util.c.

static int do_skill_attack ( object tmp,
object op,
char *  string 

We have got an appropriate opponent from either move_object() 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.

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

Definition at line 432 of file skill_util.c.

void init_new_exp_system ( void  )

Initialize the experience system.

Definition at line 219 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.


Definition at line 287 of file skill_util.c.

int SK_level ( object op)

Get the level of player's chosen skill.

The level of the chosen skill, level of the player if no chosen skill.

Definition at line 470 of file skill_util.c.

object* SK_skill ( object op)

Get pointer to player's chosen skill object.

Chosen skill object, NULL if no chosen skill.

Definition at line 496 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_object(), we move right onto do_skill_attack(), otherwise we find if an appropriate opponent exists.

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

Definition at line 377 of file skill_util.c.

Variable Documentation

float lev_exp[MAXLEVEL+1]
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,

Used for calculating experience gained in calc_skill_exp().

Definition at line 55 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,

Table for stat modification of exp

Definition at line 42 of file skill_util.c.