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.81 by root, Sun Apr 4 04:10:47 2010 UTC vs.
Revision 1.82 by root, Mon Apr 5 02:05:32 2010 UTC

1466 * 'throwable' (ie not applied cursed obj, worn, etc). 1466 * 'throwable' (ie not applied cursed obj, worn, etc).
1467 */ 1467 */
1468static object * 1468static object *
1469find_throw_ob (object *op, const char *request) 1469find_throw_ob (object *op, const char *request)
1470{ 1470{
1471 object *tmp;
1472
1473 if (!op)
1474 { /* safety */
1475 LOG (llevError, "find_throw_ob(): confused! have a NULL thrower!\n");
1476 return (object *) NULL;
1477 }
1478
1479 /* prefer marked item */ 1471 /* prefer marked item */
1480 tmp = find_marked_object (op); 1472 object *tmp = find_marked_object (op);
1481 if (tmp != NULL) 1473
1482 {
1483 /* can't toss invisible or inv-locked items */ 1474 /* can't toss invisible or inv-locked items */
1484 if (tmp->invisible || QUERY_FLAG (tmp, FLAG_INV_LOCKED)) 1475 if (tmp && (tmp->invisible || QUERY_FLAG (tmp, FLAG_INV_LOCKED)))
1485 { 1476 tmp = 0;
1486 tmp = NULL;
1487 }
1488 }
1489 1477
1490 /* look through the inventory */ 1478 /* look through the inventory */
1491 if (tmp == NULL) 1479 if (tmp)
1492 {
1493 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 1480 for (tmp = op->inv; tmp; tmp = tmp->below)
1494 { 1481 {
1495 /* can't toss invisible or inv-locked items */ 1482 /* can't toss invisible or inv-locked items */
1496 if (tmp->invisible || QUERY_FLAG (tmp, FLAG_INV_LOCKED)) 1483 if (tmp->invisible || QUERY_FLAG (tmp, FLAG_INV_LOCKED))
1497 continue; 1484 continue;
1485
1498 if (!request || !strcmp (query_name (tmp), request) || !strcmp (&tmp->name, request)) 1486 if (!request || !strcmp (query_name (tmp), request) || !strcmp (&tmp->name, request))
1499 break; 1487 break;
1500 } 1488 }
1501 }
1502 1489
1503 /* this should prevent us from throwing away 1490 /* this should prevent us from throwing away
1504 * cursed items, worn armour, etc. Only weapons 1491 * cursed items, worn armour, etc. Only weapons
1505 * can be thrown from 'hand'. 1492 * can be thrown from 'hand'.
1506 */ 1493 */
1507 if (!tmp) 1494 if (!tmp)
1508 return NULL; 1495 return 0;
1509 1496
1510 if (QUERY_FLAG (tmp, FLAG_APPLIED)) 1497 if (tmp->flag [FLAG_APPLIED])
1511 { 1498 {
1512 if (tmp->type != WEAPON) 1499 if (tmp->type != WEAPON)
1513 { 1500 {
1514 new_draw_info_format (NDI_UNIQUE, 0, op, "You can't throw %s.", query_name (tmp)); 1501 new_draw_info_format (NDI_UNIQUE, 0, op, "You can't throw %s. H<Unapply it first.>", query_name (tmp));
1515 tmp = NULL; 1502 tmp = 0;
1516 } 1503 }
1517 else if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 1504 else if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED))
1518 { 1505 {
1519 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s sticks to your hand!", query_name (tmp)); 1506 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s sticks to your hand! H<Cursed or damned items cannot be removed.>", query_name (tmp));
1520 tmp = NULL; 1507 tmp = 0;
1521 } 1508 }
1522 else 1509 else
1523 { 1510 {
1524 if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) 1511 if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE))
1525 { 1512 {
1526 LOG (llevError, "BUG: find_throw_ob(): couldn't unapply\n"); 1513 LOG (llevError, "BUG: find_throw_ob(): couldn't unapply\n");
1527 tmp = NULL; 1514 tmp = 0;
1528 } 1515 }
1529 } 1516 }
1530 } 1517 }
1531 else if (QUERY_FLAG (tmp, FLAG_UNPAID)) 1518 else if (QUERY_FLAG (tmp, FLAG_UNPAID))
1532 { 1519 {
1533 new_draw_info_format (NDI_UNIQUE, 0, op, "You should pay for the %s first.", query_name (tmp)); 1520 new_draw_info_format (NDI_UNIQUE, 0, op, "You should pay for the %s first.", query_name (tmp));
1534 tmp = NULL; 1521 tmp = 0;
1535 } 1522 }
1536 1523
1524 //TODO: why not chekc first and give sensible message to player?
1537 if (tmp && QUERY_FLAG (tmp, FLAG_INV_LOCKED)) 1525 if (tmp && QUERY_FLAG (tmp, FLAG_INV_LOCKED))
1538 { 1526 {
1539 LOG (llevError, "BUG: find_throw_ob(): object is locked\n"); 1527 LOG (llevError, "BUG: find_throw_ob(): object is locked\n");
1540 tmp = NULL; 1528 tmp = 0;
1541 } 1529 }
1530
1542 return tmp; 1531 return tmp;
1543} 1532}
1544 1533
1545/* make_throw_ob() We construct the 'carrier' object in 1534/* make_throw_ob() We construct the 'carrier' object in
1546 * which we will insert the object that is being thrown. 1535 * which we will insert the object that is being thrown.
1581 int pause_f, weight_f = 0, mflags; 1570 int pause_f, weight_f = 0, mflags;
1582 float str_factor = 1.0, load_factor = 1.0, item_factor = 1.0; 1571 float str_factor = 1.0, load_factor = 1.0, item_factor = 1.0;
1583 maptile *m; 1572 maptile *m;
1584 sint16 sx, sy; 1573 sint16 sx, sy;
1585 1574
1586 if (throw_ob == NULL) 1575 if (!throw_ob)
1587 { 1576 {
1588 if (op->type == PLAYER) 1577 if (op->type == PLAYER)
1589 new_draw_info (NDI_UNIQUE, 0, op, "You have nothing to throw."); 1578 new_draw_info (NDI_UNIQUE, 0, op, "You have nothing to throw.");
1590 1579
1591 return 0; 1580 return 0;
1592 } 1581 }
1582
1593 if (QUERY_FLAG (throw_ob, FLAG_STARTEQUIP)) 1583 if (QUERY_FLAG (throw_ob, FLAG_STARTEQUIP))
1594 { 1584 {
1595 if (op->type == PLAYER) 1585 if (op->type == PLAYER)
1596 new_draw_info (NDI_UNIQUE, 0, op, "The gods won't let you throw that."); 1586 new_draw_info (NDI_UNIQUE, 0, op,
1587 "The gods won't let you throw that. "
1588 "H<Well, they would, but they would retrieve it "
1589 "- you wouldn't want that, would you?>");
1597 1590
1598 return 0; 1591 return 0;
1599 } 1592 }
1600 1593
1601 /* Because throwing effectiveness must be reduced by the 1594 /* Because throwing effectiveness must be reduced by the
1618 /* lighter items are thrown harder, farther, faster */ 1611 /* lighter items are thrown harder, farther, faster */
1619 if (throw_ob->weight > 0) 1612 if (throw_ob->weight > 0)
1620 item_factor = (float) maxc / (float) (3.0 * throw_ob->weight); 1613 item_factor = (float) maxc / (float) (3.0 * throw_ob->weight);
1621 else 1614 else
1622 { /* 0 or negative weight?!? Odd object, can't throw it */ 1615 { /* 0 or negative weight?!? Odd object, can't throw it */
1623 new_draw_info_format (NDI_UNIQUE, 0, op, "You can't throw %s.\n", query_name (throw_ob)); 1616 new_draw_info_format (NDI_UNIQUE, 0, op, "You can't throw %s. H<Better report this to your dungeon master.>\n", query_name (throw_ob));
1624 return 0; 1617 return 0;
1625 } 1618 }
1626 1619
1627 eff_str = (int) (str * (load_factor < 1.0 ? load_factor : 1.0)); 1620 eff_str = (str * (load_factor < 1.0 ? load_factor : 1.0))
1628 eff_str = (int) ((float) eff_str * item_factor * str_factor); 1621 * item_factor * str_factor;
1629 1622
1630 /* alas, arrays limit us to a value of MAX_STAT (30). Use str_factor to 1623 /* alas, arrays limit us to a value of MAX_STAT (30). Use str_factor to
1631 * account for super-strong throwers. */ 1624 * account for super-strong throwers. */
1632 if (eff_str > MAX_STAT) 1625 min_it (eff_str, MAX_STAT);
1633 eff_str = MAX_STAT;
1634 1626
1635#ifdef DEBUG_THROW 1627#ifdef DEBUG_THROW
1636 LOG (llevDebug, "%s carries %d, eff_str=%d\n", op->name, op->carrying, eff_str); 1628 LOG (llevDebug, "%s carries %d, eff_str=%d\n", op->name, op->carrying, eff_str);
1637 LOG (llevDebug, " max_c=%d, item_f=%f, load_f=%f, str=%d\n", maxc, item_factor, load_factor, op->stats.Str); 1629 LOG (llevDebug, " max_c=%d, item_f=%f, load_f=%f, str=%d\n", maxc, item_factor, load_factor, op->stats.Str);
1638 LOG (llevDebug, " str_factor=%f\n", str_factor); 1630 LOG (llevDebug, " str_factor=%f\n", str_factor);
1774 if (throw_ob->weight > 50) 1766 if (throw_ob->weight > 50)
1775 throw_ob->speed *= 0.5; 1767 throw_ob->speed *= 0.5;
1776 } /* else tailor thrown object */ 1768 } /* else tailor thrown object */
1777 1769
1778 /* some limits, and safeties (needed?) */ 1770 /* some limits, and safeties (needed?) */
1779 if (throw_ob->stats.dam < 0) 1771 max_it (throw_ob->stats.dam, 0);
1780 throw_ob->stats.dam = 0;
1781 if (throw_ob->last_sp > eff_str) 1772 min_it (throw_ob->last_sp, eff_str);
1782 throw_ob->last_sp = eff_str;
1783 if (throw_ob->stats.food < 0) 1773 max_it (throw_ob->stats.food, 0);
1784 throw_ob->stats.food = 0;
1785 if (throw_ob->stats.food > 100)
1786 throw_ob->stats.food = 100;
1787 if (throw_ob->stats.wc > 30) 1774 min_it (throw_ob->stats.wc, 30);
1788 throw_ob->stats.wc = 30;
1789 1775
1790 /* how long to pause the thrower. Higher values mean less pause */ 1776 /* how long to pause the thrower. Higher values mean less pause */
1791 pause_f = ((2 * eff_str) / 3) + 20 + skill->level; 1777 pause_f = ((2 * eff_str) / 3) + 20 + skill->level;
1792 1778
1793 /* Put a lower limit on this */ 1779 /* Put a lower limit on this */
1794 if (pause_f < 10) 1780 clamp_it (pause_f, 10, 100);
1795 pause_f = 10;
1796 if (pause_f > 100)
1797 pause_f = 100;
1798 1781
1799 /* Changed in 0.94.2 - the calculation before was really goofy. 1782 /* Changed in 0.94.2 - the calculation before was really goofy.
1800 * In short summary, a throw can take anywhere between speed 5 and 1783 * In short summary, a throw can take anywhere between speed 5 and
1801 * speed 0.5 1784 * speed 0.5
1802 */ 1785 */
1844} 1827}
1845 1828
1846bool 1829bool
1847skill_mining (object *who, object *tool, object *skill, int dir, const char *string) 1830skill_mining (object *who, object *tool, object *skill, int dir, const char *string)
1848{ 1831{
1849 printf ("******** mining\n"); 1832 if (!who->is_player ())
1833 return 0;
1834
1835 if (!dir)
1836 {
1837 who->failmsg ("In what direction?");
1838 return 0;
1839 }
1840
1841 mapxy pos (who); pos.move (dir);
1842
1843 if (!pos.normalise ())
1844 {
1845 who->failmsg (format (
1846 "You brandish your %s, with not so convincing results. "
1847 "H<There is nothing in this direction.>",
1848 &tool->name
1849 ));
1850 return 0;
1851 }
1852
1853 mapspace &ms = pos.ms ();
1854
1855 for (object *vein = pos.ms ().top; vein; vein = vein->below)
1856 if (vein->type == VEIN)
1857 {
1858 who->speed_left -= who->speed / tool->speed;
1859
1860 who->play_sound (tool->sound);
1861
1862 if (rndm (100 - vein->stats.ac) > rndm (tool->stats.wc))
1863 who->failmsg (format (
1864 "You use your %s.... nothing. "
1865 "H<Try again, perhaps?>",
1866 &tool->name
1867 ));
1868 else if (vein->race != tool->race)
1869 who->failmsg (format (
1870 "You use your %s.... but it doesn't work. "
1871 "H<Maybe you are using the wrong tool?>",
1872 &tool->name
1873 ));
1874 else if (!vein->stats.food)
1875 who->failmsg (format (
1876 "You use your %s.... but there is nothing. "
1877 "H<This space is exhausted, you should try somewhere else.>",
1878 &tool->name
1879 ));
1880 else
1881 {
1882 --vein->stats.food;
1883
1884 object *ore = vein->other_arch->instance ();
1885
1886 who->statusmsg (format (
1887 "You use your %s.... and find some %s!",
1888 &tool->name, &ore->name
1889 ));
1890
1891 ore->insert_at (who);
1892
1893 return true;
1894 }
1895 }
1896
1850 return false; 1897 return false;
1851} 1898}
1852 1899
1853bool 1900bool
1854skill_fishing (object *who, object *tool, object *skill, int dir, const char *string) 1901skill_fishing (object *who, object *tool, object *skill, int dir, const char *string)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines