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

Go to the source code of this file.

Defines

#define ENCUMBRANCE_LIMIT   65.0f

Functions

void set_attr_value (living *stats, int attr, sint8 value)
void change_attr_value (living *stats, int attr, sint8 value)
sint8 get_attr_value (living *stats, int attr)
void check_stat_bounds (living *stats)
int change_abil (object *op, object *tmp)
void drain_stat (object *op)
void drain_specific_stat (object *op, int deplete_stats)
void fix_player (object *op)
void fix_monster (object *op)
objectinsert_base_info_object (object *op)
objectfind_base_info_object (object *op)
void set_mobile_speed (object *op, int idx)

Variables

int dam_bonus [MAX_STAT+1]
int thaco_bonus [MAX_STAT+1]
static float con_bonus [MAX_STAT+1]
static float pow_bonus [MAX_STAT+1]
static float wis_bonus [MAX_STAT+1]
float cha_bonus [MAX_STAT+1]
float speed_bonus [MAX_STAT+1]
uint32 weight_limit [MAX_STAT+1]
int learn_spell [MAX_STAT+1]
int cleric_chance [MAX_STAT+1]
int savethrow [MAXLEVEL+1]
static const char *const drain_msg [NUM_STATS]
const char *const restore_msg [NUM_STATS]
static const char *const gain_msg [NUM_STATS]
const char *const lose_msg [NUM_STATS]
const char *const statname [NUM_STATS]
const char *const short_stat_name [NUM_STATS]

Detailed Description

Functions related to attributes, weight, experience, which concern only living things.

Definition in file living.c.


Define Documentation

#define ENCUMBRANCE_LIMIT   65.0f

When we carry more than this of our weight_limit, we get encumbered.

Definition at line 34 of file living.c.


Function Documentation

int change_abil ( object op,
object tmp 
)

Permanently alters an object's stats/flags based on another object.

Returns:
1 if we successfully changed a stat, 0 if nothing was changed.
Note:
Flag is set to 1 if we are applying the object, -1 if we are removing the object.
It is the calling functions responsibility to check to see if the object can be applied or not.

Definition at line 373 of file living.c.

void change_attr_value ( living stats,
int  attr,
sint8  value 
)

Like set_attr_value(), but instead the value (which can be negative) is added to the specified stat.

Checking is performed to make sure old value + new value doesn't overflow the stat integer.

Parameters:
statsItem to modify. Must not be NULL.
attrAttribute to change.
valueDelta (can be positive).

Definition at line 287 of file living.c.

void check_stat_bounds ( living stats)

Ensures that all stats (str/dex/con/wis/cha/int) are within the passed in range of MIN_STAT and MAX_STAT.

Parameters:
statsAttributes to check.

Definition at line 346 of file living.c.

void drain_specific_stat ( object op,
int  deplete_stats 
)

Drain a specified stat from op.

Parameters:
opVictim to drain.
deplete_statsStatistic to drain.

Definition at line 806 of file living.c.

void drain_stat ( object op)

Drains a random stat from op.

Parameters:
opObject to drain.

Definition at line 797 of file living.c.

object* find_base_info_object ( object op)

Find base info object in monster.

Parameters:
opMonster object.
Returns:
Pointer to the base info if found, NULL otherwise.

Definition at line 2121 of file living.c.

void fix_monster ( object op)

Like fix_player(), but for monsters.

Parameters:
opThe monster.

Definition at line 1917 of file living.c.

void fix_player ( object op)

Updates all abilities given by applied objects in the inventory of the given object.

This functions starts from base values (archetype or player object) and then adjusts them according to what the player/monster has equipped.

Note that a player always has stats reset to their initial value.

Parameters:
opObject to reset.
Todo:
This function is too long, and should be cleaned / split.

Definition at line 843 of file living.c.

sint8 get_attr_value ( living stats,
int  attr 
)

Gets the value of a stat.

Parameters:
statsItem from which to get stat.
attrAttribute to get.
Returns:
Specified attribute, 0 if not found.
See also:
set_attr_value().

Definition at line 313 of file living.c.

