Atrinik Server  4.0
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
player.h File Reference
#include <decls.h>
#include <attack.h>

Go to the source code of this file.

Data Structures

struct  _level_color
struct  player_path
struct  player_faction
struct  pl_player


#define MAX_QUICKSLOT   32
#define PLAYER_TESTING_NAME1   "Tester"
#define PLAYER_TESTING_NAME2   "Tester Testington"
#define ACCOUNT_TESTING_NAME   "tester"
#define PLAYER_REGEN_HP_RATE   2000.0
#define PLAYER_REGEN_SP_RATE   1200.0
#define SKILL_LEVEL(_pl, _skill)   ((_pl)->skill_ptr[(_skill)] ? (_pl)->skill_ptr[(_skill)]->level : 1)


typedef struct _level_color _level_color
typedef struct player_path player_path


enum  {


void player_init (void)
void player_deinit (void)
void player_disconnect_all (void)
playerfind_player (const char *plname)
playerfind_player_sh (shstr *plname)
void display_motd (object *op)
void free_player (player *pl)
void give_initial_items (object *pl, treasure_list_t *items)
int handle_newcs_player (player *pl)
void kill_player (object *op)
void cast_dust (object *op, object *throw_ob, int dir)
int pvp_area (object *attacker, object *victim)
objectfind_skill (object *op, int skillnr)
int player_can_carry (object *pl, uint32_t weight)
void player_path_add (player *pl, mapstruct *map, int16_t x, int16_t y)
void player_path_clear (player *pl)
void player_path_handle (player *pl)
player_faction_tplayer_faction_create (player *pl, shstr *name)
void player_faction_free (player *pl, player_faction_t *faction)
player_faction_tplayer_faction_find (player *pl, shstr *name)
void player_faction_update (player *pl, shstr *name, double reputation)
double player_faction_reputation (player *pl, shstr *name)
char * player_sanitize_input (char *str)
void player_cleanup_name (char *str)
objectfind_marked_object (object *op)
void examine (object *op, object *tmp, StringBuffer *sb_capture)
int sack_can_hold (object *pl, object *sack, object *op, int nrof)
void pick_up (object *op, object *alt, int no_mevent)
void put_object_in_sack (object *op, object *sack, object *tmp, long nrof)
void drop_object (object *op, object *tmp, long nrof, int no_mevent)
void drop (object *op, object *tmp, int no_mevent)
char * player_make_path (const char *name, const char *ext)
int player_exists (const char *name)
void player_save (object *op)
objectplayer_get_dummy (const char *name, const char *host)
objectplayer_find_spell (object *op, spell_struct *spell)
void player_set_talking_to (player *pl, object *npc)
const char * player_get_killer (player *pl)
void player_set_killer (player *pl, const char *killer)
void player_clear_killer (player *pl)
void player_login (socket_struct *ns, const char *name, struct archetype *at)
void player_logout (player *pl)
void object_type_init_player (void)


mempool_struct * pool_player

Detailed Description

Handles player related structures, enums and defines.

Definition in file player.h.

Macro Definition Documentation

#define MAX_QUICKSLOT   32

Maximum quickslots allowed.

Definition at line 89 of file player.h.


Maximum failures allowed when trying to reach destination path.

Definition at line 92 of file player.h.

Typedef Documentation

typedef struct _level_color _level_color

Level color structure.

typedef struct player_path player_path

One path player is attempting to reach.

Enumeration Type Documentation

anonymous enum

Fire modes submitted from client.


No fire mode.











Definition at line 58 of file player.h.

Function Documentation

void cast_dust ( object op,
object throw_ob,
int  dir 

Handles object throwing objects of type "DUST".

This function needs to be rewritten. Works for area effect spells only now.
opObject throwing.
throw_obWhat to throw.
dirDirection to throw into.

Definition at line 918 of file player.c.

void display_motd ( object op)

Grab the Message of the Day from a file.

First motd_custom is tried, and if that doesn't exist, motd is used instead.

opPlayer object to print the message to.

Definition at line 136 of file player.c.

void drop ( object op,
object tmp,
int  no_mevent 

Drop an item, either on the floor or in a container.

opWho is dropping an item.
tmpWhat object to drop.
no_meventIf 1, no drop map-wide event will be triggered.

Definition at line 2304 of file player.c.

void drop_object ( object op,
object tmp,
long  nrof,
int  no_mevent 

Drop an object onto the floor.

opPlayer object.
tmpThe object to drop.
nrofNumber of items to drop (0 for all).
no_meventIf 1, no map-wide event will be triggered.

Definition at line 2195 of file player.c.

void examine ( object op,
object tmp,
StringBuffer *  sb_capture 

Player examines some object.

tmpObject to examine.

Definition at line 1521 of file player.c.

object* find_marked_object ( object op)

Return the object the player has marked.

opObject. Should be a player.
Marked object if still valid, NULL otherwise.

Definition at line 1393 of file player.c.

player* find_player ( const char *  plname)

Loop through the player list and find player specified by plname.

plnameThe player name to find.
Player structure if found, NULL otherwise.

Definition at line 96 of file player.c.

player* find_player_sh ( shstr *  plname)

Loop through the player list and find player specified by plname.

plnameThe player name to find. Must be a shared string.
Player structure if found, NULL otherwise.

Definition at line 116 of file player.c.

object* find_skill ( object op,
int  skillnr 

Looks for the skill and returns a pointer to it if found.

opThe object to look for the skill in.
skillnrSkill ID.
The skill if found, NULL otherwise.

Definition at line 1013 of file player.c.

void free_player ( player pl)

Free a player structure. Takes care of removing this player from the list of players, and frees the socket for this player.

plThe player structure to free.

Definition at line 219 of file player.c.

void give_initial_items ( object pl,
treasure_list_t items 

Give initial items to object pl. This is used when player creates a new character.

plThe player object.
itemsTreasure list of items to give.

Definition at line 292 of file player.c.

int handle_newcs_player ( player pl)

This is similar to handle_player(), but is only used by the new client/server stuff.

This is sort of special, in that the new client/server actually uses the new speed values for commands.

plPlayer to handle.
Return values
-1Player is invalid.
0No more actions to do.
1There are more actions we can do.

Definition at line 347 of file player.c.

void kill_player ( object op)

If the player should die (lack of hp, food, etc), we call this.

Will remove diseases, apply death penalties, and so on.

opThe player in jeopardy.

Definition at line 765 of file player.c.

void pick_up ( object op,
object alt,
int  no_mevent 

Try to pick up an item.

opObject trying to pick up.
altOptional object op is trying to pick. If NULL, try to pick first item under op.
no_meventIf 1, no map-wide pickup event will be triggered.

Definition at line 2019 of file player.c.

int player_can_carry ( object pl,
uint32_t  weight 

Check whether player can carry the specified weight.

weightWeight to check.
1 if the player can carry that weight, 0 otherwise.

Definition at line 1036 of file player.c.

void player_cleanup_name ( char *  str)

Cleans up a string that is, presumably, a player name.

strThe player name to clean up.

Definition at line 1330 of file player.c.

void player_clear_killer ( player pl)

Clear the specified player's killer, if any.


Definition at line 2715 of file player.c.

void player_deinit ( void  )

Deinitialize the player API.

Definition at line 68 of file player.c.

void player_disconnect_all ( void  )

Disconnect all currently connected players.

Definition at line 79 of file player.c.

player_faction_t* player_faction_create ( player pl,
shstr *  name 

Creates a new ::player_faction_t structure and adds it to the specified player.

nameName of the faction to create a structure for.
New ::player_faction_t structure.

Definition at line 1202 of file player.c.

player_faction_t* player_faction_find ( player pl,
shstr *  name 

Find the specified faction name in the player's factions hash table.

nameName of the faction to find.
::player_faction_t if found, NULL otherwise.

Definition at line 1243 of file player.c.

void player_faction_free ( player pl,
player_faction_t faction 

Frees the specified ::player_faction_t structure, removing it from the player's hash table of factions.

faction::player_faction_t to free.

Definition at line 1223 of file player.c.

double player_faction_reputation ( player pl,
shstr *  name 

Get player's reputation with a particular faction.

nameName of the faction.
Player's reputation with the specified faction.

Definition at line 1287 of file player.c.

void player_faction_update ( player pl,
shstr *  name,
double  reputation 

Update the player's reputation with a particular faction.

nameName of the faction to update.
reputationReputation to add/subtract.

Definition at line 1263 of file player.c.

object* player_get_dummy ( const char *  name,
const char *  host 

Creates a dummy player structure and returns a pointer to the player's object.

nameName of the player to create.
hostIP address of the player.
Created player object, never NULL. Will abort() in case of failure.

Definition at line 2583 of file player.c.

const char* player_get_killer ( player pl)

Acquire the name of the player's killer, if any.

Name of the killer, NULL if none.

Definition at line 2676 of file player.c.

void player_init ( void  )

Initialize the player API.

Definition at line 58 of file player.c.

void player_login ( socket_struct ns,
const char *  name,
struct archetype at 

Perform player login.

nsClient that wants to log in.
nameCharacter name to log in to.
atCharacter archetype. Will be used to perform new character creation if this is the first time the player is logging in to this character.

Definition at line 2738 of file player.c.

void player_logout ( player pl)

Remove a player from the game that has been disconnected by logging out, the socket connection was interrupted, etc.

plThe player to remove.

Definition at line 2895 of file player.c.

void player_path_add ( player pl,
mapstruct map,
int16_t  x,
int16_t  y 

Add a new path to player's paths queue.

plPlayer to add the path for.
mapMap we want to reach.
xX we want to reach.
yY we want to reach.

Definition at line 1061 of file player.c.

void player_path_clear ( player pl)

Clear all queued paths.

plPlayer to clear paths for.

Definition at line 1086 of file player.c.

void player_path_handle ( player pl)

Handle player moving along pre-calculated path.


Definition at line 1109 of file player.c.

char* player_sanitize_input ( char *  str)

Sanitize player's text input, removing extraneous whitespace, unprintable characters, etc.

strInput to sanitize.
Sanitized input; can be NULL if there's nothing in the string left.

Definition at line 1311 of file player.c.

void player_save ( object op)

Saves the specified player.

opPlayer object to save.

Definition at line 2379 of file player.c.

void player_set_killer ( player pl,
const char *  killer 

Store the name of the player's killer.

killerName of the killer to store. Will be copied.

Definition at line 2696 of file player.c.

void player_set_talking_to ( player pl,
object npc 

Updates who the player is talking to.

npcNPC the player is now talking to.

Definition at line 2647 of file player.c.

void put_object_in_sack ( object op,
object sack,
object tmp,
long  nrof 

Player tries to put object into sack, if nrof is non zero, then nrof objects is tried to put into sack.

opPlayer object.
sackThe sack.
tmpThe object to put into sack.
nrofNumber of items to put into sack (0 for all).

Definition at line 2122 of file player.c.

int pvp_area ( object attacker,
object victim 

Test for PVP area.

If only one object is given, it tests for that. Otherwise if two objects are given, both objects must be in PVP area.

Considers parties.

attackerFirst object.
victimSecond object.
1 if PVP is possible, 0 otherwise.

Definition at line 977 of file player.c.

int sack_can_hold ( object pl,
object sack,
object op,
int  nrof 

Check if an item op can be put into a sack. If pl exists then tell a player the reason of failure.

plPlayer object.
sackThe sack.
opThe object to check.
nrofNumber of objects we want to put in.
1 if the object will fit, 0 if it will not.

Definition at line 1870 of file player.c.