| 1 | /** |
| 2 | * @file |
| 3 | * Player-specific structures. |
| 4 | */ |
| 5 | |
| 6 | #ifndef PLAYER_H |
| 7 | #define PLAYER_H |
| 8 | |
| 9 | /** |
| 10 | * What range is currently selected by the player. |
| 11 | * |
| 12 | * Wand/rod/horn rolled into range_misc. They all use the same body location |
| 13 | * anyways. |
| 14 | */ |
| 15 | typedef enum rangetype { |
| 16 | range_bottom = -1, /**< Minimum, exclusive, value. */ |
| 17 | range_none = 0, /**< No range selected. */ |
| 18 | range_bow = 1, /**< Bow. */ |
| 19 | range_magic = 2, /**< Spells. */ |
| 20 | range_misc = 3, /**< Misc items. */ |
| 21 | range_golem = 4, /**< Control golem. */ |
| 22 | range_skill = 5, /**< Use skill. */ |
| 23 | range_builder = 6, /**< Map builder. */ |
| 24 | range_size = 7 /**< Maximum, exclusive, value. */ |
| 25 | } rangetype; |
| 26 | |
| 27 | /** Bow firing mode.*/ |
| 28 | typedef enum _bowtype { |
| 29 | bow_normal = 0, /**< Standard mode, one random arrow. */ |
| 30 | bow_threewide = 1, /**< Fire three arrows in the same direction. */ |
| 31 | bow_spreadshot = 2, /**< Fire three arrows in a cone. */ |
| 32 | bow_n = 3, /**< Fire north whatever the facing direction. Must stay at 3. */ |
| 33 | bow_ne = 4, /**< Fire north-east whatever the facing direction. */ |
| 34 | bow_e = 5, /**< Fire east whatever the facing direction. */ |
| 35 | bow_se = 6, /**< Fire south-east whatever the facing direction. */ |
| 36 | bow_s = 7, /**< Fire south whatever the facing direction. */ |
| 37 | bow_sw = 8, /**< Fire south-west whatever the facing direction. */ |
| 38 | bow_w = 9, /**< Fire west whatever the facing direction. */ |
| 39 | bow_nw = 10, /**< Fire north-west whatever the facing direction. */ |
| 40 | bow_bestarrow = 11 /**< Try to find an arrow matching the target. */ |
| 41 | } bowtype_t; |
| 42 | |
| 43 | /** Petmode. */ |
| 44 | typedef enum _petmode { |
| 45 | pet_normal = 0, /**< Standard mode/ */ |
| 46 | pet_sad = 1, /**< Try to find enemies. */ |
| 47 | pet_defend = 2, /**< Stay close to the owner. */ |
| 48 | pet_arena = 3 /**< Attack other players in arena. */ |
| 49 | } petmode_t; |
| 50 | |
| 51 | /** How to use keys. */ |
| 52 | typedef enum usekeytype { |
| 53 | key_inventory = 0, /**< Only use keys in inventory. */ |
| 54 | keyrings = 1, /**< Use keys in inventory and active key rings. */ |
| 55 | containers = 2 /**< Use keys in inventory and active containers. */ |
| 56 | } usekeytype; |
| 57 | |
| 58 | /** |
| 59 | * This is used to control what to do when we need to unapply |
| 60 | * an object before we can apply another one. |
| 61 | */ |
| 62 | typedef enum unapplymode { |
| 63 | unapply_nochoice = 0, /**< Will unapply objects when there no choice to unapply. */ |
| 64 | unapply_never = 1, /**< Will not unapply objects automatically. */ |
| 65 | unapply_always = 2 /**< Will unapply whatever is necessary - this goes beyond |
| 66 | * no choice - if there are multiple ojbect of the same type |
| 67 | * that need to be unapplied, there is no way for the player |
| 68 | * to control which of these will be unapplied. */ |
| 69 | } unapplymode; |
| 70 | |
| 71 | /** |
| 72 | * This stores, for a spell a player knows, the last sp/gr/dam information sent to client. |
| 73 | */ |
| 74 | typedef struct client_spell { |
| 75 | object *spell; /**< Spell object this structure is about. */ |
| 76 | int16_t last_sp; /**< Last spell cost. */ |
| 77 | int16_t last_grace; /**< Last grace cost. */ |
| 78 | int16_t last_dam; /**< Last damage. */ |
| 79 | struct client_spell *next; /**< Next spell information. */ |
| 80 | } client_spell; |
| 81 | |
| 82 | /** |
| 83 | * Whether to rejoin party at login or not. |
| 84 | */ |
| 85 | typedef enum party_rejoin_mode { |
| 86 | party_rejoin_no = 0, /**< Don't rejoin. */ |
| 87 | party_rejoin_if_exists = 1, /**< Rejoin if party exists. */ |
| 88 | party_rejoin_always = 2 /**< If party doesn't exist, form it. */ |
| 89 | } party_rejoin_mode; |
| 90 | |
| 91 | /** One player. */ |
| 92 | typedef struct pl { |
| 93 | struct pl *next; /**< Pointer to next player, NULL if this is last. */ |
| 94 | socket_struct socket; /**< Socket information for this player. See the page on |
| 95 | * @ref page_connection "the login process" for a description of its use. */ |
| 96 | char maplevel[MAX_BUF]; /**< On which level is the player? */ |
| 97 | char savebed_map[MAX_BUF]; /**< Map where player will respawn after death. */ |
| 98 | int16_t bed_x, bed_y; /**< x,y - coordinates of respawn (savebed). */ |
| 99 | rangetype shoottype; /**< Which range-attack is being used by player. */ |
| 100 | char spellparam[MAX_BUF]; /**< What param to add to spells. */ |
| 101 | bowtype_t bowtype; /**< Which firemode? */ |
| 102 | petmode_t petmode; /**< Which petmode? */ |
| 103 | object *ranges[range_size]; /**< Object for each range. Set up in fix_object(). Note |
| 104 | * That not all are used, it is just nice to map this 1:1 |
| 105 | * With the range names. */ |
| 106 | uint32_t golem_count; /**< To track the golem. */ |
| 107 | usekeytype usekeys; /**< Method for finding keys for doors. */ |
| 108 | unapplymode unapply; /**< Method for auto unapply. */ |
| 109 | uint32_t count; /**< Any numbers typed before a command. */ |
| 110 | uint32_t mode; /**< Mode of player for pickup. */ |
| 111 | |
| 112 | int16_t digestion; /**< Any bonuses/penalties to digestion. */ |
| 113 | int16_t gen_hp; /**< Bonuses to regeneration speed of hp. */ |
| 114 | int16_t gen_sp; /**< Bonuses to regeneration speed of sp. */ |
| 115 | int16_t gen_sp_armour; /**< Penalty to sp regen from armour. */ |
| 116 | int16_t gen_grace; /**< Bonuses to regeneration speed of grace. */ |
| 117 | int16_t item_power; /**< Total item power of objects equipped. */ |
| 118 | uint8_t state; /**< Input state of the player (name, password, etc). See the page on |
| 119 | * @ref page_connection "the login process" for a description of its use. */ |
| 120 | uint8_t listening; /**< Which priority will be used in info_all. */ |
| 121 | int8_t last_level; /**< Last level we sent to client. */ |
| 122 | |
| 123 | /* Try to put all the bitfields together - saves some small amount of memory */ |
| 124 | uint32_t braced:1; /**< Will not move if braced, only attack. */ |
| 125 | uint32_t tmp_invis:1; /**< Will invis go away when we attack? */ |
| 126 | uint32_t do_los:1; /**< If true, need to call update_los() in draw(), and clear. */ |
| 127 | uint32_t fire_on:1; /**< Player should fire object, not move. */ |
| 128 | uint32_t run_on:1; /**< Player should keep moving in dir until run is off. */ |
| 129 | uint32_t has_hit:1; /**< If set, weapon_sp instead of speed will count. */ |
| 130 | uint32_t name_changed:1; /**< If true, the player has set a name. */ |
| 131 | uint32_t peaceful:1; /**< If set, won't attack friendly creatures. */ |
| 132 | uint32_t hidden:1; /**< If True, player (DM) is hidden from view. */ |
| 133 | uint32_t no_shout:1; /**< if True, player is *not *able to use shout command. */ |
| 134 | uint32_t has_directory:1; /**< If 0, the player was not yet saved, its directory doesn't exist. */ |
| 135 | const char *invis_race; /**< What race invisible to? */ |
| 136 | |
| 137 | object *last_skill_ob[MAX_SKILLS]; /**< Exp objects sent to client. */ |
| 138 | int64_t last_skill_exp[MAX_SKILLS]; /**< Last exp sent to client. If != exp. obj update client. */ |
| 139 | |
| 140 | float last_weapon_sp; /**< if diff than weapon_sp, update client. */ |
| 141 | uint16_t last_flags; /**< Fire/run on flags for last tick. */ |
| 142 | int32_t last_weight; /**< Last weight as sent to client; -1 means do not send weight. */ |
| 143 | int32_t last_weight_limit; /**< Last weight limit transmitted to client. */ |
| 144 | uint32_t last_path_attuned; /**< Last spell attunment sent to client. */ |
| 145 | uint32_t last_path_repelled; /**< Last spell repelled sent to client. */ |
| 146 | uint32_t last_path_denied; /**< Last spell denied sent to client. */ |
| 147 | int swap_first; /**< First stat player has selected to swap. */ |
| 148 | living orig_stats; /**< Permanent real stats of player. */ |
| 149 | living last_stats; /**< Last stats as sent to client. */ |
| 150 | living last_orig_stats; /**< Last permanent stats sent to client. */ |
| 151 | living last_race_stats; /**< Last race stats sent to the client. */ |
| 152 | living applied_stats; /**< Stat changes due to gear or skills. */ |
| 153 | living last_applied_stats; /**< Last applied stats sent to the client. */ |
| 154 | float last_speed; /**< Last speed as sent to client. */ |
| 155 | int16_t last_resist[NROFATTACKS]; /**< last resist values sent to client. */ |
| 156 | int16_t last_golem_hp; /**< Last golem hp value sent to the client. */ |
| 157 | int16_t last_golem_maxhp; /**< Last golem max hp value sent to the client. */ |
| 158 | object *ob; /**< The object representing the player. */ |
| 159 | int8_t blocked_los[MAP_CLIENT_X][MAP_CLIENT_Y]; /**< Array showing what spaces |
| 160 | * the player can see. For maps smaller than |
| 161 | * MAP_CLIENT_.., the upper left is used. */ |
| 162 | |
| 163 | char own_title[MAX_NAME]; /**< Title the player has chosen for themself. |
| 164 | * Note that for dragon players, this is filled in for them. */ |
| 165 | char title[BIG_NAME]; /**< Default title, like fighter, wizard, etc. */ |
| 166 | |
| 167 | int8_t levhp[11]; /**< What hp bonus the player gained on that level. */ |
| 168 | int8_t levsp[11]; /**< What sp bonus the player gained on that level. */ |
| 169 | int8_t levgrace[11]; /**< What grace bonus the player gained on that level. */ |
| 170 | |
| 171 | char killer[BIG_NAME]; /**< Who killed this player. */ |
| 172 | char last_tell[MAX_NAME]; /**< last player that told you something [mids 01/14/2002]. */ |
| 173 | |
| 174 | char write_buf[MAX_BUF]; /**< Holds arbitrary input from client. */ |
| 175 | char input_buf[MAX_BUF]; /**< Holds command to run. */ |
| 176 | char password[16]; /**< 2 (seed) + 11 (crypted) + 1 (EOS) + 2 (safety) = 16 */ |
| 177 | char new_password[16]; /**< 2 (seed) + 11 (crypted) + 1 (EOS) + 2 (safety) = 16 */ |
| 178 | |
| 179 | int16_t encumbrance; /**< How much our player is encumbered. */ |
| 180 | #ifdef SAVE_INTERVAL |
| 181 | time_t last_save_time; /**< Last time the player was saved. */ |
| 182 | #endif /* SAVE_INTERVAL */ |
| 183 | #ifdef AUTOSAVE |
| 184 | uint32_t last_save_tick; /**< Last tick the player was saved. */ |
| 185 | #endif |
| 186 | partylist *party; /**< Party this player is part of. */ |
| 187 | partylist *party_to_join; /**< Used when player wants to join a party |
| 188 | * but we will have to get password first |
| 189 | * so we have to remember which party to |
| 190 | * join. */ |
| 191 | party_rejoin_mode rejoin_party; /**< Whether to rejoin or not party at login. */ |
| 192 | char search_str[MAX_BUF]; /**< Item we are looking for. */ |
| 193 | uint32_t mark_count; /**< Count of marked object. */ |
| 194 | object *mark; /**< Marked object. */ |
| 195 | object *transport; /**< Transport the player is in. */ |
| 196 | client_spell *spell_state; /**< Spell information sent to client. */ |
| 197 | /* Special DM fields */ |
| 198 | tag_t *stack_items; /**< Item stack for patch/dump/... commands. */ |
| 199 | sstring followed_player; /**< Player the DM is following. */ |
| 200 | int stack_position; /**< Current stack position, 0 for no item. */ |
| 201 | int language; /**< The language the player wishes to use. */ |
| 202 | const char *unarmed_skill; /**< Prefered skill to use in unarmed combat */ |
| 203 | uint32_t ticks_played; /**< How many ticks this player has played */ |
| 204 | } player; |
| 205 | |
| 206 | /** |
| 207 | * @defgroup FIND_PLAYER_xxx Flags to search players through find_player(). |
| 208 | * Those flag control what player should be returned. |
| 209 | */ |
| 210 | /*@{*/ |
| 211 | |
| 212 | #define FIND_PLAYER_PARTIAL_NAME 0x1 /**< Find on partial name. */ |
| 213 | #define FIND_PLAYER_NO_HIDDEN_DM 0x2 /**< Don't find hidden DMs. */ |
| 214 | |
| 215 | /*@}*/ |
| 216 | |
| 217 | /** |
| 218 | * @defgroup ADD_PLAYER_xxx Flags - flags passed to add_player() |
| 219 | * to control behavior |
| 220 | */ |
| 221 | /*@{*/ |
| 222 | #define ADD_PLAYER_NEW 0x1 /**< Name/password provided, so skip to roll stats */ |
| 223 | #define ADD_PLAYER_NO_MAP 0x2 /**< Do not set the first map */ |
| 224 | #define ADD_PLAYER_NO_STATS_ROLL 0x4 /**< Stats provided from client */ |
| 225 | /*@}*/ |
| 226 | |
| 227 | #endif /* PLAYER_H */ |