object* insert_base_info_object ( object op)

Insert and initialize base info object in object op.

Parameters:
opObject.
Returns:
Pointer to the inserted base info object.

Definition at line 2072 of file living.c.

void set_attr_value ( living stats,
int  attr,
sint8  value 
)

Sets Str/Dex/con/Wis/Cha/Int/Pow in stats to value, depending on what attr is (STR to POW).

Parameters:
statsItem to modify. Must not be NULL.
attrAttribute to change.
valueNew value.

Definition at line 244 of file living.c.

void set_mobile_speed ( object op,
int  idx 
)

Set the movement speed of a monster. 1/5 = mob is slowed (by magic) 2/5 = normal mob speed - moving normal 3/5 = mob is moving fast 4/5 = mov is running/attack speed 5/5 = mob is hasted and moving full speed

Parameters:
opMonster.
idxIndex.

Definition at line 2145 of file living.c.


Variable Documentation

float cha_bonus[MAX_STAT+1]
Initial value:
{
    -0.15f,
    -0.10f, -0.08f,-0.05f, -0.03f, -0.02f,
    -0.01f, -0.005f, -0.003f, -0.001f, 0.0f,
    0.0f, 0.0f, 0.0f, 0.005f, 0.010f,
    0.015f, 0.02f, 0.025f, 0.03f, 0.035f,
    0.04f, 0.045f, 0.05f, 0.055f, 0.06f,
    0.065f, 0.07f, 0.08f, 0.09f, 0.1f
}

Charisma bonus.

As a base value, you get in a shop 20% of the real value of an item.

With a charisma bonus, you can go up to 30% at maximum or 5% at minimum (actually this is 10% minimum, because stats cannot go below 1). For buying, these values are used in reverse. You can buy for 90% at best, or 115% (110%, because stats cannot go below 1) at worst.

Definition at line 89 of file living.c.

int cleric_chance[MAX_STAT+1]
Initial value:
{
    100, 100, 100, 100, 90,
    80, 70, 60, 50, 40,
    30, 20, 10, 9, 8,
    7, 6, 5, 4, 3,
    2, 1, 0, 0, 0,
    0, 0, 0, 0, 0,
    0
}

Probability of messing up a divine spell. Based on wisdom.

Definition at line 142 of file living.c.

float con_bonus[MAX_STAT+1] [static]
Initial value:
{
    -0.8f, -0.6f, -0.5f, -0.4f, -0.35f, -0.3f, -0.25f, -0.2f, -0.15f, -0.11f, -0.07f,
    0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
    0.1f, 0.15f, 0.2f, 0.25f, 0.3f, 0.35f, 0.4f, 0.45f, 0.5f, 0.55f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f
}

Constitution bonus.

Definition at line 55 of file living.c.

int dam_bonus[MAX_STAT+1]
Initial value:
{
    -5, -4, -4, -3, -3, -3, -2, -2, -2, -1, -1,
    0, 0, 0, 0, 0,
    1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 6, 7, 8, 10, 12
}

dam_bonus, thaco_bonus, weight limit all are based on strength.

Definition at line 38 of file living.c.

const char* const drain_msg[NUM_STATS] [static]
Initial value:
{
    "Oh no! You are weakened!",
    "You're feeling clumsy!",
    "You feel less healthy",
    "You suddenly begin to lose your memory!",
    "Your face gets distorted!",
    "Watch out, your mind is going!",
    "Your spirit feels drained!"
}

Message when a player is drained of a stat.

Definition at line 167 of file living.c.

const char* const gain_msg[NUM_STATS] [static]
Initial value:
{
    "You feel stronger.",
    "You feel more agile.",
    "You feel healthy.",
    "You feel wiser.",
    "You seem to look better.",
    "You feel smarter.",
    "You feel more potent."
}

Message when a player increases a stat.

Definition at line 191 of file living.c.

int learn_spell[MAX_STAT+1]
Initial value:
{
    0, 0, 0, 1, 2, 4, 8, 12, 16, 25, 36, 45, 55, 65, 70, 75, 80, 85, 90, 95, 100, 100, 100, 100, 100,
    100, 100, 100, 100, 100, 100
}

