ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/skills.C
(Generate patch)

Comparing deliantra/server/server/skills.C (file contents):
Revision 1.62 by root, Sun Jan 11 04:45:01 2009 UTC vs.
Revision 1.68 by root, Sat Oct 17 21:40:38 2009 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2003,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2003,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * it under the terms of the GNU General Public License as published by 9 * the terms of the Affero GNU General Public License as published by the
10 * the Free Software Foundation, either version 3 of the License, or 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * (at your option) any later version. 11 * option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.
20 * 21 *
21 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
22 */ 23 */
23 24
24#include <global.h> 25#include <global.h>
1052} 1053}
1053 1054
1054/* remove_trap() - This skill will disarm any previously discovered trap 1055/* remove_trap() - This skill will disarm any previously discovered trap
1055 * the algorithm is based (almost totally) on the old command_disarm() - b.t. 1056 * the algorithm is based (almost totally) on the old command_disarm() - b.t.
1056 */ 1057 */
1057
1058int 1058int
1059remove_trap (object *op, int dir, object *skill) 1059remove_trap (object *op, int dir, object *skill)
1060{ 1060{
1061 object *tmp, *tmp2; 1061 object *tmp, *tmp2;
1062 int i, success = 0, mflags; 1062 int i, success = 0, mflags;
1095 } 1095 }
1096 } 1096 }
1097 if ((tmp->type == RUNE || tmp->type == TRAP) && tmp->stats.Cha <= 1) 1097 if ((tmp->type == RUNE || tmp->type == TRAP) && tmp->stats.Cha <= 1)
1098 { 1098 {
1099 trap_show (tmp, tmp); 1099 trap_show (tmp, tmp);
1100
1100 if (trap_disarm (op, tmp, 1, skill) && (!tmp->owner || tmp->owner->type != PLAYER)) 1101 if (trap_disarm (op, tmp, 1, skill) && (!tmp->owner || tmp->owner->type != PLAYER))
1101 { 1102 {
1102 tmp->stats.exp = tmp->stats.Cha * tmp->level; 1103 tmp->stats.exp = tmp->stats.Cha * tmp->level;
1103 success += calc_skill_exp (op, tmp, skill); 1104 success += calc_skill_exp (op, tmp, skill);
1104 } 1105 }
1130 /* Check all objects - we could stop at floor objects, 1131 /* Check all objects - we could stop at floor objects,
1131 * but if someone buries an altar, I don't see a problem with 1132 * but if someone buries an altar, I don't see a problem with
1132 * going through all the objects, and it shouldn't be much slower 1133 * going through all the objects, and it shouldn't be much slower
1133 * than extra checks on object attributes. 1134 * than extra checks on object attributes.
1134 */ 1135 */
1135 for (tmp = pl->below; tmp != NULL; tmp = tmp->below) 1136 for (tmp = pl->below; tmp; tmp = tmp->below)
1136 { 1137 {
1137 /* Only if the altar actually belongs to someone do you get special benefits */ 1138 /* Only if the altar actually belongs to someone do you get special benefits */
1138 if (tmp && tmp->type == HOLY_ALTAR && tmp->other_arch) 1139 if (tmp && tmp->type == HOLY_ALTAR && tmp->other_arch)
1139 { 1140 {
1140 sprintf (buf, "You pray over the %s.", &tmp->name); 1141 sprintf (buf, "You pray over the %s.", &tmp->name);
1215 * ordinary inscribable 'books' (anything that is not a SPELL). b.t. 1216 * ordinary inscribable 'books' (anything that is not a SPELL). b.t.
1216 */ 1217 */
1217static int 1218static int
1218write_note (object *pl, object *item, const char *msg, object *skill) 1219write_note (object *pl, object *item, const char *msg, object *skill)
1219{ 1220{
1220 if (strstr (msg, "\nendmsg")) 1221 if (!msg_is_safe (msg))
1221 { 1222 {
1222 new_draw_info (NDI_UNIQUE, 0, pl, "Trying to cheat now are we?"); 1223 new_draw_info (NDI_UNIQUE, 0, pl, "Trying to cheat now are we?");
1224 LOG (llevInfo, "write_note: player %s tried to write bogus note %s\n", &pl->name, msg);
1223 return 0; 1225 return 0;
1224 } 1226 }
1225 1227
1226 int len = strlen (msg); 1228 int len = strlen (msg);
1227 1229
1232 } 1234 }
1233 1235
1234 if (INVOKE_OBJECT (INSCRIBE_NOTE, item, ARG_PLAYER (pl->contr), ARG_STRING (msg), ARG_OBJECT (skill))) 1236 if (INVOKE_OBJECT (INSCRIBE_NOTE, item, ARG_PLAYER (pl->contr), ARG_STRING (msg), ARG_OBJECT (skill)))
1235 return RESULT_INT (0); 1237 return RESULT_INT (0);
1236 1238
1237 char buf[1024]; 1239 STRLEN char_len = utf8_length ((U8 *)msg, (U8 *)(msg+len));
1238 1240
1239 if (len < sizeof (buf) - 2) 1241 if (char_len <= item->weight_limit)
1240 { 1242 {
1241 snprintf (buf, sizeof (buf), "%s\n", msg);
1242
1243 object *newbook = arch_to_object (item->other_arch); 1243 object *newbook = arch_to_object (item->other_arch);
1244 item->decrease (); 1244 item->decrease ();
1245 newbook->nrof = 1; 1245 newbook->nrof = 1;
1246 newbook->msg = buf; 1246 newbook->msg = shstr (msg);
1247 newbook->flag [FLAG_IDENTIFIED] = true; 1247 newbook->flag [FLAG_IDENTIFIED] = true;
1248 1248
1249 if (item->subtype == 1) // mailscrolls 1249 if (item->subtype == 1) // mailscrolls
1250 { 1250 {
1251 newbook->name = item->name; 1251 newbook->name = item->name;
1254 1254
1255 pl->insert (newbook); 1255 pl->insert (newbook);
1256 1256
1257 pl->contr->play_sound (sound_find ("inscribe_success")); 1257 pl->contr->play_sound (sound_find ("inscribe_success"));
1258 new_draw_info_format (NDI_UNIQUE, 0, pl, "You write in the %s.", &item->name); 1258 new_draw_info_format (NDI_UNIQUE, 0, pl, "You write in the %s.", &item->name);
1259 return strlen (msg); 1259 return char_len;
1260 } 1260 }
1261 else 1261 else
1262 new_draw_info_format (NDI_UNIQUE, 0, pl, "Your message won't fit in the %s!", &item->name); 1262 new_draw_info_format (NDI_UNIQUE, 0, pl, "Your message won't fit in the %s! H<It is only big enough for %d characters, your message had %d characters.>",
1263 &item->name, item->weight_limit, char_len);
1263 1264
1264 return 0; 1265 return 0;
1265} 1266}
1266 1267
1267/* write_scroll() - this routine allows players to inscribe spell scrolls 1268/* write_scroll() - this routine allows players to inscribe spell scrolls
1721 { 1722 {
1722 throw_ob->last_sp += eff_str / 3; /* fly a little further */ 1723 throw_ob->last_sp += eff_str / 3; /* fly a little further */
1723 throw_ob->stats.dam += throw_ob->inv->stats.dam + throw_ob->magic + 2; 1724 throw_ob->stats.dam += throw_ob->inv->stats.dam + throw_ob->magic + 2;
1724 throw_ob->stats.wc -= throw_ob->magic + throw_ob->inv->stats.wc; 1725 throw_ob->stats.wc -= throw_ob->magic + throw_ob->inv->stats.wc;
1725 /* only throw objects get directional faces */ 1726 /* only throw objects get directional faces */
1726 if (GET_ANIM_ID (throw_ob) && NUM_ANIMATIONS (throw_ob)) 1727 if (throw_ob->has_anim () && throw_ob->anim_frames ())
1727 SET_ANIMATION (throw_ob, dir); 1728 throw_ob->set_anim_frame (dir);
1728 } 1729 }
1729 else 1730 else
1730 { 1731 {
1731 uint16 mat = throw_ob->materials; 1732 uint16 mat = throw_ob->materials;
1732 1733

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines