… | |
… | |
319 | player::set_object (object *op) |
319 | player::set_object (object *op) |
320 | { |
320 | { |
321 | ob = op; |
321 | ob = op; |
322 | ob->contr = this; /* this aren't yet in archetype */ |
322 | ob->contr = this; /* this aren't yet in archetype */ |
323 | |
323 | |
324 | ob->speed_left = 0.5; |
324 | ob->speed_left = 0.5f; |
325 | ob->speed = 1.0; |
325 | ob->speed = 1.0f; |
326 | ob->direction = 5; /* So player faces south */ |
326 | ob->direction = 5; /* So player faces south */ |
327 | } |
327 | } |
328 | |
328 | |
329 | player::player () |
329 | player::player () |
330 | { |
330 | { |
… | |
… | |
784 | } |
784 | } |
785 | |
785 | |
786 | void |
786 | void |
787 | object::roll_stats () |
787 | object::roll_stats () |
788 | { |
788 | { |
789 | int statsort [7]; |
789 | int statsort [NUM_STATS]; |
790 | |
790 | |
791 | for (;;) |
791 | for (;;) |
792 | { |
792 | { |
793 | int sum = 0; |
793 | int sum = 0; |
794 | for (int i = 7; i--; ) |
794 | for (int i = NUM_STATS; i--; ) |
795 | sum += statsort [i] = roll_stat (); |
795 | sum += statsort [i] = roll_stat (); |
796 | |
796 | |
797 | if (sum >= 82 && sum <= 116) |
797 | if (sum >= 82 && sum <= 116) |
798 | break; |
798 | break; |
799 | } |
799 | } |
800 | |
800 | |
801 | // Sort the stats so that rerolling is easier... |
801 | // Sort the stats so that rerolling is easier... |
802 | std::sort (statsort, statsort + 7, std::greater<int>()); |
802 | std::sort (statsort, statsort + NUM_STATS, std::greater<int>()); |
803 | |
803 | |
|
|
804 | for (int i = 0; i < NUM_STATS; ++i) |
804 | stats.Str = statsort[0]; |
805 | 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 | |
806 | |
812 | stats.exp = 0; |
807 | stats.exp = 0; |
813 | stats.ac = 0; |
808 | stats.ac = 0; |
814 | |
809 | |
815 | stats.hp = stats.maxhp; |
810 | stats.hp = stats.maxhp; |
… | |
… | |
827 | } |
822 | } |
828 | |
823 | |
829 | void |
824 | void |
830 | object::swap_stats (int a, int b) |
825 | object::swap_stats (int a, int b) |
831 | { |
826 | { |
832 | int tmp = get_attr_value (&contr->orig_stats, a); |
827 | 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 | |
828 | |
|
|
829 | for (int i = 0; i < NUM_STATS; ++i) |
836 | stats.Str = contr->orig_stats.Str; |
830 | 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 | |
831 | |
844 | //TODO: the following code looks so borked and should, at the very least, |
832 | //TODO: the following code looks so borked and should, at the very least, |
845 | // be merged with the similar code in roll_stats |
833 | // be merged with the similar code in roll_stats |
846 | stats.ac = 0; |
834 | stats.ac = 0; |
847 | |
835 | |
… | |
… | |
1547 | */ |
1535 | */ |
1548 | int |
1536 | int |
1549 | fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) |
1537 | fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) |
1550 | { |
1538 | { |
1551 | object *left, *bow; |
1539 | object *left, *bow; |
1552 | int bowspeed, mflags; |
1540 | int mflags; |
1553 | maptile *m; |
1541 | maptile *m; |
1554 | |
1542 | |
1555 | if (!dir) |
1543 | if (!dir) |
1556 | { |
1544 | { |
1557 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1545 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
… | |
… | |
1559 | } |
1547 | } |
1560 | |
1548 | |
1561 | if (player *pl = op->contr) |
1549 | if (player *pl = op->contr) |
1562 | { |
1550 | { |
1563 | bow = pl->ranged_ob; |
1551 | bow = pl->ranged_ob; |
1564 | op->set_weapon (bow); |
1552 | if (!op->change_weapon (bow)) |
|
|
1553 | return 0; |
1565 | } |
1554 | } |
1566 | else |
1555 | else |
1567 | { |
1556 | { |
1568 | for (bow = op->inv; bow; bow = bow->below) |
1557 | for (bow = op->inv; bow; bow = bow->below) |
1569 | /* Don't check for applied - monsters don't apply bows - in that way, they |
1558 | /* Don't check for applied - monsters don't apply bows - in that way, they |
… | |
… | |
1591 | { |
1580 | { |
1592 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); |
1581 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); |
1593 | return 0; |
1582 | return 0; |
1594 | } |
1583 | } |
1595 | |
1584 | |
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) |
1585 | if (arrow == NULL) |
1606 | { |
1586 | { |
1607 | if ((arrow = find_arrow (op, bow->race)) == NULL) |
1587 | if ((arrow = find_arrow (op, bow->race)) == NULL) |
1608 | { |
1588 | { |
1609 | if (op->type == PLAYER) |
1589 | if (op->type == PLAYER) |
… | |
… | |
1650 | arrow->stats.grace = arrow->attacktype; |
1630 | arrow->stats.grace = arrow->attacktype; |
1651 | |
1631 | |
1652 | if (arrow->slaying) |
1632 | if (arrow->slaying) |
1653 | arrow->spellarg = strdup (arrow->slaying); |
1633 | arrow->spellarg = strdup (arrow->slaying); |
1654 | |
1634 | |
|
|
1635 | if (player *pl = op->contr) |
|
|
1636 | { |
|
|
1637 | pl->has_hit = 1; |
|
|
1638 | #if 0 |
|
|
1639 | float speed = pl->weapon_sp; |
|
|
1640 | |
|
|
1641 | /* penalize ROF for bestarrow */ |
|
|
1642 | if (pl->bowtype == bow_bestarrow) |
|
|
1643 | speed *= .9f; |
|
|
1644 | else |
|
|
1645 | speed *= 1.f + dex_bonus[op->stats.Dex] * .2f; |
|
|
1646 | |
|
|
1647 | op->speed_left += speed - op->speed; |
|
|
1648 | #endif |
|
|
1649 | } |
|
|
1650 | |
|
|
1651 | SET_ANIMATION (arrow, arrow->direction); |
|
|
1652 | |
|
|
1653 | /* update the speed */ |
|
|
1654 | arrow->speed = ((bow->flag [FLAG_NO_STRENGTH] ? 0 : dam_bonus[op->stats.Str]) + bow->magic + arrow->magic) / 5.0 |
|
|
1655 | + bow->stats.dam / 7.0; |
|
|
1656 | |
|
|
1657 | arrow->set_speed (max (arrow->speed, 2.0)); |
|
|
1658 | arrow->speed_left = 0; |
|
|
1659 | |
|
|
1660 | int wc = op->stats.wc + wc_mod - arrow->magic - arrow->stats.wc; |
|
|
1661 | |
1655 | if (op->type == PLAYER) |
1662 | if (op->type == PLAYER) |
1656 | { |
1663 | { |
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; |
1664 | arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; |
1677 | arrow->stats.wc -= dex_bonus[op->stats.Dex]; |
1665 | wc -= dex_bonus[op->stats.Dex]; |
1678 | |
1666 | |
1679 | if (!arrow->slaying) |
1667 | if (!arrow->slaying) |
1680 | arrow->slaying = op->slaying; |
1668 | arrow->slaying = op->slaying; |
1681 | |
1669 | |
1682 | arrow->attacktype |= op->attacktype; |
1670 | arrow->attacktype |= op->attacktype; |
… | |
… | |
1690 | arrow->slaying = bow->slaying; |
1678 | arrow->slaying = bow->slaying; |
1691 | |
1679 | |
1692 | arrow->attacktype |= bow->attacktype; |
1680 | arrow->attacktype |= bow->attacktype; |
1693 | } |
1681 | } |
1694 | |
1682 | |
1695 | arrow->stats.wc -= arrow->level; |
1683 | wc -= arrow->level; |
|
|
1684 | arrow->stats.dam = clamp (arrow->stats.dam + op->stats.dam + arrow->magic, MIN_DAM, MAX_DAM); |
1696 | |
1685 | |
|
|
1686 | arrow->stats.wc = clamp (wc, MIN_WC, MAX_WC); |
1697 | arrow->move_type = MOVE_FLY_LOW; |
1687 | arrow->move_type = MOVE_FLY_LOW; |
1698 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1688 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1699 | |
1689 | |
1700 | play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); |
1690 | play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); |
1701 | m->insert (arrow, sx, sy, op); |
1691 | m->insert (arrow, sx, sy, op); |
… | |
… | |
1777 | { |
1767 | { |
1778 | LOG (llevError, "Object %s lacks a spell\n", &item->name); |
1768 | LOG (llevError, "Object %s lacks a spell\n", &item->name); |
1779 | return; |
1769 | return; |
1780 | } |
1770 | } |
1781 | |
1771 | |
1782 | op->set_weapon (item); |
1772 | if (!op->change_weapon (item)) |
|
|
1773 | return; |
1783 | |
1774 | |
1784 | if (item->type == WAND) |
1775 | if (item->type == WAND) |
1785 | { |
1776 | { |
1786 | if (item->stats.food <= 0) |
1777 | if (item->stats.food <= 0) |
1787 | { |
1778 | { |
… | |
… | |
2176 | * that party_number -1 is no party, so attacks can still happen. |
2167 | * that party_number -1 is no party, so attacks can still happen. |
2177 | */ |
2168 | */ |
2178 | else if ((mon->stats.hp >= 0) && QUERY_FLAG (mon, FLAG_ALIVE) && |
2169 | 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))) |
2170 | ((mon->type != PLAYER || op->contr->party == NULL || op->contr->party != mon->contr->party))) |
2180 | { |
2171 | { |
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) |
2172 | op->contr->has_hit = 1; |
2188 | { |
|
|
2189 | op->speed_left += op->speed / op->contr->weapon_sp; |
|
|
2190 | |
|
|
2191 | op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */ |
|
|
2192 | } |
|
|
2193 | |
2173 | |
2194 | skill_attack (mon, op, 0, 0, 0); |
2174 | skill_attack (mon, op, 0, 0, 0); |
2195 | |
2175 | |
2196 | /* If attacking another player, that player gets automatic |
2176 | /* If attacking another player, that player gets automatic |
2197 | * hitback, and doesn't loose luck either. |
2177 | * hitback, and doesn't loose luck either. |
… | |
… | |
2274 | handle_newcs_player (object *op) |
2254 | handle_newcs_player (object *op) |
2275 | { |
2255 | { |
2276 | if (QUERY_FLAG (op, FLAG_SCARED)) |
2256 | if (QUERY_FLAG (op, FLAG_SCARED)) |
2277 | { |
2257 | { |
2278 | flee_player (op); |
2258 | flee_player (op); |
|
|
2259 | |
2279 | /* If player is still scared, that is his action for this tick */ |
2260 | /* If player is still scared, that is his action for this tick */ |
2280 | if (QUERY_FLAG (op, FLAG_SCARED)) |
2261 | if (op->flag [FLAG_SCARED]) |
2281 | { |
2262 | { |
2282 | op->speed_left--; |
2263 | --op->speed_left; |
2283 | return 0; |
2264 | return 0; |
2284 | } |
2265 | } |
2285 | } |
2266 | } |
2286 | |
2267 | |
2287 | /* call this here - we also will call this in do_ericserver, but |
2268 | /* call this here - we also will call this in do_ericserver, but |
… | |
… | |
2289 | * called, so we recheck it here. |
2270 | * called, so we recheck it here. |
2290 | */ |
2271 | */ |
2291 | if (op->contr->ns->handle_command ()) |
2272 | if (op->contr->ns->handle_command ()) |
2292 | return 1; |
2273 | return 1; |
2293 | |
2274 | |
2294 | if (op->speed_left > 0) |
2275 | if (op->speed_left > 0.f) |
2295 | { |
2276 | { |
2296 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2277 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2297 | { |
2278 | { |
2298 | /* All move commands take 1 tick, at least for now */ |
2279 | /* All move commands take 1 tick, at least for now */ |
2299 | op->speed_left--; |
2280 | --op->speed_left; |
2300 | |
2281 | |
2301 | /* Instead of all the stuff below, let move_player take care |
2282 | /* Instead of all the stuff below, let move_player take care |
2302 | * of it. Also, some of the skill stuff is only put in |
2283 | * of it. Also, some of the skill stuff is only put in |
2303 | * there, as well as the confusion stuff. |
2284 | * there, as well as the confusion stuff. |
2304 | */ |
2285 | */ |
2305 | move_player (op, op->direction); |
2286 | move_player (op, op->direction); |
2306 | |
2287 | |
2307 | return op->speed_left > 0; |
2288 | return op->speed_left > 0.f; |
2308 | } |
2289 | } |
2309 | } |
2290 | } |
2310 | |
2291 | |
2311 | return 0; |
2292 | return 0; |
2312 | } |
2293 | } |
… | |
… | |
2942 | object *force; |
2923 | object *force; |
2943 | int at; |
2924 | int at; |
2944 | |
2925 | |
2945 | force = get_archetype (FORCE_NAME); |
2926 | force = get_archetype (FORCE_NAME); |
2946 | /* 50 ticks should be enough time for the spell to abate */ |
2927 | /* 50 ticks should be enough time for the spell to abate */ |
2947 | force->speed = 0.1; |
2928 | force->speed = 0.1f; |
2948 | force->speed_left = -5.0; |
2929 | force->speed_left = -5.f; |
2949 | SET_FLAG (force, FLAG_APPLIED); |
2930 | SET_FLAG (force, FLAG_APPLIED); |
2950 | for (at = 0; at < NROFATTACKS; at++) |
2931 | for (at = 0; at < NROFATTACKS; at++) |
2951 | if (will_kill_again & (1 << at)) |
2932 | if (will_kill_again & (1 << at)) |
2952 | force->resist[at] = 100; |
2933 | force->resist[at] = 100; |
2953 | |
2934 | |