Atrinik Server 2.5
Functions
types/player.c File Reference
#include <global.h>

Go to the source code of this file.

Functions

static archetypeget_player_archetype (archetype *at)
static int save_life (object *op)
static void remove_unpaid_objects (object *op, object *env)
playerfind_player (const char *plname)
void display_motd (object *op)
int playername_ok (char *cp)
static playerget_player (player *p)
void free_player (player *pl)
int add_player (socket_struct *ns)
void give_initial_items (object *pl, treasurelist *items)
void get_name (object *op)
void get_password (object *op)
void confirm_password (object *op)
objectfind_arrow (object *op, const char *type)
void fire (object *op, int dir)
int move_player (object *op, int dir)
int handle_newcs_player (player *pl)
static int get_regen_amount (uint16 regen, uint16 *remainder)
void do_some_living (object *op)
void kill_player (object *op)
void cast_dust (object *op, object *throw_ob, int dir)
int pvp_area (object *attacker, object *victim)
int player_exists (char *player_name)
objectfind_skill (object *op, int skillnr)
int player_can_carry (object *pl, uint32 weight)
char * player_get_race_class (object *op, char *buf, size_t size)
void player_path_add (player *pl, mapstruct *map, sint16 x, sint16 y)
void player_path_clear (player *pl)
void player_path_handle (player *pl)
sint64 player_faction_reputation (player *pl, shstr *faction)
void player_faction_reputation_update (player *pl, shstr *faction, sint64 add)

Detailed Description

Player related functions.

Definition in file player.c.


Function Documentation

int add_player ( socket_struct ns)

Tries to add a player on the connection in ns.

All we can really get in this is some settings like host and display mode.

Parameters:
nsThe socket of this player.
Returns:
0.

Definition at line 301 of file player.c.

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 1533 of file player.c.

void confirm_password ( object op)

If this is a new character, we will need to confirm the password.

Parameters:
opObject to send the query to.

Definition at line 439 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 61 of file player.c.

void do_some_living ( object op)

Regenerate player's hp/mana/grace, decrease food, etc.

We will only regenerate HP and mana if the player has some food in their stomach.

Parameters:
opPlayer.

Definition at line 1035 of file player.c.

object* find_arrow ( object op,
const char *  type 
)

Find an arrow in the inventory and after that in the right type container (quiver).

Parameters:
opObject to check.
typeAmmunition type (bolts, arrows, etc).
Returns:
Pointer to the found object, NULL if not found.

Definition at line 452 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 40 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 1648 of file player.c.

void fire ( object op,
int  dir 
)

Fire command for spells, range, throwing, etc.

Parameters:
opObject firing this.
dirDirection to fire to.

Definition at line 475 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 get_name ( object op)

Send query to op's socket to get player name.

Parameters:
opObject to send the query to.

Definition at line 419 of file player.c.

void get_password ( object op)

Send query to op's socket to get player's password.

Parameters:
opObject to send the query to.

Definition at line 429 of file player.c.

static player* get_player ( player p) [static]

Returns the player structure. If 'p' is null, we create a new one. Otherwise, we recycle the one that is passed.

Parameters:
pPlayer structure to recycle or NULL for new structure.
Returns:
The player structure.

Definition at line 124 of file player.c.

static archetype * get_player_archetype ( archetype at) [static]

Returns the next player archetype from archetype list. Not very efficient routine, but used only when creating new players.

Note:
There MUST be at least one player archetype!
Parameters:
atThe archetype list.
Returns:
The archetype, if not found, fatal error.

Definition at line 327 of file player.c.

static int get_regen_amount ( uint16  regen,
uint16 remainder 
) [static]

Figures out how much hp/mana/grace points to regenerate.

Parameters:
regenRegeneration value used for client (for example, player::gen_client_hp).
remainderPointer to regen remainder (for example, player::gen_hp_remainder).
Returns:
How much to regenerate.

Definition at line 995 of file player.c.

void give_initial_items ( object pl,
treasurelist 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 360 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 863 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 1278 of file player.c.

int move_player ( object op,
int  dir 
)

Move a player.

Parameters:
opPlayer object.
dirDirection to move to.
Returns:
1 on success, 0 on failure.

Definition at line 785 of file player.c.

int player_can_carry ( object pl,
uint32  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 1668 of file player.c.

int player_exists ( char *  player_name)

Check whether the specified player exists.

Parameters:
player_namePlayer name to check for.
Returns:
1 if the player exists, 0 otherwise.

Definition at line 1626 of file player.c.

sint64 player_faction_reputation ( player pl,
shstr faction 
)

Get player's reputation for the specified faction.

Parameters:
plThe player.
factionThe faction name.
Returns:
The faction reputation.

Definition at line 1840 of file player.c.

void player_faction_reputation_update ( player pl,
shstr faction,
sint64  add 
)

Update player's faction reputation.

Parameters:
plThe player.
factionName of the faction.
addHow much to modify the player's faction reputation (if any).

Definition at line 1861 of file player.c.

char* player_get_race_class ( object op,
char *  buf,
size_t  size 
)

Combine player's race with their class (if there is one).

Parameters:
opPlayer.
bufBuffer to write into.
sizeSize of 'buf'.
Returns:
'buf'.

Definition at line 1690 of file player.c.

void player_path_add ( player pl,
mapstruct map,
sint16  x,
sint16  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 1719 of file player.c.

void player_path_clear ( player pl)

Clear all queued paths.

Parameters:
plPlayer to clear paths for.

Definition at line 1744 of file player.c.

void player_path_handle ( player pl)

Handle player moving along pre-calculated path.

Parameters:
plPlayer.

Definition at line 1766 of file player.c.

int playername_ok ( char *  cp)

Checks if player name contains illegal characters or not.

Parameters:
cpThe player name.
Returns:
1 if the player name doesn't contain illegal characters, 0 otherwise.

Definition at line 106 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 1590 of file player.c.

static void remove_unpaid_objects ( object op,
object env 
) [static]

This goes through the inventory and removes unpaid objects, and puts them back in the map (location and map determined by values of env). This function will descend into containers.

Parameters:
opObject to start the search from.
envMap location determined by this object.

Definition at line 964 of file player.c.

static int save_life ( object op) [static]

Can the player be saved by an item?

Parameters:
opPlayer to try to save.
Return values:
1Player had his life saved by an item, first item saving life is removed.
0Player had no life-saving item.

Definition at line 911 of file player.c.