… | |
… | |
21 | * |
21 | * |
22 | * The author can be reached via e-mail to <crossfire@schmorp.de> |
22 | * The author can be reached via e-mail to <crossfire@schmorp.de> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | #include <global.h> |
25 | #include <global.h> |
26 | #include <pwd.h> |
|
|
27 | #include <sproto.h> |
26 | #include <sproto.h> |
28 | #include <sounds.h> |
27 | #include <sounds.h> |
29 | #include <living.h> |
28 | #include <living.h> |
30 | #include <object.h> |
29 | #include <object.h> |
31 | #include <spells.h> |
30 | #include <spells.h> |
… | |
… | |
146 | } |
145 | } |
147 | |
146 | |
148 | draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, |
147 | draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, |
149 | MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s\n", (char *)"%s\n%s", subject, news); |
148 | MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s\n", (char *)"%s\n%s", subject, news); |
150 | close_and_delete (fp, comp); |
149 | close_and_delete (fp, comp); |
|
|
150 | } |
|
|
151 | |
|
|
152 | float |
|
|
153 | player::weapon_speed () const |
|
|
154 | { |
|
|
155 | return ob->speed / weapon_sp * .5f;//TODO, the .5 is arbitrary |
151 | } |
156 | } |
152 | |
157 | |
153 | /* This loads the first map an puts the player on it. */ |
158 | /* This loads the first map an puts the player on it. */ |
154 | static void |
159 | static void |
155 | set_first_map (object *op) |
160 | set_first_map (object *op) |
… | |
… | |
208 | |
213 | |
209 | players.erase (this); |
214 | players.erase (this); |
210 | } |
215 | } |
211 | |
216 | |
212 | // connect the player with a specific client |
217 | // connect the player with a specific client |
213 | // also changed, rationalises, and fixes some incorrect settings |
218 | // also changes, rationalises, and fixes some incorrect settings |
214 | void |
219 | void |
215 | player::connect (client *ns) |
220 | player::connect (client *ns) |
216 | { |
221 | { |
217 | this->ns = ns; |
222 | this->ns = ns; |
218 | ns->pl = this; |
223 | ns->pl = this; |
… | |
… | |
259 | |
264 | |
260 | new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!"); |
265 | new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!"); |
261 | |
266 | |
262 | esrv_new_player (this, ob->weight + ob->carrying); |
267 | esrv_new_player (this, ob->weight + ob->carrying); |
263 | |
268 | |
|
|
269 | ob->flag [FLAG_READY_WEAPON] = false; |
|
|
270 | ob->flag [FLAG_READY_SKILL] = false; |
|
|
271 | ob->flag [FLAG_READY_BOW] = false; |
|
|
272 | |
|
|
273 | for (object *op = ob->inv; op; op = op->below) |
|
|
274 | if (op->flag [FLAG_APPLIED]) |
|
|
275 | switch (op->type) |
|
|
276 | { |
|
|
277 | case WAND: |
|
|
278 | case ROD: |
|
|
279 | case HORN: |
|
|
280 | case BOW: |
|
|
281 | case SKILL_TOOL: |
|
|
282 | case WEAPON: |
|
|
283 | op->flag [FLAG_APPLIED] = false; |
|
|
284 | apply_special (ob, op, AP_APPLY); |
|
|
285 | break; |
|
|
286 | |
|
|
287 | case SKILL: |
|
|
288 | op->flag [FLAG_APPLIED] = false; |
|
|
289 | break; |
|
|
290 | } |
|
|
291 | |
|
|
292 | ob->change_weapon (combat_ob ? combat_ob : ranged_ob); |
264 | ob->update_stats (); |
293 | ob->update_stats (); |
|
|
294 | |
265 | ns->floorbox_update (); |
295 | ns->floorbox_update (); |
266 | |
|
|
267 | esrv_send_inventory (ob, ob); |
296 | esrv_send_inventory (ob, ob); |
268 | esrv_add_spells (this, 0); |
297 | esrv_add_spells (this, 0); |
269 | |
298 | |
270 | activate (); |
299 | activate (); |
271 | |
300 | |
… | |
… | |
304 | player::set_object (object *op) |
333 | player::set_object (object *op) |
305 | { |
334 | { |
306 | ob = op; |
335 | ob = op; |
307 | ob->contr = this; /* this aren't yet in archetype */ |
336 | ob->contr = this; /* this aren't yet in archetype */ |
308 | |
337 | |
309 | ob->speed_left = 0.5; |
338 | ob->speed_left = 0.5f; |
310 | ob->speed = 1.0; |
339 | ob->speed = 1.0f; |
311 | ob->direction = 5; /* So player faces south */ |
340 | ob->direction = 5; /* So player faces south */ |
312 | } |
341 | } |
313 | |
342 | |
314 | player::player () |
343 | player::player () |
315 | { |
344 | { |
… | |
… | |
769 | } |
798 | } |
770 | |
799 | |
771 | void |
800 | void |
772 | object::roll_stats () |
801 | object::roll_stats () |
773 | { |
802 | { |
774 | int statsort [7]; |
803 | int statsort [NUM_STATS]; |
775 | |
804 | |
776 | for (;;) |
805 | for (;;) |
777 | { |
806 | { |
778 | int sum = 0; |
807 | int sum = 0; |
779 | for (int i = 7; i--; ) |
808 | for (int i = NUM_STATS; i--; ) |
780 | sum += statsort [i] = roll_stat (); |
809 | sum += statsort [i] = roll_stat (); |
781 | |
810 | |
782 | if (sum >= 82 && sum <= 116) |
811 | if (sum >= 82 && sum <= 116) |
783 | break; |
812 | break; |
784 | } |
813 | } |
785 | |
814 | |
786 | // Sort the stats so that rerolling is easier... |
815 | // Sort the stats so that rerolling is easier... |
787 | std::sort (statsort, statsort + 7, std::greater<int>()); |
816 | std::sort (statsort, statsort + NUM_STATS, std::greater<int>()); |
788 | |
817 | |
|
|
818 | for (int i = 0; i < NUM_STATS; ++i) |
789 | stats.Str = statsort[0]; |
819 | stats.stat (i) = statsort [i]; |
790 | stats.Dex = statsort[1]; |
|
|
791 | stats.Con = statsort[2]; |
|
|
792 | stats.Int = statsort[3]; |
|
|
793 | stats.Wis = statsort[4]; |
|
|
794 | stats.Pow = statsort[5]; |
|
|
795 | stats.Cha = statsort[6]; |
|
|
796 | |
820 | |
797 | stats.exp = 0; |
821 | stats.exp = 0; |
798 | stats.ac = 0; |
822 | stats.ac = 0; |
799 | |
823 | |
800 | stats.hp = stats.maxhp; |
824 | stats.hp = stats.maxhp; |
… | |
… | |
812 | } |
836 | } |
813 | |
837 | |
814 | void |
838 | void |
815 | object::swap_stats (int a, int b) |
839 | object::swap_stats (int a, int b) |
816 | { |
840 | { |
817 | int tmp = get_attr_value (&contr->orig_stats, a); |
841 | swap (contr->orig_stats.stat (a), contr->orig_stats.stat (b)); |
818 | set_attr_value (&contr->orig_stats, a, get_attr_value (&contr->orig_stats, b)); |
|
|
819 | set_attr_value (&contr->orig_stats, b, tmp); |
|
|
820 | |
842 | |
|
|
843 | for (int i = 0; i < NUM_STATS; ++i) |
821 | stats.Str = contr->orig_stats.Str; |
844 | stats.stat (i) = contr->orig_stats.stat (i); |
822 | stats.Dex = contr->orig_stats.Dex; |
|
|
823 | stats.Con = contr->orig_stats.Con; |
|
|
824 | stats.Int = contr->orig_stats.Int; |
|
|
825 | stats.Wis = contr->orig_stats.Wis; |
|
|
826 | stats.Pow = contr->orig_stats.Pow; |
|
|
827 | stats.Cha = contr->orig_stats.Cha; |
|
|
828 | |
845 | |
829 | //TODO: the following code looks so borked and should, at the very least, |
846 | //TODO: the following code looks so borked and should, at the very least, |
830 | // be merged with the similar code in roll_stats |
847 | // be merged with the similar code in roll_stats |
831 | stats.ac = 0; |
848 | stats.ac = 0; |
832 | |
849 | |
… | |
… | |
1009 | /* Cornered, get rid of scared */ |
1026 | /* Cornered, get rid of scared */ |
1010 | CLEAR_FLAG (op, FLAG_SCARED); |
1027 | CLEAR_FLAG (op, FLAG_SCARED); |
1011 | op->enemy = NULL; |
1028 | op->enemy = NULL; |
1012 | } |
1029 | } |
1013 | |
1030 | |
1014 | |
|
|
1015 | /* check_pick sees if there is stuff to be picked up/picks up stuff. |
1031 | /* check_pick sees if there is stuff to be picked up/picks up stuff. |
1016 | * IT returns 1 if the player should keep on moving, 0 if he should |
1032 | * It returns 1 if the player should keep on moving, 0 if he should |
1017 | * stop. |
1033 | * stop. |
1018 | */ |
1034 | */ |
1019 | int |
1035 | int |
1020 | check_pick (object *op) |
1036 | check_pick (object *op) |
1021 | { |
1037 | { |
… | |
… | |
1533 | */ |
1549 | */ |
1534 | int |
1550 | int |
1535 | fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) |
1551 | fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) |
1536 | { |
1552 | { |
1537 | object *left, *bow; |
1553 | object *left, *bow; |
1538 | int bowspeed, mflags; |
1554 | int mflags; |
1539 | maptile *m; |
1555 | maptile *m; |
1540 | |
1556 | |
1541 | if (!dir) |
1557 | if (!dir) |
1542 | { |
1558 | { |
1543 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1559 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1544 | return 0; |
1560 | return 0; |
1545 | } |
1561 | } |
1546 | |
1562 | |
1547 | if (player *pl = op->contr) |
1563 | if (op->contr) |
1548 | { |
1564 | bow = op->current_weapon; |
1549 | bow = pl->ranged_ob; |
|
|
1550 | |
|
|
1551 | if (op->current_weapon != pl->ranged_ob) |
|
|
1552 | { |
|
|
1553 | op->current_weapon = pl->ranged_ob; |
|
|
1554 | new_draw_info_format (NDI_UNIQUE, 0, op, "You switch to your %s.", &op->current_weapon->name); |
|
|
1555 | op->update_stats (); |
|
|
1556 | } |
|
|
1557 | } |
|
|
1558 | else |
1565 | else |
1559 | { |
1566 | { |
1560 | for (bow = op->inv; bow; bow = bow->below) |
1567 | for (bow = op->inv; bow; bow = bow->below) |
1561 | /* Don't check for applied - monsters don't apply bows - in that way, they |
1568 | /* Don't check for applied - monsters don't apply bows - in that way, they |
1562 | * don't need to switch back and forth between bows and weapons. |
1569 | * don't need to switch back and forth between bows and weapons. |
… | |
… | |
1583 | { |
1590 | { |
1584 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); |
1591 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); |
1585 | return 0; |
1592 | return 0; |
1586 | } |
1593 | } |
1587 | |
1594 | |
1588 | bowspeed = bow->stats.sp + dex_bonus[op->stats.Dex]; |
|
|
1589 | |
|
|
1590 | /* penalize ROF for bestarrow */ |
|
|
1591 | if (op->type == PLAYER && op->contr->bowtype == bow_bestarrow) |
|
|
1592 | bowspeed -= dex_bonus[op->stats.Dex] + 5; |
|
|
1593 | |
|
|
1594 | if (bowspeed < 1) |
|
|
1595 | bowspeed = 1; |
|
|
1596 | |
|
|
1597 | if (arrow == NULL) |
1595 | if (arrow == NULL) |
1598 | { |
1596 | { |
1599 | if ((arrow = find_arrow (op, bow->race)) == NULL) |
1597 | if ((arrow = find_arrow (op, bow->race)) == NULL) |
1600 | { |
1598 | { |
1601 | if (op->type == PLAYER) |
1599 | if (op->type == PLAYER) |
… | |
… | |
1635 | |
1633 | |
1636 | arrow->set_owner (op); |
1634 | arrow->set_owner (op); |
1637 | arrow->skill = bow->skill; |
1635 | arrow->skill = bow->skill; |
1638 | arrow->direction = dir; |
1636 | arrow->direction = dir; |
1639 | |
1637 | |
1640 | if (op->type == PLAYER) |
|
|
1641 | { |
|
|
1642 | op->speed_left = 0.01 - (float) FABS (op->speed) * 100 / bowspeed; |
|
|
1643 | op->update_stats (); |
|
|
1644 | } |
|
|
1645 | |
|
|
1646 | SET_ANIMATION (arrow, arrow->direction); |
|
|
1647 | |
|
|
1648 | arrow->stats.sp = arrow->stats.wc; /* save original wc and dam */ |
1638 | arrow->stats.sp = arrow->stats.wc; /* save original wc, dam, attacktype and slaying */ |
1649 | arrow->stats.hp = arrow->stats.dam; |
1639 | arrow->stats.hp = arrow->stats.dam; |
1650 | arrow->stats.grace = arrow->attacktype; |
1640 | arrow->stats.grace = arrow->attacktype; |
1651 | |
1641 | |
1652 | if (arrow->slaying) |
1642 | if (arrow->slaying) |
1653 | arrow->spellarg = strdup (arrow->slaying); |
1643 | arrow->spellarg = strdup (arrow->slaying); |
1654 | |
1644 | |
1655 | arrow->stats.dam += op->stats.dam + arrow->magic; |
1645 | if (player *pl = op->contr) |
|
|
1646 | { |
|
|
1647 | if (!pl->has_hit) |
|
|
1648 | { |
|
|
1649 | pl->has_hit = 1; |
|
|
1650 | pl->ob->speed_left += pl->weapon_speed () - pl->ob->speed; |
|
|
1651 | } |
|
|
1652 | #if 0 |
|
|
1653 | float speed = pl->weapon_sp; |
|
|
1654 | |
|
|
1655 | /* penalize ROF for bestarrow */ |
|
|
1656 | if (pl->bowtype == bow_bestarrow) |
|
|
1657 | speed *= .9f; |
|
|
1658 | else |
|
|
1659 | speed *= 1.f + dex_bonus[op->stats.Dex] * .2f; |
|
|
1660 | |
|
|
1661 | op->speed_left += speed - op->speed; |
|
|
1662 | #endif |
|
|
1663 | } |
|
|
1664 | |
|
|
1665 | SET_ANIMATION (arrow, arrow->direction); |
1656 | |
1666 | |
1657 | /* update the speed */ |
1667 | /* update the speed */ |
1658 | arrow->speed = (float) ((QUERY_FLAG (bow, FLAG_NO_STRENGTH) ? |
1668 | arrow->speed = ((bow->flag [FLAG_NO_STRENGTH] ? 0 : dam_bonus[op->stats.Str]) + bow->magic + arrow->magic) / 5.0 |
1659 | 0 : dam_bonus[op->stats.Str]) + bow->magic + arrow->magic) / 5.0 + (float) bow->stats.dam / 7.0; |
1669 | + bow->stats.dam / 7.0; |
1660 | |
1670 | |
1661 | arrow->set_speed (max (arrow->speed, 1.0)); |
1671 | arrow->set_speed (max (arrow->speed, 2.0)); |
1662 | arrow->speed_left = 0; |
1672 | arrow->speed_left = 0; |
1663 | |
1673 | |
1664 | arrow->stats.wc = op->stats.wc + wc_mod - arrow->magic - arrow->stats.wc; |
1674 | int wc = op->stats.wc + wc_mod - arrow->magic - arrow->stats.wc; |
1665 | |
1675 | |
1666 | if (op->type == PLAYER) |
1676 | if (op->type == PLAYER) |
1667 | { |
1677 | { |
1668 | arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; |
1678 | arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; |
1669 | arrow->stats.wc -= dex_bonus[op->stats.Dex]; |
1679 | wc -= dex_bonus[op->stats.Dex]; |
1670 | |
1680 | |
1671 | if (!arrow->slaying) |
1681 | if (!arrow->slaying) |
1672 | arrow->slaying = op->slaying; |
1682 | arrow->slaying = op->slaying; |
|
|
1683 | |
|
|
1684 | arrow->attacktype |= op->attacktype; |
1673 | } |
1685 | } |
1674 | else |
1686 | else |
1675 | { |
1687 | { |
1676 | arrow->level = op->level; |
1688 | arrow->level = op->level; |
1677 | arrow->stats.wc -= bow->magic; |
1689 | arrow->stats.wc -= bow->magic; |
1678 | |
1690 | |
1679 | if (!arrow->slaying) |
1691 | if (!arrow->slaying) |
1680 | arrow->slaying = bow->slaying; |
1692 | arrow->slaying = bow->slaying; |
1681 | } |
|
|
1682 | |
1693 | |
1683 | arrow->stats.wc -= arrow->level; |
|
|
1684 | |
|
|
1685 | arrow->attacktype |= bow->attacktype; |
1694 | arrow->attacktype |= bow->attacktype; |
|
|
1695 | } |
1686 | |
1696 | |
|
|
1697 | wc -= arrow->level; |
|
|
1698 | arrow->stats.dam = clamp (arrow->stats.dam + op->stats.dam + arrow->magic, MIN_DAM, MAX_DAM); |
|
|
1699 | |
|
|
1700 | arrow->stats.wc = clamp (wc, MIN_WC, MAX_WC); |
1687 | arrow->move_type = MOVE_FLY_LOW; |
1701 | arrow->move_type = MOVE_FLY_LOW; |
1688 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1702 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1689 | |
1703 | |
1690 | play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); |
1704 | play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); |
1691 | m->insert (arrow, sx, sy, op); |
1705 | m->insert (arrow, sx, sy, op); |
… | |
… | |
1736 | else if (op->contr->bowtype == bow_spreadshot) |
1750 | else if (op->contr->bowtype == bow_spreadshot) |
1737 | { |
1751 | { |
1738 | ret |= fire_bow (op, op, NULL, dir, 0, op->x, op->y); |
1752 | ret |= fire_bow (op, op, NULL, dir, 0, op->x, op->y); |
1739 | ret |= fire_bow (op, op, NULL, absdir (dir - 1), -5, op->x, op->y); |
1753 | ret |= fire_bow (op, op, NULL, absdir (dir - 1), -5, op->x, op->y); |
1740 | ret |= fire_bow (op, op, NULL, absdir (dir + 1), -5, op->x, op->y); |
1754 | ret |= fire_bow (op, op, NULL, absdir (dir + 1), -5, op->x, op->y); |
1741 | |
|
|
1742 | } |
1755 | } |
1743 | else |
1756 | else |
1744 | { |
1757 | { |
1745 | /* Simple case */ |
1758 | /* Simple case */ |
1746 | ret = fire_bow (op, op, NULL, dir, 0, op->x, op->y); |
1759 | ret = fire_bow (op, op, NULL, dir, 0, op->x, op->y); |
1747 | } |
1760 | } |
|
|
1761 | |
1748 | return ret; |
1762 | return ret; |
1749 | } |
1763 | } |
1750 | |
|
|
1751 | |
1764 | |
1752 | /* Fires a misc (wand/rod/horn) object in 'dir'. |
1765 | /* Fires a misc (wand/rod/horn) object in 'dir'. |
1753 | * Broken apart from 'fire' to keep it more readable. |
1766 | * Broken apart from 'fire' to keep it more readable. |
1754 | */ |
1767 | */ |
1755 | void |
1768 | void |
… | |
… | |
1767 | { |
1780 | { |
1768 | LOG (llevError, "Object %s lacks a spell\n", &item->name); |
1781 | LOG (llevError, "Object %s lacks a spell\n", &item->name); |
1769 | return; |
1782 | return; |
1770 | } |
1783 | } |
1771 | |
1784 | |
|
|
1785 | if (!op->change_weapon (item)) |
|
|
1786 | return; |
|
|
1787 | |
1772 | if (item->type == WAND) |
1788 | if (item->type == WAND) |
1773 | { |
1789 | { |
1774 | if (item->stats.food <= 0) |
1790 | if (item->stats.food <= 0) |
1775 | { |
1791 | { |
1776 | play_sound_player_only (op->contr, SOUND_WAND_POOF, 0, 0); |
1792 | play_sound_player_only (op->contr, SOUND_WAND_POOF, 0, 0); |
1777 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s goes poof.", query_base_name (item, 0)); |
1793 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s goes poof.", query_base_name (item, 0)); |
|
|
1794 | |
1778 | return; |
1795 | return; |
1779 | } |
1796 | } |
1780 | } |
1797 | } |
1781 | else if (item->type == ROD || item->type == HORN) |
1798 | else if (item->type == ROD || item->type == HORN) |
1782 | { |
1799 | { |
1783 | if (item->stats.hp < MAX (item->inv->stats.sp, item->inv->stats.grace)) |
1800 | if (item->stats.hp < MAX (item->inv->stats.sp, item->inv->stats.grace)) |
1784 | { |
1801 | { |
1785 | play_sound_player_only (op->contr, SOUND_WAND_POOF, 0, 0); |
1802 | play_sound_player_only (op->contr, SOUND_WAND_POOF, 0, 0); |
|
|
1803 | |
1786 | if (item->type == ROD) |
1804 | if (item->type == ROD) |
1787 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s whines for a while, but nothing happens.", query_base_name (item, 0)); |
1805 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s whines for a while, but nothing happens.", query_base_name (item, 0)); |
1788 | else |
1806 | else |
1789 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s needs more time to charge.", query_base_name (item, 0)); |
1807 | new_draw_info_format (NDI_UNIQUE, 0, op, "The %s needs more time to charge.", query_base_name (item, 0)); |
|
|
1808 | |
1790 | return; |
1809 | return; |
1791 | } |
1810 | } |
1792 | } |
1811 | } |
1793 | |
1812 | |
1794 | if (cast_spell (op, item, dir, item->inv, NULL)) |
1813 | if (cast_spell (op, item, dir, item->inv, NULL)) |
… | |
… | |
1838 | object *ob = pl->ranged_ob; |
1857 | object *ob = pl->ranged_ob; |
1839 | |
1858 | |
1840 | if (!ob) |
1859 | if (!ob) |
1841 | return; |
1860 | return; |
1842 | |
1861 | |
|
|
1862 | if (!op->change_weapon (ob)) |
|
|
1863 | return; |
|
|
1864 | |
1843 | switch (ob->type) |
1865 | switch (ob->type) |
1844 | { |
1866 | { |
1845 | case BOW: |
1867 | case BOW: |
1846 | player_fire_bow (op, dir); |
1868 | player_fire_bow (op, dir); |
1847 | break; |
1869 | break; |
… | |
… | |
1853 | case BUILDER: |
1875 | case BUILDER: |
1854 | apply_map_builder (op, dir); |
1876 | apply_map_builder (op, dir); |
1855 | break; |
1877 | break; |
1856 | |
1878 | |
1857 | case SKILL: |
1879 | case SKILL: |
1858 | case SKILL_TOOL: |
|
|
1859 | do_skill (op, op, ob, dir, 0); |
1880 | do_skill (op, op, ob, dir, 0); |
1860 | break; |
1881 | break; |
1861 | |
1882 | |
1862 | default: |
1883 | default: |
1863 | fire_misc_object (op, dir); |
1884 | fire_misc_object (op, dir); |
… | |
… | |
2091 | |
2112 | |
2092 | /* If the creature is a pet, push it even if the player is not |
2113 | /* If the creature is a pet, push it even if the player is not |
2093 | * peaceful. Our assumption is the creature is a pet if the |
2114 | * peaceful. Our assumption is the creature is a pet if the |
2094 | * player owns it and it is either friendly or unagressive. |
2115 | * player owns it and it is either friendly or unagressive. |
2095 | */ |
2116 | */ |
2096 | if ((op->type == PLAYER) |
2117 | if (op->type == PLAYER |
2097 | #if COZY_SERVER |
|
|
2098 | && |
|
|
2099 | ((mon->owner && mon->owner->contr |
2118 | && ((mon->owner && mon->owner->contr |
2100 | && same_party (mon->owner->contr->party, op->contr->party)) || mon->owner == op) |
2119 | && same_party (mon->owner->contr->party, op->contr->party)) |
2101 | #else |
|
|
2102 | && mon->owner == op |
2120 | || mon->owner == op) |
2103 | #endif |
|
|
2104 | && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) |
2121 | && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) |
2105 | { |
2122 | { |
2106 | /* If we're braced, we don't want to switch places with it */ |
2123 | /* If we're braced, we don't want to switch places with it */ |
2107 | if (op->contr->braced) |
2124 | if (op->contr->braced) |
2108 | return; |
2125 | return; |
… | |
… | |
2118 | /* in certain circumstances, you shouldn't attack friendly |
2135 | /* in certain circumstances, you shouldn't attack friendly |
2119 | * creatures. Note that if you are braced, you can't push |
2136 | * creatures. Note that if you are braced, you can't push |
2120 | * someone, but put it inside this loop so that you won't |
2137 | * someone, but put it inside this loop so that you won't |
2121 | * attack them either. |
2138 | * attack them either. |
2122 | */ |
2139 | */ |
2123 | if ((mon->type == PLAYER || mon->enemy != op) && |
2140 | if ((mon->type == PLAYER || mon->enemy != op) |
2124 | (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) && ( |
2141 | && (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) |
2125 | #ifdef PROHIBIT_PLAYERKILL |
|
|
2126 | (op->contr->peaceful |
2142 | && ((op->contr->peaceful |
2127 | || (mon->type == PLAYER |
2143 | || (mon->type == PLAYER && mon->contr->peaceful)) |
2128 | && mon->contr-> |
|
|
2129 | peaceful)) && |
|
|
2130 | #else |
|
|
2131 | op->contr->peaceful && |
|
|
2132 | #endif |
|
|
2133 | !on_battleground)) |
2144 | && !on_battleground)) |
2134 | { |
2145 | { |
2135 | if (!op->contr->braced) |
2146 | if (!op->contr->braced) |
2136 | { |
2147 | { |
2137 | play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER); |
2148 | play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER); |
2138 | push_ob (mon, dir, op); |
2149 | push_ob (mon, dir, op); |
… | |
… | |
2161 | * that party_number -1 is no party, so attacks can still happen. |
2172 | * that party_number -1 is no party, so attacks can still happen. |
2162 | */ |
2173 | */ |
2163 | else if ((mon->stats.hp >= 0) && QUERY_FLAG (mon, FLAG_ALIVE) && |
2174 | else if ((mon->stats.hp >= 0) && QUERY_FLAG (mon, FLAG_ALIVE) && |
2164 | ((mon->type != PLAYER || op->contr->party == NULL || op->contr->party != mon->contr->party))) |
2175 | ((mon->type != PLAYER || op->contr->party == NULL || op->contr->party != mon->contr->party))) |
2165 | { |
2176 | { |
2166 | |
|
|
2167 | /* If the player hasn't hit something this tick, and does |
|
|
2168 | * so, give them speed boost based on weapon speed. Doing |
|
|
2169 | * it here is better than process_players2, which basically |
|
|
2170 | * incurred a 1 tick offset. |
|
|
2171 | */ |
|
|
2172 | if (!op->contr->has_hit) |
2177 | if (!op->contr->has_hit) |
2173 | { |
2178 | { |
|
|
2179 | op->contr->has_hit = 1; |
2174 | op->speed_left += op->speed / op->contr->weapon_sp; |
2180 | op->speed_left += op->contr->weapon_speed () - op->speed; |
2175 | |
|
|
2176 | op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */ |
|
|
2177 | } |
2181 | } |
2178 | |
2182 | |
2179 | skill_attack (mon, op, 0, 0, 0); |
2183 | skill_attack (mon, op, 0, 0, 0); |
2180 | |
2184 | |
2181 | /* If attacking another player, that player gets automatic |
2185 | /* If attacking another player, that player gets automatic |
… | |
… | |
2259 | handle_newcs_player (object *op) |
2263 | handle_newcs_player (object *op) |
2260 | { |
2264 | { |
2261 | if (QUERY_FLAG (op, FLAG_SCARED)) |
2265 | if (QUERY_FLAG (op, FLAG_SCARED)) |
2262 | { |
2266 | { |
2263 | flee_player (op); |
2267 | flee_player (op); |
|
|
2268 | |
2264 | /* If player is still scared, that is his action for this tick */ |
2269 | /* If player is still scared, that is his action for this tick */ |
2265 | if (QUERY_FLAG (op, FLAG_SCARED)) |
2270 | if (op->flag [FLAG_SCARED]) |
2266 | { |
2271 | { |
2267 | op->speed_left--; |
2272 | --op->speed_left; |
2268 | return 0; |
2273 | return 0; |
2269 | } |
2274 | } |
2270 | } |
2275 | } |
2271 | |
2276 | |
2272 | /* call this here - we also will call this in do_ericserver, but |
2277 | /* call this here - we also will call this in do_ericserver, but |
… | |
… | |
2274 | * called, so we recheck it here. |
2279 | * called, so we recheck it here. |
2275 | */ |
2280 | */ |
2276 | if (op->contr->ns->handle_command ()) |
2281 | if (op->contr->ns->handle_command ()) |
2277 | return 1; |
2282 | return 1; |
2278 | |
2283 | |
2279 | if (op->speed_left > 0) |
2284 | if (op->speed_left > 0.f) |
2280 | { |
2285 | { |
2281 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2286 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2282 | { |
2287 | { |
2283 | /* All move commands take 1 tick, at least for now */ |
2288 | /* All move commands take 1 tick, at least for now */ |
2284 | op->speed_left--; |
2289 | --op->speed_left; |
2285 | |
2290 | |
2286 | /* Instead of all the stuff below, let move_player take care |
2291 | /* Instead of all the stuff below, let move_player take care |
2287 | * of it. Also, some of the skill stuff is only put in |
2292 | * of it. Also, some of the skill stuff is only put in |
2288 | * there, as well as the confusion stuff. |
2293 | * there, as well as the confusion stuff. |
2289 | */ |
2294 | */ |
2290 | move_player (op, op->direction); |
2295 | move_player (op, op->direction); |
2291 | |
2296 | |
2292 | return op->speed_left > 0; |
2297 | return op->speed_left > 0.f; |
2293 | } |
2298 | } |
2294 | } |
2299 | } |
2295 | |
2300 | |
2296 | return 0; |
2301 | return 0; |
2297 | } |
2302 | } |
… | |
… | |
2567 | } |
2572 | } |
2568 | |
2573 | |
2569 | /* Digestion */ |
2574 | /* Digestion */ |
2570 | if (--op->last_eat < 0) |
2575 | if (--op->last_eat < 0) |
2571 | { |
2576 | { |
2572 | #ifdef COZY_SERVER |
|
|
2573 | int dg = op->contr->digestion >= 0 && op->contr->digestion < 2 ? 2 : op->contr->digestion; |
|
|
2574 | int bonus = dg > 0 ? dg : 0, penalty = dg < 0 ? -dg : 0; |
|
|
2575 | #else |
|
|
2576 | int bonus = op->contr->digestion > 0 ? op->contr->digestion : 0, penalty = op->contr->digestion < 0 ? -op->contr->digestion : 0; |
2577 | int bonus = op->contr->digestion > 0 ? op->contr->digestion : 0, penalty = op->contr->digestion < 0 ? -op->contr->digestion : 0; |
2577 | #endif |
|
|
2578 | |
2578 | |
2579 | if (op->contr->gen_hp > 0) |
2579 | if (op->contr->gen_hp > 0) |
2580 | op->last_eat = 25 * (1 + bonus) / (op->contr->gen_hp + penalty + 1); |
2580 | op->last_eat = 25 * (1 + bonus) / (op->contr->gen_hp + penalty + 1); |
2581 | else |
2581 | else |
2582 | op->last_eat = 25 * (1 + bonus) / (penalty + 1); |
2582 | op->last_eat = 25 * (1 + bonus) / (penalty + 1); |
… | |
… | |
2927 | object *force; |
2927 | object *force; |
2928 | int at; |
2928 | int at; |
2929 | |
2929 | |
2930 | force = get_archetype (FORCE_NAME); |
2930 | force = get_archetype (FORCE_NAME); |
2931 | /* 50 ticks should be enough time for the spell to abate */ |
2931 | /* 50 ticks should be enough time for the spell to abate */ |
2932 | force->speed = 0.1; |
2932 | force->speed = 0.1f; |
2933 | force->speed_left = -5.0; |
2933 | force->speed_left = -5.f; |
2934 | SET_FLAG (force, FLAG_APPLIED); |
2934 | SET_FLAG (force, FLAG_APPLIED); |
2935 | for (at = 0; at < NROFATTACKS; at++) |
2935 | for (at = 0; at < NROFATTACKS; at++) |
2936 | if (will_kill_again & (1 << at)) |
2936 | if (will_kill_again & (1 << at)) |
2937 | force->resist[at] = 100; |
2937 | force->resist[at] = 100; |
2938 | |
2938 | |