… | |
… | |
147 | draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, |
147 | draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, |
148 | 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); |
149 | close_and_delete (fp, comp); |
149 | close_and_delete (fp, comp); |
150 | } |
150 | } |
151 | |
151 | |
|
|
152 | float |
|
|
153 | player::weapon_speed () const |
|
|
154 | { |
|
|
155 | return ob->speed / weapon_sp * .5f;//TODO, the .5 is arbitrary |
|
|
156 | } |
|
|
157 | |
152 | /* This loads the first map an puts the player on it. */ |
158 | /* This loads the first map an puts the player on it. */ |
153 | static void |
159 | static void |
154 | set_first_map (object *op) |
160 | set_first_map (object *op) |
155 | { |
161 | { |
156 | op->contr->maplevel = first_map_path; |
162 | op->contr->maplevel = first_map_path; |
… | |
… | |
258 | |
264 | |
259 | new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!"); |
265 | new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!"); |
260 | |
266 | |
261 | esrv_new_player (this, ob->weight + ob->carrying); |
267 | esrv_new_player (this, ob->weight + ob->carrying); |
262 | |
268 | |
|
|
269 | ob->flag [FLAG_READY_WEAPON] = false; |
|
|
270 | ob->flag [FLAG_READY_SKILL] = false; |
|
|
271 | ob->flag [FLAG_READY_BOW] = false; |
|
|
272 | |
263 | for (object *op = ob->inv; op; op = op->below) |
273 | for (object *op = ob->inv; op; op = op->below) |
264 | if (op->flag [FLAG_APPLIED]) |
274 | if (op->flag [FLAG_APPLIED]) |
265 | switch (op->type) |
275 | switch (op->type) |
266 | { |
276 | { |
267 | case WAND: |
277 | case WAND: |
268 | case ROD: |
278 | case ROD: |
269 | case HORN: |
279 | case HORN: |
270 | case BOW: |
280 | case BOW: |
271 | case SKILL: |
|
|
272 | case SKILL_TOOL: |
281 | case SKILL_TOOL: |
273 | case WEAPON: |
282 | case WEAPON: |
274 | apply_special (ob, op, AP_UNAPPLY); |
283 | op->flag [FLAG_APPLIED] = false; |
275 | apply_special (ob, op, AP_APPLY); |
284 | apply_special (ob, op, AP_APPLY); |
276 | break; |
285 | break; |
277 | } |
|
|
278 | |
286 | |
|
|
287 | case SKILL: |
|
|
288 | op->flag [FLAG_APPLIED] = false; |
|
|
289 | break; |
|
|
290 | } |
|
|
291 | |
|
|
292 | ob->change_weapon (combat_ob ? combat_ob : ranged_ob); |
279 | ob->update_stats (); |
293 | ob->update_stats (); |
|
|
294 | |
280 | ns->floorbox_update (); |
295 | ns->floorbox_update (); |
281 | |
|
|
282 | esrv_send_inventory (ob, ob); |
296 | esrv_send_inventory (ob, ob); |
283 | esrv_add_spells (this, 0); |
297 | esrv_add_spells (this, 0); |
284 | |
298 | |
285 | activate (); |
299 | activate (); |
286 | |
300 | |
… | |
… | |
319 | player::set_object (object *op) |
333 | player::set_object (object *op) |
320 | { |
334 | { |
321 | ob = op; |
335 | ob = op; |
322 | ob->contr = this; /* this aren't yet in archetype */ |
336 | ob->contr = this; /* this aren't yet in archetype */ |
323 | |
337 | |
324 | ob->speed_left = 0.5; |
338 | ob->speed_left = 0.5f; |
325 | ob->speed = 1.0; |
339 | ob->speed = 1.0f; |
326 | ob->direction = 5; /* So player faces south */ |
340 | ob->direction = 5; /* So player faces south */ |
327 | } |
341 | } |
328 | |
342 | |
329 | player::player () |
343 | player::player () |
330 | { |
344 | { |
… | |
… | |
784 | } |
798 | } |
785 | |
799 | |
786 | void |
800 | void |
787 | object::roll_stats () |
801 | object::roll_stats () |
788 | { |
802 | { |
789 | int statsort [7]; |
803 | int statsort [NUM_STATS]; |
790 | |
804 | |
791 | for (;;) |
805 | for (;;) |
792 | { |
806 | { |
793 | int sum = 0; |
807 | int sum = 0; |
794 | for (int i = 7; i--; ) |
808 | for (int i = NUM_STATS; i--; ) |
795 | sum += statsort [i] = roll_stat (); |
809 | sum += statsort [i] = roll_stat (); |
796 | |
810 | |
797 | if (sum >= 82 && sum <= 116) |
811 | if (sum >= 82 && sum <= 116) |
798 | break; |
812 | break; |
799 | } |
813 | } |
800 | |
814 | |
801 | // Sort the stats so that rerolling is easier... |
815 | // Sort the stats so that rerolling is easier... |
802 | std::sort (statsort, statsort + 7, std::greater<int>()); |
816 | std::sort (statsort, statsort + NUM_STATS, std::greater<int>()); |
803 | |
817 | |
|
|
818 | for (int i = 0; i < NUM_STATS; ++i) |
804 | stats.Str = statsort[0]; |
819 | stats.stat (i) = statsort [i]; |
805 | stats.Dex = statsort[1]; |
|
|
806 | stats.Con = statsort[2]; |
|
|
807 | stats.Int = statsort[3]; |
|
|
808 | stats.Wis = statsort[4]; |
|
|
809 | stats.Pow = statsort[5]; |
|
|
810 | stats.Cha = statsort[6]; |
|
|
811 | |
820 | |
812 | stats.exp = 0; |
821 | stats.exp = 0; |
813 | stats.ac = 0; |
822 | stats.ac = 0; |
814 | |
823 | |
815 | stats.hp = stats.maxhp; |
824 | stats.hp = stats.maxhp; |
… | |
… | |
827 | } |
836 | } |
828 | |
837 | |
829 | void |
838 | void |
830 | object::swap_stats (int a, int b) |
839 | object::swap_stats (int a, int b) |
831 | { |
840 | { |
832 | int tmp = get_attr_value (&contr->orig_stats, a); |
841 | swap (contr->orig_stats.stat (a), contr->orig_stats.stat (b)); |
833 | set_attr_value (&contr->orig_stats, a, get_attr_value (&contr->orig_stats, b)); |
|
|
834 | set_attr_value (&contr->orig_stats, b, tmp); |
|
|
835 | |
842 | |
|
|
843 | for (int i = 0; i < NUM_STATS; ++i) |
836 | stats.Str = contr->orig_stats.Str; |
844 | stats.stat (i) = contr->orig_stats.stat (i); |
837 | stats.Dex = contr->orig_stats.Dex; |
|
|
838 | stats.Con = contr->orig_stats.Con; |
|
|
839 | stats.Int = contr->orig_stats.Int; |
|
|
840 | stats.Wis = contr->orig_stats.Wis; |
|
|
841 | stats.Pow = contr->orig_stats.Pow; |
|
|
842 | stats.Cha = contr->orig_stats.Cha; |
|
|
843 | |
845 | |
844 | //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, |
845 | // be merged with the similar code in roll_stats |
847 | // be merged with the similar code in roll_stats |
846 | stats.ac = 0; |
848 | stats.ac = 0; |
847 | |
849 | |
… | |
… | |
1547 | */ |
1549 | */ |
1548 | int |
1550 | int |
1549 | 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) |
1550 | { |
1552 | { |
1551 | object *left, *bow; |
1553 | object *left, *bow; |
1552 | int bowspeed, mflags; |
1554 | int mflags; |
1553 | maptile *m; |
1555 | maptile *m; |
1554 | |
1556 | |
1555 | if (!dir) |
1557 | if (!dir) |
1556 | { |
1558 | { |
1557 | 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!"); |
1558 | return 0; |
1560 | return 0; |
1559 | } |
1561 | } |
1560 | |
1562 | |
1561 | if (player *pl = op->contr) |
1563 | if (op->contr) |
1562 | { |
1564 | bow = op->current_weapon; |
1563 | bow = pl->ranged_ob; |
|
|
1564 | op->set_weapon (bow); |
|
|
1565 | } |
|
|
1566 | else |
1565 | else |
1567 | { |
1566 | { |
1568 | for (bow = op->inv; bow; bow = bow->below) |
1567 | for (bow = op->inv; bow; bow = bow->below) |
1569 | /* 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 |
1570 | * 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. |
… | |
… | |
1591 | { |
1590 | { |
1592 | 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); |
1593 | return 0; |
1592 | return 0; |
1594 | } |
1593 | } |
1595 | |
1594 | |
1596 | bowspeed = bow->stats.sp + dex_bonus[op->stats.Dex]; |
|
|
1597 | |
|
|
1598 | /* penalize ROF for bestarrow */ |
|
|
1599 | if (op->type == PLAYER && op->contr->bowtype == bow_bestarrow) |
|
|
1600 | bowspeed -= dex_bonus[op->stats.Dex] + 5; |
|
|
1601 | |
|
|
1602 | if (bowspeed < 1) |
|
|
1603 | bowspeed = 1; |
|
|
1604 | |
|
|
1605 | if (arrow == NULL) |
1595 | if (arrow == NULL) |
1606 | { |
1596 | { |
1607 | if ((arrow = find_arrow (op, bow->race)) == NULL) |
1597 | if ((arrow = find_arrow (op, bow->race)) == NULL) |
1608 | { |
1598 | { |
1609 | if (op->type == PLAYER) |
1599 | if (op->type == PLAYER) |
… | |
… | |
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 | |
|
|
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); |
|
|
1666 | |
|
|
1667 | /* update the speed */ |
|
|
1668 | arrow->speed = ((bow->flag [FLAG_NO_STRENGTH] ? 0 : dam_bonus[op->stats.Str]) + bow->magic + arrow->magic) / 5.0 |
|
|
1669 | + bow->stats.dam / 7.0; |
|
|
1670 | |
|
|
1671 | arrow->set_speed (max (arrow->speed, 2.0)); |
|
|
1672 | arrow->speed_left = 0; |
|
|
1673 | |
|
|
1674 | int wc = op->stats.wc + wc_mod - arrow->magic - arrow->stats.wc; |
|
|
1675 | |
1655 | if (op->type == PLAYER) |
1676 | if (op->type == PLAYER) |
1656 | { |
1677 | { |
1657 | op->speed_left = 0.01 - (float) FABS (op->speed) * 100 / bowspeed; |
|
|
1658 | op->update_stats (); |
|
|
1659 | } |
|
|
1660 | |
|
|
1661 | SET_ANIMATION (arrow, arrow->direction); |
|
|
1662 | |
|
|
1663 | arrow->stats.dam += op->stats.dam + arrow->magic; |
|
|
1664 | |
|
|
1665 | /* update the speed */ |
|
|
1666 | arrow->speed = (float) ((QUERY_FLAG (bow, FLAG_NO_STRENGTH) ? |
|
|
1667 | 0 : dam_bonus[op->stats.Str]) + bow->magic + arrow->magic) / 5.0 + (float) bow->stats.dam / 7.0; |
|
|
1668 | |
|
|
1669 | arrow->set_speed (max (arrow->speed, 1.0)); |
|
|
1670 | arrow->speed_left = 0; |
|
|
1671 | |
|
|
1672 | arrow->stats.wc = op->stats.wc + wc_mod - arrow->magic - arrow->stats.wc; |
|
|
1673 | |
|
|
1674 | if (op->type == PLAYER) |
|
|
1675 | { |
|
|
1676 | arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; |
1678 | arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; |
1677 | arrow->stats.wc -= dex_bonus[op->stats.Dex]; |
1679 | wc -= dex_bonus[op->stats.Dex]; |
1678 | |
1680 | |
1679 | if (!arrow->slaying) |
1681 | if (!arrow->slaying) |
1680 | arrow->slaying = op->slaying; |
1682 | arrow->slaying = op->slaying; |
1681 | |
1683 | |
1682 | arrow->attacktype |= op->attacktype; |
1684 | arrow->attacktype |= op->attacktype; |
… | |
… | |
1690 | arrow->slaying = bow->slaying; |
1692 | arrow->slaying = bow->slaying; |
1691 | |
1693 | |
1692 | arrow->attacktype |= bow->attacktype; |
1694 | arrow->attacktype |= bow->attacktype; |
1693 | } |
1695 | } |
1694 | |
1696 | |
1695 | arrow->stats.wc -= arrow->level; |
1697 | wc -= arrow->level; |
|
|
1698 | arrow->stats.dam = clamp (arrow->stats.dam + op->stats.dam + arrow->magic, MIN_DAM, MAX_DAM); |
1696 | |
1699 | |
|
|
1700 | arrow->stats.wc = clamp (wc, MIN_WC, MAX_WC); |
1697 | arrow->move_type = MOVE_FLY_LOW; |
1701 | arrow->move_type = MOVE_FLY_LOW; |
1698 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1702 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1699 | |
1703 | |
1700 | 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); |
1701 | m->insert (arrow, sx, sy, op); |
1705 | m->insert (arrow, sx, sy, op); |
… | |
… | |
1756 | } |
1760 | } |
1757 | |
1761 | |
1758 | return ret; |
1762 | return ret; |
1759 | } |
1763 | } |
1760 | |
1764 | |
1761 | |
|
|
1762 | /* Fires a misc (wand/rod/horn) object in 'dir'. |
1765 | /* Fires a misc (wand/rod/horn) object in 'dir'. |
1763 | * Broken apart from 'fire' to keep it more readable. |
1766 | * Broken apart from 'fire' to keep it more readable. |
1764 | */ |
1767 | */ |
1765 | void |
1768 | void |
1766 | fire_misc_object (object *op, int dir) |
1769 | fire_misc_object (object *op, int dir) |
… | |
… | |
1777 | { |
1780 | { |
1778 | LOG (llevError, "Object %s lacks a spell\n", &item->name); |
1781 | LOG (llevError, "Object %s lacks a spell\n", &item->name); |
1779 | return; |
1782 | return; |
1780 | } |
1783 | } |
1781 | |
1784 | |
1782 | op->set_weapon (item); |
1785 | if (!op->change_weapon (item)) |
|
|
1786 | return; |
1783 | |
1787 | |
1784 | if (item->type == WAND) |
1788 | if (item->type == WAND) |
1785 | { |
1789 | { |
1786 | if (item->stats.food <= 0) |
1790 | if (item->stats.food <= 0) |
1787 | { |
1791 | { |
… | |
… | |
1853 | object *ob = pl->ranged_ob; |
1857 | object *ob = pl->ranged_ob; |
1854 | |
1858 | |
1855 | if (!ob) |
1859 | if (!ob) |
1856 | return; |
1860 | return; |
1857 | |
1861 | |
|
|
1862 | if (!op->change_weapon (ob)) |
|
|
1863 | return; |
|
|
1864 | |
1858 | switch (ob->type) |
1865 | switch (ob->type) |
1859 | { |
1866 | { |
1860 | case BOW: |
1867 | case BOW: |
1861 | player_fire_bow (op, dir); |
1868 | player_fire_bow (op, dir); |
1862 | break; |
1869 | break; |
… | |
… | |
1868 | case BUILDER: |
1875 | case BUILDER: |
1869 | apply_map_builder (op, dir); |
1876 | apply_map_builder (op, dir); |
1870 | break; |
1877 | break; |
1871 | |
1878 | |
1872 | case SKILL: |
1879 | case SKILL: |
1873 | case SKILL_TOOL: |
|
|
1874 | do_skill (op, op, ob, dir, 0); |
1880 | do_skill (op, op, ob, dir, 0); |
1875 | break; |
1881 | break; |
1876 | |
1882 | |
1877 | default: |
1883 | default: |
1878 | fire_misc_object (op, dir); |
1884 | fire_misc_object (op, dir); |
… | |
… | |
2106 | |
2112 | |
2107 | /* 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 |
2108 | * peaceful. Our assumption is the creature is a pet if the |
2114 | * peaceful. Our assumption is the creature is a pet if the |
2109 | * player owns it and it is either friendly or unagressive. |
2115 | * player owns it and it is either friendly or unagressive. |
2110 | */ |
2116 | */ |
2111 | if ((op->type == PLAYER) |
2117 | if (op->type == PLAYER |
2112 | #if COZY_SERVER |
|
|
2113 | && |
|
|
2114 | ((mon->owner && mon->owner->contr |
2118 | && ((mon->owner && mon->owner->contr |
2115 | && same_party (mon->owner->contr->party, op->contr->party)) || mon->owner == op) |
2119 | && same_party (mon->owner->contr->party, op->contr->party)) |
2116 | #else |
|
|
2117 | && mon->owner == op |
2120 | || mon->owner == op) |
2118 | #endif |
|
|
2119 | && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) |
2121 | && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) |
2120 | { |
2122 | { |
2121 | /* 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 */ |
2122 | if (op->contr->braced) |
2124 | if (op->contr->braced) |
2123 | return; |
2125 | return; |
… | |
… | |
2133 | /* in certain circumstances, you shouldn't attack friendly |
2135 | /* in certain circumstances, you shouldn't attack friendly |
2134 | * creatures. Note that if you are braced, you can't push |
2136 | * creatures. Note that if you are braced, you can't push |
2135 | * 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 |
2136 | * attack them either. |
2138 | * attack them either. |
2137 | */ |
2139 | */ |
2138 | if ((mon->type == PLAYER || mon->enemy != op) && |
2140 | if ((mon->type == PLAYER || mon->enemy != op) |
2139 | (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)) |
2140 | #ifdef PROHIBIT_PLAYERKILL |
|
|
2141 | (op->contr->peaceful |
2142 | && ((op->contr->peaceful |
2142 | || (mon->type == PLAYER |
2143 | || (mon->type == PLAYER && mon->contr->peaceful)) |
2143 | && mon->contr-> |
|
|
2144 | peaceful)) && |
|
|
2145 | #else |
|
|
2146 | op->contr->peaceful && |
|
|
2147 | #endif |
|
|
2148 | !on_battleground)) |
2144 | && !on_battleground)) |
2149 | { |
2145 | { |
2150 | if (!op->contr->braced) |
2146 | if (!op->contr->braced) |
2151 | { |
2147 | { |
2152 | 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); |
2153 | push_ob (mon, dir, op); |
2149 | push_ob (mon, dir, op); |
… | |
… | |
2176 | * 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. |
2177 | */ |
2173 | */ |
2178 | else if ((mon->stats.hp >= 0) && QUERY_FLAG (mon, FLAG_ALIVE) && |
2174 | else if ((mon->stats.hp >= 0) && QUERY_FLAG (mon, FLAG_ALIVE) && |
2179 | ((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))) |
2180 | { |
2176 | { |
2181 | |
|
|
2182 | /* If the player hasn't hit something this tick, and does |
|
|
2183 | * so, give them speed boost based on weapon speed. Doing |
|
|
2184 | * it here is better than process_players2, which basically |
|
|
2185 | * incurred a 1 tick offset. |
|
|
2186 | */ |
|
|
2187 | if (!op->contr->has_hit) |
2177 | if (!op->contr->has_hit) |
2188 | { |
2178 | { |
|
|
2179 | op->contr->has_hit = 1; |
2189 | op->speed_left += op->speed / op->contr->weapon_sp; |
2180 | op->speed_left += op->contr->weapon_speed () - op->speed; |
2190 | |
|
|
2191 | op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */ |
|
|
2192 | } |
2181 | } |
2193 | |
2182 | |
2194 | skill_attack (mon, op, 0, 0, 0); |
2183 | skill_attack (mon, op, 0, 0, 0); |
2195 | |
2184 | |
2196 | /* If attacking another player, that player gets automatic |
2185 | /* If attacking another player, that player gets automatic |
… | |
… | |
2274 | handle_newcs_player (object *op) |
2263 | handle_newcs_player (object *op) |
2275 | { |
2264 | { |
2276 | if (QUERY_FLAG (op, FLAG_SCARED)) |
2265 | if (QUERY_FLAG (op, FLAG_SCARED)) |
2277 | { |
2266 | { |
2278 | flee_player (op); |
2267 | flee_player (op); |
|
|
2268 | |
2279 | /* 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 */ |
2280 | if (QUERY_FLAG (op, FLAG_SCARED)) |
2270 | if (op->flag [FLAG_SCARED]) |
2281 | { |
2271 | { |
2282 | op->speed_left--; |
2272 | --op->speed_left; |
2283 | return 0; |
2273 | return 0; |
2284 | } |
2274 | } |
2285 | } |
2275 | } |
2286 | |
2276 | |
2287 | /* 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 |
… | |
… | |
2289 | * called, so we recheck it here. |
2279 | * called, so we recheck it here. |
2290 | */ |
2280 | */ |
2291 | if (op->contr->ns->handle_command ()) |
2281 | if (op->contr->ns->handle_command ()) |
2292 | return 1; |
2282 | return 1; |
2293 | |
2283 | |
2294 | if (op->speed_left > 0) |
2284 | if (op->speed_left > 0.f) |
2295 | { |
2285 | { |
2296 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2286 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2297 | { |
2287 | { |
2298 | /* All move commands take 1 tick, at least for now */ |
2288 | /* All move commands take 1 tick, at least for now */ |
2299 | op->speed_left--; |
2289 | --op->speed_left; |
2300 | |
2290 | |
2301 | /* Instead of all the stuff below, let move_player take care |
2291 | /* Instead of all the stuff below, let move_player take care |
2302 | * 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 |
2303 | * there, as well as the confusion stuff. |
2293 | * there, as well as the confusion stuff. |
2304 | */ |
2294 | */ |
2305 | move_player (op, op->direction); |
2295 | move_player (op, op->direction); |
2306 | |
2296 | |
2307 | return op->speed_left > 0; |
2297 | return op->speed_left > 0.f; |
2308 | } |
2298 | } |
2309 | } |
2299 | } |
2310 | |
2300 | |
2311 | return 0; |
2301 | return 0; |
2312 | } |
2302 | } |
… | |
… | |
2582 | } |
2572 | } |
2583 | |
2573 | |
2584 | /* Digestion */ |
2574 | /* Digestion */ |
2585 | if (--op->last_eat < 0) |
2575 | if (--op->last_eat < 0) |
2586 | { |
2576 | { |
2587 | #ifdef COZY_SERVER |
|
|
2588 | int dg = op->contr->digestion >= 0 && op->contr->digestion < 2 ? 2 : op->contr->digestion; |
|
|
2589 | int bonus = dg > 0 ? dg : 0, penalty = dg < 0 ? -dg : 0; |
|
|
2590 | #else |
|
|
2591 | 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; |
2592 | #endif |
|
|
2593 | |
2578 | |
2594 | if (op->contr->gen_hp > 0) |
2579 | if (op->contr->gen_hp > 0) |
2595 | 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); |
2596 | else |
2581 | else |
2597 | op->last_eat = 25 * (1 + bonus) / (penalty + 1); |
2582 | op->last_eat = 25 * (1 + bonus) / (penalty + 1); |
… | |
… | |
2942 | object *force; |
2927 | object *force; |
2943 | int at; |
2928 | int at; |
2944 | |
2929 | |
2945 | force = get_archetype (FORCE_NAME); |
2930 | force = get_archetype (FORCE_NAME); |
2946 | /* 50 ticks should be enough time for the spell to abate */ |
2931 | /* 50 ticks should be enough time for the spell to abate */ |
2947 | force->speed = 0.1; |
2932 | force->speed = 0.1f; |
2948 | force->speed_left = -5.0; |
2933 | force->speed_left = -5.f; |
2949 | SET_FLAG (force, FLAG_APPLIED); |
2934 | SET_FLAG (force, FLAG_APPLIED); |
2950 | for (at = 0; at < NROFATTACKS; at++) |
2935 | for (at = 0; at < NROFATTACKS; at++) |
2951 | if (will_kill_again & (1 << at)) |
2936 | if (will_kill_again & (1 << at)) |
2952 | force->resist[at] = 100; |
2937 | force->resist[at] = 100; |
2953 | |
2938 | |