Crossfire Server, Branches 1.12
R18729
|
#include <global.h>
#include <assert.h>
#include <pwd.h>
#include <sproto.h>
#include <sounds.h>
#include <living.h>
#include <object.h>
#include <spells.h>
#include <skills.h>
#include <newclient.h>
Go to the source code of this file.
Macros | |
#define | DETOUR_AMOUNT 2 |
#define | MAX_SPACES 50 |
Functions | |
static int | action_makes_visible (object *op) |
void | add_player (socket_struct *ns) |
void | cast_dust (object *op, object *throw_ob, int dir) |
int | check_pick (object *op) |
void | confirm_password (object *op) |
void | display_motd (const object *op) |
void | do_hidden_move (object *op) |
void | do_some_living (object *op) |
void | dragon_ability_gain (object *who, int atnr, int level) |
static object * | find_arrow (object *op, const char *type) |
static object * | find_better_arrow (object *op, object *target, const char *type, int *better) |
object * | find_key (object *pl, object *container, object *door) |
player * | find_player (const char *plname) |
player * | find_player_partial_name (const char *plname) |
void | fire (object *op, int dir) |
int | fire_bow (object *op, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) |
static void | fire_misc_object (object *op, int dir) |
void | fix_luck (void) |
void | fix_weight (void) |
static void | flee_player (object *op) |
void | get_name (object *op) |
object * | get_nearest_player (object *mon) |
void | get_party_password (object *op, partylist *party) |
void | get_password (object *op) |
static player * | get_player (player *p) |
static archetype * | get_player_archetype (archetype *at) |
void | give_initial_items (object *pl, treasurelist *items) |
static const char * | gravestone_text (object *op, char *buf2, int len) |
int | handle_newcs_player (object *op) |
int | hideability (object *ob) |
int | is_true_undead (object *op) |
void | key_change_class (object *op, char key) |
void | key_confirm_quit (object *op, char key) |
void | key_roll_stat (object *op, char key) |
void | kill_player (object *op) |
static void | loot_object (object *op) |
void | make_visible (object *op) |
int | move_player (object *op, int dir) |
void | move_player_attack (object *op, int dir) |
int | op_on_battleground (object *op, int *x, int *y, archetype **trophy) |
int | path_to_player (object *mon, object *pl, unsigned mindiff) |
static object * | pick_arrow_target (object *op, const char *type, int dir) |
void | play_again (object *op) |
static int | player_attack_door (object *op, object *door) |
int | player_can_view (object *pl, object *op) |
static int | player_fire_bow (object *op, int dir) |
void | player_unready_range_ob (player *pl, object *ob) |
int | playername_ok (const char *cp) |
void | receive_play_again (object *op, char key) |
void | remove_unpaid_objects (object *op, object *env, int free_items) |
void | roll_again (object *op) |
int | roll_stat (void) |
void | roll_stats (object *op) |
static int | save_life (object *op) |
void | send_news (const object *op) |
void | send_rules (const object *op) |
static void | set_first_map (object *op) |
int | stand_near_hostile (object *who) |
static void | swap_stat (object *op, int Swap_Second) |
static int | turn_one_transport (object *transport, object *captain, int dir) |
static int | turn_transport (object *transport, object *captain, int dir) |
static void | update_transport_block (object *transport, int dir) |
Player-related functions, including those used during the login and creation phases.
Definition in file player.c.
#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 508 of file player.c.
Referenced by path_to_player().
#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 523 of file player.c.
Referenced by path_to_player().
|
static |
We call this when there is a possibility for our action disturbing our hiding place or invisiblity spell. Artefact invisiblity is not effected by this. If we arent invisible to begin with, we return 0.
This routine works for both players and monsters.
op | object to check. |
Definition at line 3958 of file player.c.
References obj::contr, draw_ext_info_format(), FLAG_ALIVE, FLAG_MAKE_INVIS, obj::hide, obj::invisible, MSG_SUBTYPE_NONE, MSG_TYPE_MISC, NDI_UNIQUE, QUERY_FLAG, and pl::tmp_invis.
Referenced by fire(), move_player_attack(), and player_attack_door().
void add_player | ( | socket_struct * | ns | ) |
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. |
Definition at line 383 of file player.c.
References add_friendly_object(), CLEAR_FLAG, display_motd(), socket_struct::faces_sent, fatal(), FLAG_FRIENDLY, get_name(), get_player(), socket_struct::inbuf, pl::ob, OUT_OF_MEMORY, send_news(), send_rules(), set_first_map(), pl::socket, and SockList_ResetRead().
Referenced by add_me_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 3682 of file player.c.
References cast_spell(), draw_ext_info_format(), find_skill_by_name(), FLAG_REMOVED, free_object(), obj::inv, llevError, LOG(), MSG_TYPE_APPLY, MSG_TYPE_APPLY_SUCCESS, obj::name, NDI_UNIQUE, PLAYER, POTION, QUERY_FLAG, remove_ob(), obj::skill, and obj::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 1384 of file player.c.
References AMULET, obj::arch, ARMOUR, ARROW, obj::below, BOOK, BOOTS, BOW, can_pick(), CLOAK, obj::contr, obj::count, draw_ext_info(), draw_ext_info_format(), DRINK, F_TRUE, FLAG_IS_THROWN, FLAG_KNOWN_CURSED, FLAG_KNOWN_MAGICAL, FLAG_UNPAID, obj::flags, FLESH, FOOD, GEM, GLOVES, HELMET, HORN, item_matched_string(), KEY, MAX, pl::mode, MONEY, MOVE_FLYING, obj::move_type, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_DEBUG, MSG_TYPE_COMMAND_SUCCESS, obj::name, archt::name, NDI_UNIQUE, obj::nrof, pick_up(), POISON, POTION, PU_ALLWEAPON, PU_ARMOUR, PU_ARROW, PU_BOOTS, PU_BOW, PU_CLOAK, PU_DEBUG, PU_DRINK, PU_FLESH, PU_FOOD, PU_GLOVES, PU_HELMET, PU_INHIBIT, PU_JEWELS, PU_KEY, PU_MAGIC_DEVICE, PU_MAGICAL, 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_cost(), QUERY_FLAG, RING, ROD, SCROLL, Settings::search_items, pl::search_str, settings, SHIELD, SKILLSCROLL, snprintf(), SPECIAL_KEY, SPELLBOOK, TRUE, obj::type, WAND, was_destroyed, WEAPON, and obj::weight.
Referenced by move_player().
void confirm_password | ( | object * | op | ) |
Ask the player to confirm her password during creation.
op | player. |
Definition at line 877 of file player.c.
References obj::contr, CS_QUERY_HIDEINPUT, send_query(), pl::socket, ST_CONFIRM_PASSWORD, pl::state, and pl::write_buf.
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 112 of file player.c.
References close_and_delete(), Settings::confdir, draw_ext_info(), HUGE_BUF, MAX_BUF, Settings::motd, MSG_SUBTYPE_NONE, MSG_TYPE_MOTD, NDI_GREEN, NDI_UNIQUE, open_and_uncompress(), settings, and snprintf().
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 3796 of file player.c.
References calc_skill_exp(), change_exp(), obj::contr, mapdef::difficulty, draw_ext_info(), find_obj_by_type_subtype(), hide(), hideability(), obj::invisible, obj::level, make_visible(), obj::map, MSG_TYPE_SKILL, MSG_TYPE_SKILL_FAILURE, NDI_UNIQUE, PLAYER, PREFER_LOW, random_roll(), pl::run_on, SK_HIDING, SKILL, obj::skill, and obj::type.
Referenced by move_monster(), 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 3017 of file player.c.
References Output_Buf::buf, obj::contr, Output_Buf::first_update, flush_output_element(), liv::food, pl::gen_hp, pl::gen_sp, liv::maxhp, liv::maxsp, NUM_OUTPUT_BUFS, pl::outputs, pl::outputs_sync, pticks, ST_PLAYING, pl::state, and obj::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 4060 of file player.c.
References obj::anim_speed, animate_object(), obj::animation_id, obj::arch, arch_to_object(), AT_PHYSICAL, ATNR_COLD, ATNR_ELECTRICITY, ATNR_FIRE, ATNR_POISON, obj::attacktype, obj::below, check_spell_known(), archt::clone, obj::direction, do_learn_spell(), draw_ext_info(), draw_ext_info_format(), esrv_send_item(), obj::face, find_skill_by_name(), find_treasurelist(), FLAG_SEE_IN_DARK, FLAG_STEALTH, FLAG_XRAYS, FORCE, HUGE_BUF, insert_ob_in_ob(), obj::inv, obj::invisible, treasurestruct::item, treasureliststruct::items, obj::last_anim, llevDebug, LOG(), MAX_BUF, obj::msg, MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_RACE, MSG_TYPE_ITEM, MSG_TYPE_ITEM_ADD, obj::name, archt::name, NDI_BLUE, NDI_UNIQUE, NRSPELLPATHS, obj::path_attuned, PLAYER, QUERY_FLAG, query_short_name(), SET_FLAG, SK_CLAWING, obj::skill, SKILL_TOOL, snprintf(), SPELL, SPELLBOOK, spellpathnames, obj::state, obj::subtype, and obj::type.
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 1751 of file player.c.
References ARROW, obj::below, CONTAINER, FLAG_APPLIED, obj::inv, QUERY_FLAG, obj::race, and obj::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 1782 of file player.c.
References obj::arch, ARROW, AT_DEATH, obj::below, archt::clone, CONTAINER, find_arrow(), FLAG_APPLIED, obj::inv, obj::magic, NROFATTACKS, QUERY_FLAG, obj::race, and obj::resist.
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 2278 of file player.c.
References obj::below, CONTAINER, obj::contr, DOOR, draw_ext_info_format(), FLAG_APPLIED, obj::inv, KEY, key_inventory, keyrings, MAX_BUF, MSG_TYPE_ITEM, MSG_TYPE_ITEM_INFO, NDI_BROWN, NDI_UNIQUE, QUERY_FLAG, query_name(), obj::race, obj::slaying, SPECIAL_KEY, obj::type, and pl::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 62 of file player.c.
References first_player, MAX_BUF, pl::next, pl::ob, and query_name().
Referenced by command_reply(), and list_players().
player* find_player_partial_name | ( | const char * | plname | ) |
Find a player by a partial name.
plname | name to match. |
Definition at line 84 of file player.c.
References first_player, obj::name, pl::next, pl::ob, and strncasecmp().
Referenced by cfapi_player_find(), command_follow(), command_stats(), command_teleport(), do_tell(), and process_players1().
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 2204 of file player.c.
References action_makes_visible(), apply_map_builder(), cast_spell(), obj::chosen_skill, obj::contr, control_golem(), obj::count, do_skill(), draw_ext_info(), fire_misc_object(), pl::golem_count, make_visible(), MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, NDI_UNIQUE, PLAYER, player_fire_bow(), range_bow, range_builder, range_golem, range_magic, range_misc, range_none, range_skill, pl::ranges, pl::shoottype, pl::spellparam, and obj::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 1922 of file player.c.
References add_refcount(), add_string(), AT_PHYSICAL, obj::attacktype, obj::below, BOW, bow_bestarrow, pl::bowtype, obj::chosen_skill, CLEAR_FLAG, obj::contr, obj::count, liv::dam, dam_bonus, liv::Dex, dex_bonus, obj::direction, draw_ext_info(), draw_ext_info_format(), FABS, find_arrow(), fix_object(), FLAG_NO_STRENGTH, FLAG_READY_BOW, free_object(), free_string(), get_map_flags(), GET_MAP_MOVE_BLOCK, get_split_ob(), liv::grace, liv::hp, insert_ob_in_map(), obj::inv, obj::level, llevError, LOG(), obj::magic, obj::map, MOVE_FLY_LOW, obj::move_on, obj::move_type, MOVE_WALK, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, obj::name, NDI_UNIQUE, obj::nrof, ob_process(), P_OUT_OF_MAP, play_sound_map(), PLAYER, QUERY_FLAG, obj::race, range_bow, pl::ranges, remove_ob(), SET_ANIMATION, set_owner(), obj::skill, obj::slaying, SOUND_TYPE_ITEM, liv::sp, obj::speed, obj::speed_left, obj::spellarg, obj::stats, liv::Str, strdup_local(), thaco_bonus, obj::type, update_ob_speed(), was_destroyed, liv::wc, obj::x, and obj::y.
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 2143 of file player.c.
References cast_spell(), obj::contr, drain_rod_charge(), drain_wand_charge(), draw_ext_info(), draw_ext_info_format(), FLAG_BEEN_APPLIED, liv::food, HORN, liv::hp, obj::inv, llevError, LOG(), MAX_BUF, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR, MSG_TYPE_COMMAND_FAILURE, obj::name, NDI_UNIQUE, play_sound_player_only(), query_base_name(), range_misc, pl::ranges, ROD, SET_FLAG, SOUND_TYPE_ITEM, SP_level_spellpoint_cost(), SPELL_HIGHEST, obj::stats, obj::type, and WAND.
Referenced by fire().
void fix_luck | ( | void | ) |
Fixes luck of players, slowly move it towards 0.
Definition at line 3661 of file player.c.
References change_luck(), obj::contr, first_player, pl::next, pl::ob, and pl::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 3645 of file player.c.
References obj::carrying, first_player, fix_object(), llevDebug, LOG(), obj::name, pl::next, pl::ob, and 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 1329 of file player.c.
References absdir(), CLEAR_FLAG, did_make_save(), rv_vector::direction, obj::enemy, FLAG_SCARED, get_rangevector(), liv::hp, obj::level, llevDebug, LOG(), obj::map, move_ob(), PREFER_LOW, random_roll(), and obj::stats.
Referenced by handle_newcs_player().
void get_name | ( | object * | op | ) |
Waiting for the player's name.
op | player. |
Definition at line 786 of file player.c.
References obj::contr, send_query(), pl::socket, ST_GET_NAME, pl::state, and pl::write_buf.
Referenced by add_player(), receive_play_again(), receive_player_name(), receive_player_password(), and wrong_password().
Finds the nearest visible player for some object.
mon | what object is searching a player. |
Definition at line 447 of file player.c.
References can_detect_enemy(), rv_vector::distance, first_friendly_object, first_player, FLAG_FREED, FLAG_FRIENDLY, llevDebug, LOG(), pl::next, oblnk::next, pl::ob, oblnk::ob, QUERY_FLAG, and remove_friendly_object().
Referenced by find_enemy(), and move_monster().
Ask the player for the password of the party she wants to join.
op | player. |
party | party op wishes to join. |
Definition at line 891 of file player.c.
References obj::contr, CS_QUERY_HIDEINPUT, llevError, LOG(), obj::name, pl::party_to_join, send_query(), pl::socket, ST_GET_PARTY_PASSWORD, pl::state, and pl::write_buf.
Referenced by command_party().
void get_password | ( | object * | op | ) |
Waiting for the player's password.
op | player. |
Definition at line 798 of file player.c.
References obj::contr, CS_QUERY_HIDEINPUT, send_query(), pl::socket, ST_GET_PASSWORD, pl::state, and pl::write_buf.
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 less bugfree and simpler.
p | if NULL, a new player structure is created, else p is recycled. |
Definition at line 258 of file player.c.
References add_string(), obj::arch, arch_to_object(), bow_normal, pl::bowtype, CLEAR_FLAG, clear_los(), clear_player(), archt::clone, obj::contr, obj::direction, pl::do_los, liv::exp, pl::explore, fatal(), first_map_path, first_player, FLAG_READY_SKILL, pl::gen_sp_armour, get_player_archetype(), pl::language, pl::last_resist, pl::last_skill_exp, pl::last_skill_ob, pl::last_speed, pl::last_stats, pl::last_weapon_sp, pl::last_weight, pl::listening, socket_struct::look_position, socket_struct::monitor_spells, obj::name, pl::next, pl::no_shout, NROFATTACKS, NUM_SKILLS, pl::ob, offsetof, OUT_OF_MEMORY, pl::outputs_count, pl::outputs_sync, pl::party, party_rejoin_if_exists, pl::peaceful, pet_normal, pl::petmode, obj::race, range_none, pl::rejoin_party, roll_stats(), obj::run_away, pl::savebed_map, pl::shoottype, pl::socket, obj::speed, obj::speed_left, ST_ROLL_STAT, pl::state, obj::stats, pl::Swap_First, pl::title, pl::unapply, unapply_nochoice, socket_struct::update_look, and liv::wc.
Referenced by add_player(), 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 422 of file player.c.
References archt::clone, first_archetype, llevError, LOG(), archt::next, PLAYER, and obj::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 688 of file player.c.
References AP_NOPRINT, obj::below, CLEAR_FLAG, create_treasure(), liv::exp, 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, FORCE, free_object(), GT_ONLY_GOOD, GT_STARTEQUIP, obj::inv, IS_ARMOR, IS_SHIELD, IS_WEAPON, obj::level, link_player_skills(), llevError, LOG(), manual_apply(), obj::name, need_identify(), obj::nrof, PLAYER, QUERY_FLAG, obj::randomitems, remove_ob(), SET_FLAG, SKILL, SPELL, SPELLBOOK, obj::stats, and obj::type.
Referenced by apply_changes_to_player(), and key_change_class().
|
static |
Create a text for a player's gravestobe.
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 2982 of file player.c.
References obj::contr, pl::killer, obj::level, MAX_BUF, obj::name, PLAYER, snprintf(), pl::title, and obj::type.
Referenced by kill_player().
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 2826 of file player.c.
References obj::contr, obj::count, obj::direction, draw_ext_info(), pl::fire_on, FLAG_MAKE_INVIS, FLAG_REMOVED, FLAG_SCARED, flee_player(), pl::golem_count, handle_client(), pl::hidden, obj::invisible, make_visible(), move_player(), MSG_TYPE_SPELL, MSG_TYPE_SPELL_END, NDI_UNIQUE, pticks, QUERY_FLAG, range_golem, pl::ranges, pl::run_on, pl::socket, and obj::speed_left.
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 3755 of file player.c.
References mapdef::darkness, freearr_x, freearr_y, get_map_flags(), has_carried_lights(), obj::map, P_BLOCKSVIEW, P_OUT_OF_MAP, obj::x, and obj::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 3731 of file player.c.
References obj::arch, obj::below, archt::clone, EXPERIENCE, FLAG_UNDEAD, obj::inv, PLAYER, QUERY_FLAG, obj::stats, obj::type, and liv::Wis.
Referenced by can_see_enemy(), and makes_invisible_to().
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 1156 of file player.c.
References add_statbonus(), add_string(), allowed_class(), obj::arch, pl::bed_x, pl::bed_y, obj::carrying, CLEAR_FLAG, archt::clone, obj::contr, copy_object(), create_treasure(), CS_QUERY_SINGLECHAR, draw_ext_info(), enter_exit(), esrv_new_player(), esrv_send_inventory(), esrv_update_item(), EVENT_BORN, EVENT_LOGIN, execute_global_event(), EXIT_PATH, EXIT_X, EXIT_Y, find_treasurelist(), first_map_ext_path, fix_object(), FLAG_WIZ, free_object(), free_string(), get_object(), get_player_archetype(), give_initial_items(), liv::grace, socket_struct::host, liv::hp, insert_ob_in_map(), link_player_skills(), llevDebug, Settings::localdir, LOG(), make_path_to_file(), obj::map, MAX_BUF, liv::maxhp, liv::maxsp, obj::msg, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_NEWPLAYER, obj::name, archt::name, obj::name_pl, NDI_BLUE, pl::orig_stats, play_again(), Settings::playerdir, pticks, obj::randomitems, remove_ob(), remove_statbonus(), pl::savebed_map, send_query(), SET_ANIMATION, settings, snprintf(), pl::socket, liv::sp, ST_PLAYING, start_info(), pl::state, obj::stats, pl::title, UP_OBJ_FACE, UPD_FACE, update_object(), obj::weight, obj::x, and obj::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 1278 of file player.c.
References check_score(), obj::contr, delete_character(), delete_map(), obj::direction, draw_ext_info(), draw_ext_info_format(), EVENT_REMOVE, execute_global_event(), first_map, FLAG_WAS_WIZ, pl::killer, Settings::localdir, MAX_BUF, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_LOGIN, MSG_TYPE_ADMIN_PLAYER, obj::name, NDI_ALL, NDI_DK_ORANGE, NDI_UNIQUE, mapdef::next, pl::own_title, pl::party, mapdef::path, play_again(), Settings::playerdir, QUERY_FLAG, remove_ob(), Settings::set_title, settings, snprintf(), ST_PLAYING, pl::state, terminate_all_pets(), 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 1079 of file player.c.
References add_statbonus(), CHA, CON, obj::contr, CS_QUERY_SINGLECHAR, DEX, draw_ext_info(), draw_ext_info_format(), FLAG_WIZ, INT, llevError, LOG(), obj::map, obj::msg, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_NEWPLAYER, NDI_BLUE, NDI_UNIQUE, play_again(), POW, roll_stats(), send_query(), SET_ANIMATION, SET_FLAG, short_stat_name, pl::socket, ST_CHANGE_CLASS, pl::state, STR, pl::Swap_First, swap_stat(), and WIS.
Referenced by reply_cmd().
void kill_player | ( | object * | op | ) |
When a player should die (lack of hp, food, etc), we call this.
If the player can not be saved (permadeath, no lifesave), this will take care of removing the player file.
Will remove diseases, apply death penalties, and so on.
Takes battleground into account.
op | player in jeopardy. |
Definition at line 3238 of file player.c.
References obj::above, add_string(), apply_death_exp_penalty(), arch_to_object(), obj::attacktype, Settings::balanced_stat_loss, BALSL_LOSS_CHANCE_RATIO, BALSL_MAX_LOSS_RATIO, BALSL_NUMBER_LOSSES_RATIO, pl::braced, change_attr_value(), check_score(), check_stat_bounds(), obj::contr, create_archetype(), cure_disease(), dead_player(), delete_character(), determine_god(), obj::direction, draw_ext_info(), draw_ext_info_format(), Settings::emergency_mapname, Settings::emergency_x, Settings::emergency_y, enter_player_savebed(), EVENT_DEATH, EVENT_PLAYER_DEATH, execute_event(), execute_global_event(), liv::exp, pl::explore, find_archetype(), fix_object(), FLAG_APPLIED, FLAG_UNIQUE, FLAG_WAS_WIZ, FLESH, liv::food, FORCE_NAME, FREE_AND_COPY, free_object(), free_string(), get_attr_value(), GET_MAP_OB, pl::golem_count, liv::grace, gravestone_text(), liv::hp, insert_ob_in_map(), insert_ob_in_ob(), obj::inv, is_in_shop(), pl::killer, obj::level, loot_object(), lose_msg, obj::map, pl::maplevel, obj::material, obj::materialname, MAX, MAX_BUF, liv::maxgrace, liv::maxhp, liv::maxsp, obj::msg, MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_BAD_EFFECT_END, MSG_TYPE_ATTRIBUTE_GOD, MSG_TYPE_ATTRIBUTE_STAT_LOSS, MSG_TYPE_VICTIM, MSG_TYPE_VICTIM_DIED, obj::name, obj::name_pl, NDI_ALL, NDI_NAVY, NDI_UNIQUE, Settings::not_permadeth, NROFATTACKS, op_on_battleground(), pl::orig_stats, pl::own_title, pl::party, play_again(), play_sound_player_only(), PREFER_LOW, present_arch_in_ob(), QUERY_FLAG, random_roll(), range_golem, pl::ranges, remove_friendly_object(), remove_ob(), remove_unpaid_objects(), obj::resist, Settings::resurrection, save_life(), save_player(), SCRIPT_FIX_ALL, SET_FLAG, Settings::set_title, settings, snprintf(), SOUND_TYPE_LIVING, liv::sp, obj::speed, obj::speed_left, SPELL_EFFECT, Settings::stat_loss_on_death, obj::stats, pl::title, transfer_ob(), TRUE, obj::type, obj::value, obj::x, and obj::y.
Referenced by check_login(), deep_swamp_type_process(), and kill_object().
|
static |
Grab and destroy some treasure.
op | object to loot. |
Definition at line 3195 of file player.c.
References apply_container(), obj::below, obj::container, CONTAINER, EXPERIENCE, FLAG_NO_DROP, FLAG_STARTEQUIP, FLAG_UNIQUE, free_object(), get_split_ob(), insert_ob_in_map(), obj::inv, obj::invisible, obj::map, obj::nrof, QUERY_FLAG, remove_ob(), obj::type, obj::x, and obj::y.
Referenced by kill_player().
void make_visible | ( | object * | op | ) |
Makes an object visible again.
op | what to make visible. |
Definition at line 3712 of file player.c.
References obj::contr, FREE_AND_CLEAR_STR, obj::hide, pl::invis_race, obj::invisible, PLAYER, pl::tmp_invis, obj::type, UP_OBJ_FACE, and update_object().
Referenced by attack_ob_simple(), attempt_steal(), can_detect_enemy(), can_see_enemy(), do_hidden_move(), fire(), handle_newcs_player(), hide(), move_player_attack(), and player_attack_door().
int move_player | ( | object * | op, |
int | dir | ||
) |
Player gave us a direction, check whether to move or fire.
op | player. |
dir | direction to move/fire. |
Definition at line 2741 of file player.c.
References absdir(), animate_object(), check_pick(), obj::contr, obj::direction, do_hidden_move(), obj::facing, fire(), pl::fire_on, FLAG_CONFUSED, obj::hide, mapdef::in_memory, llevError, LOG(), obj::map, MAP_IN_MEMORY, move_player_attack(), QUERY_FLAG, pl::run_on, obj::speed_left, obj::state, pl::transport, and turn_transport().
Referenced by cfapi_object_move(), command_fire(), command_run(), handle_newcs_player(), move_internal(), move_player_mover(), 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 2419 of file player.c.
References obj::above, action_makes_visible(), pl::braced, obj::contr, DOOR, draw_ext_info(), obj::enemy, FLAG_ALIVE, FLAG_CAN_ROLL, FLAG_FRIENDLY, FLAG_MONSTER, FLAG_UNAGGRESSIVE, FLAG_WIZ, freearr_x, freearr_y, get_map_from_coord(), GET_MAP_OB, get_owner(), pl::has_hit, obj::head, obj::hide, liv::hp, LOCKED_DOOR, liv::luck, make_visible(), obj::map, mon, move_ob(), MSG_TYPE_ATTACK, MSG_TYPE_ATTACK_NOATTACK, op_on_battleground(), out_of_map(), OUT_OF_REAL_MAP, pl::party, pl::peaceful, play_sound_map(), PLAYER, player_attack_door(), push_ob(), QUERY_FLAG, recursive_roll(), skill_attack(), SOUND_TYPE_LIVING, obj::speed, obj::speed_left, obj::stats, pl::tmp_invis, pl::transport, obj::type, pl::weapon_sp, obj::x, and obj::y.
Referenced by move_player().
Checks if the given object op (usually a player) is standing on a valid battleground-tile.
Function returns TRUE/FALSE. If true x, y returns the battleground -exit-coord. (and if x, y not NULL)
19 March 2005 - josh@ modifed to check if the battleground also has slaying, maxhp, and maxsp set and if those are all set and the player has a marker that matches the slaying send them to a different x, y Default is to do the same as before, so only people wanting to have different points need worry about this woos world .net
28 July 2008 - Modified to allow other archetypes than fingers as trophies. If other_arch is specified in the battleground floor, then that archetype will be used instead of the default ("finger"). -R.Q.
op | object to check. | |
[out] | x | |
[out] | y | if not null and if on battleground (return 1), will contain the exit coordinates for the battleground. |
[out] | trophy | if not null and if on battleground (return 1), will contain a pointer to the archetype that can be collected by the winner |
Definition at line 4002 of file player.c.
References BATTLEGROUND, obj::below, EXIT_ALT_X, EXIT_ALT_Y, EXIT_PATH, EXIT_X, EXIT_Y, find_archetype(), FLAG_IS_FLOOR, FLAG_NO_PICK, FORCE, obj::inv, obj::name, obj::other_arch, QUERY_FLAG, obj::slaying, and obj::type.
Referenced by hit_with_one_attacktype(), infect_object(), kill_object(), kill_player(), move_player_attack(), 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 556 of file player.c.
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(), obj::map, MAX, MAX_SPACES, MOVE_ALL, OB_TYPE_MOVE_BLOCK, P_IS_ALIVE, P_OUT_OF_MAP, obj::x, and obj::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 1852 of file player.c.
References obj::above, obj::chosen_skill, liv::Dex, die_roll(), find_arrow(), find_better_arrow(), FLAG_ALIVE, freearr_x, freearr_y, get_map_flags(), GET_MAP_MOVE_BLOCK, GET_MAP_OB, obj::head, obj::level, obj::map, MOVE_FLY_LOW, P_BLOCKSVIEW, P_IS_ALIVE, P_OUT_OF_MAP, PREFER_LOW, QUERY_FLAG, obj::stats, obj::x, and obj::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 810 of file player.c.
References obj::chosen_skill, obj::contr, CS_QUERY_SINGLECHAR, FLAG_REMOVED, obj::map, QUERY_FLAG, remove_ob(), send_query(), pl::socket, ST_PLAY_AGAIN, and pl::state.
Referenced by apply_savebed(), command_shutdown(), key_change_class(), key_confirm_quit(), key_roll_stat(), kill_player(), 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 2361 of file player.c.
References action_makes_visible(), AT_PHYSICAL, decrease_ob, DOOR, draw_ext_info(), draw_ext_info_format(), obj::env, esrv_update_item(), find_key(), hit_player(), HUGE_BUF, obj::inv, LOCKED_DOOR, make_visible(), obj::msg, MSG_TYPE_ATTACK, MSG_TYPE_ATTACK_NOKEY, MSG_TYPE_ITEM, MSG_TYPE_ITEM_REMOVE, NDI_BROWN, NDI_NAVY, NDI_UNIQUE, play_sound_map(), query_short_name(), remove_locked_door(), RUNE, SOUND_TYPE_GROUND, spring_trap(), TRAP, obj::type, and UPD_WEIGHT.
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 3906 of file player.c.
References obj::arch, pl::blocked_los, archt::clone, obj::contr, rv_vector::distance_x, rv_vector::distance_y, FABS, get_rangevector(), obj::head, llevError, LOG(), socket_struct::mapx, socket_struct::mapy, obj::more, PLAYER, pl::socket, obj::type, obj::x, and obj::y.
Referenced by 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 2106 of file player.c.
References absdir(), bow_bestarrow, bow_n, bow_nw, bow_spreadshot, bow_threewide, pl::bowtype, obj::contr, fire_bow(), freearr_x, freearr_y, pick_arrow_target(), obj::race, range_bow, pl::ranges, similar_direction(), obj::x, and obj::y.
Referenced by fire().
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 4221 of file player.c.
References range_none, range_size, pl::ranges, and pl::shoottype.
Referenced by become_follower(), check_special_prayers(), and do_forget_spell().
int playername_ok | ( | const char * | cp | ) |
Is the player name valid.
cp | name to test. |
Definition at line 230 of file player.c.
Referenced by check_name().
void receive_play_again | ( | object * | op, |
char | key | ||
) |
Player replied to play again / disconnect.
op | player. |
key | received choice. |
Definition at line 839 of file player.c.
References add_friendly_object(), add_refcount(), add_string(), obj::contr, draw_ext_info(), FREE_AND_CLEAR_STR, free_object(), get_name(), get_player(), leave(), MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_LOGIN, obj::name, obj::name_pl, NDI_UNIQUE, pl::ob, pl::password, play_again(), remove_friendly_object(), and set_first_map().
Referenced by 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 2943 of file player.c.
References obj::below, FLAG_UNPAID, free_object(), insert_ob_in_map(), obj::inv, obj::map, QUERY_FLAG, remove_ob(), obj::x, and obj::y.
Referenced by check_login(), and kill_player().
void roll_again | ( | object * | op | ) |
Ask the player what to do with the statistics.
op | player. |
Definition at line 1006 of file player.c.
References obj::contr, CS_QUERY_SINGLECHAR, esrv_new_player(), send_query(), and pl::socket.
Referenced by receive_player_password().
int roll_stat | ( | void | ) |
This rolls four 1-6 rolls and sums the best 3 of the 4.
Definition at line 908 of file player.c.
Referenced by roll_stats().
void roll_stats | ( | object * | op | ) |
Roll the initial player's statistics.
op | player to roll for. |
Definition at line 932 of file player.c.
References liv::ac, liv::Cha, liv::Con, obj::contr, liv::Dex, liv::exp, fix_object(), liv::grace, liv::hp, liv::Int, obj::level, pl::levgrace, pl::levhp, pl::levsp, liv::maxgrace, liv::maxhp, liv::maxsp, pl::orig_stats, liv::Pow, roll_stat(), liv::sp, obj::stats, liv::Str, and liv::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 2899 of file player.c.
References obj::below, CLEAR_FLAG, draw_ext_info_format(), enter_player_savebed(), fix_object(), FLAG_APPLIED, FLAG_LIFESAVE, liv::food, free_object(), liv::hp, obj::inv, llevError, LOG(), MAX_BUF, liv::maxhp, MSG_TYPE_ITEM, MSG_TYPE_ITEM_REMOVE, NDI_UNIQUE, play_sound_map(), QUERY_FLAG, query_name(), remove_ob(), SOUND_TYPE_ITEM, and obj::stats.
Referenced by kill_player().
void send_news | ( | const object * | op | ) |
Send the news to a player.
op | player to send to. |
Definition at line 176 of file player.c.
References close_and_delete(), Settings::confdir, draw_ext_info_format(), HUGE_BUF, llevDebug, LOG(), MAX_BUF, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, NDI_GREEN, NDI_UNIQUE, Settings::news, open_and_uncompress(), settings, snprintf(), 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 142 of file player.c.
References close_and_delete(), Settings::confdir, draw_ext_info(), HUGE_BUF, llevDebug, LOG(), MAX_BUF, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_RULES, NDI_GREEN, NDI_UNIQUE, open_and_uncompress(), Settings::rules, settings, and snprintf().
Referenced by add_player(), and command_rules().
|
static |
This loads the first map an puts the player on it.
op | player to put on map. |
Definition at line 368 of file player.c.
References obj::contr, enter_exit(), first_map_path, pl::maplevel, obj::x, and obj::y.
Referenced by add_player(), and receive_play_again().
int stand_near_hostile | ( | object * | who | ) |
Determine if who is standing near a hostile creature.
who | object to check. |
Definition at line 3837 of file player.c.
References obj::above, obj::contr, FLAG_FRIENDLY, FLAG_MONSTER, FLAG_UNAGGRESSIVE, FLAG_WIZ, freearr_x, freearr_y, get_map_flags(), GET_MAP_MOVE_BLOCK, GET_MAP_OB, pl::hidden, obj::map, OB_TYPE_MOVE_BLOCK, P_OUT_OF_MAP, PLAYER, QUERY_FLAG, obj::type, obj::x, and obj::y.
Referenced by attempt_hide().
|
static |
Player finishes selecting what stats to swap.
op | player. |
Swap_Second | second statistic to swap. |
Definition at line 1020 of file player.c.
References liv::ac, liv::Cha, liv::Con, obj::contr, liv::Dex, draw_ext_info_format(), liv::exp, fix_object(), get_attr_value(), liv::grace, liv::hp, liv::Int, obj::level, pl::levgrace, pl::levhp, pl::levsp, llevError, LOG(), liv::maxgrace, liv::maxhp, liv::maxsp, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_NEWPLAYER, NDI_UNIQUE, pl::orig_stats, liv::Pow, set_attr_value(), short_stat_name, liv::sp, obj::stats, liv::Str, pl::Swap_First, and liv::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 2639 of file player.c.
References animate_object(), obj::below, obj::contr, obj::direction, pl::do_los, esrv_map_scroll(), obj::facing, freearr_x, freearr_y, insert_ob_in_map(), insert_ob_in_map_at(), obj::inv, socket_struct::look_position, obj::map, ob_blocked(), PLAYER, remove_ob(), pl::socket, TRANSPORT, obj::type, socket_struct::update_look, update_transport_block(), obj::x, and obj::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 2711 of file player.c.
References absdir(), animate_object(), obj::direction, obj::facing, get_ob_key_value(), TRANSPORT, turn_one_transport(), and obj::type.
Referenced by 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 2594 of file player.c.
References get_multi_size(), obj::more, and obj::move_type.
Referenced by turn_one_transport().