|
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 00030 #include <global.h> 00031 00037 int client_command_check(const char *cmd) 00038 { 00039 if (!strncasecmp(cmd, "/ready_spell", 12)) 00040 { 00041 cmd = strchr(cmd, ' '); 00042 00043 if (!cmd || *++cmd == '\0') 00044 { 00045 draw_info(COLOR_GREEN, "Usage: /ready_spell <spell name>"); 00046 } 00047 else 00048 { 00049 size_t spell_path, spell_id; 00050 00051 if (spell_find(cmd, &spell_path, &spell_id)) 00052 { 00053 spell_entry_struct *spell = spell_get(spell_path, spell_id); 00054 00055 if (spell->known) 00056 { 00057 fire_mode_tab[FIRE_MODE_SPELL].spell = spell; 00058 RangeFireMode = FIRE_MODE_SPELL; 00059 draw_info_format(COLOR_GREEN, "Readied %s.", spell->name); 00060 return 1; 00061 } 00062 else 00063 { 00064 draw_info_format(COLOR_RED, "You have no knowledge of the spell %s.", spell->name); 00065 return 1; 00066 } 00067 } 00068 } 00069 00070 draw_info(COLOR_RED, "Unknown spell."); 00071 return 1; 00072 } 00073 else if (!strncasecmp(cmd, "/ready_skill", 12)) 00074 { 00075 cmd = strchr(cmd, ' '); 00076 00077 if (!cmd || *++cmd == '\0') 00078 { 00079 draw_info(COLOR_RED, "Usage: /ready_skill <skill name>"); 00080 } 00081 else 00082 { 00083 size_t type, id; 00084 00085 if (skill_find(cmd, &type, &id)) 00086 { 00087 skill_entry_struct *skill = skill_get(type, id); 00088 00089 if (skill->known) 00090 { 00091 char buf[MAX_BUF]; 00092 00093 fire_mode_tab[FIRE_MODE_SKILL].skill = skill; 00094 RangeFireMode = FIRE_MODE_SKILL; 00095 draw_info_format(COLOR_GREEN, "Readied %s.", skill->name); 00096 00097 snprintf(buf, sizeof(buf), "/ready_skill %s", skill->name); 00098 send_command(buf); 00099 return 1; 00100 } 00101 else 00102 { 00103 draw_info_format(COLOR_RED, "You have no knowledge of the skill %s.", skill->name); 00104 return 1; 00105 } 00106 } 00107 } 00108 00109 draw_info(COLOR_RED, "Unknown skill."); 00110 return 1; 00111 } 00112 else if (!strncasecmp(cmd, "/pray", 5)) 00113 { 00114 /* Give out "You are at full grace." when needed - 00115 * server will not send us anything when this happens */ 00116 if (cpl.stats.grace == cpl.stats.maxgrace) 00117 draw_info(COLOR_WHITE, "You are at full grace. You stop praying."); 00118 } 00119 else if (!strncmp(cmd, "/help", 5)) 00120 { 00121 cmd += 5; 00122 00123 if (cmd == NULL || strcmp(cmd, "") == 0) 00124 show_help("main"); 00125 else 00126 show_help(cmd + 1); 00127 00128 return 1; 00129 } 00130 else if (!strncmp(cmd, "/script ", 8)) 00131 { 00132 cmd += 8; 00133 00134 if (!strncmp(cmd, "load ", 5)) 00135 { 00136 cmd += 5; 00137 00138 script_load(cmd); 00139 } 00140 if (!strncmp(cmd, "unload ", 7)) 00141 { 00142 cmd += 7; 00143 00144 script_unload(cmd); 00145 } 00146 else if (!strncmp(cmd, "list", 4)) 00147 { 00148 script_list(); 00149 } 00150 else if (!strncmp(cmd, "send ", 5)) 00151 { 00152 cmd += 5; 00153 00154 script_send(cmd); 00155 } 00156 00157 return 1; 00158 } 00159 else if (!strncmp(cmd, "/ignore", 7)) 00160 { 00161 ignore_command(cmd + 7); 00162 return 1; 00163 } 00164 else if (!strncmp(cmd, "/reply", 6)) 00165 { 00166 cmd = strchr(cmd, ' '); 00167 00168 if (!cmd || *++cmd == '\0') 00169 { 00170 draw_info(COLOR_RED, "Usage: /reply <message>"); 00171 } 00172 else 00173 { 00174 if (!cpl.player_reply[0]) 00175 { 00176 draw_info(COLOR_RED, "There is no one you can /reply."); 00177 } 00178 else 00179 { 00180 char buf[2048]; 00181 00182 snprintf(buf, sizeof(buf), "/tell %s %s", cpl.player_reply, cmd); 00183 send_command(buf); 00184 } 00185 } 00186 00187 return 1; 00188 } 00189 else if (!strncmp(cmd, "/resetwidgets", 13)) 00190 { 00191 reset_widget(NULL); 00192 return 1; 00193 } 00194 else if (!strncmp(cmd, "/resetwidget", 12)) 00195 { 00196 cmd = strchr(cmd, ' '); 00197 00198 if (!cmd || *++cmd == '\0') 00199 { 00200 draw_info(COLOR_RED, "Usage: /resetwidget <name>"); 00201 } 00202 else 00203 { 00204 reset_widget(cmd); 00205 } 00206 00207 return 1; 00208 } 00209 else if (!strncmp(cmd, "/effect ", 8)) 00210 { 00211 if (!strcmp(cmd + 8, "none")) 00212 { 00213 effect_stop(); 00214 draw_info(COLOR_GREEN, "Stopped effect."); 00215 return 1; 00216 } 00217 00218 if (effect_start(cmd + 8)) 00219 { 00220 draw_info_format(COLOR_GREEN, "Started effect %s.", cmd + 8); 00221 } 00222 else 00223 { 00224 draw_info_format(COLOR_RED, "No such effect %s.", cmd + 8); 00225 } 00226 00227 return 1; 00228 } 00229 else if (!strncmp(cmd, "/d_effect ", 10)) 00230 { 00231 effect_debug(cmd + 10); 00232 return 1; 00233 } 00234 else if (!strncmp(cmd, "/np", 3)) 00235 { 00236 mplayer_now_playing(); 00237 return 1; 00238 } 00239 else if (!strncmp(cmd, "/music_pause", 12)) 00240 { 00241 sound_pause_music(); 00242 return 1; 00243 } 00244 else if (!strncmp(cmd, "/music_resume", 13)) 00245 { 00246 sound_resume_music(); 00247 return 1; 00248 } 00249 else if (!strncmp(cmd, "/party joinpassword ", 20)) 00250 { 00251 cmd += 20; 00252 00253 if (cpl.partyjoin[0] != '\0') 00254 { 00255 char buf[MAX_BUF]; 00256 00257 snprintf(buf, sizeof(buf), "/party join %s\t%s", cpl.partyjoin, cmd ? cmd : " "); 00258 send_command(buf); 00259 } 00260 00261 return 1; 00262 } 00263 else if (!strncmp(cmd, "/invfilter ", 11)) 00264 { 00265 cmd += 11; 00266 00267 if (!strcmp(cmd, "all")) 00268 { 00269 inventory_filter_set(INVENTORY_FILTER_ALL); 00270 } 00271 else if (!strcmp(cmd, "applied")) 00272 { 00273 inventory_filter_set(INVENTORY_FILTER_APPLIED); 00274 } 00275 else if (!strcmp(cmd, "container")) 00276 { 00277 inventory_filter_set(INVENTORY_FILTER_CONTAINER); 00278 } 00279 else if (!strcmp(cmd, "magical")) 00280 { 00281 inventory_filter_set(INVENTORY_FILTER_MAGICAL); 00282 } 00283 else if (!strcmp(cmd, "cursed")) 00284 { 00285 inventory_filter_set(INVENTORY_FILTER_CURSED); 00286 } 00287 else if (!strcmp(cmd, "unidentified")) 00288 { 00289 inventory_filter_set(INVENTORY_FILTER_UNIDENTIFIED); 00290 } 00291 else if (!strcmp(cmd, "unapplied")) 00292 { 00293 inventory_filter_set(INVENTORY_FILTER_UNAPPLIED); 00294 } 00295 else if (!strcmp(cmd, "locked")) 00296 { 00297 inventory_filter_set(INVENTORY_FILTER_LOCKED); 00298 } 00299 00300 return 1; 00301 } 00302 00303 return 0; 00304 } 00305 00309 void send_command_check(const char *cmd) 00310 { 00311 if (!client_command_check(cmd)) 00312 { 00313 send_command(cmd); 00314 } 00315 } 00316 00322 void blt_inventory_face_from_tag(int tag, int x, int y) 00323 { 00324 object *tmp; 00325 00326 /* Check item is in inventory and faces are loaded, etc */ 00327 tmp = object_find(tag); 00328 00329 if (!tmp) 00330 return; 00331 00332 blt_inv_item_centered(tmp, x, y); 00333 } 00334 00337 void show_menu() 00338 { 00339 if (!cpl.menustatus) 00340 return; 00341 00342 if (cpl.menustatus == MENU_BOOK) 00343 book_show(); 00344 else if (cpl.menustatus == MENU_REGION_MAP) 00345 { 00346 region_map_show(); 00347 } 00348 } 00349 00359 void blt_window_slider(_Sprite *slider, int maxlen, int winlen, int startoff, int len, int x, int y) 00360 { 00361 SDL_Rect box; 00362 double temp; 00363 int startpos, len_h; 00364 00365 if (len != -1) 00366 len_h = len; 00367 else 00368 len_h = slider->bitmap->h; 00369 00370 if (maxlen < winlen) 00371 maxlen = winlen; 00372 00373 if (startoff + winlen > maxlen) 00374 maxlen = startoff + winlen; 00375 00376 box.x = 0; 00377 box.y = 0; 00378 box.w = slider->bitmap->w; 00379 00380 /* now we have 100% = 1.0 to 0% = 0.0 of the length */ 00381 00382 /* between 0.0 <-> 1.0 */ 00383 temp = (double)winlen / (double)maxlen; 00384 00385 /* startpixel */ 00386 startpos = (int)((double)startoff * ((double)len_h / (double )maxlen)); 00387 00388 temp = (double)len_h * temp; 00389 box.h = (Uint16) temp; 00390 00391 if (!box.h) 00392 box.h = 1; 00393 00394 if (startoff + winlen >= maxlen && startpos + box.h < len_h) 00395 startpos ++; 00396 00397 sprite_blt(slider, x, y + startpos, &box, NULL); 00398 }
1.7.4