|
Atrinik Client 2.5
|
00001 /************************************************************************ 00002 * Atrinik, a Multiplayer Online Role Playing Game * 00003 * * 00004 * Copyright (C) 2009-2011 Alex Tokar and Atrinik Development Team * 00005 * * 00006 * Fork from Daimonin (Massive Multiplayer Online Role Playing Game) * 00007 * and Crossfire (Multiplayer game for X-windows). * 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 00013 * * 00014 * This program is distributed in the hope that it will be useful, * 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00017 * GNU General Public License for more details. * 00018 * * 00019 * You should have received a copy of the GNU General Public License * 00020 * along with this program; if not, write to the Free Software * 00021 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00022 * * 00023 * The author can be reached at admin@atrinik.org * 00024 ************************************************************************/ 00025 00031 #define WINDOW_DEFAULT_WIDTH 1024 00032 00033 #define WINDOW_DEFAULT_HEIGHT 768 00034 00035 /* How many skill types server supports/client will get sent to it. 00036 * If more skills are added to server, this needs to get increased. */ 00037 #define MAX_SKILL 6 00038 00039 /* Defines for the ext map command */ 00040 00041 /* Object is sleeping */ 00042 #define FFLAG_SLEEP 0x01 00043 /* Object is confused */ 00044 #define FFLAG_CONFUSED 0x02 00045 /* Object is paralyzed */ 00046 #define FFLAG_PARALYZED 0x04 00047 /* Object is scared */ 00048 #define FFLAG_SCARED 0x08 00049 /* Object is blinded */ 00050 #define FFLAG_BLINDED 0x10 00051 /* Object is invisible (but when sent, player can see it) */ 00052 #define FFLAG_INVISIBLE 0x20 00053 00054 #define INPUT_MODE_NO 0 00055 #define INPUT_MODE_CONSOLE 1 00056 #define INPUT_MODE_NUMBER 2 00057 00058 #define NUM_MODE_GET 1 00059 #define NUM_MODE_DROP 2 00060 00061 typedef struct Animations 00062 { 00063 /* 0 = all fields are invalid, 1 = anim is loaded */ 00064 int loaded; 00065 00066 /* Length of one a animation frame (num_anim / facings) */ 00067 int frame; 00068 uint16 *faces; 00069 00070 /* Number of frames */ 00071 uint8 facings; 00072 00073 /* Number of animations. Value of 2 means 00074 * only faces[0], [1] have meaningful values. */ 00075 uint8 num_animations; 00076 uint8 flags; 00077 } Animations; 00078 00079 typedef struct _anim_table 00080 { 00081 /* Length of anim_cmd data */ 00082 int len; 00083 00084 /* Faked animation command */ 00085 char *anim_cmd; 00086 }_anim_table; 00087 00088 extern _anim_table *anim_table; 00089 extern Animations *animations; 00090 extern size_t animations_num; 00091 00094 #define SOCKET_TIMEOUT_MS 4000 00095 00098 typedef struct command_buffer 00099 { 00101 struct command_buffer *next; 00102 00104 struct command_buffer *prev; 00105 00107 int len; 00108 00110 uint8 data[1]; 00111 } command_buffer; 00112 00115 typedef struct SockList 00116 { 00119 int len; 00122 int pos; 00125 unsigned char *buf; 00126 } SockList; 00127 00128 /* ClientSocket could probably hold more of the global values - it could 00129 * probably hold most all socket/communication related values instead 00130 * of globals. */ 00131 typedef struct ClientSocket 00132 { 00133 int fd; 00134 } ClientSocket; 00135 00136 extern ClientSocket csocket; 00137 00138 typedef struct Stat_struct 00139 { 00140 sint8 Str, Dex, Con, Wis, Cha, Int, Pow; 00141 00142 /* Weapon Class and Armour Class */ 00143 sint16 wc, ac; 00144 uint32 level; 00145 00146 /* Hit Points. */ 00147 sint32 hp; 00148 00149 /* Max hit points*/ 00150 sint32 maxhp; 00151 00152 /* Spell points. Used to cast spells. */ 00153 sint32 sp; 00154 00155 /* Max spell points. */ 00156 sint32 maxsp; 00157 00158 /* Grace. Used to cast prayers. */ 00159 sint32 grace; 00160 00161 /* Max grace */ 00162 sint32 maxgrace; 00163 00164 /* Experience. Killers gain 1/10. */ 00165 sint64 exp; 00166 00167 /* How much food in stomach. 0 = starved. */ 00168 sint16 food; 00169 00170 /* How much damage this object does when hitting */ 00171 sint16 dam; 00172 00173 /* Gets converted to a float for display */ 00174 sint32 speed; 00175 00176 /* Gets converted to a float for display */ 00177 int weapon_sp; 00178 00179 /* Contains fire on/run on flags */ 00180 uint16 flags; 00181 00182 /* Resistant values */ 00183 sint16 protection[20]; 00184 00185 /* Level and experience totals for */ 00186 sint16 skill_level[MAX_SKILL]; 00187 00188 /* Skills */ 00189 sint64 skill_exp[MAX_SKILL]; 00190 00192 sint16 ranged_dam; 00193 00195 sint16 ranged_wc; 00196 00198 sint32 ranged_ws; 00199 } Stats; 00200 00201 typedef enum _inventory_win 00202 { 00203 IWIN_BELOW, 00204 IWIN_INV 00205 }_inventory_win; 00206 00208 typedef struct Player_Struct 00209 { 00210 /* Player object */ 00211 object *ob; 00212 00213 /* Items below the player (pl.below->inv) */ 00214 object *below; 00215 00216 /* inventory of a open container */ 00217 object *sack; 00218 00219 /* Pointer to open container */ 00220 object *container; 00221 00222 /* Tag of the container */ 00223 sint32 container_tag; 00224 00225 uint32 weight_limit; 00226 00227 /* Repeat count on command */ 00228 uint32 count; 00229 00231 int dm; 00232 00233 /* Target mode */ 00234 int target_mode; 00235 00236 /* Target */ 00237 int target_code; 00238 00239 /* Target's color */ 00240 char target_color[COLOR_BUF]; 00241 00242 /* Inventory windows */ 00243 int inventory_win; 00244 00245 /* Menu that is opened */ 00246 int menustatus; 00247 00248 int loc; 00249 int tag; 00250 int nrof; 00251 00252 skill_entry_struct *skill; 00253 00254 int warn_hp; 00255 00256 int win_inv_slot; 00257 int win_inv_tag; 00258 int win_pdoll_tag; 00259 int win_inv_start; 00260 int win_inv_count; 00261 int win_inv_ctag; 00262 00263 int win_below_slot; 00264 int win_below_tag; 00265 int win_below_start; 00266 int win_below_count; 00267 int win_below_ctag; 00268 00269 /* Input mode: no, console (textstring), numinput */ 00270 int input_mode; 00271 int nummode; 00272 00274 int mark_count; 00275 00276 /* HP, mana and grace regeneration */ 00277 float gen_hp; 00278 float gen_sp; 00279 float gen_grace; 00280 00281 /* Skill cooldown time */ 00282 float action_timer; 00283 00284 /* True if fire key is pressed = action key (ALT;CTRL) */ 00285 uint32 fire_on:1; 00286 00287 /* True if run key is on = action key (ALT;CTRL) */ 00288 uint32 run_on:1; 00289 00290 /* True if fire key is pressed = permanent mode */ 00291 uint32 firekey_on:1; 00292 00293 /* True if run key is pressed = permanent mode */ 00294 uint32 runkey_on:1; 00295 00296 float window_weight; 00297 float real_weight; 00298 00299 int warn_statdown; 00300 int warn_statup; 00301 00302 /* Player stats */ 00303 Stats stats; 00304 00305 /* HP of our target in % */ 00306 char target_hp; 00307 00308 /* Name and password. Only used while logging in. */ 00309 char name[40]; 00310 char password[40]; 00311 00312 /* Target name */ 00313 char target_name[MAX_BUF]; 00314 char num_text[300]; 00315 char skill_name[128]; 00316 00317 /* Rank and name of char */ 00318 char ext_title[MAX_BUF]; 00319 00320 /* Range attack chosen */ 00321 char range[MAX_BUF]; 00322 00324 char partyname[MAX_BUF]; 00325 00329 char partyjoin[MAX_BUF]; 00330 00332 char player_reply[64]; 00333 00334 union 00335 { 00336 int tag; 00337 00338 spell_entry_struct *spell; 00339 } dragging; 00340 } Client_Player; 00341 00342 /* Player object. */ 00343 extern Client_Player cpl; 00344 00345 /* These are multiplication values that should be used when changing 00346 * floats to ints, and vice version. MULTI is integer representation 00347 * (float to int), MULTF is float, for going from int to float. */ 00348 #define FLOAT_MULTI 100000 00349 #define FLOAT_MULTF 100000.0 00350 00351 /* ID's for the various stats that get sent across. */ 00352 #define CS_STAT_HP 1 00353 #define CS_STAT_MAXHP 2 00354 #define CS_STAT_SP 3 00355 #define CS_STAT_MAXSP 4 00356 #define CS_STAT_STR 5 00357 #define CS_STAT_INT 6 00358 #define CS_STAT_WIS 7 00359 #define CS_STAT_DEX 8 00360 #define CS_STAT_CON 9 00361 #define CS_STAT_CHA 10 00362 #define CS_STAT_EXP 11 00363 #define CS_STAT_LEVEL 12 00364 #define CS_STAT_WC 13 00365 #define CS_STAT_AC 14 00366 #define CS_STAT_DAM 15 00367 #define CS_STAT_ARMOUR 16 00368 #define CS_STAT_SPEED 17 00369 #define CS_STAT_FOOD 18 00370 #define CS_STAT_WEAP_SP 19 00371 #define CS_STAT_RANGE 20 00372 #define CS_STAT_TITLE 21 00373 #define CS_STAT_POW 22 00374 #define CS_STAT_GRACE 23 00375 #define CS_STAT_MAXGRACE 24 00376 #define CS_STAT_FLAGS 25 00377 #define CS_STAT_WEIGHT_LIM 26 00378 #define CS_STAT_EXT_TITLE 27 00379 #define CS_STAT_REG_HP 28 00380 #define CS_STAT_REG_MANA 29 00381 #define CS_STAT_REG_GRACE 30 00382 #define CS_STAT_TARGET_HP 31 00383 #define CS_STAT_ACTION_TIME 36 00384 #define CS_STAT_RANGED_DAM 37 00385 #define CS_STAT_RANGED_WC 38 00386 #define CS_STAT_RANGED_WS 39 00387 00388 /* Start and end of resistances, inclusive. */ 00389 #define CS_STAT_RESIST_START 100 00390 #define CS_STAT_RESIST_END 117 00391 #define CS_STAT_RES_PHYS 100 00392 #define CS_STAT_RES_MAG 101 00393 #define CS_STAT_RES_FIRE 102 00394 #define CS_STAT_RES_ELEC 103 00395 #define CS_STAT_RES_COLD 104 00396 #define CS_STAT_RES_CONF 105 00397 #define CS_STAT_RES_ACID 106 00398 #define CS_STAT_RES_DRAIN 107 00399 #define CS_STAT_RES_GHOSTHIT 108 00400 #define CS_STAT_RES_POISON 109 00401 #define CS_STAT_RES_SLOW 110 00402 #define CS_STAT_RES_PARA 111 00403 #define CS_STAT_TURN_UNDEAD 112 00404 #define CS_STAT_RES_FEAR 113 00405 #define CS_STAT_RES_DEPLETE 114 00406 #define CS_STAT_RES_DEATH 115 00407 #define CS_STAT_RES_HOLYWORD 116 00408 #define CS_STAT_RES_BLIND 117 00409 00410 /* Start and end of skill experience + skill level, inclusive. */ 00411 #define CS_STAT_SKILLEXP_START 118 00412 #define CS_STAT_SKILLEXP_END 129 00413 #define CS_STAT_SKILLEXP_AGILITY 118 00414 #define CS_STAT_SKILLEXP_AGLEVEL 119 00415 #define CS_STAT_SKILLEXP_PERSONAL 120 00416 #define CS_STAT_SKILLEXP_PELEVEL 121 00417 #define CS_STAT_SKILLEXP_MENTAL 122 00418 #define CS_STAT_SKILLEXP_MELEVEL 123 00419 #define CS_STAT_SKILLEXP_PHYSIQUE 124 00420 #define CS_STAT_SKILLEXP_PHLEVEL 125 00421 #define CS_STAT_SKILLEXP_MAGIC 126 00422 #define CS_STAT_SKILLEXP_MALEVEL 127 00423 #define CS_STAT_SKILLEXP_WISDOM 128 00424 #define CS_STAT_SKILLEXP_WILEVEL 129 00425 00426 #define CS_STAT_PROT_START 130 00427 #define CS_STAT_PROT_END 149 00428 00429 #define CS_STAT_PROT_HIT 130 00430 #define CS_STAT_PROT_SLASH 131 00431 #define CS_STAT_PROT_CLEAVE 132 00432 #define CS_STAT_PROT_PIERCE 133 00433 #define CS_STAT_PROT_WMAGIC 134 00434 00435 #define CS_STAT_PROT_FIRE 135 00436 #define CS_STAT_PROT_COLD 136 00437 #define CS_STAT_PROT_ELEC 137 00438 #define CS_STAT_PROT_POISON 138 00439 #define CS_STAT_PROT_ACID 139 00440 00441 #define CS_STAT_PROT_MAGIC 140 00442 #define CS_STAT_PROT_MIND 141 00443 #define CS_STAT_PROT_BODY 142 00444 #define CS_STAT_PROT_PSIONIC 143 00445 #define CS_STAT_PROT_ENERGY 144 00446 00447 #define CS_STAT_PROT_NETHER 145 00448 #define CS_STAT_PROT_CHAOS 146 00449 #define CS_STAT_PROT_DEATH 147 00450 #define CS_STAT_PROT_HOLY 148 00451 #define CS_STAT_PROT_CORRUPT 149 00452 00453 /* These are used with CS_STAT_FLAGS above to communicate S->C what the 00454 * server thinks the fireon & runon states are. */ 00455 #define SF_FIREON 1 00456 #define SF_RUNON 2 00457 #define SF_BLIND 4 00458 #define SF_XRAYS 8 00459 #define SF_INFRAVISION 16 00460 00462 #define NDI_SAY 0x0100 00463 00464 #define NDI_SHOUT 0x0200 00465 00466 #define NDI_TELL 0x0400 00467 00468 #define NDI_PLAYER 0x0800 00469 00470 #define NDI_EMOTE 0x01000 00471 00474 #define NDI_ANIM 0x02000 00475 00476 /* Flags for the item command */ 00477 #define F_APPLIED 0x000F 00478 #define F_LOCATION 0x00F0 00479 #define F_UNPAID 0x0200 00480 #define F_MAGIC 0x0400 00481 #define F_CURSED 0x0800 00482 #define F_DAMNED 0x1000 00483 #define F_OPEN 0x2000 00484 #define F_NOPICK 0x4000 00485 #define F_LOCKED 0x8000 00486 #define F_TRAPPED 0x10000 00487 00488 #define UPD_LOCATION 0x01 00489 #define UPD_FLAGS 0x02 00490 #define UPD_WEIGHT 0x04 00491 #define UPD_FACE 0x08 00492 #define UPD_NAME 0x10 00493 #define UPD_ANIM 0x20 00494 #define UPD_ANIMSPEED 0x40 00495 #define UPD_NROF 0x80 00496 #define UPD_DIRECTION 0x100 00497 00498 #define MAP_UPDATE_CMD_SAME 0 00499 #define MAP_UPDATE_CMD_NEW 1 00500 #define MAP_UPDATE_CMD_CONNECTED 2 00501 00508 #define MAP2_FLAG_MULTI 1 00509 00510 #define MAP2_FLAG_NAME 2 00511 00512 #define MAP2_FLAG_PROBE 4 00513 00514 #define MAP2_FLAG_HEIGHT 8 00515 00516 #define MAP2_FLAG_ZOOM 16 00517 00518 #define MAP2_FLAG_ALIGN 32 00519 00520 #define MAP2_FLAG_DOUBLE 64 00521 00522 #define MAP2_FLAG_MORE 128 00523 00531 #define MAP2_FLAG2_ALPHA 1 00532 00533 #define MAP2_FLAG2_ROTATE 2 00534 00535 #define MAP2_FLAG2_INFRAVISION 4 00536 00544 #define MAP2_FLAG_EXT_ANIM 1 00545 00552 #define MAP2_MASK_CLEAR 0x2 00553 00554 #define MAP2_MASK_DARKNESS 0x4 00555 00561 #define MAP2_LAYER_CLEAR 255 00562 00569 #define CMD_QUICKSLOT_SET 1 00570 00571 #define CMD_QUICKSLOT_SETSPELL 2 00572 00573 #define CMD_QUICKSLOT_UNSET 3 00574 00581 #define QUICKSLOT_TYPE_ITEM 1 00582 00583 #define QUICKSLOT_TYPE_SPELL 2 00584 00591 #define CMD_SOUND_EFFECT 1 00592 00593 #define CMD_SOUND_BACKGROUND 2 00594 00595 #define CMD_SOUND_ABSOLUTE 3 00596 00603 #define CMD_MAPSTATS_NAME 1 00604 00605 #define CMD_MAPSTATS_MUSIC 2 00606 00607 #define CMD_MAPSTATS_WEATHER 3 00608 00611 #define KEYWORD_IS_TRUE(_keyword) (!strcmp((_keyword), "yes") || !strcmp((_keyword), "on") || !strcmp((_keyword), "true")) 00612 00613 #define KEYWORD_IS_FALSE(_keyword) (!strcmp((_keyword), "no") || !strcmp((_keyword), "off") || !strcmp((_keyword), "false"))
1.7.4