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.61 by root, Thu Jan 1 16:05:13 2009 UTC vs.
Revision 1.70 by root, Fri Nov 6 12:49:19 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>
41 /* Only prohibit stealing if the player does not have a free 42 /* Only prohibit stealing if the player does not have a free
42 * hand available and in fact does have hands. 43 * hand available and in fact does have hands.
43 */ 44 */
44 if (op->type == PLAYER && op->slot[body_arm].used <= 0 && op->slot[body_arm].info) 45 if (op->type == PLAYER && op->slot[body_arm].used <= 0 && op->slot[body_arm].info)
45 { 46 {
46 new_draw_info (NDI_UNIQUE, 0, op, "But you have no free hands to steal with!"); 47 new_draw_info (NDI_UNIQUE, 0, op, "But you have no free hands to steal with! "
48 "H<Try to unapply weapons or things you hold in your hands, use the C<body> command.>");
47 return -1; 49 return -1;
48 } 50 }
49 51
50 /* ADJUSTMENTS */ 52 /* ADJUSTMENTS */
51 53
657} 659}
658 660
659/* Helper function for do_skill_ident, so that we can loop 661/* Helper function for do_skill_ident, so that we can loop
660 * over inventory AND objects on the ground conveniently. 662 * over inventory AND objects on the ground conveniently.
661 */ 663 */
662int 664static int
663do_skill_ident2 (object *tmp, object *pl, int obj_class, object *skill) 665do_skill_ident2 (object *tmp, object *pl, int obj_class, object *skill)
664{ 666{
665 int success = 0, chance; 667 int success = 0, chance;
666 int skill_value = skill->level * pl->stats.Int ? pl->stats.Int : 10; 668 int skill_value = skill->level * pl->stats.Int ? pl->stats.Int : 10;
667 669
1051} 1053}
1052 1054
1053/* remove_trap() - This skill will disarm any previously discovered trap 1055/* remove_trap() - This skill will disarm any previously discovered trap
1054 * 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.
1055 */ 1057 */
1056
1057int 1058int
1058remove_trap (object *op, int dir, object *skill) 1059remove_trap (object *op, int dir, object *skill)
1059{ 1060{
1060 object *tmp, *tmp2; 1061 object *tmp, *tmp2;
1061 int i, success = 0, mflags; 1062 int i, success = 0, mflags;
1071 mflags = get_map_flags (m, &m, x, y, &x, &y); 1072 mflags = get_map_flags (m, &m, x, y, &x, &y);
1072 if (mflags & P_OUT_OF_MAP) 1073 if (mflags & P_OUT_OF_MAP)
1073 continue; 1074 continue;
1074 1075
1075 /* Check everything in the square for trapness */ 1076 /* Check everything in the square for trapness */
1076 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) 1077 for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above)
1077 { 1078 {
1078 /* And now we'd better do an inventory traversal of each 1079 /* And now we'd better do an inventory traversal of each
1079 * of these objects inventory. Like above, only 1080 * of these objects inventory. Like above, only
1080 * do this for interesting objects. 1081 * do this for interesting objects.
1081 */ 1082 */
1082 1083
1083 if (tmp->type != PLAYER && !QUERY_FLAG (tmp, FLAG_MONSTER)) 1084 if (tmp->type != PLAYER && !QUERY_FLAG (tmp, FLAG_MONSTER))
1084 { 1085 {
1085 for (tmp2 = tmp->inv; tmp2 != NULL; tmp2 = tmp2->below) 1086 for (tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below)
1086 if ((tmp2->type == RUNE || tmp2->type == TRAP) && tmp2->stats.Cha <= 1) 1087 if ((tmp2->type == RUNE || tmp2->type == TRAP) && tmp2->stats.Cha <= 1)
1087 { 1088 {
1088 trap_show (tmp2, tmp); 1089 trap_show (tmp2, tmp);
1090
1089 if (trap_disarm (op, tmp2, 1, skill) && (!tmp2->owner || tmp2->owner->type != PLAYER)) 1091 if (trap_disarm (op, tmp2, 1, skill) && (!tmp2->owner || tmp2->owner->type != PLAYER))
1090 { 1092 {
1091 tmp->stats.exp = tmp->stats.Cha * tmp->level; 1093 tmp->stats.exp = tmp->stats.Cha * tmp->level;
1092 success += calc_skill_exp (op, tmp2, skill); 1094 success += calc_skill_exp (op, tmp2, skill);
1093 } 1095 }
1094 } 1096 }
1095 } 1097 }
1098
1096 if ((tmp->type == RUNE || tmp->type == TRAP) && tmp->stats.Cha <= 1) 1099 if ((tmp->type == RUNE || tmp->type == TRAP) && tmp->stats.Cha <= 1)
1097 { 1100 {
1098 trap_show (tmp, tmp); 1101 trap_show (tmp, tmp);
1102
1099 if (trap_disarm (op, tmp, 1, skill) && (!tmp->owner || tmp->owner->type != PLAYER)) 1103 if (trap_disarm (op, tmp, 1, skill) && (!tmp->owner || tmp->owner->type != PLAYER))
1100 { 1104 {
1101 tmp->stats.exp = tmp->stats.Cha * tmp->level; 1105 tmp->stats.exp = tmp->stats.Cha * tmp->level;
1102 success += calc_skill_exp (op, tmp, skill); 1106 success += calc_skill_exp (op, tmp, skill);
1103 } 1107 }
1129 /* Check all objects - we could stop at floor objects, 1133 /* Check all objects - we could stop at floor objects,
1130 * but if someone buries an altar, I don't see a problem with 1134 * but if someone buries an altar, I don't see a problem with
1131 * going through all the objects, and it shouldn't be much slower 1135 * going through all the objects, and it shouldn't be much slower
1132 * than extra checks on object attributes. 1136 * than extra checks on object attributes.
1133 */ 1137 */
1134 for (tmp = pl->below; tmp != NULL; tmp = tmp->below) 1138 for (tmp = pl->below; tmp; tmp = tmp->below)
1135 { 1139 {
1136 /* Only if the altar actually belongs to someone do you get special benefits */ 1140 /* Only if the altar actually belongs to someone do you get special benefits */
1137 if (tmp && tmp->type == HOLY_ALTAR && tmp->other_arch) 1141 if (tmp && tmp->type == HOLY_ALTAR && tmp->other_arch)
1138 { 1142 {
1139 sprintf (buf, "You pray over the %s.", &tmp->name); 1143 sprintf (buf, "You pray over the %s.", &tmp->name);
1214 * ordinary inscribable 'books' (anything that is not a SPELL). b.t. 1218 * ordinary inscribable 'books' (anything that is not a SPELL). b.t.
1215 */ 1219 */
1216static int 1220static int
1217write_note (object *pl, object *item, const char *msg, object *skill) 1221write_note (object *pl, object *item, const char *msg, object *skill)
1218{ 1222{
1219 if (strstr (msg, "\nendmsg")) 1223 if (!msg_is_safe (msg))
1220 { 1224 {
1221 new_draw_info (NDI_UNIQUE, 0, pl, "Trying to cheat now are we?"); 1225 new_draw_info (NDI_UNIQUE, 0, pl, "Trying to cheat now are we?");
1226 LOG (llevInfo, "write_note: player %s tried to write bogus note %s\n", &pl->name, msg);
1222 return 0; 1227 return 0;
1223 } 1228 }
1224 1229
1225 int len = strlen (msg); 1230 int len = strlen (msg);
1226 1231
1231 } 1236 }
1232 1237
1233 if (INVOKE_OBJECT (INSCRIBE_NOTE, item, ARG_PLAYER (pl->contr), ARG_STRING (msg), ARG_OBJECT (skill))) 1238 if (INVOKE_OBJECT (INSCRIBE_NOTE, item, ARG_PLAYER (pl->contr), ARG_STRING (msg), ARG_OBJECT (skill)))
1234 return RESULT_INT (0); 1239 return RESULT_INT (0);
1235 1240
1236 char buf[1024]; 1241 STRLEN char_len = utf8_length ((U8 *)msg, (U8 *)(msg+len));
1237 1242
1238 if (len < sizeof (buf) - 2) 1243 if (char_len <= item->weight_limit)
1239 { 1244 {
1240 snprintf (buf, sizeof (buf), "%s\n", msg);
1241
1242 object *newbook = arch_to_object (item->other_arch); 1245 object *newbook = arch_to_object (item->other_arch);
1243 item->decrease (); 1246 item->decrease ();
1244 newbook->nrof = 1; 1247 newbook->nrof = 1;
1245 newbook->msg = buf; 1248 newbook->msg = shstr (msg);
1246 newbook->flag [FLAG_IDENTIFIED] = true; 1249 newbook->flag [FLAG_IDENTIFIED] = true;
1247 1250
1248 if (item->subtype == 1) // mailscrolls 1251 if (item->subtype == 1) // mailscrolls
1249 { 1252 {
1250 newbook->name = item->name; 1253 newbook->name = item->name;
1253 1256
1254 pl->insert (newbook); 1257 pl->insert (newbook);
1255 1258
1256 pl->contr->play_sound (sound_find ("inscribe_success")); 1259 pl->contr->play_sound (sound_find ("inscribe_success"));
1257 new_draw_info_format (NDI_UNIQUE, 0, pl, "You write in the %s.", &item->name); 1260 new_draw_info_format (NDI_UNIQUE, 0, pl, "You write in the %s.", &item->name);
1258 return strlen (msg); 1261 return char_len;
1259 } 1262 }
1260 else 1263 else
1261 new_draw_info_format (NDI_UNIQUE, 0, pl, "Your message won't fit in the %s!", &item->name); 1264 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.>",
1265 &item->name, item->weight_limit, char_len);
1262 1266
1263 return 0; 1267 return 0;
1264} 1268}
1265 1269
1266/* write_scroll() - this routine allows players to inscribe spell scrolls 1270/* write_scroll() - this routine allows players to inscribe spell scrolls
1720 { 1724 {
1721 throw_ob->last_sp += eff_str / 3; /* fly a little further */ 1725 throw_ob->last_sp += eff_str / 3; /* fly a little further */
1722 throw_ob->stats.dam += throw_ob->inv->stats.dam + throw_ob->magic + 2; 1726 throw_ob->stats.dam += throw_ob->inv->stats.dam + throw_ob->magic + 2;
1723 throw_ob->stats.wc -= throw_ob->magic + throw_ob->inv->stats.wc; 1727 throw_ob->stats.wc -= throw_ob->magic + throw_ob->inv->stats.wc;
1724 /* only throw objects get directional faces */ 1728 /* only throw objects get directional faces */
1725 if (GET_ANIM_ID (throw_ob) && NUM_ANIMATIONS (throw_ob)) 1729 if (throw_ob->has_anim () && throw_ob->anim_frames ())
1726 SET_ANIMATION (throw_ob, dir); 1730 throw_ob->set_anim_frame (dir);
1727 } 1731 }
1728 else 1732 else
1729 { 1733 {
1730 uint16 mat = throw_ob->materials; 1734 uint16 mat = throw_ob->materials;
1731 1735

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines