Atrinik Server  4.0
player.h
Go to the documentation of this file.
1 /*************************************************************************
2  * Atrinik, a Multiplayer Online Role Playing Game *
3  * *
4  * Copyright (C) 2009-2014 Alex Tokar and Atrinik Development Team *
5  * *
6  * Fork from Crossfire (Multiplayer game for X-windows). *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the Free Software *
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
21  * *
22  * The author can be reached at admin@atrinik.org *
23  ************************************************************************/
24 
30 #ifndef PLAYER_H
31 #define PLAYER_H
32 
33 #include <decls.h>
34 #include <attack.h>
35 
37 typedef struct _level_color {
39  int green;
40 
42  int blue;
43 
45  int yellow;
46 
48  int orange;
49 
51  int red;
52 
54  int purple;
55 } _level_color;
56 
58 enum {
71 };
72 
77 #define PLAYER_AFLAG_FIGHT 1
78 
83 #define PLAYER_AFLAG_ENEMY 2
84 
85 #define PLAYER_AFLAG_ADDFRAME 4
86 
89 #define MAX_QUICKSLOT 32
90 
92 #define PLAYER_PATH_MAX_FAILS 15
93 
94 #define PLAYER_TESTING_NAME1 "Tester"
95 #define PLAYER_TESTING_NAME2 "Tester Testington"
96 
97 #define ACCOUNT_TESTING_NAME "tester"
98 
99 #define PLAYER_REGEN_HP_RATE 2000.0
100 #define PLAYER_REGEN_SP_RATE 1200.0
101 
102 #define PLAYER_REGEN_MODIFIER 10.0
103 #define PLAYER_REGEN_MODIFIER_MAX 10.0
104 
106 typedef struct player_path {
108  struct player_path *next;
109 
112 
114  int16_t x;
115 
117  int16_t y;
118 
124  uint8_t fails;
125 } player_path;
126 
127 #define SKILL_LEVEL(_pl, _skill) ((_pl)->skill_ptr[(_skill)] ? (_pl)->skill_ptr[(_skill)]->level : 1)
128 
134  shstr *name;
135  double reputation;
136  UT_hash_handle hh;
137 };
138 
140 struct pl_player {
142  struct pl_player *prev;
143 
145  struct pl_player *next;
146 
149 
150  /* Everything below will be cleared by memset() in get_player(). */
151 
153  char maplevel[MAX_BUF];
154 
156  char quick_name[MAX_BUF];
157 
159  char savebed_map[MAX_BUF];
160 
162  char *killer;
163 
166 
169 
171  char map_info_name[HUGE_BUF];
172 
174  char map_info_music[HUGE_BUF];
175 
177  char map_info_weather[MAX_BUF];
178 
183 
185  object *ob;
186 
188  object *target_object;
189 
191  object *equipment[PLAYER_EQUIP_MAX];
192 
195 
197  object *mark;
198 
200  object *map_below;
201 
203  object *map_above;
204 
206  object *container;
207 
210 
213 
216 
218  char target_hp;
219 
221  int bed_x;
222 
224  int bed_y;
225 
230  int blocked_los[MAP_CLIENT_X][MAP_CLIENT_Y];
231 
234 
237 
240 
243 
246 
249 
252 
255 
257  int64_t fame;
258 
259  uint32_t action_attack;
260 
263 
266 
268  double last_speed;
269 
272 
274  unsigned char last_level;
275 
277  signed char digestion;
278 
280  signed char gen_sp_armour;
281 
283  signed char gen_hp;
284 
286  signed char gen_sp;
287 
289  unsigned int run_on : 1;
290 
292  unsigned int run_on_dir : 3;
293 
294 #ifdef AUTOSAVE
295 
296  long last_save_tick;
297 #endif
298 
301 
302 #ifdef SAVE_INTERVAL
303 
304  time_t last_save_time;
305 #endif
306 
309 
311  uint32_t container_count;
312 
314  uint32_t mark_count;
315 
318 
320  uint64_t stat_deaths;
321 
323  uint64_t stat_kills_mob;
324 
326  uint64_t stat_kills_pvp;
327 
330 
333 
335  uint64_t stat_hp_regen;
336 
338  uint64_t stat_sp_regen;
339 
342 
345 
348 
351 
354 
357 
360 
363 
365  uint64_t stat_time_afk;
366 
369 
372 
375 
377  uint64_t stat_books_read;
378 
381 
384 
387 
389  uint64_t stat_exp_gained;
390 
392  uint64_t stat_exp_lost;
393 
396 
399 
402 
405 
408 
411 
413  uint64_t stat_afk_used;
414 
417 
420 
423 
426 
432 
435 
438 
440  uint32_t update_los : 1;
441 
443  uint32_t afk : 1;
444 
446  uint32_t count;
447 
450 
455 
460 
465 
469  uint32_t last_equipment[PLAYER_EQUIP_MAX];
470 
472  uint16_t last_flags;
473 
476 
479 
481  uint16_t gen_client_hp;
482 
484  uint16_t gen_client_sp;
485 
487  uint16_t last_gen_hp;
488 
490  uint16_t last_gen_sp;
491 
494 
496  uint16_t anim_flags;
497 
499  int16_t item_power;
500 
503 
505  int16_t last_ranged_wc;
506 
507  int16_t dam_bonus;
508 
511 
513  uint8_t last_gender;
514 
516  uint8_t no_chat;
517 
519  uint8_t last_party_hp;
520 
522  uint8_t last_party_sp;
523 
525  uint8_t tcl;
526 
528  uint8_t tgm;
529 
531  uint8_t tli;
532 
534  uint8_t tls;
535 
537  uint8_t tsi;
538 
543  uint8_t combat;
544 
549  uint8_t combat_force;
550 
553 
556 
559 
562 
566  char player_reply[64];
567 
569  char afk_auto_reply[MAX_BUF];
570 
571  object *talking_to;
573 
575 
577 };
578 
579 /* Prototypes */
580 
581 mempool_struct *pool_player;
582 
583 void
584 player_init(void);
585 void
586 player_deinit(void);
587 void
589 player *
590 find_player(const char *plname);
591 player *
592 find_player_sh(shstr *plname);
593 void
594 display_motd(object *op);
595 void
596 free_player(player *pl);
597 void
598 give_initial_items(object *pl, treasure_list_t *items);
599 int
601 void
602 kill_player(object *op);
603 void
604 cast_dust(object *op, object *throw_ob, int dir);
605 int
606 pvp_area(object *attacker, object *victim);
607 object *
608 find_skill(object *op, int skillnr);
609 int
610 player_can_carry(object *pl, uint32_t weight);
611 void
612 player_path_add(player *pl, mapstruct *map, int16_t x, int16_t y);
613 void
615 void
618 player_faction_create(player *pl, shstr *name);
619 void
622 player_faction_find(player *pl, shstr *name);
623 void
624 player_faction_update(player *pl, shstr *name, double reputation);
625 double
627 char *
628 player_sanitize_input(char *str);
629 void
630 player_cleanup_name(char *str);
631 object *
632 find_marked_object(object *op);
633 void
634 examine(object *op, object *tmp, StringBuffer *sb_capture);
635 int
636 sack_can_hold(object *pl, object *sack, object *op, int nrof);
637 void
638 pick_up(object *op, object *alt, int no_mevent);
639 void
640 put_object_in_sack(object *op, object *sack, object *tmp, long nrof);
641 void
642 drop_object(object *op, object *tmp, long nrof, int no_mevent);
643 void
644 drop(object *op, object *tmp, int no_mevent);
645 char *
646 player_make_path(const char *name, const char *ext);
647 int
648 player_exists(const char *name);
649 void
650 player_save(object *op);
651 object *
652 player_get_dummy(const char *name, const char *host);
653 object *
654 player_find_spell(object *op, spell_struct *spell);
655 void
656 player_set_talking_to(player *pl, object *npc);
657 const char *
659 void
660 player_set_killer(player *pl, const char *killer);
661 void
663 void
664 player_login(socket_struct *ns, const char *name, struct archetype *at);
665 void
666 player_logout(player *pl);
667 void
668 object_type_init_player(void);
669 
670 #endif
player_faction_t * player_faction_create(player *pl, shstr *name)
Definition: player.c:1202
char maplevel[MAX_BUF]
Definition: player.h:153
uint8_t no_chat
Definition: player.h:516
int map_update_tile
Definition: player.h:239
uint64_t stat_books_inscribed
Definition: player.h:431
void player_logout(player *pl)
Definition: player.c:2895
uint8_t tls
Definition: player.h:534
shstr * name
Definition: map.h:553
uint8_t tgm
Definition: player.h:528
uint8_t tcl
Definition: player.h:525
int map_tile_x
Definition: player.h:242
player * find_player_sh(shstr *plname)
Definition: player.c:116
uint16_t last_gen_hp
Definition: player.h:487
object * mark
Definition: player.h:197
void player_deinit(void)
Definition: player.c:68
int map_tile_y
Definition: player.h:245
int yellow
Definition: player.h:45
int16_t skill_level[NROFSKILLS]
Definition: player.h:493
int player_can_carry(object *pl, uint32_t weight)
Definition: player.c:1036
int16_t dam_bonus
Damage bonuses from equipment (not melee weapon).
Definition: player.h:507
char map_info_music[HUGE_BUF]
Definition: player.h:174
int orange
Definition: player.h:48
int16_t x
Definition: player.h:114
uint64_t stat_spells_cast
Definition: player.h:359
double last_weapon_speed
Definition: player.h:271
UT_hash_handle hh
Hash handle.
Definition: player.h:136
int map_off_y
Definition: player.h:251
void player_init(void)
Definition: player.c:58
uint64_t stat_exp_gained
Definition: player.h:389
uint32_t mark_count
Definition: player.h:314
unsigned int run_on
Definition: player.h:289
player * find_player(const char *plname)
Definition: player.c:96
uint64_t stat_arrows_fired
Definition: player.h:371
uint64_t stat_damage_taken
Definition: player.h:329
int handle_newcs_player(player *pl)
Definition: player.c:347
object * ob
Definition: player.h:185
uint32_t target_object_count
Definition: player.h:434
void drop(object *op, object *tmp, int no_mevent)
Definition: player.c:2304
int map_off_x
Definition: player.h:248
uint64_t stat_books_read
Definition: player.h:377
uint64_t stat_deaths
Definition: player.h:320
uint16_t gen_client_sp
Definition: player.h:484
uint64_t stat_potions_used
Definition: player.h:383
uint64_t stat_damage_heal_received
Definition: player.h:353
Definition: living.h:67
void display_motd(object *op)
Definition: player.c:136
void kill_player(object *op)
Definition: player.c:765
char * killer
Definition: player.h:162
object * skill_ptr[NROFSKILLS]
Definition: player.h:194
mempool_struct * pool_player
Definition: player.c:52
char player_reply[64]
Definition: player.h:566
uint32_t afk
Definition: player.h:443
object * container_below
Definition: player.h:212
int last_skill_index
Definition: player.h:233
uint32_t container_count
Definition: player.h:311
const char * player_get_killer(player *pl)
Definition: player.c:2676
char quick_name[MAX_BUF]
Definition: player.h:156
uint32_t last_path_repelled
Definition: player.h:459
double last_speed
Definition: player.h:268
struct player_path * next
Definition: player.h:108
void player_set_talking_to(player *pl, object *npc)
Definition: player.c:2647
uint32_t last_weight_limit
Definition: player.h:437
struct mapdef * last_update
Definition: player.h:182
shstr * name
Name of the faction.
Definition: player.h:134
float last_ranged_ws
Definition: player.h:449
uint64_t stat_kills_pvp
Definition: player.h:326
uint16_t anim_flags
Definition: player.h:496
void free_player(player *pl)
Definition: player.c:219
unsigned char last_level
Definition: player.h:274
uint64_t stat_items_picked
Definition: player.h:398
void player_faction_free(player *pl, player_faction_t *faction)
Definition: player.c:1223
int16_t last_ranged_dam
Definition: player.h:502
player_path * move_path
Definition: player.h:558
void pick_up(object *op, object *alt, int no_mevent)
Definition: player.c:2019
int64_t fame
Definition: player.h:257
object * player_get_dummy(const char *name, const char *host)
Definition: player.c:2583
uint64_t stat_joined_party
Definition: player.h:419
uint64_t stat_afk_used
Definition: player.h:413
Definition: arch.h:40
mapstruct * map
Definition: player.h:111
int16_t last_ranged_wc
Definition: player.h:505
int red
Definition: player.h:51
object * container
Definition: player.h:206
double player_faction_reputation(player *pl, shstr *name)
Definition: player.c:1287
char afk_auto_reply[MAX_BUF]
Definition: player.h:569
char * player_sanitize_input(char *str)
Definition: player.c:1311
char map_info_weather[MAX_BUF]
Definition: player.h:177
void player_login(socket_struct *ns, const char *name, struct archetype *at)
Definition: player.c:2738
uint64_t stat_unique_books_read
Definition: player.h:380
uint64_t stat_missiles_thrown
Definition: player.h:374
object * map_above
Definition: player.h:203
int sack_can_hold(object *pl, object *sack, object *op, int nrof)
Definition: player.c:1870
uint8_t last_party_sp
Definition: player.h:522
uint64_t stat_food_consumed
Definition: player.h:341
int64_t skill_exp[NROFSKILLS]
Definition: player.h:317
long item_power_effects
Next time of item power effects.
Definition: player.h:576
player_path * move_path_end
Definition: player.h:561
signed char gen_sp
Definition: player.h:286
uint8_t tli
Definition: player.h:531
uint8_t last_gender
Definition: player.h:513
uint16_t gen_hp_remainder
Definition: player.h:475
object * target_object
Definition: player.h:188
uint64_t stat_formed_party
Definition: player.h:416
void player_disconnect_all(void)
Definition: player.c:79
struct pl_player * prev
Definition: player.h:142
object * find_skill(object *op, int skillnr)
Definition: player.c:1013
char savebed_map[MAX_BUF]
Definition: player.h:159
void player_set_killer(player *pl, const char *killer)
Definition: player.c:2696
signed char digestion
Definition: player.h:277
uint8_t fails
Definition: player.h:124
int8_t last_protection[NROFATTACKS]
Definition: player.h:510
uint8_t combat
Definition: player.h:543
uint32_t count
Definition: player.h:446
tag_t talking_to_count
ID of ::talking_to.
Definition: player.h:572
uint32_t update_los
Definition: player.h:440
uint32_t last_path_denied
Definition: player.h:464
int num_cmd_permissions
Definition: player.h:254
void player_path_clear(player *pl)
Definition: player.c:1086
void player_cleanup_name(char *str)
Definition: player.c:1330
int pvp_area(object *attacker, object *victim)
Definition: player.c:977
double reputation
Reputation.
Definition: player.h:135
uint64_t stat_damage_dealt
Definition: player.h:332
#define MAP_CLIENT_X
Definition: config.h:62
uint64_t stat_traps_sprung
Definition: player.h:410
uint8_t tsi
Definition: player.h:537
uint8_t combat_force
Definition: player.h:549
shstr * followed_player
Definition: player.h:165
uint8_t last_party_hp
Definition: player.h:519
int green
Definition: player.h:39
uint64_t stat_traps_disarmed
Definition: player.h:407
uint64_t stat_kills_mob
Definition: player.h:323
living last_stats
Definition: player.h:552
uint64_t stat_corpses_searched
Definition: player.h:401
int bed_x
Definition: player.h:221
uint64_t stat_damage_healed_other
Definition: player.h:350
int bed_y
Definition: player.h:224
float last_action_timer
Definition: player.h:265
uint16_t gen_sp_remainder
Definition: player.h:478
uint16_t last_flags
Definition: player.h:472
void player_path_handle(player *pl)
Definition: player.c:1109
struct player_path player_path
void player_faction_update(player *pl, shstr *name, double reputation)
Definition: player.c:1263
uint64_t stat_steps_taken
Definition: player.h:356
signed char gen_sp_armour
Definition: player.h:280
object * equipment[PLAYER_EQUIP_MAX]
Definition: player.h:191
void give_initial_items(object *pl, treasure_list_t *items)
Definition: player.c:292
uint64_t stat_scrolls_used
Definition: player.h:386
socket_struct * cs
Definition: player.h:148
uint64_t stat_items_dropped
Definition: player.h:395
void examine(object *op, object *tmp, StringBuffer *sb_capture)
Definition: player.c:1521
static faction_t factions
Definition: faction.c:132
uint64_t stat_damage_healed
Definition: player.h:347
long last_weight
Definition: player.h:300
uint32_t last_path_attuned
Definition: player.h:454
party_struct * party
Definition: player.h:555
uint16_t last_gen_sp
Definition: player.h:490
char target_hp
Definition: player.h:218
void player_clear_killer(player *pl)
Definition: player.c:2715
uint64_t stat_traps_found
Definition: player.h:404
void player_save(object *op)
Definition: player.c:2379
char ** cmd_permissions
Definition: player.h:168
char map_info_name[HUGE_BUF]
Definition: player.h:171
object * map_below
Definition: player.h:200
void player_path_add(player *pl, mapstruct *map, int16_t x, int16_t y)
Definition: player.c:1061
int16_t y
Definition: player.h:117
void put_object_in_sack(object *op, object *sack, object *tmp, long nrof)
Definition: player.c:2122
uint64_t stat_exp_lost
Definition: player.h:392
uint16_t gen_client_hp
Definition: player.h:481
void cast_dust(object *op, object *throw_ob, int dir)
Definition: player.c:918
void drop_object(object *op, object *tmp, long nrof, int no_mevent)
Definition: player.c:2195
uint64_t stat_time_played
Definition: player.h:362
signed char gen_hp
Definition: player.h:283
uint32_t last_equipment[PLAYER_EQUIP_MAX]
Definition: player.h:469
int blocked_los[MAP_CLIENT_X][MAP_CLIENT_Y]
Definition: player.h:230
float action_timer
Definition: player.h:262
Definition: map.h:536
object * talking_to
Object the player is talking to.
Definition: player.h:571
long last_combat
Definition: player.h:308
object * quest_container
Definition: player.h:215
object * container_above
Definition: player.h:209
uint64_t stat_renamed_items
Definition: player.h:422
uint64_t stat_emotes_used
Definition: player.h:425
int blue
Definition: player.h:42
player_faction_t * player_faction_find(player *pl, shstr *name)
Definition: player.c:1243
struct _level_color _level_color
time_t last_stat_time_played
Definition: player.h:368
struct pl_player * next
Definition: player.h:145
int16_t item_power
Definition: player.h:499
unsigned int run_on_dir
Definition: player.h:292
int map_update_cmd
Definition: player.h:236
uint64_t stat_time_afk
Definition: player.h:365
uint64_t stat_hp_regen
Definition: player.h:335
uint64_t stat_food_num_consumed
Definition: player.h:344
int purple
Definition: player.h:54
uint64_t stat_sp_regen
Definition: player.h:338
object * find_marked_object(object *op)
Definition: player.c:1393