|
Atrinik Server 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 00039 void apply_sign(object *op, object *sign) 00040 { 00041 if (!sign->msg && !sign->title) 00042 { 00043 new_draw_info(0, COLOR_WHITE, op, "Nothing is written on it."); 00044 return; 00045 } 00046 00047 if (sign->stats.food) 00048 { 00049 if (sign->last_eat >= sign->stats.food) 00050 { 00051 if (!QUERY_FLAG(sign, FLAG_WALK_ON) && !QUERY_FLAG(sign, FLAG_FLY_ON)) 00052 { 00053 new_draw_info(0, COLOR_WHITE, op, "You cannot read it anymore."); 00054 } 00055 00056 return; 00057 } 00058 00059 sign->last_eat++; 00060 } 00061 00062 /* Sign or magic mouth? Do we need to see it, or does it talk to us? 00063 * No way to know for sure. 00064 * 00065 * This check fails for signs with FLAG_WALK_ON/FLAG_FLY_ON. Checking 00066 * for FLAG_INVISIBLE instead of FLAG_WALK_ON/FLAG_FLY_ON would fail 00067 * for magic mouths that have been made visible. */ 00068 if (QUERY_FLAG(op, FLAG_BLIND) && !QUERY_FLAG(op, FLAG_WIZ) && !QUERY_FLAG(sign, FLAG_WALK_ON) && !QUERY_FLAG(sign, FLAG_FLY_ON)) 00069 { 00070 new_draw_info(0, COLOR_WHITE, op, "You are unable to read while blind."); 00071 return; 00072 } 00073 00074 if (sign->slaying || sign->stats.hp || sign->race) 00075 { 00076 object *match = check_inv_recursive(op, sign); 00077 00078 if ((match && sign->last_sp) || (!match && !sign->last_sp)) 00079 { 00080 if (!QUERY_FLAG(sign, FLAG_WALK_ON) && !QUERY_FLAG(sign, FLAG_FLY_ON)) 00081 { 00082 new_draw_info(0, COLOR_WHITE, op, "You are unable to decipher the strange symbols."); 00083 } 00084 00085 return; 00086 } 00087 } 00088 00089 if (sign->direction && QUERY_FLAG(sign, FLAG_SYS_OBJECT)) 00090 { 00091 if (op->direction != absdir(sign->direction + 4) && !(QUERY_FLAG(sign, FLAG_SPLITTING) && (op->direction == absdir(sign->direction - 5) || op->direction == absdir(sign->direction + 5)))) 00092 { 00093 return; 00094 } 00095 } 00096 00097 if (sign->title) 00098 { 00099 play_sound_player_only(CONTR(op), CMD_SOUND_EFFECT, sign->title, 0, 0, 0, 0); 00100 00101 if (!sign->msg) 00102 { 00103 return; 00104 } 00105 } 00106 00107 /* Use book GUI? */ 00108 if (QUERY_FLAG(sign, FLAG_XRAYS)) 00109 { 00110 SockList sl; 00111 unsigned char sock_buf[MAXSOCKBUF]; 00112 00113 sl.buf = sock_buf; 00114 SOCKET_SET_BINARY_CMD(&sl, BINARY_CMD_BOOK); 00115 strcpy((char *) sl.buf + sl.len, sign->msg); 00116 sl.len += strlen(sign->msg) + 1; 00117 Send_With_Handling(&CONTR(op)->socket, &sl); 00118 00119 /* Ensure player is not running, mostly for walk/fly on signs. */ 00120 CONTR(op)->run_on = CONTR(op)->fire_on = 0; 00121 } 00122 else 00123 { 00124 new_draw_info(0, COLOR_NAVY, op, sign->msg); 00125 } 00126 }
1.7.4