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.77 by root, Fri Mar 19 17:48:49 2010 UTC vs.
Revision 1.82 by root, Mon Apr 5 02:05:32 2010 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,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2003,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2003 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 11 * option) any later version.
789use_oratory (object *pl, int dir, object *skill) 789use_oratory (object *pl, int dir, object *skill)
790{ 790{
791 if (pl->type != PLAYER) 791 if (pl->type != PLAYER)
792 return 0; /* only players use this skill */ 792 return 0; /* only players use this skill */
793 793
794 if (!dir)
795 {
796 pl->failmsg ("In what direction?");
797 return 0;
798 }
799
794 sint16 x = pl->x + freearr_x[dir], 800 sint16 x = pl->x + freearr_x[dir],
795 y = pl->y + freearr_y[dir]; 801 y = pl->y + freearr_y[dir];
796 maptile *m = pl->map; 802 maptile *m = pl->map;
797 803
798 int mflags = get_map_flags (m, &m, x, y, &x, &y); 804 int mflags = get_map_flags (m, &m, x, y, &x, &y);
923 sint16 x, y; 929 sint16 x, y;
924 930
925 if (pl->type != PLAYER) 931 if (pl->type != PLAYER)
926 return 0; /* only players use this skill */ 932 return 0; /* only players use this skill */
927 933
934 if (!dir)
935 {
936 pl->failmsg ("In what direction?");
937 return 0;
938 }
939
928 new_draw_info_format (NDI_UNIQUE, 0, pl, "You sing."); 940 new_draw_info_format (NDI_UNIQUE, 0, pl, "You sing.");
941 for (int i = skill->level >= SIZEOFFREE1 ? 0 : dir;
929 for (i = 0; i < min (skill->level, SIZEOFFREE); i++) 942 i < min (skill->level, SIZEOFFREE);
943 i++)
930 { 944 {
931 x = pl->x + freearr_x[i]; 945 x = pl->x + freearr_x[i];
932 y = pl->y + freearr_y[i]; 946 y = pl->y + freearr_y[i];
933 m = pl->map; 947 m = pl->map;
934 948
1452 * 'throwable' (ie not applied cursed obj, worn, etc). 1466 * 'throwable' (ie not applied cursed obj, worn, etc).
1453 */ 1467 */
1454static object * 1468static object *
1455find_throw_ob (object *op, const char *request) 1469find_throw_ob (object *op, const char *request)
1456{ 1470{
1457 object *tmp;
1458
1459 if (!op)
1460 { /* safety */
1461 LOG (llevError, "find_throw_ob(): confused! have a NULL thrower!\n");
1462 return (object *) NULL;
1463 }
1464
1465 /* prefer marked item */ 1471 /* prefer marked item */
1466 tmp = find_marked_object (op); 1472 object *tmp = find_marked_object (op);
1467 if (tmp != NULL) 1473
1468 {
1469 /* can't toss invisible or inv-locked items */ 1474 /* can't toss invisible or inv-locked items */
1470 if (tmp->invisible || QUERY_FLAG (tmp, FLAG_INV_LOCKED)) 1475 if (tmp && (tmp->invisible || QUERY_FLAG (tmp, FLAG_INV_LOCKED)))
1471 { 1476 tmp = 0;
1472 tmp = NULL;
1473 }
1474 }
1475 1477
1476 /* look through the inventory */ 1478 /* look through the inventory */
1477 if (tmp == NULL) 1479 if (tmp)
1478 {
1479 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 1480 for (tmp = op->inv; tmp; tmp = tmp->below)
1480 { 1481 {
1481 /* can't toss invisible or inv-locked items */ 1482 /* can't toss invisible or inv-locked items */
1482 if (tmp->invisible || QUERY_FLAG (tmp, FLAG_INV_LOCKED)) 1483 if (tmp->invisible || QUERY_FLAG (tmp, FLAG_INV_LOCKED))
1483 continue; 1484 continue;
1485
1484 if (!request || !strcmp (query_name (tmp), request) || !strcmp (&tmp->name, request)) 1486 if (!request || !strcmp (query_name (tmp), request) || !strcmp (&tmp->name, request))
1485 break; 1487 break;
1486 } 1488 }
1487 }
1488 1489
1489 /* this should prevent us from throwing away 1490 /* this should prevent us from throwing away
1490 * cursed items, worn armour, etc. Only weapons 1491 * cursed items, worn armour, etc. Only weapons
1491 * can be thrown from 'hand'. 1492 * can be thrown from 'hand'.
1492 */ 1493 */
1493 if (!tmp) 1494 if (!tmp)
1494 return NULL; 1495 return 0;
1495 1496
1496 if (QUERY_FLAG (tmp, FLAG_APPLIED)) 1497 if (tmp->flag [FLAG_APPLIED])
1497 { 1498 {
1498 if (tmp->type != WEAPON) 1499 if (tmp->type != WEAPON)
1499 { 1500 {
1500 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));
1501 tmp = NULL; 1502 tmp = 0;
1502 } 1503 }
1503 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))
1504 { 1505 {
1505 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));
1506 tmp = NULL; 1507 tmp = 0;
1507 } 1508 }
1508 else 1509 else
1509 { 1510 {
1510 if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) 1511 if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE))
1511 { 1512 {
1512 LOG (llevError, "BUG: find_throw_ob(): couldn't unapply\n"); 1513 LOG (llevError, "BUG: find_throw_ob(): couldn't unapply\n");
1513 tmp = NULL; 1514 tmp = 0;
1514 } 1515 }
1515 } 1516 }
1516 } 1517 }
1517 else if (QUERY_FLAG (tmp, FLAG_UNPAID)) 1518 else if (QUERY_FLAG (tmp, FLAG_UNPAID))
1518 { 1519 {
1519 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));
1520 tmp = NULL; 1521 tmp = 0;
1521 } 1522 }
1522 1523
1524 //TODO: why not chekc first and give sensible message to player?
1523 if (tmp && QUERY_FLAG (tmp, FLAG_INV_LOCKED)) 1525 if (tmp && QUERY_FLAG (tmp, FLAG_INV_LOCKED))
1524 { 1526 {
1525 LOG (llevError, "BUG: find_throw_ob(): object is locked\n"); 1527 LOG (llevError, "BUG: find_throw_ob(): object is locked\n");
1526 tmp = NULL; 1528 tmp = 0;
1527 } 1529 }
1530
1528 return tmp; 1531 return tmp;
1529} 1532}
1530 1533
1531/* make_throw_ob() We construct the 'carrier' object in 1534/* make_throw_ob() We construct the 'carrier' object in
1532 * which we will insert the object that is being thrown. 1535 * which we will insert the object that is being thrown.
1567 int pause_f, weight_f = 0, mflags; 1570 int pause_f, weight_f = 0, mflags;
1568 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;
1569 maptile *m; 1572 maptile *m;
1570 sint16 sx, sy; 1573 sint16 sx, sy;
1571 1574
1572 if (throw_ob == NULL) 1575 if (!throw_ob)
1573 { 1576 {
1574 if (op->type == PLAYER) 1577 if (op->type == PLAYER)
1575 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.");
1576 1579
1577 return 0; 1580 return 0;
1578 } 1581 }
1582
1579 if (QUERY_FLAG (throw_ob, FLAG_STARTEQUIP)) 1583 if (QUERY_FLAG (throw_ob, FLAG_STARTEQUIP))
1580 { 1584 {
1581 if (op->type == PLAYER) 1585 if (op->type == PLAYER)
1582 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?>");
1583 1590
1584 return 0; 1591 return 0;
1585 } 1592 }
1586 1593
1587 /* Because throwing effectiveness must be reduced by the 1594 /* Because throwing effectiveness must be reduced by the
1604 /* lighter items are thrown harder, farther, faster */ 1611 /* lighter items are thrown harder, farther, faster */
1605 if (throw_ob->weight > 0) 1612 if (throw_ob->weight > 0)
1606 item_factor = (float) maxc / (float) (3.0 * throw_ob->weight); 1613 item_factor = (float) maxc / (float) (3.0 * throw_ob->weight);
1607 else 1614 else
1608 { /* 0 or negative weight?!? Odd object, can't throw it */ 1615 { /* 0 or negative weight?!? Odd object, can't throw it */
1609 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));
1610 return 0; 1617 return 0;
1611 } 1618 }
1612 1619
1613 eff_str = (int) (str * (load_factor < 1.0 ? load_factor : 1.0)); 1620 eff_str = (str * (load_factor < 1.0 ? load_factor : 1.0))
1614 eff_str = (int) ((float) eff_str * item_factor * str_factor); 1621 * item_factor * str_factor;
1615 1622
1616 /* 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
1617 * account for super-strong throwers. */ 1624 * account for super-strong throwers. */
1618 if (eff_str > MAX_STAT) 1625 min_it (eff_str, MAX_STAT);
1619 eff_str = MAX_STAT;
1620 1626
1621#ifdef DEBUG_THROW 1627#ifdef DEBUG_THROW
1622 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);
1623 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);
1624 LOG (llevDebug, " str_factor=%f\n", str_factor); 1630 LOG (llevDebug, " str_factor=%f\n", str_factor);
1760 if (throw_ob->weight > 50) 1766 if (throw_ob->weight > 50)
1761 throw_ob->speed *= 0.5; 1767 throw_ob->speed *= 0.5;
1762 } /* else tailor thrown object */ 1768 } /* else tailor thrown object */
1763 1769
1764 /* some limits, and safeties (needed?) */ 1770 /* some limits, and safeties (needed?) */
1765 if (throw_ob->stats.dam < 0) 1771 max_it (throw_ob->stats.dam, 0);
1766 throw_ob->stats.dam = 0;
1767 if (throw_ob->last_sp > eff_str) 1772 min_it (throw_ob->last_sp, eff_str);
1768 throw_ob->last_sp = eff_str;
1769 if (throw_ob->stats.food < 0) 1773 max_it (throw_ob->stats.food, 0);
1770 throw_ob->stats.food = 0;
1771 if (throw_ob->stats.food > 100)
1772 throw_ob->stats.food = 100;
1773 if (throw_ob->stats.wc > 30) 1774 min_it (throw_ob->stats.wc, 30);
1774 throw_ob->stats.wc = 30;
1775 1775
1776 /* how long to pause the thrower. Higher values mean less pause */ 1776 /* how long to pause the thrower. Higher values mean less pause */
1777 pause_f = ((2 * eff_str) / 3) + 20 + skill->level; 1777 pause_f = ((2 * eff_str) / 3) + 20 + skill->level;
1778 1778
1779 /* Put a lower limit on this */ 1779 /* Put a lower limit on this */
1780 if (pause_f < 10) 1780 clamp_it (pause_f, 10, 100);
1781 pause_f = 10;
1782 if (pause_f > 100)
1783 pause_f = 100;
1784 1781
1785 /* Changed in 0.94.2 - the calculation before was really goofy. 1782 /* Changed in 0.94.2 - the calculation before was really goofy.
1786 * 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
1787 * speed 0.5 1784 * speed 0.5
1788 */ 1785 */
1826 else 1823 else
1827 throw_ob = find_mon_throw_ob (op); 1824 throw_ob = find_mon_throw_ob (op);
1828 1825
1829 return do_throw (op, part, throw_ob, dir, skill); 1826 return do_throw (op, part, throw_ob, dir, skill);
1830} 1827}
1828
1829bool
1830skill_mining (object *who, object *tool, object *skill, int dir, const char *string)
1831{
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
1897 return false;
1898}
1899
1900bool
1901skill_fishing (object *who, object *tool, object *skill, int dir, const char *string)
1902{
1903 printf ("******** fishing\n");
1904 return false;
1905}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines