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

Comparing deliantra/server/common/readable.C (file contents):
Revision 1.45 by root, Thu Oct 15 22:50:41 2009 UTC vs.
Revision 1.46 by root, Thu Oct 15 23:02:28 2009 UTC

1440 * of a randomly selected alchemical formula. 1440 * of a randomly selected alchemical formula.
1441 */ 1441 */
1442static void 1442static void
1443make_formula_book (object *book, int level) 1443make_formula_book (object *book, int level)
1444{ 1444{
1445 char retbuf[BOOK_BUF], title[MAX_BUF]; 1445 char title[MAX_BUF];
1446 recipelist *fl; 1446 recipelist *fl;
1447 recipe *formula = NULL; 1447 recipe *formula = NULL;
1448 int chance; 1448 int chance;
1449
1450 static dynbuf_text buf; buf.clear ();
1449 1451
1450 /* the higher the book level, the more complex (ie number of 1452 /* the higher the book level, the more complex (ie number of
1451 * ingredients) the formula can be. 1453 * ingredients) the formula can be.
1452 */ 1454 */
1453 fl = get_formulalist (rndm (level) / 3 + 1); 1455 fl = get_formulalist (rndm (level) / 3 + 1);
1466 /* get a random formula, weighted by its bookchance */ 1468 /* get a random formula, weighted by its bookchance */
1467 chance = rndm (fl->total_chance); 1469 chance = rndm (fl->total_chance);
1468 for (formula = fl->items; formula; formula = formula->next) 1470 for (formula = fl->items; formula; formula = formula->next)
1469 { 1471 {
1470 chance -= formula->chance; 1472 chance -= formula->chance;
1473
1471 if (chance <= 0) 1474 if (chance <= 0)
1472 break; 1475 break;
1473 } 1476 }
1474 1477
1475 if (!formula || formula->arch_names <= 0) 1478 if (!formula || formula->arch_names <= 0)
1476 { 1479 {
1477 book->msg = "<indecipherable text>\n"; 1480 book->msg = "<indecipherable text>\n";
1478 new_text_name (book, 4); 1481 new_text_name (book, 4);
1479 add_author (book, 4); 1482 add_author (book, 4);
1480 1483 return;
1481 } 1484 }
1485
1486 /* looks like a formula was found. Base the amount
1487 * of information on the booklevel and the spellevel
1488 * of the formula. */
1489
1490 const char *op_name = formula->arch_name [rndm (formula->arch_names)];
1491 archetype *at;
1492
1493 /* preamble */
1494 buf << "Herein is described a project using B<< "
1495 << (formula->skill ? &formula->skill : "an unknown skill")
1496 << " >>:\n\n";
1497
1498 if ((at = archetype::find (op_name)))
1499 op_name = at->object::name;
1482 else 1500 else
1501 LOG (llevError, "formula_msg() can't find arch %s for formula.\n", op_name);
1502
1503 /* item name */
1504 if (formula->title != shstr_NONE)
1505 {
1506 buf.printf ("The B<< %s of %s >>", op_name, &formula->title);
1507 /* This results in things like pile of philo. sulfur.
1508 * while philo. sulfur may look better, without this,
1509 * you get things like 'the wise' because its missing the
1510 * water of section.
1511 */
1512 sprintf (title, "%s: %s of %s",
1513 formula_book_name [rndm (sizeof (formula_book_name) / sizeof (char *))], op_name, &formula->title);
1483 { 1514 }
1484 /* looks like a formula was found. Base the amount 1515 else
1485 * of information on the booklevel and the spellevel 1516 {
1486 * of the formula. */ 1517 buf << "The B<< " << op_name;
1487 1518
1488 const char *op_name = formula->arch_name [rndm (formula->arch_names)]; 1519 sprintf (title, "%s: %s", formula_book_name [rndm (sizeof (formula_book_name) / sizeof (char *))], op_name);
1520 if (at->title)
1521 {
1522 buf << " " << at->title;
1523 strcat (title, " ");
1524 strcat (title, at->title);
1525 }
1526
1527 buf << " >>";
1528 }
1529
1530 /* Lets name the book something meaningful ! */
1531 book->name = title;
1532 book->title = NULL;
1533
1534 /* ingredients to make it */
1535 if (formula->ingred)
1536 {
1537 linked_char *next;
1489 archetype *at; 1538 archetype *at;
1490 1539
1491 /* preamble */
1492 sprintf (retbuf, "Herein is described a project using %s: \n", formula->skill ? &formula->skill : "an unknown skill");
1493
1494 if ((at = archetype::find (op_name)) != (archetype *) NULL)
1495 op_name = at->object::name;
1496 else
1497 LOG (llevError, "formula_msg() can't find arch %s for formula.\n", op_name);
1498
1499 /* item name */
1500 if (formula->title != shstr_NONE)
1501 {
1502 sprintf (retbuf, "%sThe %s of %s", retbuf, op_name, &formula->title);
1503 /* This results in things like pile of philo. sulfur.
1504 * while philo. sulfur may look better, without this,
1505 * you get things like 'the wise' because its missing the
1506 * water of section.
1507 */
1508 sprintf (title, "%s: %s of %s",
1509 formula_book_name [rndm (sizeof (formula_book_name) / sizeof (char *))], op_name, &formula->title);
1510 }
1511 else
1512 {
1513 sprintf (retbuf, "%sThe %s", retbuf, op_name);
1514 sprintf (title, "%s: %s", formula_book_name [rndm (sizeof (formula_book_name) / sizeof (char *))], op_name);
1515 if (at->title)
1516 {
1517 strcat (retbuf, " ");
1518 strcat (retbuf, at->title);
1519 strcat (title, " ");
1520 strcat (title, at->title);
1521 }
1522 }
1523
1524 /* Lets name the book something meaningful ! */
1525 book->name = title;
1526 book->title = NULL;
1527
1528 /* ingredients to make it */
1529 if (formula->ingred != NULL)
1530 {
1531 linked_char *next;
1532 archetype *at;
1533
1534 at = archetype::find (formula->cauldron); 1540 at = archetype::find (formula->cauldron);
1535 1541
1536 sprintf (retbuf + strlen (retbuf), 1542 buf.printf (" may be made at %s using the following ingredients:\n\n",
1537 " may be made at %s using the following ingredients:\n", at ? query_name (at) : "an unknown place"); 1543 at ? query_name (at) : "an appropriate place");
1538 1544
1539 for (next = formula->ingred; next != NULL; next = next->next) 1545 for (next = formula->ingred; next; next = next->next)
1540 { 1546 buf << next->name << '\r';
1541 strcat (retbuf, next->name); 1547 }
1542 strcat (retbuf, "\n");
1543 }
1544 }
1545 else 1548 else
1546 LOG (llevError, "formula_msg() no ingredient list for object %s of %s\n", op_name, &formula->title); 1549 LOG (llevError, "formula_msg() no ingredient list for object %s of %s\n", op_name, &formula->title);
1547 if (retbuf[strlen (retbuf) - 1] != '\n')
1548 strcat (retbuf, "\n");
1549 1550
1550 book->msg = retbuf; 1551 book->msg = buf;
1551 }
1552} 1552}
1553 1553
1554#define DESCRIBE_PATH(retbuf, variable, name) \ 1554#define DESCRIBE_PATH(retbuf, variable, name) \
1555 if(variable) { \ 1555 if(variable) { \
1556 int i,j=0; \ 1556 int i,j=0; \
1815 * 3) make sure there are entries for your case in new_text_title() 1815 * 3) make sure there are entries for your case in new_text_title()
1816 * and add_authour(). 1816 * and add_authour().
1817 * 4) you may want separate authour/book name arrays in read.h 1817 * 4) you may want separate authour/book name arrays in read.h
1818 */ 1818 */
1819 msg_type = msg_type > 0 ? msg_type : rndm (8); 1819 msg_type = msg_type > 0 ? msg_type : rndm (8);
1820 switch (msg_type*0+2)//D 1820 switch (msg_type*0+4)//D
1821 { 1821 {
1822 case 1: /* monster attrib */ 1822 case 1: /* monster attrib */
1823 strcpy (msgbuf, mon_info_msg (level, book_buf_size)); 1823 strcpy (msgbuf, mon_info_msg (level, book_buf_size));
1824 break; 1824 break;
1825 case 2: /* artifact attrib */ 1825 case 2: /* artifact attrib */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines