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
 

Macros

#define PLAYER_AFLAG_FIGHT   1
 
#define PLAYER_AFLAG_ENEMY   2
 
#define PLAYER_AFLAG_ADDFRAME   4
 
#define MAX_QUICKSLOT   32
 
#define PLAYER_PATH_MAX_FAILS   15
 
#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 PLAYER_REGEN_MODIFIER   10.0
 
#define PLAYER_REGEN_MODIFIER_MAX   10.0
 
#define SKILL_LEVEL(_pl, _skill)   ((_pl)->skill_ptr[(_skill)] ? (_pl)->skill_ptr[(_skill)]->level : 1)
 

Typedefs

typedef struct _level_color _level_color
 
typedef struct player_path player_path
 

Enumerations

enum  {
  FIRE_MODE_NONE = -1, FIRE_MODE_BOW, FIRE_MODE_SPELL, FIRE_MODE_WAND,
  FIRE_MODE_SKILL, FIRE_MODE_THROW
}
 

Functions

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)
 

Variables

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.

#define PLAYER_PATH_MAX_FAILS   15

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.

Enumerator
FIRE_MODE_NONE 

No fire mode.

FIRE_MODE_BOW 

Bow.

FIRE_MODE_SPELL 

Spell.

FIRE_MODE_WAND 

Wand.

FIRE_MODE_SKILL 

Skill.

FIRE_MODE_THROW 

Throwing.

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

Todo:
This function needs to be rewritten. Works for area effect spells only now.
Parameters
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.

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

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

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

Parameters
opPlayer.
tmpObject to examine.

Definition at line 1521 of file player.c.

object* find_marked_object ( object op)

Return the object the player has marked.

Parameters
opObject. Should be a player.
Returns
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.

Parameters
plnameThe player name to find.
Returns
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.

Parameters
plnameThe player name to find. Must be a shared string.
Returns
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.

Parameters
opThe object to look for the skill in.
skillnrSkill ID.
Returns
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.

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

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

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

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

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

Parameters
plPlayer.
weightWeight to check.
Returns
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.

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

Parameters
plPlayer.

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.

Parameters
plPlayer.
nameName of the faction to create a structure for.
Returns
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.

Parameters
plPlayer.
nameName of the faction to find.
Returns
::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.

Parameters
plPlayer.
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.

Parameters
plPlayer.
nameName of the faction.
Returns
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.

Parameters
plPlayer.
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.

Parameters
nameName of the player to create.
hostIP address of the player.
Returns
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.

Parameters
plPlayer.
Returns
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.

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

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

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

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

Parameters
plPlayer.

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.

Parameters
strInput to sanitize.
Returns
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.

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

Parameters
plPlayer.
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.

Parameters
plPlayer.
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.

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

Parameters
attackerFirst object.
victimSecond object.
Returns
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.

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

Definition at line 1870 of file player.c.