… | |
… | |
22 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | #include <global.h> |
25 | #include <global.h> |
26 | #include <object.h> |
26 | #include <object.h> |
27 | #ifndef __CEXTRACT__ |
|
|
28 | # include <sproto.h> |
27 | #include <sproto.h> |
29 | #endif |
|
|
30 | #include <living.h> |
28 | #include <living.h> |
31 | #include <skills.h> |
29 | #include <skills.h> |
32 | #include <spells.h> |
30 | #include <spells.h> |
33 | #include <book.h> |
31 | #include <book.h> |
34 | |
32 | |
… | |
… | |
1235 | } |
1233 | } |
1236 | |
1234 | |
1237 | /* write_note() - this routine allows players to inscribe messages in |
1235 | /* write_note() - this routine allows players to inscribe messages in |
1238 | * ordinary 'books' (anything that is type BOOK). b.t. |
1236 | * ordinary 'books' (anything that is type BOOK). b.t. |
1239 | */ |
1237 | */ |
1240 | |
|
|
1241 | static int |
1238 | static int |
1242 | write_note (object *pl, object *item, const char *msg, object *skill) |
1239 | write_note (object *pl, object *item, const char *msg, object *skill) |
1243 | { |
1240 | { |
1244 | char buf[1024]; |
1241 | char buf[1024]; |
1245 | object *newBook = NULL; |
1242 | object *newBook = NULL; |
… | |
… | |
1252 | { |
1249 | { |
1253 | new_draw_info (NDI_UNIQUE, 0, pl, "No message to write!"); |
1250 | new_draw_info (NDI_UNIQUE, 0, pl, "No message to write!"); |
1254 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Usage: use_skill %s <message>", &skill->skill); |
1251 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Usage: use_skill %s <message>", &skill->skill); |
1255 | return 0; |
1252 | return 0; |
1256 | } |
1253 | } |
|
|
1254 | |
1257 | if (strcasestr_local (msg, "endmsg")) |
1255 | if (strcasestr_local (msg, "endmsg")) |
1258 | { |
1256 | { |
1259 | new_draw_info (NDI_UNIQUE, 0, pl, "Trying to cheat now are we?"); |
1257 | new_draw_info (NDI_UNIQUE, 0, pl, "Trying to cheat now are we?"); |
1260 | return 0; |
1258 | return 0; |
1261 | } |
1259 | } |
… | |
… | |
1287 | /* This shouldn't be necessary - the object hasn't changed in any |
1285 | /* This shouldn't be necessary - the object hasn't changed in any |
1288 | * visible way |
1286 | * visible way |
1289 | */ |
1287 | */ |
1290 | /* esrv_send_item(pl, item); */ |
1288 | /* esrv_send_item(pl, item); */ |
1291 | } |
1289 | } |
|
|
1290 | |
1292 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You write in the %s.", query_short_name (item)); |
1291 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You write in the %s.", query_short_name (item)); |
1293 | return strlen (msg); |
1292 | return strlen (msg); |
1294 | } |
1293 | } |
1295 | else |
1294 | else |
1296 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Your message won't fit in the %s!", query_short_name (item)); |
1295 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Your message won't fit in the %s!", query_short_name (item)); |
… | |
… | |
1322 | if (!chosen_spell) |
1321 | if (!chosen_spell) |
1323 | { |
1322 | { |
1324 | new_draw_info (NDI_UNIQUE, 0, pl, "You need a spell readied in order to inscribe!"); |
1323 | new_draw_info (NDI_UNIQUE, 0, pl, "You need a spell readied in order to inscribe!"); |
1325 | return 0; |
1324 | return 0; |
1326 | } |
1325 | } |
|
|
1326 | |
1327 | if (SP_level_spellpoint_cost (pl, chosen_spell, SPELL_GRACE) > pl->stats.grace) |
1327 | if (SP_level_spellpoint_cost (pl, chosen_spell, SPELL_GRACE) > pl->stats.grace) |
1328 | { |
1328 | { |
1329 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You don't have enough grace to write a scroll of %s.", &chosen_spell->name); |
1329 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You don't have enough grace to write a scroll of %s.", &chosen_spell->name); |
1330 | return 0; |
1330 | return 0; |
1331 | } |
1331 | } |
|
|
1332 | |
1332 | if (SP_level_spellpoint_cost (pl, chosen_spell, SPELL_MANA) > pl->stats.sp) |
1333 | if (SP_level_spellpoint_cost (pl, chosen_spell, SPELL_MANA) > pl->stats.sp) |
1333 | { |
1334 | { |
1334 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You don't have enough mana to write a scroll of %s.", &chosen_spell->name); |
1335 | 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 | return 0; |
1336 | } |
1337 | } |
… | |
… | |
1361 | newscroll = scroll->clone (); |
1362 | newscroll = scroll->clone (); |
1362 | decrease_ob (scroll); |
1363 | decrease_ob (scroll); |
1363 | newscroll->nrof = 1; |
1364 | newscroll->nrof = 1; |
1364 | } |
1365 | } |
1365 | else |
1366 | else |
1366 | { |
|
|
1367 | newscroll = scroll; |
1367 | newscroll = scroll; |
1368 | } |
|
|
1369 | |
1368 | |
1370 | if (!confused) |
1369 | if (!confused) |
1371 | { |
1370 | { |
1372 | newscroll->level = MAX (skill->level, chosen_spell->level); |
1371 | newscroll->level = MAX (skill->level, chosen_spell->level); |
1373 | new_draw_info (NDI_UNIQUE, 0, pl, "You succeed in writing a new scroll."); |
1372 | new_draw_info (NDI_UNIQUE, 0, pl, "You succeed in writing a new scroll."); |
… | |
… | |
1399 | { |
1398 | { |
1400 | /* Remove to correctly merge with other items which may exist in inventory */ |
1399 | /* Remove to correctly merge with other items which may exist in inventory */ |
1401 | newscroll->remove (); |
1400 | newscroll->remove (); |
1402 | esrv_del_item (pl->contr, newscroll->count); |
1401 | esrv_del_item (pl->contr, newscroll->count); |
1403 | } |
1402 | } |
|
|
1403 | |
1404 | newscroll = insert_ob_in_ob (newscroll, pl); |
1404 | newscroll = insert_ob_in_ob (newscroll, pl); |
1405 | esrv_send_item (pl, newscroll); |
1405 | esrv_send_item (pl, newscroll); |
1406 | success = calc_skill_exp (pl, newscroll, skill); |
1406 | success = calc_skill_exp (pl, newscroll, skill); |
1407 | if (!confused) |
1407 | if (!confused) |
1408 | success *= 2; |
1408 | success *= 2; |
… | |
… | |
1451 | if (!params) |
1451 | if (!params) |
1452 | { |
1452 | { |
1453 | params = ""; |
1453 | params = ""; |
1454 | string = params; |
1454 | string = params; |
1455 | } |
1455 | } |
|
|
1456 | |
1456 | skat = get_archetype_by_type_subtype (SKILL, SK_LITERACY); |
1457 | skat = get_archetype_by_type_subtype (SKILL, SK_LITERACY); |
1457 | |
1458 | |
1458 | /* Need to be able to read before we can write! */ |
1459 | /* Need to be able to read before we can write! */ |
1459 | if (!find_skill_by_name (pl, skat->clone.skill)) |
1460 | if (!find_skill_by_name (pl, skat->clone.skill)) |
1460 | { |
1461 | { |
… | |
… | |
1484 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You have no %s to write on", msgtype == BOOK ? "book" : "scroll"); |
1485 | new_draw_info_format (NDI_UNIQUE, 0, pl, "You have no %s to write on", msgtype == BOOK ? "book" : "scroll"); |
1485 | return 0; |
1486 | return 0; |
1486 | } |
1487 | } |
1487 | |
1488 | |
1488 | if (msgtype == SCROLL) |
1489 | if (msgtype == SCROLL) |
1489 | { |
|
|
1490 | return write_scroll (pl, item, skill); |
1490 | return write_scroll (pl, item, skill); |
1491 | } |
|
|
1492 | else if (msgtype == BOOK) |
1491 | else if (msgtype == BOOK) |
1493 | { |
|
|
1494 | return write_note (pl, item, string, skill); |
1492 | return write_note (pl, item, string, skill); |
1495 | } |
1493 | |
1496 | return 0; |
1494 | return 0; |
1497 | } |
1495 | } |
1498 | |
|
|
1499 | |
|
|
1500 | |
1496 | |
1501 | /* find_throw_ob() - if we request an object, then |
1497 | /* find_throw_ob() - if we request an object, then |
1502 | * we search for it in the inventory of the owner (you've |
1498 | * we search for it in the inventory of the owner (you've |
1503 | * got to be carrying something in order to throw it!). |
1499 | * got to be carrying something in order to throw it!). |
1504 | * If we didnt request an object, then the top object in inventory |
1500 | * If we didnt request an object, then the top object in inventory |
1505 | * (that is "throwable", ie no throwing your skills away!) |
1501 | * (that is "throwable", ie no throwing your skills away!) |
1506 | * is the object of choice. Also check to see if object is |
1502 | * is the object of choice. Also check to see if object is |
1507 | * 'throwable' (ie not applied cursed obj, worn, etc). |
1503 | * 'throwable' (ie not applied cursed obj, worn, etc). |
1508 | */ |
1504 | */ |
1509 | |
|
|
1510 | static object * |
1505 | static object * |
1511 | find_throw_ob (object *op, const char *request) |
1506 | find_throw_ob (object *op, const char *request) |
1512 | { |
1507 | { |
1513 | object *tmp; |
1508 | object *tmp; |
1514 | |
1509 | |