Probability to learn a spell or skill, based on intelligence or wisdom.

Definition at line 134 of file living.c.

const char* const lose_msg[NUM_STATS]
Initial value:
{
    "You feel weaker!",
    "You feel clumsy!",
    "You feel less healthy!",
    "You lose some of your memory!",
    "You look ugly!",
    "You feel stupid!",
    "You feel less potent!"
}

Message when a player decreases a stat.

Definition at line 203 of file living.c.

float pow_bonus[MAX_STAT+1] [static]
Initial value:
{
    -0.8f, -0.6f, -0.5f, -0.4f, -0.35f, -0.3f, -0.25f, -0.2f, -0.15f, -0.11f, -0.07f,
    0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
    0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.4f, 1.6f, 1.8f, 2.0f
}

Power bonus.

Definition at line 64 of file living.c.

const char* const restore_msg[NUM_STATS]
Initial value:
{
    "You feel your strength return.",
    "You feel your agility return.",
    "You feel your health return.",
    "You feel your wisdom return.",
    "You feel your charisma return.",
    "You feel your memory return.",
    "You feel your spirits return."
}

Message when a player has a stat restored.

Definition at line 179 of file living.c.

int savethrow[MAXLEVEL+1]
Initial value:
{
    18,
    18, 17, 16, 15, 14, 14, 13, 13, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 9,
    9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6,
    6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4,
    4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2,
    2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
}

Probability to avoid something.

Definition at line 155 of file living.c.

const char* const short_stat_name[NUM_STATS]
Initial value:
{
    "Str",
    "Dex",
    "Con",
    "Wis",
    "Cha",
    "Int",
    "Pow"
}

Short names of stats.

Definition at line 227 of file living.c.

float speed_bonus[MAX_STAT+1]
Initial value:
{
    -0.4f, -0.4f, -0.3f, -0.3f, -0.2f,
    -0.2f, -0.2f, -0.1f, -0.1f, -0.1f,
    -0.05f, 0.0, 0.0f, 0.0f, 0.025f, 0.05f,
    0.075f, 0.1f, 0.125f, 0.15f, 0.175f, 0.2f,
    0.225f, 0.25f, 0.275f, 0.3f,
    0.325f, 0.35f, 0.4f, 0.45f, 0.5f
}

Speed bonus. Uses dexterity as its stat.

Definition at line 102 of file living.c.

const char* const statname[NUM_STATS]
Initial value:
{
    "strength",
    "dexterity",
    "constitution",
    "wisdom",
    "charisma",
    "intelligence",
    "power"
}

Names of stats.

Definition at line 215 of file living.c.

int thaco_bonus[MAX_STAT+1]
Initial value:
{
    -5, -4, -4, -3, -3, -3, -2, -2, -2, -1, -1,
    0, 0, 0, 0, 0,
    1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 7, 8
}

THAC0 bonus - WC bonus

Definition at line 46 of file living.c.

uint32 weight_limit[MAX_STAT+1]
Initial value:
{
    20000,
    25000,  30000,  35000,  40000,  50000,
    60000,  70000,  80000,  90000,  100000,
    110000, 120000, 130000, 140000, 150000,
    165000, 180000, 195000, 210000, 225000,
    240000, 255000, 270000, 285000, 300000,
    325000, 350000, 375000, 400000, 450000
}

The absolute most a character can carry - a character can't pick stuff up if it would put him above this limit.

Value is in grams, so we don't need to do conversion later

These limits are probably overly generous, but being there were no values before, you need to start someplace.

Definition at line 120 of file living.c.

float wis_bonus[MAX_STAT+1] [static]
Initial value:
{
    -0.8f, -0.6f, -0.5f, -0.4f, -0.35f, -0.3f, -0.25f, -0.2f, -0.15f, -0.11f, -0.07f,
    0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
    0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.4f, 1.6f, 1.8f, 2.0f
}

Wisdom bonus.

Definition at line 73 of file living.c.