… | |
… | |
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; |
… | |
… | |
319 | player::set_object (object *op) |
325 | player::set_object (object *op) |
320 | { |
326 | { |
321 | ob = op; |
327 | ob = op; |
322 | ob->contr = this; /* this aren't yet in archetype */ |
328 | ob->contr = this; /* this aren't yet in archetype */ |
323 | |
329 | |
324 | ob->speed_left = 0.5; |
330 | ob->speed_left = 0.5f; |
325 | ob->speed = 1.0; |
331 | ob->speed = 1.0f; |
326 | ob->direction = 5; /* So player faces south */ |
332 | ob->direction = 5; /* So player faces south */ |
327 | } |
333 | } |
328 | |
334 | |
329 | player::player () |
335 | player::player () |
330 | { |
336 | { |
… | |
… | |
1535 | */ |
1541 | */ |
1536 | int |
1542 | int |
1537 | fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) |
1543 | fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) |
1538 | { |
1544 | { |
1539 | object *left, *bow; |
1545 | object *left, *bow; |
1540 | int bowspeed, mflags; |
1546 | int mflags; |
1541 | maptile *m; |
1547 | maptile *m; |
1542 | |
1548 | |
1543 | if (!dir) |
1549 | if (!dir) |
1544 | { |
1550 | { |
1545 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1551 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1546 | return 0; |
1552 | return 0; |
1547 | } |
1553 | } |
1548 | |
1554 | |
1549 | if (player *pl = op->contr) |
1555 | if (op->contr) |
1550 | { |
1556 | bow = op->current_weapon; |
1551 | bow = pl->ranged_ob; |
|
|
1552 | if (!op->change_weapon (bow)) |
|
|
1553 | return 0; |
|
|
1554 | } |
|
|
1555 | else |
1557 | else |
1556 | { |
1558 | { |
1557 | for (bow = op->inv; bow; bow = bow->below) |
1559 | for (bow = op->inv; bow; bow = bow->below) |
1558 | /* Don't check for applied - monsters don't apply bows - in that way, they |
1560 | /* Don't check for applied - monsters don't apply bows - in that way, they |
1559 | * don't need to switch back and forth between bows and weapons. |
1561 | * don't need to switch back and forth between bows and weapons. |
… | |
… | |
1580 | { |
1582 | { |
1581 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); |
1583 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); |
1582 | return 0; |
1584 | return 0; |
1583 | } |
1585 | } |
1584 | |
1586 | |
1585 | bowspeed = bow->stats.sp + dex_bonus[op->stats.Dex]; |
|
|
1586 | |
|
|
1587 | /* penalize ROF for bestarrow */ |
|
|
1588 | if (op->type == PLAYER && op->contr->bowtype == bow_bestarrow) |
|
|
1589 | bowspeed -= dex_bonus[op->stats.Dex] + 5; |
|
|
1590 | |
|
|
1591 | if (bowspeed < 1) |
|
|
1592 | bowspeed = 1; |
|
|
1593 | |
|
|
1594 | if (arrow == NULL) |
1587 | if (arrow == NULL) |
1595 | { |
1588 | { |
1596 | if ((arrow = find_arrow (op, bow->race)) == NULL) |
1589 | if ((arrow = find_arrow (op, bow->race)) == NULL) |
1597 | { |
1590 | { |
1598 | if (op->type == PLAYER) |
1591 | if (op->type == PLAYER) |
… | |
… | |
1639 | arrow->stats.grace = arrow->attacktype; |
1632 | arrow->stats.grace = arrow->attacktype; |
1640 | |
1633 | |
1641 | if (arrow->slaying) |
1634 | if (arrow->slaying) |
1642 | arrow->spellarg = strdup (arrow->slaying); |
1635 | arrow->spellarg = strdup (arrow->slaying); |
1643 | |
1636 | |
1644 | if (op->type == PLAYER) |
1637 | if (player *pl = op->contr) |
1645 | { |
1638 | { |
1646 | op->speed_left = 0.01 - (float) FABS (op->speed) * 100 / bowspeed; |
1639 | if (!pl->has_hit) |
1647 | op->update_stats (); |
1640 | { |
|
|
1641 | pl->has_hit = 1; |
|
|
1642 | pl->ob->speed_left += pl->weapon_speed () - pl->ob->speed; |
|
|
1643 | } |
|
|
1644 | #if 0 |
|
|
1645 | float speed = pl->weapon_sp; |
|
|
1646 | |
|
|
1647 | /* penalize ROF for bestarrow */ |
|
|
1648 | if (pl->bowtype == bow_bestarrow) |
|
|
1649 | speed *= .9f; |
|
|
1650 | else |
|
|
1651 | speed *= 1.f + dex_bonus[op->stats.Dex] * .2f; |
|
|
1652 | |
|
|
1653 | op->speed_left += speed - op->speed; |
|
|
1654 | #endif |
1648 | } |
1655 | } |
1649 | |
1656 | |
1650 | SET_ANIMATION (arrow, arrow->direction); |
1657 | SET_ANIMATION (arrow, arrow->direction); |
1651 | |
1658 | |
1652 | /* update the speed */ |
1659 | /* update the speed */ |
… | |
… | |
1745 | } |
1752 | } |
1746 | |
1753 | |
1747 | return ret; |
1754 | return ret; |
1748 | } |
1755 | } |
1749 | |
1756 | |
1750 | |
|
|
1751 | /* Fires a misc (wand/rod/horn) object in 'dir'. |
1757 | /* Fires a misc (wand/rod/horn) object in 'dir'. |
1752 | * Broken apart from 'fire' to keep it more readable. |
1758 | * Broken apart from 'fire' to keep it more readable. |
1753 | */ |
1759 | */ |
1754 | void |
1760 | void |
1755 | fire_misc_object (object *op, int dir) |
1761 | fire_misc_object (object *op, int dir) |
… | |
… | |
1843 | object *ob = pl->ranged_ob; |
1849 | object *ob = pl->ranged_ob; |
1844 | |
1850 | |
1845 | if (!ob) |
1851 | if (!ob) |
1846 | return; |
1852 | return; |
1847 | |
1853 | |
|
|
1854 | if (!op->change_weapon (ob)) |
|
|
1855 | return; |
|
|
1856 | |
1848 | switch (ob->type) |
1857 | switch (ob->type) |
1849 | { |
1858 | { |
1850 | case BOW: |
1859 | case BOW: |
1851 | player_fire_bow (op, dir); |
1860 | player_fire_bow (op, dir); |
1852 | break; |
1861 | break; |
… | |
… | |
1858 | case BUILDER: |
1867 | case BUILDER: |
1859 | apply_map_builder (op, dir); |
1868 | apply_map_builder (op, dir); |
1860 | break; |
1869 | break; |
1861 | |
1870 | |
1862 | case SKILL: |
1871 | case SKILL: |
1863 | case SKILL_TOOL: |
|
|
1864 | do_skill (op, op, ob, dir, 0); |
1872 | do_skill (op, op, ob, dir, 0); |
1865 | break; |
1873 | break; |
1866 | |
1874 | |
1867 | default: |
1875 | default: |
1868 | fire_misc_object (op, dir); |
1876 | fire_misc_object (op, dir); |
… | |
… | |
2166 | * that party_number -1 is no party, so attacks can still happen. |
2174 | * that party_number -1 is no party, so attacks can still happen. |
2167 | */ |
2175 | */ |
2168 | else if ((mon->stats.hp >= 0) && QUERY_FLAG (mon, FLAG_ALIVE) && |
2176 | else if ((mon->stats.hp >= 0) && QUERY_FLAG (mon, FLAG_ALIVE) && |
2169 | ((mon->type != PLAYER || op->contr->party == NULL || op->contr->party != mon->contr->party))) |
2177 | ((mon->type != PLAYER || op->contr->party == NULL || op->contr->party != mon->contr->party))) |
2170 | { |
2178 | { |
2171 | /* If the player hasn't hit something this tick, and does |
|
|
2172 | * so, give them speed boost based on weapon speed. Doing |
|
|
2173 | * it here is better than process_players2, which basically |
|
|
2174 | * incurred a 1 tick offset. |
|
|
2175 | */ |
|
|
2176 | if (!op->contr->has_hit) |
2179 | if (!op->contr->has_hit) |
2177 | { |
2180 | { |
|
|
2181 | op->contr->has_hit = 1; |
2178 | op->speed_left += op->contr->weapon_sp - op->speed; |
2182 | op->speed_left += op->contr->weapon_speed () - op->speed; |
2179 | |
|
|
2180 | op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */ |
|
|
2181 | } |
2183 | } |
2182 | |
2184 | |
2183 | skill_attack (mon, op, 0, 0, 0); |
2185 | skill_attack (mon, op, 0, 0, 0); |
2184 | |
2186 | |
2185 | /* If attacking another player, that player gets automatic |
2187 | /* If attacking another player, that player gets automatic |
… | |
… | |
2263 | handle_newcs_player (object *op) |
2265 | handle_newcs_player (object *op) |
2264 | { |
2266 | { |
2265 | if (QUERY_FLAG (op, FLAG_SCARED)) |
2267 | if (QUERY_FLAG (op, FLAG_SCARED)) |
2266 | { |
2268 | { |
2267 | flee_player (op); |
2269 | flee_player (op); |
|
|
2270 | |
2268 | /* If player is still scared, that is his action for this tick */ |
2271 | /* If player is still scared, that is his action for this tick */ |
2269 | if (QUERY_FLAG (op, FLAG_SCARED)) |
2272 | if (op->flag [FLAG_SCARED]) |
2270 | { |
2273 | { |
2271 | op->speed_left--; |
2274 | --op->speed_left; |
2272 | return 0; |
2275 | return 0; |
2273 | } |
2276 | } |
2274 | } |
2277 | } |
2275 | |
2278 | |
2276 | /* call this here - we also will call this in do_ericserver, but |
2279 | /* call this here - we also will call this in do_ericserver, but |
… | |
… | |
2278 | * called, so we recheck it here. |
2281 | * called, so we recheck it here. |
2279 | */ |
2282 | */ |
2280 | if (op->contr->ns->handle_command ()) |
2283 | if (op->contr->ns->handle_command ()) |
2281 | return 1; |
2284 | return 1; |
2282 | |
2285 | |
2283 | if (op->speed_left > 0) |
2286 | if (op->speed_left > 0.f) |
2284 | { |
2287 | { |
2285 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2288 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2286 | { |
2289 | { |
2287 | /* All move commands take 1 tick, at least for now */ |
2290 | /* All move commands take 1 tick, at least for now */ |
2288 | op->speed_left--; |
2291 | --op->speed_left; |
2289 | |
2292 | |
2290 | /* Instead of all the stuff below, let move_player take care |
2293 | /* Instead of all the stuff below, let move_player take care |
2291 | * of it. Also, some of the skill stuff is only put in |
2294 | * of it. Also, some of the skill stuff is only put in |
2292 | * there, as well as the confusion stuff. |
2295 | * there, as well as the confusion stuff. |
2293 | */ |
2296 | */ |
2294 | move_player (op, op->direction); |
2297 | move_player (op, op->direction); |
2295 | |
2298 | |
2296 | return op->speed_left > 0; |
2299 | return op->speed_left > 0.f; |
2297 | } |
2300 | } |
2298 | } |
2301 | } |
2299 | |
2302 | |
2300 | return 0; |
2303 | return 0; |
2301 | } |
2304 | } |
… | |
… | |
2931 | object *force; |
2934 | object *force; |
2932 | int at; |
2935 | int at; |
2933 | |
2936 | |
2934 | force = get_archetype (FORCE_NAME); |
2937 | force = get_archetype (FORCE_NAME); |
2935 | /* 50 ticks should be enough time for the spell to abate */ |
2938 | /* 50 ticks should be enough time for the spell to abate */ |
2936 | force->speed = 0.1; |
2939 | force->speed = 0.1f; |
2937 | force->speed_left = -5.0; |
2940 | force->speed_left = -5.f; |
2938 | SET_FLAG (force, FLAG_APPLIED); |
2941 | SET_FLAG (force, FLAG_APPLIED); |
2939 | for (at = 0; at < NROFATTACKS; at++) |
2942 | for (at = 0; at < NROFATTACKS; at++) |
2940 | if (will_kill_again & (1 << at)) |
2943 | if (will_kill_again & (1 << at)) |
2941 | force->resist[at] = 100; |
2944 | force->resist[at] = 100; |
2942 | |
2945 | |