Atrinik Server  4.0
Macros | Functions | Variables
living.c File Reference
#include <global.h>
#include <monster_data.h>
#include <arch.h>
#include <plugin.h>
#include <player.h>
#include <object.h>

Go to the source code of this file.

Macros

#define ENCUMBRANCE_LIMIT   65.0
 

Functions

void set_attr_value (living *stats, int attr, int8_t value)
 
void change_attr_value (living *stats, int attr, int8_t value)
 
int8_t get_attr_value (const living *stats, int attr)
 
void check_stat_bounds (living *stats)
 
void drain_stat (object *op)
 
void drain_specific_stat (object *op, int deplete_stats)
 
static void living_apply_flags (object *op, const object *item)
 
static void living_update_player_item (player *pl, object *op, const object *item, double *attacks, double *protect_bonus, double *protect_malus, int *max_bonus_hp, int *max_bonus_sp, double *max_speed, double *added_speed, double *bonus_speed)
 
void living_update_player (object *op)
 
void living_update_monster (object *op)
 
static int living_update_display (object *op, object *refop, player *refpl)
 
int living_update (object *op)
 
objectliving_find_base_info (object *op)
 
objectliving_get_base_info (object *op)
 
void set_mobile_speed (object *op, int idx)
 

Variables

double dam_bonus [MAX_STAT+1]
 
int wc_bonus [MAX_STAT+1]
 
static double hp_bonus [MAX_STAT+1]
 
static double sp_bonus [MAX_STAT+1]
 
float speed_bonus [MAX_STAT+1]
 
double falling_mitigation [MAX_STAT+1]
 
uint32_t weight_limit [MAX_STAT+1]
 
int learn_spell [MAX_STAT+1]
 
int monster_signal_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.

Macro Definition Documentation

#define ENCUMBRANCE_LIMIT   65.0

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

Definition at line 39 of file living.c.

Function Documentation

void change_attr_value ( living stats,
int  attr,
int8_t  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 277 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 333 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 365 of file living.c.

void drain_stat ( object op)

Drains a random stat from op.

Parameters
opObject to drain.

Definition at line 353 of file living.c.

int8_t get_attr_value ( const 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 305 of file living.c.

static void living_apply_flags ( object op,
const object item 
)
static

Propagate stats an item gives to a living object, eg, a player.

Parameters
opLiving object.
itemItem with the stats to give.

Definition at line 396 of file living.c.

object* living_find_base_info ( object op)

Find the base info object in the specified monster.

Parameters
opMonster object. Must not be NULL, cannot be a tail part and must be of type MONSTER.
Returns
Pointer to the base info if found, NULL otherwise.

Definition at line 1705 of file living.c.

object* living_get_base_info ( object op)

Acquire the base info object of the specified monster object. If the base info doesn't exist yet, it is created automatically.

Parameters
opMonster. Must not be NULL, cannot be a tail part and must be of type MONSTER.
Returns
Pointer to the base info object, NULL on failure.

Definition at line 1732 of file living.c.

int living_update ( object op)

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

Parameters
opObject to update.
Returns
Approximate number of changed stats.

Definition at line 1661 of file living.c.

static int living_update_display ( object op,
object refop,
player refpl 
)
static

Displays information about the object's updated stats.

Parameters
opObject.
refopOld state of the object.
refplOld state of the player.
Returns
Number of stats changed (approximate).

Definition at line 1329 of file living.c.

void living_update_monster ( object op)

Like living_update_player(), but for monsters.

Parameters
opThe monster.

Definition at line 1174 of file living.c.

void living_update_player ( object op)

Updates player object based on the applied items in their inventory.

Parameters
opPlayer to update.

Definition at line 614 of file living.c.

static void living_update_player_item ( player pl,
object op,
const object item,
double *  attacks,
double *  protect_bonus,
double *  protect_malus,
int *  max_bonus_hp,
int *  max_bonus_sp,
double *  max_speed,
double *  added_speed,
double *  bonus_speed 
)
static

Update player's stats that are acquired from the specified item.

Parameters
plPlayer.
opPlayer object.
itemItem the stats are acquired from.
[out]attacksAttack types.
[out]protect_bonusProtection bonuses.
[out]protect_malusProtection maluses.
[out]max_bonus_hpBonus to max HP.
[out]max_bonus_hpBonus to max SP.
[out]max_speedMaximum speed.
[out]added_speedAdded speed.
[out]bonus_speedBonus speed.

Definition at line 497 of file living.c.

void set_attr_value ( living stats,
int  attr,
int8_t  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 239 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 1785 of file living.c.

Variable Documentation

double dam_bonus[MAX_STAT+1]
Initial value:
= {
-2.5,
-2.0, -2.0, -1.5, -1.5, -1.5,
-1.0, -1.0, -1.0, -0.5, -0.5,
0.0, 0.0, 0.0, 0.0, 0.0,
0.5, 0.5, 1.0, 1.0, 1.5,
1.5, 1.5, 2.0, 2.0, 2.5,
3.0, 3.5, 4.0, 4.5, 5.0,
}

Bonus to melee/ranged damage. Based on strength.

Definition at line 44 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",
"Watch out, your mind is going!",
"Your spirit feels drained!"
}

Message when a player is drained of a stat.

Definition at line 176 of file living.c.

double falling_mitigation[MAX_STAT+1]
Initial value:
= {
2.0,
1.9, 1.8, 1.7, 1.6, 1.5,
1.4, 1.3, 1.2, 1.1, 1.0,
1.05, 1.0, 1.0, 1.0, 1.0,
0.98, 0.96, 0.94, 0.92, 0.9,
0.88, 0.84, 0.80, 0.77, 0.73,
0.7, 0.65, 0.6, 0.55, 0.5,
}

Falling damage mitigation. Based on dexterity.

Definition at line 110 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 smarter.",
"You feel more potent."
}

Message when a player increases a stat.

Definition at line 194 of file living.c.

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

Maximum health points bonus. Based on constitution.

Definition at line 70 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 143 of file living.c.

const char* const lose_msg[NUM_STATS]
Initial value:
= {
"You feel weaker!",
"You feel clumsy!",
"You feel less healthy!",
"You feel stupid!",
"You feel less potent!"
}

Message when a player decreases a stat.

Definition at line 203 of file living.c.

int monster_signal_chance[MAX_STAT+1]
Initial value:
= {
0,
0, 0, 0, 0, 0,
20, 18, 16, 14, 13,
12, 11, 10, 9, 8,
7, 6, 5, 4, 3,
2, 1, 1, 1, 1,
1, 1, 1, 1, 1,
}

Probability for monsters to signal their friends, based on their intelligence stat.

Definition at line 152 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 memory return.",
"You feel your spirits return."
}

Message when a player has a stat restored.

Definition at line 185 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 165 of file living.c.

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

Short names of stats.

Definition at line 221 of file living.c.

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

Maximum spell points bonus. Primarily based on intelligence, secondarily on power.

Definition at line 84 of file living.c.

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

Speed bonus. Based on dexterity.

Definition at line 97 of file living.c.

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

Names of stats.

Definition at line 212 of file living.c.

int wc_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,
}

WC bonus. Based on dexterity.

Definition at line 57 of file living.c.

uint32_t 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 129 of file living.c.