… | |
… | |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT 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 | * Crossfire TRT is free software; you can redistribute it and/or modify it |
8 | * Crossfire TRT is free software: you can redistribute it and/or modify |
9 | * under the terms of the GNU General Public License as published by the Free |
9 | * it under the terms of the GNU General Public License as published by |
10 | * Software Foundation; either version 2 of the License, or (at your option) |
10 | * the Free Software Foundation, either version 3 of the License, or |
11 | * any later version. |
11 | * (at your option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, but |
13 | * This program is distributed in the hope that it will be useful, |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * 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 along |
18 | * You should have received a copy of the GNU General Public License |
19 | * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51 |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
|
21 | * |
20 | * |
22 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
21 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
23 | */ |
22 | */ |
24 | |
23 | |
25 | #include <global.h> |
24 | #include <global.h> |
… | |
… | |
719 | /* do_skill_ident() - workhorse for skill_ident() -b.t. |
718 | /* do_skill_ident() - workhorse for skill_ident() -b.t. |
720 | */ |
719 | */ |
721 | static int |
720 | static int |
722 | do_skill_ident (object *pl, int obj_class, object *skill) |
721 | do_skill_ident (object *pl, int obj_class, object *skill) |
723 | { |
722 | { |
724 | object *tmp; |
|
|
725 | int success = 0; |
723 | int success = 0; |
726 | |
724 | |
727 | for (tmp = pl->inv; tmp; tmp = tmp->below) |
725 | for (object *tmp = pl->inv; tmp; tmp = tmp->below) |
728 | success += do_skill_ident2 (tmp, pl, obj_class, skill); |
726 | success += do_skill_ident2 (tmp, pl, obj_class, skill); |
729 | /* check the ground */ |
727 | /* check the ground */ |
730 | |
728 | |
731 | for (tmp = GET_MAP_OB (pl->map, pl->x, pl->y); tmp; tmp = tmp->above) |
729 | for (object *tmp = pl->ms ().bot; tmp; tmp = tmp->above) |
732 | success += do_skill_ident2 (tmp, pl, obj_class, skill); |
730 | success += do_skill_ident2 (tmp, pl, obj_class, skill); |
733 | |
731 | |
734 | return success; |
732 | return success; |
735 | } |
733 | } |
736 | |
734 | |
… | |
… | |
744 | |
742 | |
745 | new_draw_info (NDI_UNIQUE, 0, pl, "You look at the objects nearby..."); |
743 | new_draw_info (NDI_UNIQUE, 0, pl, "You look at the objects nearby..."); |
746 | |
744 | |
747 | switch (skill->subtype) |
745 | switch (skill->subtype) |
748 | { |
746 | { |
749 | case SK_SMITHERY: |
747 | case SK_SMITHERY: |
750 | success += do_skill_ident (pl, WEAPON, skill) + do_skill_ident (pl, ARMOUR, skill) |
748 | success += do_skill_ident (pl, WEAPON, skill) + do_skill_ident (pl, ARMOUR, skill) |
751 | + do_skill_ident (pl, BRACERS, skill) + do_skill_ident (pl, CLOAK, skill) |
749 | + do_skill_ident (pl, BRACERS, skill) + do_skill_ident (pl, CLOAK, skill) |
752 | + do_skill_ident (pl, BOOTS, skill) + do_skill_ident (pl, SHIELD, skill) |
750 | + do_skill_ident (pl, BOOTS, skill) + do_skill_ident (pl, SHIELD, skill) |
753 | + do_skill_ident (pl, GIRDLE, skill) + do_skill_ident (pl, HELMET, skill) + do_skill_ident (pl, GLOVES, skill); |
751 | + do_skill_ident (pl, GIRDLE, skill) + do_skill_ident (pl, HELMET, skill) + do_skill_ident (pl, GLOVES, skill); |
754 | break; |
752 | break; |
755 | |
753 | |
756 | case SK_BOWYER: |
754 | case SK_BOWYER: |
757 | success += do_skill_ident (pl, BOW, skill) + do_skill_ident (pl, ARROW, skill); |
755 | success += do_skill_ident (pl, BOW, skill) + do_skill_ident (pl, ARROW, skill); |
758 | break; |
756 | break; |
759 | |
757 | |
760 | case SK_ALCHEMY: |
758 | case SK_ALCHEMY: |
761 | success += do_skill_ident (pl, POTION, skill) + do_skill_ident (pl, POISON, skill) |
759 | success += do_skill_ident (pl, POTION, skill) + do_skill_ident (pl, POISON, skill) |
762 | + do_skill_ident (pl, CONTAINER, skill) + do_skill_ident (pl, DRINK, skill) + do_skill_ident (pl, INORGANIC, skill); |
760 | + do_skill_ident (pl, CONTAINER, skill) + do_skill_ident (pl, DRINK, skill) + do_skill_ident (pl, INORGANIC, skill); |
763 | break; |
761 | break; |
764 | |
762 | |
765 | case SK_WOODSMAN: |
763 | case SK_WOODSMAN: |
766 | success += do_skill_ident (pl, FOOD, skill) + do_skill_ident (pl, DRINK, skill) + do_skill_ident (pl, FLESH, skill); |
764 | success += do_skill_ident (pl, FOOD, skill) + do_skill_ident (pl, DRINK, skill) + do_skill_ident (pl, FLESH, skill); |
767 | break; |
765 | break; |
768 | |
766 | |
769 | case SK_JEWELER: |
767 | case SK_JEWELER: |
770 | success += do_skill_ident (pl, GEM, skill) + do_skill_ident (pl, RING, skill) + do_skill_ident (pl, AMULET, skill); |
768 | success += do_skill_ident (pl, GEM, skill) + do_skill_ident (pl, RING, skill) + do_skill_ident (pl, AMULET, skill); |
771 | break; |
769 | break; |
772 | |
770 | |
773 | case SK_LITERACY: |
771 | case SK_LITERACY: |
774 | success += do_skill_ident (pl, SPELLBOOK, skill) + do_skill_ident (pl, SCROLL, skill) + do_skill_ident (pl, BOOK, skill); |
772 | success += do_skill_ident (pl, SPELLBOOK, skill) + do_skill_ident (pl, SCROLL, skill) + do_skill_ident (pl, BOOK, skill); |
775 | break; |
773 | break; |
776 | |
774 | |
777 | case SK_THAUMATURGY: |
775 | case SK_THAUMATURGY: |
778 | success += do_skill_ident (pl, WAND, skill) + do_skill_ident (pl, ROD, skill) + do_skill_ident (pl, HORN, skill); |
776 | success += do_skill_ident (pl, WAND, skill) + do_skill_ident (pl, ROD, skill) + do_skill_ident (pl, HORN, skill); |
779 | break; |
777 | break; |
780 | |
778 | |
781 | case SK_DET_CURSE: |
779 | case SK_DET_CURSE: |
782 | success = do_skill_detect_curse (pl, skill); |
780 | success = do_skill_detect_curse (pl, skill); |
783 | if (success) |
781 | if (success) |
784 | new_draw_info (NDI_UNIQUE, 0, pl, "...and discover cursed items!"); |
782 | new_draw_info (NDI_UNIQUE, 0, pl, "...and discover cursed items!"); |
785 | break; |
783 | break; |
786 | |
784 | |
787 | case SK_DET_MAGIC: |
785 | case SK_DET_MAGIC: |
788 | success = do_skill_detect_magic (pl, skill); |
786 | success = do_skill_detect_magic (pl, skill); |
789 | if (success) |
787 | if (success) |
790 | new_draw_info (NDI_UNIQUE, 0, pl, "...and discover items imbued with mystic forces!"); |
788 | new_draw_info (NDI_UNIQUE, 0, pl, "...and discover items imbued with mystic forces!"); |
791 | break; |
789 | break; |
792 | |
790 | |
793 | default: |
791 | default: |
794 | LOG (llevError, "Error: bad call to skill_ident()\n"); |
792 | LOG (llevError, "Error: bad call to skill_ident()\n"); |
795 | return 0; |
793 | return 0; |
796 | break; |
794 | break; |
797 | } |
795 | } |
|
|
796 | |
798 | if (!success) |
797 | if (!success) |
799 | { |
|
|
800 | new_draw_info (NDI_UNIQUE, 0, pl, "...and learn nothing more."); |
798 | new_draw_info (NDI_UNIQUE, 0, pl, "...and learn nothing more."); |
801 | } |
799 | |
802 | return success; |
800 | return success; |
803 | } |
801 | } |
804 | |
802 | |
805 | /* players using this skill can 'charm' a monster -- |
803 | /* players using this skill can 'charm' a monster -- |
806 | * into working for them. It can only be used on |
804 | * into working for them. It can only be used on |
… | |
… | |
901 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You convince the %s to become your follower.\n", query_name (tmp)); |
899 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You convince the %s to become your follower.\n", query_name (tmp)); |
902 | |
900 | |
903 | tmp->set_owner (pl); |
901 | tmp->set_owner (pl); |
904 | tmp->skill = skill->skill; |
902 | tmp->skill = skill->skill; |
905 | tmp->stats.exp = 0; |
903 | tmp->stats.exp = 0; |
906 | add_friendly_object (tmp); |
|
|
907 | tmp->attack_movement = PETMOVE; |
904 | tmp->attack_movement = PETMOVE; |
|
|
905 | |
|
|
906 | if (!QUERY_FLAG (tmp, FLAG_FRIENDLY)) |
|
|
907 | add_friendly_object (tmp); |
|
|
908 | |
908 | return calc_skill_exp (pl, tmp, skill); |
909 | return calc_skill_exp (pl, tmp, skill); |
909 | } |
910 | } |
910 | /* Charm failed. Creature may be angry now */ |
911 | /* Charm failed. Creature may be angry now */ |
911 | else if ((skill->level + ((pl->stats.Cha - 10) / 2)) < random_roll (1, 2 * tmp->level, pl, PREFER_LOW)) |
912 | else if ((skill->level + ((pl->stats.Cha - 10) / 2)) < random_roll (1, 2 * tmp->level, pl, PREFER_LOW)) |
912 | { |
913 | { |
913 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Your speech angers the %s!\n", query_name (tmp)); |
914 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Your speech angers the %s!\n", query_name (tmp)); |
914 | if (QUERY_FLAG (tmp, FLAG_FRIENDLY)) |
915 | if (QUERY_FLAG (tmp, FLAG_FRIENDLY)) |
915 | { |
916 | { |
916 | CLEAR_FLAG (tmp, FLAG_FRIENDLY); |
|
|
917 | remove_friendly_object (tmp); |
917 | remove_friendly_object (tmp); |
918 | tmp->attack_movement = 0; /* needed? */ |
918 | tmp->attack_movement = 0; /* needed? */ |
919 | } |
919 | } |
920 | |
920 | |
921 | CLEAR_FLAG (tmp, FLAG_UNAGGRESSIVE); |
921 | CLEAR_FLAG (tmp, FLAG_UNAGGRESSIVE); |
… | |
… | |
1122 | success += calc_skill_exp (op, tmp, skill); |
1122 | success += calc_skill_exp (op, tmp, skill); |
1123 | } |
1123 | } |
1124 | } |
1124 | } |
1125 | } |
1125 | } |
1126 | } |
1126 | } |
|
|
1127 | |
1127 | return success; |
1128 | return success; |
1128 | } |
1129 | } |
1129 | |
|
|
1130 | |
1130 | |
1131 | /* pray() - when this skill is called from do_skill(), it allows |
1131 | /* pray() - when this skill is called from do_skill(), it allows |
1132 | * the player to regain lost grace points at a faster rate. -b.t. |
1132 | * the player to regain lost grace points at a faster rate. -b.t. |
1133 | * This always returns 0 - return value is used by calling function |
1133 | * This always returns 0 - return value is used by calling function |
1134 | * such that if it returns true, player gets exp in that skill. This |
1134 | * such that if it returns true, player gets exp in that skill. This |
1135 | * the effect here can be done on demand, we probably don't want to |
1135 | * the effect here can be done on demand, we probably don't want to |
1136 | * give infinite exp by returning true in any cases. |
1136 | * give infinite exp by returning true in any cases. |
1137 | */ |
1137 | */ |
1138 | |
|
|
1139 | int |
1138 | int |
1140 | pray (object *pl, object *skill) |
1139 | pray (object *pl, object *skill) |
1141 | { |
1140 | { |
1142 | char buf[MAX_BUF]; |
1141 | char buf[MAX_BUF]; |
1143 | object *tmp; |
1142 | object *tmp; |
… | |
… | |
1168 | if (pl->stats.grace < pl->stats.maxgrace) |
1167 | if (pl->stats.grace < pl->stats.maxgrace) |
1169 | { |
1168 | { |
1170 | pl->stats.grace++; |
1169 | pl->stats.grace++; |
1171 | pl->last_grace = -1; |
1170 | pl->last_grace = -1; |
1172 | } |
1171 | } |
|
|
1172 | |
1173 | return 0; |
1173 | return 0; |
1174 | } |
1174 | } |
1175 | |
1175 | |
1176 | /* This skill allows the player to regain a few sp or hp for a |
1176 | /* This skill allows the player to regain a few sp or hp for a |
1177 | * brief period of concentration. No armour or weapons may be |
1177 | * brief period of concentration. No armour or weapons may be |
1178 | * wielded/applied for this to work. The amount of time needed |
1178 | * wielded/applied for this to work. The amount of time needed |
1179 | * to concentrate and the # of points regained is dependant on |
1179 | * to concentrate and the # of points regained is dependant on |
1180 | * the level of the user. - b.t. thomas@astro.psu.edu |
1180 | * the level of the user. - b.t. thomas@astro.psu.edu |
1181 | */ |
1181 | */ |
1182 | |
|
|
1183 | void |
1182 | void |
1184 | meditate (object *pl, object *skill) |
1183 | meditate (object *pl, object *skill) |
1185 | { |
1184 | { |
1186 | object *tmp; |
1185 | object *tmp; |
1187 | |
1186 | |
… | |
… | |
1230 | pl->last_heal = -1; |
1229 | pl->last_heal = -1; |
1231 | } |
1230 | } |
1232 | } |
1231 | } |
1233 | |
1232 | |
1234 | /* write_note() - this routine allows players to inscribe messages in |
1233 | /* write_note() - this routine allows players to inscribe messages in |
1235 | * ordinary 'books' (anything that is type BOOK). b.t. |
1234 | * ordinary inscribable 'books' (anything that is not a SPELL). b.t. |
1236 | */ |
1235 | */ |
1237 | static int |
1236 | static int |
1238 | write_note (object *pl, object *item, const char *msg, object *skill) |
1237 | write_note (object *pl, object *item, const char *msg, object *skill) |
1239 | { |
1238 | { |
|
|
1239 | |
|
|
1240 | if (strstr (msg, "\nendmsg")) |
|
|
1241 | { |
|
|
1242 | new_draw_info (NDI_UNIQUE, 0, pl, "Trying to cheat now are we?"); |
|
|
1243 | return 0; |
|
|
1244 | } |
|
|
1245 | |
|
|
1246 | int len = strlen (msg); |
|
|
1247 | |
|
|
1248 | if (!is_utf8_string ((U8 *)msg, len)) |
|
|
1249 | { |
|
|
1250 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Your message is garbled (text must be UTF-8, client-bug)!"); |
|
|
1251 | return 0; |
|
|
1252 | } |
|
|
1253 | |
|
|
1254 | if (INVOKE_OBJECT (INSCRIBE_NOTE, item, ARG_PLAYER (pl->contr), ARG_STRING (msg), ARG_OBJECT (skill))) |
|
|
1255 | return RESULT_INT (0); |
|
|
1256 | |
1240 | char buf[1024]; |
1257 | char buf[1024]; |
1241 | object *newBook = NULL; |
|
|
1242 | |
1258 | |
1243 | /* a pair of sanity checks */ |
1259 | if (len < sizeof (buf) - 2) |
1244 | if (!item || item->type != BOOK) |
|
|
1245 | return 0; |
|
|
1246 | |
|
|
1247 | if (!msg) |
|
|
1248 | { |
|
|
1249 | new_draw_info (NDI_UNIQUE, 0, pl, "No message to write!"); |
|
|
1250 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Usage: use_skill %s <message>", &skill->skill); |
|
|
1251 | return 0; |
|
|
1252 | } |
1260 | { |
|
|
1261 | snprintf (buf, sizeof (buf), "%s\n", msg); |
1253 | |
1262 | |
1254 | if (strcasestr_local (msg, "endmsg")) |
1263 | object *newbook = arch_to_object (item->other_arch); |
1255 | { |
|
|
1256 | new_draw_info (NDI_UNIQUE, 0, pl, "Trying to cheat now are we?"); |
|
|
1257 | return 0; |
|
|
1258 | } |
|
|
1259 | |
|
|
1260 | if (INVOKE_OBJECT (INSCRIBE_NOTE, item, ARG_PLAYER (pl->contr), ARG_STRING (msg), ARG_OBJECT (skill))) |
|
|
1261 | return strlen (msg); |
|
|
1262 | |
|
|
1263 | buf[0] = 0; |
|
|
1264 | if (!book_overflow (item->msg, msg, sizeof (buf))) |
|
|
1265 | { /* add msg string to book */ |
|
|
1266 | if (item->msg) |
|
|
1267 | strcpy (buf, item->msg); |
|
|
1268 | |
|
|
1269 | strcat (buf, msg); |
|
|
1270 | strcat (buf, "\n"); /* new msg needs a LF */ |
|
|
1271 | if (item->nrof > 1) |
|
|
1272 | { |
|
|
1273 | newBook = item->clone (); |
|
|
1274 | decrease_ob (item); |
1264 | decrease_ob (item); |
1275 | esrv_send_item (pl, item); |
1265 | esrv_send_item (pl, item); |
1276 | newBook->nrof = 1; |
1266 | newbook->nrof = 1; |
1277 | newBook->msg = buf; |
1267 | newbook->msg = buf; |
|
|
1268 | newbook->flag [FLAG_IDENTIFIED] = true; |
|
|
1269 | |
|
|
1270 | if (item->subtype == 1) // mailscrolls |
|
|
1271 | { |
|
|
1272 | newbook->name = item->name; |
|
|
1273 | newbook->name_pl = item->name_pl; |
|
|
1274 | } |
|
|
1275 | |
1278 | newBook = insert_ob_in_ob (newBook, pl); |
1276 | newbook = insert_ob_in_ob (newbook, pl); |
1279 | esrv_send_item (pl, newBook); |
1277 | esrv_send_item (pl, newbook); |
1280 | } |
|
|
1281 | else |
|
|
1282 | { |
|
|
1283 | item->msg = buf; |
|
|
1284 | /* This shouldn't be necessary - the object hasn't changed in any |
|
|
1285 | * visible way |
|
|
1286 | */ |
|
|
1287 | /* esrv_send_item(pl, item); */ |
|
|
1288 | } |
|
|
1289 | |
1278 | |
|
|
1279 | pl->contr->play_sound (sound_find ("inscribe_success")); |
1290 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You write in the %s.", query_short_name (item)); |
1280 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You write in the %s.", &item->name); |
1291 | return strlen (msg); |
1281 | return strlen (msg); |
1292 | } |
1282 | } |
1293 | else |
1283 | else |
1294 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Your message won't fit in the %s!", query_short_name (item)); |
1284 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Your message won't fit in the %s!", &item->name); |
1295 | |
1285 | |
1296 | return 0; |
1286 | return 0; |
1297 | } |
1287 | } |
1298 | |
1288 | |
1299 | /* write_scroll() - this routine allows players to inscribe spell scrolls |
1289 | /* write_scroll() - this routine allows players to inscribe spell scrolls |
1300 | * of spells which they know. Backfire effects are possible with the |
1290 | * of spells which they know. Backfire effects are possible with the |
1301 | * severity of the backlash correlated with the difficulty of the scroll |
1291 | * severity of the backlash correlated with the difficulty of the scroll |
1302 | * that is attempted. -b.t. thomas@astro.psu.edu |
1292 | * that is attempted. -b.t. thomas@astro.psu.edu |
1303 | */ |
1293 | */ |
1304 | |
|
|
1305 | static int |
1294 | static int |
1306 | write_scroll (object *pl, object *scroll, object *skill) |
1295 | write_scroll (object *pl, object *scroll, object *skill) |
1307 | { |
1296 | { |
1308 | int success = 0, confused = 0; |
1297 | int success = 0, confused = 0; |
1309 | object *newscroll, *chosen_spell, *tmp; |
|
|
1310 | |
|
|
1311 | /* this is a sanity check */ |
|
|
1312 | if (scroll->type != SCROLL) |
|
|
1313 | { |
|
|
1314 | new_draw_info (NDI_UNIQUE, 0, pl, "A spell can only be inscribed into a scroll!"); |
|
|
1315 | return 0; |
|
|
1316 | } |
|
|
1317 | |
1298 | |
1318 | /* Check if we are ready to attempt inscription */ |
1299 | /* Check if we are ready to attempt inscription */ |
1319 | chosen_spell = pl->contr->ranged_ob; |
1300 | object *chosen_spell = pl->contr->ranged_ob; |
|
|
1301 | |
1320 | if (!chosen_spell || chosen_spell->type != SPELL) |
1302 | if (!chosen_spell || chosen_spell->type != SPELL) |
1321 | { |
1303 | { |
1322 | new_draw_info (NDI_UNIQUE, 0, pl, "You need a spell readied in order to inscribe!"); |
1304 | new_draw_info (NDI_UNIQUE, 0, pl, "You need a spell readied in order to inscribe!"); |
1323 | return 0; |
1305 | return 0; |
1324 | } |
1306 | } |
… | |
… | |
1330 | } |
1312 | } |
1331 | |
1313 | |
1332 | if (SP_level_spellpoint_cost (pl, chosen_spell, SPELL_MANA) > pl->stats.sp) |
1314 | if (SP_level_spellpoint_cost (pl, chosen_spell, SPELL_MANA) > pl->stats.sp) |
1333 | { |
1315 | { |
1334 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You don't have enough mana to write a scroll of %s.", &chosen_spell->name); |
1316 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You don't have enough mana to write a scroll of %s.", &chosen_spell->name); |
1335 | return 0; |
|
|
1336 | } |
|
|
1337 | |
|
|
1338 | /* if there is a spell already on the scroll then player could easily |
|
|
1339 | * accidently read it while trying to write the new one. give player |
|
|
1340 | * a 50% chance to overwrite spell at their own level |
|
|
1341 | */ |
|
|
1342 | if ((scroll->stats.sp || scroll->inv) && random_roll (0, scroll->level * 2, pl, PREFER_LOW) > skill->level) |
|
|
1343 | { |
|
|
1344 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Oops! You accidently read it while trying to write on it."); |
|
|
1345 | manual_apply (pl, scroll, 0); |
|
|
1346 | return 0; |
1317 | return 0; |
1347 | } |
1318 | } |
1348 | |
1319 | |
1349 | /* ok, we are ready to try inscription */ |
1320 | /* ok, we are ready to try inscription */ |
1350 | if (QUERY_FLAG (pl, FLAG_CONFUSED)) |
1321 | if (QUERY_FLAG (pl, FLAG_CONFUSED)) |
… | |
… | |
1354 | pl->stats.grace -= SP_level_spellpoint_cost (pl, chosen_spell, SPELL_GRACE); |
1325 | pl->stats.grace -= SP_level_spellpoint_cost (pl, chosen_spell, SPELL_GRACE); |
1355 | pl->stats.sp -= SP_level_spellpoint_cost (pl, chosen_spell, SPELL_MANA); |
1326 | pl->stats.sp -= SP_level_spellpoint_cost (pl, chosen_spell, SPELL_MANA); |
1356 | |
1327 | |
1357 | if (random_roll (0, chosen_spell->level * 4 - 1, pl, PREFER_LOW) < skill->level) |
1328 | if (random_roll (0, chosen_spell->level * 4 - 1, pl, PREFER_LOW) < skill->level) |
1358 | { |
1329 | { |
1359 | if (scroll->nrof > 1) |
1330 | object *newscroll = arch_to_object (scroll->other_arch); |
1360 | { |
|
|
1361 | newscroll = scroll->clone (); |
|
|
1362 | decrease_ob (scroll); |
1331 | decrease_ob (scroll); |
1363 | newscroll->nrof = 1; |
1332 | newscroll->nrof = 1; |
1364 | } |
1333 | |
1365 | else |
1334 | pl->contr->play_sound (sound_find ("inscribe_success")); |
1366 | newscroll = scroll; |
|
|
1367 | |
1335 | |
1368 | if (!confused) |
1336 | if (!confused) |
1369 | { |
1337 | { |
1370 | newscroll->level = MAX (skill->level, chosen_spell->level); |
1338 | newscroll->level = MAX (skill->level, chosen_spell->level); |
|
|
1339 | newscroll->flag [FLAG_IDENTIFIED] = true; |
1371 | new_draw_info (NDI_UNIQUE, 0, pl, "You succeed in writing a new scroll."); |
1340 | new_draw_info (NDI_UNIQUE, 0, pl, "You succeed in writing the spell."); |
1372 | } |
1341 | } |
1373 | else |
1342 | else |
1374 | { |
1343 | { |
1375 | chosen_spell = find_random_spell_in_ob (pl, NULL); |
1344 | chosen_spell = find_random_spell_in_ob (pl, NULL); |
1376 | if (!chosen_spell) |
1345 | if (!chosen_spell) |
… | |
… | |
1378 | |
1347 | |
1379 | newscroll->level = MAX (skill->level, chosen_spell->level); |
1348 | newscroll->level = MAX (skill->level, chosen_spell->level); |
1380 | new_draw_info (NDI_UNIQUE, 0, pl, "In your confused state, you write down some odd spell."); |
1349 | new_draw_info (NDI_UNIQUE, 0, pl, "In your confused state, you write down some odd spell."); |
1381 | } |
1350 | } |
1382 | |
1351 | |
1383 | if (newscroll->inv) |
|
|
1384 | newscroll->inv->destroy (); |
|
|
1385 | |
|
|
1386 | tmp = chosen_spell->clone (); |
1352 | object *tmp = chosen_spell->clone (); |
1387 | insert_ob_in_ob (tmp, newscroll); |
1353 | insert_ob_in_ob (tmp, newscroll); |
1388 | |
1354 | |
1389 | /* Same code as from treasure.c - so they can better merge. |
1355 | /* Same code as from treasure.C - so they can better merge. |
1390 | * if players want to sell them, so be it. |
1356 | * if players want to sell them, so be it. |
1391 | */ |
1357 | */ |
1392 | newscroll->value = newscroll->arch->value * newscroll->inv->value * (newscroll->level + 50) / (newscroll->inv->level + 50); |
1358 | newscroll->value = newscroll->arch->value * newscroll->inv->value * (newscroll->level + 50) / (newscroll->inv->level + 50); |
1393 | newscroll->stats.exp = newscroll->value / 5; |
1359 | newscroll->stats.exp = newscroll->value / 5; |
1394 | |
1360 | |
1395 | /* wait until finished manipulating the scroll before inserting it */ |
|
|
1396 | if (newscroll == scroll) |
|
|
1397 | { |
|
|
1398 | /* Remove to correctly merge with other items which may exist in inventory */ |
|
|
1399 | newscroll->remove (); |
|
|
1400 | esrv_del_item (pl->contr, newscroll->count); |
|
|
1401 | } |
|
|
1402 | |
|
|
1403 | newscroll = insert_ob_in_ob (newscroll, pl); |
1361 | newscroll = insert_ob_in_ob (newscroll, pl); |
1404 | esrv_send_item (pl, newscroll); |
1362 | esrv_send_item (pl, newscroll); |
|
|
1363 | |
1405 | success = calc_skill_exp (pl, newscroll, skill); |
1364 | success = calc_skill_exp (pl, newscroll, skill); |
1406 | if (!confused) |
1365 | if (!confused) |
1407 | success *= 2; |
1366 | success *= 2; |
|
|
1367 | |
1408 | success = success * skill->level; |
1368 | success = success * skill->level; |
1409 | return success; |
1369 | return success; |
1410 | |
|
|
1411 | } |
1370 | } |
1412 | else |
1371 | else |
1413 | { /* Inscription has failed */ |
1372 | { /* Inscription has failed */ |
|
|
1373 | pl->contr->play_sound (sound_find ("inscribe_fail")); |
1414 | |
1374 | |
1415 | if (chosen_spell->level > skill->level || confused) |
1375 | if (chosen_spell->level > skill->level || confused) |
1416 | { /*backfire! */ |
1376 | { /*backfire! */ |
1417 | new_draw_info (NDI_UNIQUE, 0, pl, "Ouch! Your attempt to write a new scroll strains your mind!"); |
1377 | new_draw_info (NDI_UNIQUE, 0, pl, "Ouch! Your attempt to write a new scroll strains your mind!"); |
|
|
1378 | |
1418 | if (random_roll (0, 1, pl, PREFER_LOW) == 1) |
1379 | if (random_roll (0, 1, pl, PREFER_LOW) == 1) |
1419 | pl->drain_specific_stat (4); |
1380 | pl->drain_specific_stat (4); |
1420 | else |
1381 | else |
1421 | { |
1382 | { |
1422 | confuse_player (pl, pl, 99); |
1383 | confuse_player (pl, pl, 99); |
1423 | return (-30 * chosen_spell->level); |
1384 | return -30 * chosen_spell->level; |
1424 | } |
1385 | } |
1425 | } |
1386 | } |
1426 | else if (random_roll (0, pl->stats.Int - 1, pl, PREFER_HIGH) < 15) |
1387 | else if (random_roll (0, pl->stats.Int - 1, pl, PREFER_HIGH) < 15) |
1427 | { |
1388 | { |
1428 | new_draw_info (NDI_UNIQUE, 0, pl, "Your attempt to write a new scroll rattles your mind!"); |
1389 | new_draw_info (NDI_UNIQUE, 0, pl, "Your attempt to write a new scroll rattles your mind! H<Frankly spoken, you were too dumb and unlucky.>"); |
1429 | confuse_player (pl, pl, 99); |
1390 | confuse_player (pl, pl, 99); |
1430 | } |
1391 | } |
1431 | else |
1392 | else |
1432 | new_draw_info (NDI_UNIQUE, 0, pl, "You fail to write a new scroll."); |
1393 | new_draw_info (NDI_UNIQUE, 0, pl, "You fail to write a new scroll. H<Try a lower-level spell, if possible at all.>"); |
1433 | } |
1394 | } |
1434 | |
1395 | |
1435 | return 0; |
1396 | return 0; |
1436 | } |
1397 | } |
1437 | |
1398 | |
1438 | /* write_on_item() - wrapper for write_note and write_scroll */ |
1399 | /* write_on_item() - wrapper for write_note and write_scroll */ |
1439 | int |
1400 | int |
1440 | write_on_item (object *pl, const char *params, object *skill) |
1401 | write_on_item (object *pl, const char *params, object *skill) |
1441 | { |
1402 | { |
1442 | object *item; |
|
|
1443 | const char *string = params; |
|
|
1444 | int msgtype; |
|
|
1445 | archetype *skat; |
1403 | archetype *skat; |
1446 | |
1404 | |
1447 | if (pl->type != PLAYER) |
1405 | if (pl->type != PLAYER) |
1448 | return 0; |
1406 | return 0; |
1449 | |
1407 | |
1450 | if (!params) |
1408 | if (!params) |
1451 | { |
|
|
1452 | params = ""; |
1409 | params = ""; |
1453 | string = params; |
|
|
1454 | } |
|
|
1455 | |
1410 | |
1456 | skat = get_archetype_by_type_subtype (SKILL, SK_LITERACY); |
1411 | skat = get_archetype_by_type_subtype (SKILL, SK_LITERACY); |
1457 | |
1412 | |
1458 | /* Need to be able to read before we can write! */ |
1413 | /* Need to be able to read before we can write! */ |
1459 | if (!find_skill_by_name (pl, skat->skill)) |
1414 | if (!find_skill_by_name (pl, skat->skill)) |
1460 | { |
1415 | { |
1461 | new_draw_info (NDI_UNIQUE, 0, pl, "You must learn to read before you can write!"); |
1416 | new_draw_info (NDI_UNIQUE, 0, pl, "You must learn to read before you can write! H<You lack the literacy skill.>"); |
1462 | return 0; |
1417 | return 0; |
1463 | } |
1418 | } |
1464 | |
1419 | |
1465 | /* if there is a message then it goes in a book and no message means |
1420 | object *item = find_marked_object (pl); |
1466 | * write active spell into the scroll |
|
|
1467 | */ |
|
|
1468 | msgtype = (string[0] != '\0') ? BOOK : SCROLL; |
|
|
1469 | |
1421 | |
1470 | /* find an item of correct type to write on */ |
1422 | /* find an item of correct type to write on */ |
1471 | if (!(item = find_marked_object (pl))) |
1423 | if (!item) |
|
|
1424 | { |
|
|
1425 | new_draw_info (NDI_UNIQUE, 0, pl, "You don't have any marked item to write on. H<Use the mark command or the popup menu to makr an item.>"); |
|
|
1426 | return 0; |
1472 | { |
1427 | } |
1473 | new_draw_info (NDI_UNIQUE, 0, pl, "You don't have any marked item to write on."); |
1428 | |
|
|
1429 | if (item->type != INSCRIBABLE) |
|
|
1430 | { |
|
|
1431 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You cannot inscribe this! H<You can only inscribe empty scrolls and books.>"); |
1474 | return 0; |
1432 | return 0; |
1475 | } |
1433 | } |
1476 | |
1434 | |
1477 | if (QUERY_FLAG (item, FLAG_UNPAID)) |
1435 | if (QUERY_FLAG (item, FLAG_UNPAID)) |
1478 | { |
1436 | { |
1479 | new_draw_info (NDI_UNIQUE, 0, pl, "You had better pay for that before you write on it."); |
1437 | new_draw_info (NDI_UNIQUE, 0, pl, "You had better pay for that before you write on it."); |
1480 | return 0; |
1438 | return 0; |
1481 | } |
1439 | } |
1482 | if (msgtype != item->type) |
1440 | |
|
|
1441 | if (item->other_arch->type == SCROLL) |
1483 | { |
1442 | { |
1484 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You have no %s to write on", msgtype == BOOK ? "book" : "scroll"); |
1443 | if (*params) |
|
|
1444 | { |
|
|
1445 | // check readied scroll |
|
|
1446 | new_draw_info_format (NDI_UNIQUE, 0, pl, |
|
|
1447 | "When inscribing spells you need to ready a spell and do not specify a string argument.\n" |
|
|
1448 | "Usage: cast [spell name]; use_skill %s", &skill->skill); |
1485 | return 0; |
1449 | return 0; |
1486 | } |
1450 | } |
1487 | |
1451 | |
1488 | if (msgtype == SCROLL) |
|
|
1489 | return write_scroll (pl, item, skill); |
1452 | return write_scroll (pl, item, skill); |
1490 | else if (msgtype == BOOK) |
1453 | } |
|
|
1454 | else |
|
|
1455 | { |
|
|
1456 | if (!*params) |
|
|
1457 | { |
|
|
1458 | new_draw_info_format (NDI_UNIQUE, 0, pl, |
|
|
1459 | "When inscribing books you need to specify the words you want to inscribe as command argument.\n" |
|
|
1460 | "Usage: use_skill %s <message>", &skill->skill); |
|
|
1461 | return 0; |
|
|
1462 | } |
|
|
1463 | |
1491 | return write_note (pl, item, string, skill); |
1464 | return write_note (pl, item, params, skill); |
|
|
1465 | } |
1492 | |
1466 | |
1493 | return 0; |
1467 | return 0; |
1494 | } |
1468 | } |
1495 | |
1469 | |
1496 | /* find_throw_ob() - if we request an object, then |
1470 | /* find_throw_ob() - if we request an object, then |
… | |
… | |
1598 | object *toss_item = orig->clone (); |
1572 | object *toss_item = orig->clone (); |
1599 | |
1573 | |
1600 | toss_item->type = THROWN_OBJ; |
1574 | toss_item->type = THROWN_OBJ; |
1601 | CLEAR_FLAG (toss_item, FLAG_CHANGING); |
1575 | CLEAR_FLAG (toss_item, FLAG_CHANGING); |
1602 | toss_item->stats.dam = 0; /* default damage */ |
1576 | toss_item->stats.dam = 0; /* default damage */ |
1603 | insert_ob_in_ob (orig, toss_item); |
1577 | toss_item->insert (orig); |
|
|
1578 | |
1604 | return toss_item; |
1579 | return toss_item; |
1605 | } |
1580 | } |
1606 | |
1581 | |
1607 | /* do_throw() - op throws any object toss_item. This code |
1582 | /* do_throw() - op throws any object toss_item. This code |
1608 | * was borrowed from fire_bow. |
1583 | * was borrowed from fire_bow. |
… | |
… | |
1748 | */ |
1723 | */ |
1749 | throw_ob->inv->set_owner (op); |
1724 | throw_ob->inv->set_owner (op); |
1750 | throw_ob->direction = dir; |
1725 | throw_ob->direction = dir; |
1751 | |
1726 | |
1752 | /* the damage bonus from the force of the throw */ |
1727 | /* the damage bonus from the force of the throw */ |
1753 | dam = (int) (str_factor * dam_bonus[eff_str]); |
1728 | dam = int (str_factor * dam_bonus[eff_str]); |
1754 | |
1729 | |
1755 | /* Now, lets adjust the properties of the thrown_ob. */ |
1730 | /* Now, lets adjust the properties of the thrown_ob. */ |
1756 | |
1731 | |
1757 | /* how far to fly */ |
1732 | /* how far to fly */ |
1758 | throw_ob->last_sp = (eff_str * 3) / 5; |
1733 | throw_ob->last_sp = (eff_str * 3) / 5; |