![]() |
Crossfire Server, Trunk
1.75.0
|
#include "global.h"
#include <assert.h>
#include <ctype.h>
#include <math.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <pwd.h>
#include "server.h"
#include "living.h"
#include "object.h"
#include "shared/newclient.h"
#include "shop.h"
#include "skills.h"
#include "sounds.h"
#include "spells.h"
#include "sproto.h"
#include "assets.h"
#include "AssetsManager.h"
Go to the source code of this file.
Macros | |
#define | DETOUR_AMOUNT 2 |
This value basically determines how large a detour a monster will take from the direction path when looking for a path to the player. More... | |
#define | MAX_SPACES 50 |
This is used to prevent infinite loops. More... | |
Functions | |
static int | action_makes_visible (object *op) |
We call this when there is a possibility for our action disturbing our hiding place or invisibility spell. More... | |
player * | add_player (socket_struct *ns, int flags) |
Tries to add player on the connection passwd in ns. More... | |
int | apply_race_and_class (object *op, archetype *race, archetype *opclass, living *stats) |
This is somewhat like key_change_class() above, except we know the race to change to, but we still basically need to do the same work (apply bonuses, update archetype, etc.) More... | |
void | cast_dust (object *op, object *throw_ob, int dir) |
Handles op throwing objects of type 'DUST'. More... | |
int | check_pick (object *op) |
Sees if there is stuff to be picked up/picks up stuff, for players only. More... | |
int | check_race_and_class (living *stats, archetype *race, archetype *opclass) |
This checks to see if the race and class are legal. More... | |
void | confirm_password (object *op) |
Ask the player to confirm her password during creation. More... | |
void | display_motd (const object *op) |
Sends the message of the day to the player. More... | |
void | do_hidden_move (object *op) |
For hidden creatures - a chance of becoming 'unhidden' every time they move - as we subtract off 'invisibility' AND, for players, if they move into a ridiculously unhideable spot (surrounded by clear terrain in broad daylight). More... | |
void | do_some_living (object *op) |
Regenerate hp/sp/gr, decreases food. More... | |
void | dragon_ability_gain (object *who, int atnr, int level) |
When a dragon-player gains a new stage of evolution, he gets some treasure. More... | |
int | face_player (object *op, int dir) |
Face player in the given direction. More... | |
static object * | find_arrow (object *op, const char *type) |
Find an arrow in the inventory and after that in the right type container (quiver). More... | |
static object * | find_better_arrow (object *op, object *target, const char *type, int *better) |
Similar to find_arrow(), but looks for (roughly) the best arrow to use against the target. More... | |
object * | find_key (object *pl, object *container, object *door) |
We try to find a key for the door as passed. More... | |
player * | find_player (const char *plname) |
Find a player by her full name. More... | |
player * | find_player_options (const char *plname, int options, const mapstruct *map) |
Find a player. More... | |
player * | find_player_partial_name (const char *plname) |
Find a player by a partial name. More... | |
player * | find_player_socket (const socket_struct *ns) |
Return a player for a socket structure. More... | |
void | fire (object *op, int dir) |
Received a fire command for the player - go and do it. More... | |
int | fire_bow (object *op, object *arrow, int dir, int wc_mod, int16_t sx, int16_t sy) |
Creature (monster or player) fires a bow. More... | |
static void | fire_misc_object (object *op, int dir) |
Fires a misc (wand/rod/horn) object in 'dir'. More... | |
void | fix_luck (void) |
Fixes luck of players, slowly move it towards 0. More... | |
void | fix_weight (void) |
Check recursively the weight of all players, and fix what needs to be fixed. More... | |
static void | flee_player (object *op) |
The player is scared, and should flee. More... | |
void | get_name (object *op) |
Waiting for the player's name. More... | |
object * | get_nearest_criminal (object *mon) |
object * | get_nearest_player (object *mon) |
Finds the nearest visible player or player-friendly for some object. More... | |
int | get_party_password (object *op, partylist *party) |
Ask the player for the password of the party she wants to join. More... | |
void | get_password (object *op) |
Waiting for the player's password. More... | |
player * | get_player (player *p) |
Create a player's object, initialize a player's structure. More... | |
static archetype * | get_player_archetype (archetype *at) |
Get next player archetype from archetype list. More... | |
void | give_initial_items (object *pl, treasurelist *items) |
Gives a new player her initial items. More... | |
static const char * | gravestone_text (object *op, char *buf2, int len) |
Create a text for a player's gravestone. More... | |
int | handle_newcs_player (object *op) |
Handles commands the player can send us, and various checks on invisibility, golem and such. More... | |
int | hideability (object *ob) |
Look at the surrounding terrain to determine the hideability of this object. More... | |
int | is_true_undead (object *op) |
Is the object a true undead? More... | |
void | key_change_class (object *op, char key) |
This function takes the key that is passed, and does the appropriate action with it (change race, or other things). More... | |
void | key_confirm_quit (object *op, char key) |
We receive the reply to the 'quit confirmation' message. More... | |
void | key_roll_stat (object *op, char key) |
Player is currently swapping stats. More... | |
void | kill_player (object *op, const object *killer) |
Handle a player's death. More... | |
static void | kill_player_not_permadeath (object *op) |
Kills a player in non-permadeath mode. More... | |
static void | kill_player_permadeath (object *op) |
Kills a player in permadeath mode. More... | |
static void | loot_object (object *op) |
Grab and destroy some treasure. More... | |
void | make_visible (object *op) |
Makes an object visible again. More... | |
int | move_player (object *op, int dir) |
Move player in the given direction. More... | |
void | move_player_attack (object *op, int dir) |
The player is also actually going to try and move (not fire weapons). More... | |
int | op_on_battleground (object *op, int *x, int *y, archetype **trophy) |
Check if the given object (usually a player) is standing on a battleground tile. More... | |
int | path_to_player (object *mon, object *pl, unsigned mindiff) |
Returns the direction to the player, if valid. More... | |
static object * | pick_arrow_target (object *op, const char *type, int dir) |
Looks in a given direction, finds the first valid target, and calls find_better_arrow() to find a decent arrow to use. More... | |
void | play_again (object *op) |
Ask the player whether to play again or disconnect. More... | |
static int | player_attack_door (object *op, object *door) |
Player is "attacking" a door. More... | |
int | player_can_view (object *pl, object *op) |
Check the player los field for viewability of the object op. More... | |
static int | player_fire_bow (object *op, int dir) |
Special fire code for players - this takes into account the special fire modes players can have but monsters can't. More... | |
SockList * | player_get_delayed_buffer (player *pl) |
Get a delayed socket buffer, that will be sent after the player's tick is complete. More... | |
void | player_set_state (player *pl, uint8_t state) |
Set the player's state to the specified one. More... | |
void | player_unready_range_ob (player *pl, object *ob) |
Unready an object for a player. More... | |
int | playername_ok (const char *cp) |
Is the player name valid. More... | |
void | receive_play_again (object *op, char key) |
Player replied to play again / disconnect. More... | |
void | remove_unpaid_objects (object *op, object *env, int free_items) |
This goes throws the inventory and removes unpaid objects, and puts them back in the map (location and map determined by values of env) or frees them. More... | |
static void | restore_player (object *op) |
Remove confusion, disease, and poison on death. More... | |
void | roll_again (object *op) |
Ask the player what to do with the statistics. More... | |
int | roll_stat (void) |
This rolls four 1-6 rolls and sums the best 3 of the 4. More... | |
void | roll_stats (object *op) |
Roll the initial player's statistics. More... | |
static int | save_life (object *op) |
Can the player be saved by an item? More... | |
void | send_delayed_buffers (player *pl) |
Send all delayed buffers for a player. More... | |
void | send_news (const object *op) |
Send the news to a player. More... | |
void | send_rules (const object *op) |
Send the rules to a player. More... | |
void | set_first_map (object *op) |
This loads the first map an puts the player on it. More... | |
void | set_player_socket (player *p, socket_struct *ns) |
This copies the data from the socket into the player structure. More... | |
static int | similar_direction (int a, int b) |
Is direction a similar to direction b? Find out in this exciting function below. More... | |
int | stand_near_hostile (object *who) |
Determine if who is standing near a hostile creature. More... | |
static bool | starving (object *op) |
static void | swap_stat (object *op, int swap_second) |
Player finishes selecting what stats to swap. More... | |
static int | turn_one_transport (object *transport, object *captain, int dir) |
Turn a transport to an adjacent direction (+1 or -1), updating the move_type flags in the same process. More... | |
static int | turn_transport (object *transport, object *captain, int dir) |
Try to turn a transport in the desired direction. More... | |
static void | update_transport_block (object *transport, int dir) |
Update the move_type of a transport based on the direction. More... | |
Variables | |
std::vector< archetype * > | players |
Player-related functions, including those used during the login and creation phases.
Definition in file player.cpp.
#define DETOUR_AMOUNT 2 |
This value basically determines how large a detour a monster will take from the direction path when looking for a path to the player.
The values are in the amount of direction the deviation is.
I believe this can safely go to 2, 3 is questionable, 4 will likely result in a monster paths backtracking.
Definition at line 611 of file player.cpp.
#define MAX_SPACES 50 |
This is used to prevent infinite loops.
Consider a case where the player is in a chamber (with gate closed), and monsters are outside. with DETOUR_AMOUNT==2, the function will turn each corner, trying to find a path into the chamber. This is a good thing, but since there is no real path, it will just keep circling the chamber for ever (this could be a nice effect for monsters, but not for the function to get stuck in. I think for the monsters, if max is reached and we return the first direction the creature could move would result in the circling behaviour. Unfortunately, this function is also used to determined if the creature should cast a spell, so returning a direction in that case is probably not a good thing.
Definition at line 626 of file player.cpp.
|
static |
We call this when there is a possibility for our action disturbing our hiding place or invisibility spell.
Artefact invisibility is not effected by this. If we aren't invisible to begin with, we return 0.
This routine works for both players and monsters.
op | object to check. |
Definition at line 4215 of file player.cpp.
References object::contr, draw_ext_info_format(), FLAG_ALIVE, FLAG_MAKE_INVIS, object::hide, object::invisible, MSG_SUBTYPE_NONE, MSG_TYPE_MISC, NDI_UNIQUE, QUERY_FLAG, and player::tmp_invis.
Referenced by fire(), move_player_attack(), and player_attack_door().
player* add_player | ( | socket_struct * | ns, |
int | flags | ||
) |
Tries to add player on the connection passwd in ns.
Player object is created and put on the first map, rules/news/motd are sent.
ns | connection. |
flags | flag values are define in player.h: ADD_PLAYER_NEW - If set, go right to new character creation - used in case of new account code. We don't display motd and other bits in this case either. ADD_PLAYER_NO_MAP - Do not set up map information - used in character login method >2 where we do not use the same starting map. |
Definition at line 468 of file player.cpp.
References add_friendly_object(), ADD_PLAYER_NEW, ADD_PLAYER_NO_MAP, ADD_PLAYER_NO_STATS_ROLL, CLEAR_FLAG, display_motd(), FLAG_FRIENDLY, flags, get_name(), get_player(), Ns_Avail, player::ob, player_set_state(), roll_again(), send_news(), send_rules(), set_first_map(), set_player_socket(), ST_ROLL_STAT, and socket_struct::status.
Referenced by add_me_cmd(), and create_player_cmd().
This is somewhat like key_change_class() above, except we know the race to change to, but we still basically need to do the same work (apply bonuses, update archetype, etc.)
op | Player object |
race | race to use - caller should do sanity checking that this is a valid race. |
opclass | class to use - like race, caller should do sanity checking. |
stats | If set, use these stats for the character, do not apply new ones. Note: It is required that the caller only use valid stat values (generated by check_race_and_class() for example), as this function will not do checking on the stats. |
Definition at line 1488 of file player.cpp.
References AC_PLAYER_STAT_NO_CHANGE, add_statbonus(), add_string(), allowed_class(), apply_changes_to_player(), object::arch, buf, object::carrying, CLEAR_FLAG, archetype::clone, object::contr, create_treasure(), esrv_add_spells(), esrv_new_player(), esrv_send_inventory(), esrv_update_item(), EVENT_BORN, EVENT_LOGIN, events_execute_global_event(), find_treasurelist(), fix_object(), FLAG_WIZ, free_string(), get_attr_value(), give_initial_items(), living::grace, socket_struct::host, living::hp, object::inv, player::is_wraith, link_player_skills(), Settings::localdir, make_path_to_file(), MAX_BUF, living::maxhp, living::maxsp, name, object::name, object::name_pl, NUM_STATS, object_copy(), object_find_by_name(), object_free(), object_remove(), object_set_msg(), object_update(), player::orig_stats, Settings::playerdir, pticks, object::randomitems, SET_ANIMATION, set_attr_value(), settings, player::socket, living::sp, stats, object::stats, strlcpy(), player::title, UP_OBJ_FACE, UPD_FACE, and object::weight.
Referenced by create_player_cmd().
Handles op throwing objects of type 'DUST'.
This is much simpler in the new spell code - we basically just treat this as any other spell casting object.
op | object throwing. |
throw_ob | what to throw. |
dir | direction to throw into. |
Definition at line 3948 of file player.cpp.
References cast_spell(), draw_ext_info_format(), find_skill_by_name(), FLAG_REMOVED, object::inv, llevError, LOG(), MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS, object::name, NDI_UNIQUE, object_free_drop_inventory(), object_remove(), PLAYER, POTION, QUERY_FLAG, object::skill, and object::type.
Referenced by do_throw().
int check_pick | ( | object * | op | ) |
Sees if there is stuff to be picked up/picks up stuff, for players only.
op | player to check for. |
1 | player should keep on moving. |
0 | player should stop. |
Definition at line 1734 of file player.cpp.
References object::contr, object::count, draw_ext_info, draw_ext_info_format(), FLAG_KNOWN_CURSED, FLAG_KNOWN_MAGICAL, FLAG_UNPAID, FOR_BELOW_FINISH, FOR_BELOW_PREPARE, is_valid_types_gen::found, GEM, m, MAX, player::mode, MONEY, MOVE_FLYING, object::move_type, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_DEBUG, MSG_TYPE_COMMAND_SUCCESS, NDI_UNIQUE, object_can_pick(), object_matches_pickup_mode(), object_matches_string(), object_was_destroyed, pick_up(), price_base(), PU_ARMOUR, PU_ARROW, PU_BOOTS, PU_BOW, PU_CLOAK, PU_CONTAINER, PU_CURSED, PU_DEBUG, PU_DRINK, PU_FLESH, PU_FOOD, PU_GLOVES, PU_HELMET, PU_INHIBIT, PU_JEWELS, PU_KEY, PU_MAGIC_DEVICE, PU_MAGICAL, PU_MELEEWEAPON, PU_MISSILEWEAPON, PU_NEWMODE, PU_NOT_CURSED, PU_NOTHING, PU_POTION, PU_RATIO, PU_READABLES, PU_SHIELD, PU_SKILLSCROLL, PU_SPELLBOOK, PU_STOP, PU_VALUABLES, QUERY_FLAG, Settings::search_items, player::search_str, settings, and TRUE.
Referenced by move_player(), and stop_jump().
This checks to see if the race and class are legal.
Legal in this contexts means that after apply the race/class stat modifiers, the race is still in legal range.
stats | The statistics to modify - this data is modified, so the caller can use it on the next update. |
race | The race to try and apply. It can be NULL, in which case no race will be applied. |
opclass | The class to apply. It can be NULL, in which case no class will be applied. |
Definition at line 1438 of file player.cpp.
References archetype::clone, get_attr_value(), Settings::max_stat, MIN_STAT, NUM_STATS, set_attr_value(), settings, stats, and object::stats.
Referenced by create_player_cmd().
void confirm_password | ( | object * | op | ) |
Ask the player to confirm her password during creation.
op | player. |
Definition at line 1014 of file player.cpp.
References object::contr, CS_QUERY_HIDEINPUT, i18n(), player_set_state(), send_query(), player::socket, and ST_CONFIRM_PASSWORD.
Referenced by check_login().
void display_motd | ( | const object * | op | ) |
Sends the message of the day to the player.
op | player to send to. |
Definition at line 139 of file player.cpp.
References buf, Settings::confdir, draw_ext_info, HUGE_BUF, MAX_BUF, motd, Settings::motd, MSG_SUBTYPE_NONE, MSG_TYPE_MOTD, NDI_GREEN, NDI_UNIQUE, safe_strcat(), and settings.
Referenced by add_player(), command_motd(), and receive_player_password().
void do_hidden_move | ( | object * | op | ) |
For hidden creatures - a chance of becoming 'unhidden' every time they move - as we subtract off 'invisibility' AND, for players, if they move into a ridiculously unhideable spot (surrounded by clear terrain in broad daylight).
-b.t.
op | object moving. |
Definition at line 4054 of file player.cpp.
References calc_skill_exp(), change_exp(), object::contr, mapstruct::difficulty, draw_ext_info, hide, hideability(), object::invisible, object::level, make_visible(), object::map, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, NDI_UNIQUE, object_find_by_type_subtype(), PLAYER, PREFER_LOW, random_roll(), player::run_on, SK_HIDING, SKILL, object::skill, and object::type.
Referenced by face_player(), monster_move(), and move_player().
void do_some_living | ( | object * | op | ) |
Regenerate hp/sp/gr, decreases food.
This only works for players. Will grab food if needed, or kill player.
op | player to regenerate for. |
Definition at line 3293 of file player.cpp.
References object::contr, living::food, player::gen_hp, player::gen_sp, living::maxhp, living::maxsp, ST_PLAYING, player::state, and object::stats.
Referenced by command_possess(), and process_players1().
void dragon_ability_gain | ( | object * | who, |
int | atnr, | ||
int | level | ||
) |
When a dragon-player gains a new stage of evolution, he gets some treasure.
who | the dragon player. |
atnr | the attack-number of the ability focus. |
level | ability level. |
Definition at line 4312 of file player.cpp.
References object::anim_speed, animate_object(), object::animation, arch_to_object(), AT_PHYSICAL, ATNR_COLD, ATNR_ELECTRICITY, ATNR_FIRE, ATNR_POISON, object::attacktype, buf, check_spell_known(), archetype::clone, object::direction, do_learn_spell(), draw_ext_info, draw_ext_info_format(), esrv_send_item(), object::face, find_skill_by_name(), find_treasurelist(), FLAG_SEE_IN_DARK, FLAG_STEALTH, FLAG_XRAYS, FORCE, HUGE_BUF, object::inv, object::invisible, treasure::item, treasurelist::items, object::last_anim, level, llevDebug, LOG(), treasure::magic, MAX_BUF, object::msg, MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_RACE, MSG_TYPE_ITEM, MSG_TYPE_ITEM_ADD, name, object::name, NDI_BLUE, NDI_UNIQUE, treasure::next, NRSPELLPATHS, object_find_by_arch_name(), object_insert_in_ob(), object::path_attuned, PLAYER, QUERY_FLAG, query_short_name(), SET_FLAG, SK_CLAWING, object::skill, SKILL_TOOL, SPELL, SPELLBOOK, spellpathnames, object::state, object::subtype, and object::type.
Referenced by dragon_level_gain().
int face_player | ( | object * | op, |
int | dir | ||
) |
Face player in the given direction.
op | player. |
dir | direction to face |
Definition at line 3044 of file player.cpp.
References animate_object(), object::contr, object::direction, do_hidden_move(), object::facing, player::fire_on, FLAG_CONFUSED, get_randomized_dir(), object::hide, mapstruct::in_memory, llevError, LOG(), object::map, MAP_IN_MEMORY, QUERY_FLAG, player::run_on, object::state, player::transport, and turn_transport().
Referenced by command_face().
Find an arrow in the inventory and after that in the right type container (quiver).
Pointer to the found object is returned.
op | object to find arrow for. |
type | what arrow race to search for. |
Definition at line 1939 of file player.cpp.
References ARROW, CONTAINER, FLAG_APPLIED, FOR_INV_FINISH, FOR_INV_PREPARE, QUERY_FLAG, is_valid_types_gen::type, and object::type.
Referenced by find_better_arrow(), fire_bow(), and pick_arrow_target().
|
static |
Similar to find_arrow(), but looks for (roughly) the best arrow to use against the target.
A full test is not performed, simply a basic test of resistances. The archer is making a quick guess at what he sees down the hall. Failing that it does it's best to pick the highest plus arrow.
op | who to search arrows for. | |
target | what op is aiming at. | |
type | arrow race to search for. | |
[out] | better | will contain the arrow's value if not NULL. |
Definition at line 1971 of file player.cpp.
References object::arch, ARROW, AT_DEATH, archetype::clone, CONTAINER, find_arrow(), FLAG_APPLIED, FOR_INV_FINISH, FOR_INV_PREPARE, object::magic, NROFATTACKS, QUERY_FLAG, object::race, object::resist, and is_valid_types_gen::type.
Referenced by pick_arrow_target().
We try to find a key for the door as passed.
If we find a key and player can use it (based on the usekeys settings), we return the key, otherwise NULL.
This function merges both normal and locked door, since the logic for both is the same - just the specific key is different.
This function can be called recursively to search containers.
pl | player. |
container | inventory to searched for keys. |
door | door we are trying to match against. |
Definition at line 2485 of file player.cpp.
References CONTAINER, object::contr, DOOR, draw_ext_info_format(), FLAG_APPLIED, FLAG_UNPAID, FOR_INV_FINISH, FOR_INV_PREPARE, object::inv, KEY, key_inventory, keyrings, MAX_BUF, MSG_TYPE_ITEM, MSG_TYPE_ITEM_INFO, NDI_BROWN, NDI_UNIQUE, object_find_by_type_and_slaying(), object_find_by_type_without_flags(), QUERY_FLAG, query_name(), object::race, object::slaying, SPECIAL_KEY, object::type, and player::usekeys.
Referenced by apply_container(), and player_attack_door().
player* find_player | ( | const char * | plname | ) |
Find a player by her full name.
plname | name to find. |
Definition at line 59 of file player.cpp.
References find_player_options().
Referenced by command_reply(), and list_players().
Find a player.
plname | name of the player to search for. Can be partial. |
options | combination of FIND_PLAYER_xxx flags. |
map | optional map the player must be on (adjacent maps are ok too). |
Definition at line 70 of file player.cpp.
References object::contr, FIND_PLAYER_NO_HIDDEN_DM, FIND_PLAYER_PARTIAL_NAME, first_player, FLAG_WIZ, is_valid_types_gen::found, player::hidden, object::map, MAX_BUF, name, object::name, player::next, player::ob, options, QUERY_FLAG, and query_name().
Referenced by basic_emote(), find_player(), and find_player_partial_name().
player* find_player_partial_name | ( | const char * | plname | ) |
Find a player by a partial name.
plname | name to match. |
Definition at line 114 of file player.cpp.
References find_player_options(), and FIND_PLAYER_PARTIAL_NAME.
Referenced by cfapi_player_find(), command_follow(), command_quest(), command_stats(), command_teleport(), do_follow(), and do_tell().
player* find_player_socket | ( | const socket_struct * | ns | ) |
Return a player for a socket structure.
ns | socket to search for. |
Definition at line 123 of file player.cpp.
References first_player, player::next, and player::socket.
Referenced by add_me_cmd(), and set_up_cmd().
void fire | ( | object * | op, |
int | dir | ||
) |
Received a fire command for the player - go and do it.
op | player. |
dir | direction to fire into. |
Definition at line 2413 of file player.cpp.
References action_makes_visible(), apply_map_builder(), cast_spell(), object::chosen_skill, object::contr, object::count, do_skill(), draw_ext_info, fire_misc_object(), player::golem_count, make_visible(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, pets_control_golem(), PLAYER, player_fire_bow(), range_bow, range_builder, range_golem, range_magic, range_misc, range_none, range_skill, player::ranges, player::shoottype, player::spellparam, and object::type.
Referenced by command_stay(), and move_player().
Creature (monster or player) fires a bow.
op | object firing the bow. |
arrow | object to fire. |
dir | direction of fire. |
wc_mod | any special modifier to give (used in special player fire modes) |
sx | |
sy | coordinates to fire arrow from - also used in some of the special player fire modes. |
Definition at line 2110 of file player.cpp.
References add_refcount(), add_string(), object::anim_suffix, apply_anim_suffix(), AT_PHYSICAL, object::attacktype, BOW, bow_bestarrow, player::bowtype, change_skill(), object::chosen_skill, CLEAR_FLAG, object::contr, object::count, living::dam, living::Dex, object::direction, draw_ext_info, draw_ext_info_format(), FABS, find_arrow(), find_skill_by_name(), fix_object(), FLAG_NO_STRENGTH, FLAG_READY_BOW, free_string(), get_dam_bonus(), get_dex_bonus(), get_map_flags(), GET_MAP_MOVE_BLOCK, get_thaco_bonus(), living::grace, living::hp, if(), object::level, llevError, LOG(), m, object::magic, object::map, MOVE_FLY_LOW, object::move_on, object::move_type, MOVE_WALK, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, object::name, NDI_UNIQUE, object::nrof, ob_process(), object_find_by_type(), object_free_drop_inventory(), object_insert_in_map_at(), object_remove(), object_set_owner(), object_split(), object_update_speed(), object_update_turn_face(), object_was_destroyed, P_OUT_OF_MAP, play_sound_map(), PLAYER, QUERY_FLAG, object::race, range_bow, player::ranges, object::skill, skill, object::slaying, SOUND_TYPE_ITEM, living::sp, object::speed, object::speed_left, object::spellarg, object::stats, living::Str, strdup_local, object::type, and living::wc.
Referenced by monster_use_bow(), and player_fire_bow().
|
static |
Fires a misc (wand/rod/horn) object in 'dir'.
Broken apart from 'fire' to keep it more readable.
op | player firing. |
dir | firing direction. |
Definition at line 2361 of file player.cpp.
References cast_spell(), object::contr, drain_rod_charge(), drain_wand_charge(), draw_ext_info, draw_ext_info_format(), FLAG_BEEN_APPLIED, living::food, living::hp, object::inv, llevError, LOG(), MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_FAILURE, name, object::name, NDI_UNIQUE, play_sound_player_only(), query_base_name(), range_misc, player::ranges, ROD, SET_FLAG, SOUND_TYPE_ITEM, SP_level_spellpoint_cost(), SPELL_HIGHEST, object::stats, object::type, and WAND.
Referenced by fire().
void fix_luck | ( | void | ) |
Fixes luck of players, slowly move it towards 0.
Definition at line 3927 of file player.cpp.
References change_luck(), object::contr, first_player, player::next, player::ob, and player::state.
Referenced by do_specials().
void fix_weight | ( | void | ) |
Check recursively the weight of all players, and fix what needs to be fixed.
Refresh windows and fix speed if anything was changed.
Definition at line 3911 of file player.cpp.
References object::carrying, first_player, fix_object(), llevDebug, LOG(), object::name, player::next, player::ob, and object_sum_weight().
Referenced by do_specials().
|
static |
The player is scared, and should flee.
If she can't, then she isn't scared anymore.
op | player. |
Definition at line 1675 of file player.cpp.
References absdir(), CLEAR_FLAG, did_make_save(), rv_vector::direction, object::enemy, FLAG_SCARED, get_rangevector(), living::hp, object::level, llevDebug, LOG(), m, object::map, move_ob(), object_set_enemy(), PREFER_LOW, RANDOM, random_roll(), and object::stats.
Referenced by handle_newcs_player().
void get_name | ( | object * | op | ) |
Waiting for the player's name.
op | player. |
Definition at line 889 of file player.cpp.
References object::contr, i18n(), player_set_state(), send_query(), player::socket, and ST_GET_NAME.
Referenced by add_player(), receive_play_again(), receive_player_name(), receive_player_password(), and wrong_password().
Definition at line 591 of file player.cpp.
References first_player, is_criminal(), monster_can_detect_enemy(), and player::next.
Referenced by monster_find_enemy().
Finds the nearest visible player or player-friendly for some object.
mon | what object is searching a player. |
Definition at line 548 of file player.cpp.
References rv_vector::distance, first_player, FLAG_FREED, FLAG_FRIENDLY, free_objectlink(), get_friends_of(), list, monster_can_detect_enemy(), player::next, objectlink::next, player::ob, objectlink::ob, and QUERY_FLAG.
Referenced by monster_find_enemy(), and monster_move().
Ask the player for the password of the party she wants to join.
op | player. |
party | party op wishes to join. |
Definition at line 1029 of file player.cpp.
References object::contr, CS_QUERY_HIDEINPUT, i18n(), party_get_password(), player::party_to_join, player_set_state(), send_query(), player::socket, and ST_GET_PARTY_PASSWORD.
Referenced by command_party().
void get_password | ( | object * | op | ) |
Waiting for the player's password.
op | player. |
Definition at line 900 of file player.cpp.
References object::contr, CS_QUERY_HIDEINPUT, i18n(), player_set_state(), send_query(), player::socket, and ST_GET_PASSWORD.
Referenced by receive_player_name().
Create a player's object, initialize a player's structure.
This no longer sets the player map. Also, it now updates all the pointers so the caller doesn't need to do that. Caller is responsible for setting the correct map.
Redo this to do both get_player_ob and get_player. Hopefully this will be bugfree and simpler.
p | if NULL, a new player structure is created, else p is recycled. |
Definition at line 285 of file player.cpp.
References add_string(), object::arch, arch_to_object(), bow_normal, player::bowtype, living::Cha, CLEAR_FLAG, clear_los(), clear_player(), archetype::clone, living::Con, object::contr, living::Dex, object::direction, player::do_los, living::exp, fatal(), first_map_path, first_player, FLAG_READY_SKILL, player::gen_sp_armour, get_player_archetype(), i18n_get_language_by_code(), living::Int, player::language, player::last_applied_stats, player::last_character_flags, player::last_character_load, player::last_item_power, player::last_path_attuned, player::last_path_denied, player::last_path_repelled, player::last_resist, player::last_skill_exp, player::last_skill_ob, player::last_speed, player::last_stats, player::last_weapon_sp, player::last_weight, player::last_weight_limit, player::listening, MAX_SKILLS, object::name, player::next, player::no_shout, NROFATTACKS, player::ob, offsetof, OUT_OF_MEMORY, player::party, party_rejoin_if_exists, player::peaceful, pet_normal, player::petmode, player_set_state(), living::Pow, object::race, range_none, player::rejoin_party, roll_stats(), object::run_away, player::savebed_map, player::shoottype, object::speed, object::speed_left, ST_ROLL_STAT, object::stats, living::Str, player::swap_first, player::ticks_played, player::title, player::unapply, unapply_nochoice, player::unarmed_skill, living::wc, and living::Wis.
Referenced by account_play_cmd(), add_player(), make_perma_dead(), and receive_play_again().
Get next player archetype from archetype list.
Not very efficient routine, but used only creating new players.
at | archetype to search from. |
Definition at line 513 of file player.cpp.
References AssetsManager::archetypes(), archetype::clone, AssetsCollection< T, Key >::each(), fatal(), getManager(), llevError, LOG(), PLAYER, players, SEE_LAST_ERROR, and object::type.
Referenced by get_player(), and key_change_class().
void give_initial_items | ( | object * | pl, |
treasurelist * | items | ||
) |
Gives a new player her initial items.
They will be god-given, and suitable for the player's race/restrictions.
pl | player. |
items | treasure list containing the items. |
Now we do a second loop, to apply weapons/armors/... This is because weapons require the skill, which can be given after the first loop.
Definition at line 792 of file player.cpp.
References AP_NOPRINT, apply_manual(), CLEAR_FLAG, create_treasure(), FLAG_APPLIED, FLAG_CAN_USE_SKILL, FLAG_CURSED, FLAG_DAMNED, FLAG_IDENTIFIED, FLAG_INV_LOCKED, FLAG_NEUTRAL, FLAG_STARTEQUIP, FLAG_USE_ARMOUR, FLAG_USE_SHIELD, FLAG_USE_WEAPON, FOR_BELOW_FINISH, FOR_BELOW_PREPARE, FOR_INV_FINISH, FOR_INV_PREPARE, FORCE, is_valid_types_gen::found, GT_ONLY_GOOD, GT_STARTEQUIP, IS_ARMOR, is_identifiable_type(), IS_SHIELD, IS_WEAPON, link_player_skills(), llevError, LOG(), object_can_merge(), object_free_drop_inventory(), object_remove(), PLAYER, QUERY_FLAG, object::randomitems, SET_FLAG, SKILL, SPELLBOOK, and object::type.
Referenced by apply_changes_to_player(), apply_race_and_class(), and key_change_class().
|
static |
Create a text for a player's gravestone.
Moved from apply.c to player.c - player.c is what actually uses this function. player.c may not be quite the best, a misc file for object actions is probably better, but there isn't one in the server directory.
op | player. |
buf2 | buffer to write the text to. Mustn't be NULL. |
len | length of buf2. |
Definition at line 3254 of file player.cpp.
References buf, object::contr, player::killer, object::level, MAX_BUF, object::name, PLAYER, time, player::title, and object::type.
Referenced by kill_player_permadeath().
int handle_newcs_player | ( | object * | op | ) |
Handles commands the player can send us, and various checks on invisibility, golem and such.
This is sort of special, in that the new client/server actually uses the new speed values for commands.
op | player to handle. |
Definition at line 3103 of file player.cpp.
References CLEAR_FLAG, object::contr, object::count, object::direction, draw_ext_info, player::fire_on, FLAG_MAKE_INVIS, FLAG_PARALYZED, FLAG_REMOVED, FLAG_SCARED, flee_player(), player::golem_count, player::hidden, object::invisible, make_visible(), move_player(), MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_BAD_EFFECT_END, MSG_TYPE_SPELL, MSG_TYPE_SPELL_END, NDI_UNIQUE, PLAYER, pticks, QUERY_FLAG, range_golem, player::ranges, player::run_on, object::speed_left, and object::type.
Referenced by process_players1().
int hideability | ( | object * | ob | ) |
Look at the surrounding terrain to determine the hideability of this object.
Positive levels indicate greater hideability.
ob | object that may want to hide. |
Definition at line 4013 of file player.cpp.
References mapstruct::darkness, freearr_x, freearr_y, get_map_flags(), has_carried_lights(), level, object::map, P_BLOCKSVIEW, P_OUT_OF_MAP, object::x, and object::y.
Referenced by attempt_hide(), and do_hidden_move().
int is_true_undead | ( | object * | op | ) |
Is the object a true undead?
op | object to test. |
Definition at line 3996 of file player.cpp.
References object::arch, archetype::clone, FLAG_UNDEAD, and QUERY_FLAG.
Referenced by makes_invisible_to(), monster_can_detect_enemy(), and monster_can_see_enemy().
void key_change_class | ( | object * | op, |
char | key | ||
) |
This function takes the key that is passed, and does the appropriate action with it (change race, or other things).
The function name is for historical reasons - now we have separate race and class; this actually changes the RACE, not the class.
op | player. |
key | key to handle. |
Definition at line 1297 of file player.cpp.
References add_statbonus(), add_string(), allowed_class(), object::arch, player::bed_x, player::bed_y, buf, object::carrying, CLEAR_FLAG, archetype::clone, object::contr, create_treasure(), CS_QUERY_SINGLECHAR, draw_ext_info, draw_ext_info_format(), enter_exit(), esrv_new_player(), esrv_send_inventory(), esrv_update_item(), EVENT_BORN, EVENT_LOGIN, events_execute_global_event(), EXIT_PATH, EXIT_X, EXIT_Y, find_treasurelist(), first_map_ext_path, fix_object(), FLAG_WIZ, free_string(), get_player_archetype(), give_initial_items(), living::grace, socket_struct::host, living::hp, i18n(), player::is_wraith, link_player_skills(), llevDebug, Settings::localdir, LOG(), make_path_to_file(), object::map, MAX_BUF, living::maxhp, living::maxsp, object::msg, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_LOGIN, MSG_TYPE_ADMIN_PLAYER, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_NEWPLAYER, name, object::name, archetype::name, object::name_pl, NDI_ALL, NDI_BLUE, NDI_DK_ORANGE, NDI_UNIQUE, object_copy(), object_find_by_name(), object_free_drop_inventory(), object_insert_in_map_at(), object_new(), object_remove(), object_set_msg(), object_update(), player::orig_stats, play_again(), player_set_state(), Settings::playerdir, pticks, object::randomitems, remove_statbonus(), player::savebed_map, send_query(), SET_ANIMATION, settings, player::socket, living::sp, ST_PLAYING, object::stats, strlcpy(), player::title, UP_OBJ_FACE, UPD_FACE, object::weight, object::x, and object::y.
Referenced by reply_cmd().
void key_confirm_quit | ( | object * | op, |
char | key | ||
) |
We receive the reply to the 'quit confirmation' message.
op | player. |
key | reply. |
Definition at line 1602 of file player.cpp.
References account_char_free(), account_char_remove(), account_char_save(), socket_struct::account_chars, socket_struct::account_name, account_remove_player(), buf, object::contr, delete_character(), delete_map(), object::direction, draw_ext_info, draw_ext_info_format(), EVENT_REMOVE, events_execute_global_event(), first_map, FLAG_WIZ, FREE_AND_CLEAR_STR, hiscore_check(), player::killer, MAX_BUF, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_LOGIN, MSG_TYPE_ADMIN_PLAYER, object::name, NDI_ALL, NDI_DK_ORANGE, NDI_UNIQUE, mapstruct::next, object_remove(), party_leave(), mapstruct::path, pets_terminate_all(), play_again(), player_set_own_title(), player_set_state(), Settings::playerdir, QUERY_FLAG, send_account_players(), Settings::set_title, settings, player::socket, ST_PLAYING, and TRUE.
Referenced by reply_cmd().
void key_roll_stat | ( | object * | op, |
char | key | ||
) |
Player is currently swapping stats.
This code has been greatly reduced, because with set_attr_value and get_attr_value, the stats can be accessed just numeric ids. stat_trans is a table that translate the number entered into the actual stat. It is needed because the order the stats are displayed in the stat window is not the same as how the number's access that stat. The table does that translation.
op | player. |
key | received key. |
Definition at line 1221 of file player.cpp.
References add_statbonus(), CHARISMA, CONSTITUTION, object::contr, CS_QUERY_SINGLECHAR, DEXTERITY, draw_ext_info, draw_ext_info_format(), FLAG_WIZ, i18n(), INTELLIGENCE, llevError, LOG(), object::map, object::msg, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_NEWPLAYER, NDI_BLUE, NDI_UNIQUE, play_again(), player_set_state(), POWER, roll_stats(), send_query(), SET_ANIMATION, SET_FLAG, short_stat_name, player::socket, ST_CHANGE_CLASS, STRENGTH, player::swap_first, swap_stat(), and WISDOM.
Referenced by reply_cmd().
Handle a player's death.
Also deals with lifesaving objects, arena deaths, cleaning disease/poison, death penalties, and removing the player file in case of permadeath.
op | Player to be killed. |
killer | The object that's trying to kill op, which can be NULL. |
Definition at line 3509 of file player.cpp.
References add_string(), arch_to_object(), player::braced, buf, object::contr, draw_ext_info, EVENT_DEATH, EVENT_PLAYER_DEATH, events_execute_global_event(), events_execute_object_event(), FLESH, living::food, living::hp, kill_player_not_permadeath(), kill_player_permadeath(), player::killer, object::level, object::map, object::material, object::materialname, MAX_BUF, MAX_FOOD, living::maxhp, MSG_TYPE_VICTIM, MSG_TYPE_VICTIM_DIED, object::name, NDI_NAVY, NDI_UNIQUE, Settings::not_permadeth, object_insert_in_map_at(), object_set_msg(), op_on_battleground(), play_sound_player_only(), restore_player(), save_life(), SCRIPT_FIX_ALL, settings, SOUND_TYPE_LIVING, starving(), object::stats, player::title, transfer_ob(), TRUE, object::type, object::value, object::x, and object::y.
Referenced by check_login(), deep_swamp_type_process(), kill_object(), and save_throw_object().
|
static |
Kills a player in non-permadeath mode.
This basically brings the character back to life if they are dead - it takes some exp and a random stat. See the config.h file for a little more in depth detail about this.
op | the player to kill. |
Definition at line 3590 of file player.cpp.
References apply_death_exp_penalty(), ARCH_DEPLETION, arch_present_in_ob(), arch_to_object(), object::attacktype, Settings::balanced_stat_loss, BALSL_LOSS_CHANCE_RATIO, BALSL_MAX_LOSS_RATIO, BALSL_NUMBER_LOSSES_RATIO, player::braced, buf, change_attr_value(), check_stat_bounds(), command_search_items(), object::contr, create_archetype(), determine_god(), drain_msg, draw_ext_info, draw_ext_info_format(), enter_player_savebed(), esrv_send_pickup(), find_archetype(), fix_object(), FLAG_APPLIED, living::food, FOR_MAP_FINISH, FOR_MAP_PREPARE, FORCE_NAME, FREE_AND_COPY, get_attr_value(), living::grace, living::hp, object::inv, player::killer, object::level, level, lose_msg, object::map, MAX, MAX_BUF, Settings::max_stat, living::maxgrace, living::maxhp, living::maxsp, MIN_STAT, player::mode, MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_GOD, MSG_TYPE_ATTRIBUTE_STAT_LOSS, MSG_TYPE_VICTIM, MSG_TYPE_VICTIM_DIED, object::name, object::name_pl, NDI_UNIQUE, NROFATTACKS, object_insert_in_map_at(), object_insert_in_ob(), object_set_msg(), player::orig_stats, PREFER_LOW, PU_INHIBIT, PU_NEWMODE, RANDOM, random_roll(), remove_unpaid_objects(), object::resist, restore_player(), save_player(), player::search_str, SET_FLAG, settings, shop_contains(), living::sp, object::speed, object::speed_left, SPELL_EFFECT, Settings::stat_loss_on_death, object::stats, player::title, object::type, object::x, and object::y.
Referenced by kill_player().
|
static |
Kills a player in permadeath mode.
op | the player to kill. |
Definition at line 3814 of file player.cpp.
References account_char_free(), account_char_remove(), account_char_save(), socket_struct::account_chars, socket_struct::account_name, account_remove_player(), arch_to_object(), buf, object::contr, dead_player(), delete_character(), object::direction, draw_ext_info, Settings::emergency_mapname, Settings::emergency_x, Settings::emergency_y, living::exp, find_archetype(), FLAG_UNIQUE, FLAG_WAS_WIZ, living::food, FREE_AND_COPY, player::golem_count, gravestone_text(), hiscore_check(), living::hp, object::level, loot_object(), object::map, player::maplevel, MAX_BUF, MAX_FOOD, living::maxhp, MSG_TYPE_VICTIM, MSG_TYPE_VICTIM_DIED, object::name, object::name_pl, NDI_ALL, NDI_UNIQUE, object_free_drop_inventory(), object_insert_in_map_at(), object_remove(), object_set_msg(), party_leave(), play_again(), player_set_own_title(), QUERY_FLAG, range_golem, player::ranges, remove_friendly_object(), Settings::resurrection, safe_strncpy, save_player(), send_account_players(), SET_FLAG, Settings::set_title, settings, object::slaying, player::socket, object::stats, TRUE, object::x, and object::y.
Referenced by kill_player().
|
static |
Grab and destroy some treasure.
op | object to loot. |
Definition at line 3432 of file player.cpp.
References AP_NULL, apply_container(), CONTAINER, object::container, FLAG_NO_DROP, FLAG_STARTEQUIP, FLAG_UNIQUE, FOR_INV_FINISH, FOR_INV_PREPARE, object::map, object_free_drop_inventory(), object_insert_in_map_at(), object_remove(), object_split(), QUERY_FLAG, RANDOM, object::x, and object::y.
Referenced by kill_player_permadeath().
void make_visible | ( | object * | op | ) |
Makes an object visible again.
op | what to make visible. |
Definition at line 3977 of file player.cpp.
References object::contr, FREE_AND_CLEAR_STR, object::hide, player::invis_race, object::invisible, object_update(), PLAYER, player::tmp_invis, object::type, and UP_OBJ_FACE.
Referenced by attack_ob_simple(), attempt_steal(), do_hidden_move(), fire(), handle_newcs_player(), hide(), monster_can_detect_enemy(), monster_can_see_enemy(), move_player_attack(), and player_attack_door().
int move_player | ( | object * | op, |
int | dir | ||
) |
Move player in the given direction.
Can be called by a client through a movement command, or by the server for some other reasons.
op | player. |
dir | direction to move/fire. |
Definition at line 2965 of file player.cpp.
References animate_object(), check_pick(), object::contr, object::direction, do_hidden_move(), object::facing, fire(), player::fire_on, FLAG_CONFUSED, get_randomized_dir(), object::hide, mapstruct::in_memory, llevError, LOG(), object::map, MAP_IN_MEMORY, move_player_attack(), QUERY_FLAG, player::run_on, object::speed_left, object::state, player::transport, and turn_transport().
Referenced by cfapi_object_move(), command_fire(), command_run(), handle_newcs_player(), move_internal(), move_player_mover(), move_towards(), and pray_at_altar().
void move_player_attack | ( | object * | op, |
int | dir | ||
) |
The player is also actually going to try and move (not fire weapons).
This function is just part of a breakup from move_player(). It should keep the code cleaner. When this is called, the players direction has been updated (taking into account confusion).
op | player moving. |
dir | moving direction. |
Definition at line 2640 of file player.cpp.
References action_makes_visible(), player::braced, object::contr, DOOR, draw_ext_info, object::enemy, FLAG_ALIVE, FLAG_CAN_ROLL, FLAG_FRIENDLY, FLAG_MONSTER, FLAG_UNAGGRESSIVE, FLAG_WIZ, FOR_MAP_FINISH, FOR_MAP_PREPARE, freearr_x, freearr_y, get_map_from_coord(), GET_MAP_OB, player::has_hit, HEAD, object::hide, living::hp, LOCKED_DOOR, living::luck, m, make_visible(), object::map, move_ob(), MSG_TYPE_ATTACK, MSG_TYPE_ATTACK_NOATTACK, object_get_owner(), op_on_battleground(), out_of_map(), OUT_OF_REAL_MAP, player::party, player::peaceful, play_sound_map(), PLAYER, player_attack_door(), player_map_change_common(), push_ob(), QUERY_FLAG, recursive_roll(), skill_attack(), SOUND_TYPE_LIVING, object::speed_left, object::stats, player::tmp_invis, player::transport, object::type, object::weapon_speed_left, object::x, and object::y.
Referenced by move_player().
Check if the given object (usually a player) is standing on a battleground tile.
This is used to handle deaths and special attacks in arenas.
A battleground tile must have the following attributes set:
If the tile has 'slaying', 'maxhp', and 'maxsp' set, and the player has a matching marker, send the player to those coordinates instead.
If the tile has 'other_arch' set, then create that archetype as the trophy instead of the default ("finger").
op | Object to check (usually a player). | |
[out] | x | |
[out] | y | If not NULL and standing on a battleground tile, store exit coordinates. |
[out] | trophy | If not NULL and standing on a battleground tile, store a pointer to the archetype that can be collected by the winner. |
Definition at line 4262 of file player.cpp.
References BATTLEGROUND, EXIT_ALT_X, EXIT_ALT_Y, EXIT_PATH, EXIT_X, EXIT_Y, find_archetype(), FLAG_IS_FLOOR, FLAG_NO_PICK, FOR_BELOW_FINISH, FOR_BELOW_PREPARE, FORCE, object_find_by_type_and_slaying(), and QUERY_FLAG.
Referenced by hit_player(), hit_with_drain(), hit_with_one_attacktype(), infect_object(), kill_object(), kill_player(), move_player_attack(), pets_should_arena_attack(), and spell_find_dir().
Returns the direction to the player, if valid.
Returns 0 otherwise.
Modified to verify there is a path to the player. Does this by stepping towards player and if path is blocked then see if blockage is close enough to player that direction to player is changed (ie zig or zag). Continue zig zag until either reach player or path is blocked. Thus, will only return true if there is a free path to player. Though path may not be a straight line. Note that it will find player hiding along a corridor at right angles to the corridor with the monster.
Modified by MSW 2001-08-06 to handle tiled maps. Various notes:
mon | source object. |
pl | target. |
mindiff | minimal distance mon and pl should have. |
Definition at line 659 of file player.cpp.
References absdir(), blocked_link(), DETOUR_AMOUNT, rv_vector::direction, rv_vector::distance, rv_vector::distance_x, rv_vector::distance_y, FABS, freearr_x, freearr_y, get_map_flags(), GET_MAP_MOVE_BLOCK, get_rangevector(), get_rangevector_from_mapcoord(), m, object::map, MAX, MAX_SPACES, MOVE_ALL, OB_TYPE_MOVE_BLOCK, P_IS_ALIVE, P_OUT_OF_MAP, object::x, and object::y.
Referenced by monster_cast_spell(), monster_use_range(), monster_use_scroll(), and monster_use_skill().
Looks in a given direction, finds the first valid target, and calls find_better_arrow() to find a decent arrow to use.
op | shooter. |
type | arrow's race to search for (the bow's usually). |
dir | fire direction. |
Definition at line 2041 of file player.cpp.
References object::chosen_skill, living::Dex, die_roll(), find_arrow(), find_better_arrow(), FLAG_ALIVE, FOR_MAP_FINISH, FOR_MAP_PREPARE, is_valid_types_gen::found, freearr_x, freearr_y, get_map_flags(), GET_MAP_MOVE_BLOCK, HEAD, object::level, m, object::map, MOVE_FLY_LOW, P_BLOCKSVIEW, P_IS_ALIVE, P_OUT_OF_MAP, PREFER_LOW, QUERY_FLAG, object::stats, is_valid_types_gen::type, object::x, and object::y.
Referenced by player_fire_bow().
void play_again | ( | object * | op | ) |
Ask the player whether to play again or disconnect.
op | player. |
Definition at line 911 of file player.cpp.
References object::chosen_skill, object::contr, CS_QUERY_SINGLECHAR, FLAG_REMOVED, i18n(), socket_struct::login_method, object::map, Ns_Add, object_remove(), player_set_state(), QUERY_FLAG, receive_play_again(), send_query(), Send_With_Handling(), player::socket, SockList_AddChar(), SockList_AddInt(), SockList_AddString(), SockList_Init(), SockList_Term(), ST_PLAY_AGAIN, and socket_struct::status.
Referenced by apply_savebed(), key_change_class(), key_confirm_quit(), key_roll_stat(), kill_player_permadeath(), and receive_play_again().
Player is "attacking" a door.
Will try to open it with a key, or warn if can't open it.
Moved out of move_player_attack().
1 | player has opened the door with a key such that the caller should not do anything more. |
0 | nothing happened. |
Definition at line 2567 of file player.cpp.
References action_makes_visible(), object::contr, do_skill(), DOOR, draw_ext_info, draw_ext_info_format(), object::facing, find_key(), find_skill_by_name(), HUGE_BUF, object::inv, LOCKED_DOOR, make_visible(), object::msg, MSG_TYPE_ITEM, MSG_TYPE_ITEM_INFO, MSG_TYPE_ITEM_REMOVE, name, NDI_BROWN, NDI_NAVY, NDI_UNIQUE, object_decrease_nrof_by_one, play_sound_map(), query_short_name(), remove_door(), remove_locked_door(), player::run_on, RUNE, SOUND_TYPE_GROUND, spring_trap(), TRAP, and object::type.
Referenced by move_player_attack().
Check the player los field for viewability of the object op.
This function works fine for monsters, but we dont worry if the object isnt the top one in a pile (say a coin under a table would return "viewable" by this routine). Another question, should we be concerned with the direction the player is looking in? Realistically, most of use cant see stuff behind our backs...on the other hand, does the "facing" direction imply the way your head, or body is facing? Its possible for them to differ. Sigh, this fctn could get a bit more complex. -b.t.
This function is now map tiling safe.
pl | player that may see op. |
op | what may be seen by pl. |
-1 | pl isn't a player |
0 | pl can't see op. |
1 | pl can see op. |
Definition at line 4163 of file player.cpp.
References object::arch, player::blocked_los, archetype::clone, object::contr, rv_vector::distance_x, rv_vector::distance_y, FABS, get_rangevector(), HEAD, llevError, LOG(), socket_struct::mapx, socket_struct::mapy, object::more, PLAYER, player::socket, object::type, object::x, and object::y.
Referenced by adj_attackroll(), monster_can_detect_enemy(), and monster_can_see_enemy().
|
static |
Special fire code for players - this takes into account the special fire modes players can have but monsters can't.
Putting that code here makes the fire_bow() code much cleaner.
This function should only be called if 'op' is a player, hence the function name.
op | player. |
dir | firing direction. |
Definition at line 2325 of file player.cpp.
References absdir(), bow_bestarrow, bow_n, bow_nw, bow_spreadshot, bow_threewide, player::bowtype, object::contr, fire_bow(), freearr_x, freearr_y, pick_arrow_target(), object::race, range_bow, player::ranges, similar_direction(), object::x, and object::y.
Referenced by fire().
Get a delayed socket buffer, that will be sent after the player's tick is complete.
Will fatal() if memory error.
pl | player to get a buffer for. |
Definition at line 4501 of file player.cpp.
References player::delayed_buffers, player::delayed_buffers_allocated, player::delayed_buffers_used, fatal(), llevError, LOG(), object::name, player::ob, OUT_OF_MEMORY, SockList_Init(), and UINT8_MAX.
Referenced by draw_ext_info(), and quest_set_state().
void player_set_state | ( | player * | pl, |
uint8_t | state | ||
) |
Set the player's state to the specified one.
pl | who to set state for. |
state | new state. |
Definition at line 4488 of file player.cpp.
References ST_CHANGE_PASSWORD_CONFIRM, and player::state.
Referenced by add_player(), check_login(), command_delete(), command_passwd(), confirm_password(), create_player_cmd(), get_name(), get_party_password(), get_password(), get_player(), key_change_class(), key_confirm_quit(), key_roll_stat(), play_again(), receive_party_password(), receive_play_again(), and receive_player_password().
Unready an object for a player.
This function does nothing if the object was not readied.
pl | player. |
ob | object to unready. |
Definition at line 4470 of file player.cpp.
References range_none, range_size, player::ranges, and player::shoottype.
Referenced by become_follower(), do_forget_spell(), and remove_special_prayers().
int playername_ok | ( | const char * | cp | ) |
Is the player name valid.
cp | name to test. |
Definition at line 257 of file player.cpp.
Referenced by check_name(), and create_player_cmd().
void receive_play_again | ( | object * | op, |
char | key | ||
) |
Player replied to play again / disconnect.
op | player. |
key | received choice. |
Definition at line 964 of file player.cpp.
References socket_struct::account_name, add_friendly_object(), add_refcount(), add_string(), object::contr, draw_ext_info, FREE_AND_CLEAR_STR, get_name(), get_player(), leave(), socket_struct::login_method, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_LOGIN, name, object::name, object::name_pl, NDI_UNIQUE, player::ob, object_free_drop_inventory(), player::password, play_again(), player_set_state(), remove_friendly_object(), send_account_players(), set_first_map(), player::socket, and ST_GET_NAME.
Referenced by play_again(), and reply_cmd().
This goes throws the inventory and removes unpaid objects, and puts them back in the map (location and map determined by values of env) or frees them.
This function will descend into containers.
op | object to start the search from. |
env | top-level container, should be in a map if free_items is 0, unused if free_items is 1. |
free_items | if set, unpaid items are freed, else they are inserted in the same map as env. |
Definition at line 3224 of file player.cpp.
References env, FLAG_UNPAID, FOR_OB_AND_BELOW_FINISH, FOR_OB_AND_BELOW_PREPARE, object::inv, object_free_drop_inventory(), object_insert_in_map_at(), object_remove(), and QUERY_FLAG.
Referenced by check_login(), execute_word_of_recall(), and kill_player_not_permadeath().
|
static |
Remove confusion, disease, and poison on death.
Used in battleground not-death and non-perma-death
Abstracted out to its own function to de-spaghettify the death code a little
op | The player object being killed. Assumes that the object is a player, but does not check |
Definition at line 3471 of file player.cpp.
References arch_present_in_ob(), cure_disease(), draw_ext_info, find_archetype(), MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_BAD_EFFECT_END, NDI_UNIQUE, object_free_drop_inventory(), and object_remove().
Referenced by kill_player(), and kill_player_not_permadeath().
void roll_again | ( | object * | op | ) |
Ask the player what to do with the statistics.
op | player. |
Definition at line 1149 of file player.cpp.
References object::contr, CS_QUERY_SINGLECHAR, esrv_new_player(), i18n(), send_query(), and player::socket.
Referenced by add_player(), and receive_player_password().
int roll_stat | ( | void | ) |
This rolls four 1-6 rolls and sums the best 3 of the 4.
Definition at line 1046 of file player.cpp.
References RANDOM.
Referenced by roll_stats().
void roll_stats | ( | object * | op | ) |
Roll the initial player's statistics.
op | player to roll for. |
Definition at line 1070 of file player.cpp.
References living::ac, living::Cha, living::Con, object::contr, living::Dex, living::exp, fix_object(), living::grace, living::hp, living::Int, object::level, player::levgrace, player::levhp, player::levsp, living::maxgrace, living::maxhp, living::maxsp, player::orig_stats, living::Pow, roll_stat(), Settings::roll_stat_points, settings, living::sp, object::stats, living::Str, and living::Wis.
Referenced by get_player(), and key_roll_stat().
|
static |
Can the player be saved by an item?
op | player to try to save. |
1 | player had his life saved by an item, first item saving life is removed. |
0 | player had no life-saving item. |
Definition at line 3181 of file player.cpp.
References CLEAR_FLAG, draw_ext_info_format(), enter_player_savebed(), fix_object(), FLAG_LIFESAVE, living::food, living::hp, llevError, LOG(), MAX_BUF, MAX_FOOD, living::maxhp, MSG_TYPE_ITEM, MSG_TYPE_ITEM_REMOVE, name, NDI_UNIQUE, object_find_by_flag_applied(), object_free_drop_inventory(), object_remove(), play_sound_map(), QUERY_FLAG, query_name(), SOUND_TYPE_ITEM, and object::stats.
Referenced by kill_player().
void send_delayed_buffers | ( | player * | pl | ) |
Send all delayed buffers for a player.
pl | player to send buffers for. |
Definition at line 4530 of file player.cpp.
References buf, player::delayed_buffers, player::delayed_buffers_used, Send_With_Handling(), and player::socket.
Referenced by process_players2().
void send_news | ( | const object * | op | ) |
Send the news to a player.
op | player to send to. |
Definition at line 206 of file player.cpp.
References buf, Settings::confdir, draw_ext_info_format(), HUGE_BUF, llevDebug, LOG(), MAX_BUF, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, NDI_GREEN, NDI_UNIQUE, news, Settings::news, safe_strcat(), safe_strncpy, settings, and strip_endline().
Referenced by add_player(), and command_news().
void send_rules | ( | const object * | op | ) |
Send the rules to a player.
op | player to send rules to. |
Definition at line 170 of file player.cpp.
References buf, Settings::confdir, draw_ext_info, HUGE_BUF, llevDebug, LOG(), MAX_BUF, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_RULES, NDI_GREEN, NDI_UNIQUE, Settings::rules, safe_strcat(), and settings.
Referenced by add_player(), and command_rules().
void set_first_map | ( | object * | op | ) |
This loads the first map an puts the player on it.
op | player to put on map. |
Definition at line 402 of file player.cpp.
References object::contr, enter_player_maplevel(), first_map_path, player::maplevel, object::x, and object::y.
Referenced by add_player(), and receive_play_again().
void set_player_socket | ( | player * | p, |
socket_struct * | ns | ||
) |
This copies the data from the socket into the player structure.
Originally written to separate this logic from add_player() so new character method could use it, but that did not work out, but still a good thing to have this separate.
p | The target player object to copy the data into |
ns | the socket structure to copy. |
Definition at line 421 of file player.cpp.
References account_char_free(), socket_struct::account_chars, socket_struct::account_name, socket_struct::faces_sent, fatal(), socket_struct::host, socket_struct::inbuf, OUT_OF_MEMORY, player::socket, SockList_ResetRead(), and strdup_local.
Referenced by account_play_cmd(), and add_player().
|
static |
Is direction a similar to direction b? Find out in this exciting function below.
a | |
b | directions to compare. |
Definition at line 2291 of file player.cpp.
References a().
Referenced by player_fire_bow().
int stand_near_hostile | ( | object * | who | ) |
Determine if who is standing near a hostile creature.
who | object to check. |
Definition at line 4095 of file player.cpp.
References FLAG_FRIENDLY, FLAG_MONSTER, FLAG_UNAGGRESSIVE, FLAG_WIZ, FOR_MAP_FINISH, FOR_MAP_PREPARE, freearr_x, freearr_y, friendly, get_map_flags(), GET_MAP_MOVE_BLOCK, m, object::map, OB_TYPE_MOVE_BLOCK, P_OUT_OF_MAP, PLAYER, QUERY_FLAG, object::type, object::x, and object::y.
Referenced by attempt_hide().
|
static |
Definition at line 3282 of file player.cpp.
References living::food, and object::stats.
Referenced by kill_player().
|
static |
Player finishes selecting what stats to swap.
op | player. |
swap_second | second statistic to swap. |
Definition at line 1163 of file player.cpp.
References living::ac, living::Cha, living::Con, object::contr, living::Dex, draw_ext_info_format(), living::exp, fix_object(), get_attr_value(), living::grace, living::hp, living::Int, object::level, player::levgrace, player::levhp, player::levsp, llevError, LOG(), living::maxgrace, living::maxhp, living::maxsp, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_NEWPLAYER, NDI_UNIQUE, player::orig_stats, living::Pow, set_attr_value(), short_stat_name, living::sp, object::stats, living::Str, player::swap_first, and living::Wis.
Referenced by key_roll_stat().
Turn a transport to an adjacent direction (+1 or -1), updating the move_type flags in the same process.
transport | what to turn. Must be of type TRANSPORT. |
captain | who wants to turn the boat. |
dir | direction to turn to. |
Definition at line 2862 of file player.cpp.
References animate_object(), object::direction, esrv_map_scroll(), object::facing, FOR_INV_FINISH, FOR_INV_PREPARE, freearr_x, freearr_y, object::map, ob_blocked(), object_insert_in_map_at(), object_remove(), PLAYER, TRANSPORT, object::type, update_transport_block(), object::x, and object::y.
Referenced by turn_transport().
Try to turn a transport in the desired direction.
This takes into account transports that turn and don't occupy the same space depending on the direction it is facing. The transport MUST be a square for it to turn correctly when adjusting tile occupation.
transport | what to turn. Must be of type TRANSPORT. |
captain | who wants to turn the boat. |
dir | direction to turn to. |
Definition at line 2932 of file player.cpp.
References absdir(), animate_object(), object::direction, object::facing, FLAG_ANIMATE, object_value_set(), QUERY_FLAG, TRANSPORT, turn_one_transport(), and object::type.
Referenced by face_player(), and move_player().
|
static |
Update the move_type of a transport based on the direction.
The transport MUST be square. Depending on the direction, the right column of tiles or the bottom line of tiles will have a move_type of 0.
transport | what to update. |
dir | direction to update flags for. |
Definition at line 2817 of file player.cpp.
References object::more, object::move_type, and object_get_multi_size().
Referenced by turn_one_transport().
std::vector<archetype *> players |
Definition at line 501 of file player.cpp.
Referenced by get_player_archetype(), getPlayers(), and malloc_info().