… | |
… | |
299 | set_first_map (object *op) |
299 | set_first_map (object *op) |
300 | { |
300 | { |
301 | strcpy (op->contr->maplevel, first_map_path); |
301 | strcpy (op->contr->maplevel, first_map_path); |
302 | op->x = -1; |
302 | op->x = -1; |
303 | op->y = -1; |
303 | op->y = -1; |
304 | enter_exit (op, NULL); |
304 | enter_exit (op, 0); |
305 | } |
305 | } |
306 | |
306 | |
307 | /* Tries to add player on the connection passwd in ns. |
307 | /* Tries to add player on the connection passwd in ns. |
308 | * All we can really get in this is some settings like host and display |
308 | * All we can really get in this is some settings like host and display |
309 | * mode. |
309 | * mode. |
… | |
… | |
348 | { |
348 | { |
349 | if (at == NULL || at->next == NULL) |
349 | if (at == NULL || at->next == NULL) |
350 | at = first_archetype; |
350 | at = first_archetype; |
351 | else |
351 | else |
352 | at = at->next; |
352 | at = at->next; |
|
|
353 | |
353 | if (at->clone.type == PLAYER) |
354 | if (at->clone.type == PLAYER) |
354 | return at; |
355 | return at; |
|
|
356 | |
355 | if (at == start) |
357 | if (at == start) |
356 | { |
358 | { |
357 | LOG (llevError, "No Player archetypes\n"); |
359 | LOG (llevError, "No Player archetypes\n"); |
358 | exit (-1); |
360 | exit (-1); |
359 | } |
361 | } |
360 | } |
362 | } |
361 | } |
363 | } |
362 | |
|
|
363 | |
364 | |
364 | object * |
365 | object * |
365 | get_nearest_player (object *mon) |
366 | get_nearest_player (object *mon) |
366 | { |
367 | { |
367 | object *op = NULL; |
368 | object *op = NULL; |
… | |
… | |
1091 | * if the map isn't there, then stay on the |
1092 | * if the map isn't there, then stay on the |
1092 | * default initial map */ |
1093 | * default initial map */ |
1093 | tmp->destroy (); |
1094 | tmp->destroy (); |
1094 | } |
1095 | } |
1095 | else |
1096 | else |
1096 | { |
|
|
1097 | LOG (llevDebug, "first_map_ext_path not set\n"); |
1097 | LOG (llevDebug, "first_map_ext_path not set\n"); |
1098 | } |
1098 | |
1099 | return 0; |
1099 | return 0; |
1100 | } |
1100 | } |
1101 | |
1101 | |
1102 | /* Following actually changes the race - this is the default command |
1102 | /* Following actually changes the race - this is the default command |
1103 | * if we don't match with one of the options above. |
1103 | * if we don't match with one of the options above. |
… | |
… | |
1800 | if (!dir) |
1800 | if (!dir) |
1801 | { |
1801 | { |
1802 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1802 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1803 | return 0; |
1803 | return 0; |
1804 | } |
1804 | } |
|
|
1805 | |
1805 | if (op->type == PLAYER) |
1806 | if (op->type == PLAYER) |
1806 | bow = op->contr->ranges[range_bow]; |
1807 | bow = op->contr->ranges[range_bow]; |
1807 | else |
1808 | else |
1808 | { |
1809 | { |
1809 | for (bow = op->inv; bow; bow = bow->below) |
1810 | for (bow = op->inv; bow; bow = bow->below) |
… | |
… | |
1817 | { |
1818 | { |
1818 | LOG (llevError, "Range: bow without activated bow (%s).\n", &op->name); |
1819 | LOG (llevError, "Range: bow without activated bow (%s).\n", &op->name); |
1819 | return 0; |
1820 | return 0; |
1820 | } |
1821 | } |
1821 | } |
1822 | } |
|
|
1823 | |
1822 | if (!bow->race || !bow->skill) |
1824 | if (!bow->race || !bow->skill) |
1823 | { |
1825 | { |
1824 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); |
1826 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); |
1825 | return 0; |
1827 | return 0; |
1826 | } |
1828 | } |
… | |
… | |
1828 | bowspeed = bow->stats.sp + dex_bonus[op->stats.Dex]; |
1830 | bowspeed = bow->stats.sp + dex_bonus[op->stats.Dex]; |
1829 | |
1831 | |
1830 | /* penalize ROF for bestarrow */ |
1832 | /* penalize ROF for bestarrow */ |
1831 | if (op->type == PLAYER && op->contr->bowtype == bow_bestarrow) |
1833 | if (op->type == PLAYER && op->contr->bowtype == bow_bestarrow) |
1832 | bowspeed -= dex_bonus[op->stats.Dex] + 5; |
1834 | bowspeed -= dex_bonus[op->stats.Dex] + 5; |
|
|
1835 | |
1833 | if (bowspeed < 1) |
1836 | if (bowspeed < 1) |
1834 | bowspeed = 1; |
1837 | bowspeed = 1; |
1835 | |
1838 | |
1836 | if (arrow == NULL) |
1839 | if (arrow == NULL) |
1837 | { |
1840 | { |
… | |
… | |
1843 | else |
1846 | else |
1844 | CLEAR_FLAG (op, FLAG_READY_BOW); |
1847 | CLEAR_FLAG (op, FLAG_READY_BOW); |
1845 | return 0; |
1848 | return 0; |
1846 | } |
1849 | } |
1847 | } |
1850 | } |
|
|
1851 | |
1848 | mflags = get_map_flags (op->map, &m, sx, sy, &sx, &sy); |
1852 | mflags = get_map_flags (op->map, &m, sx, sy, &sx, &sy); |
1849 | if (mflags & P_OUT_OF_MAP) |
1853 | if (mflags & P_OUT_OF_MAP) |
1850 | { |
|
|
1851 | return 0; |
1854 | return 0; |
1852 | } |
1855 | |
1853 | if (GET_MAP_MOVE_BLOCK (m, sx, sy) == MOVE_FLY_LOW) |
1856 | if (GET_MAP_MOVE_BLOCK (m, sx, sy) == MOVE_FLY_LOW) |
1854 | { |
1857 | { |
1855 | new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); |
1858 | new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); |
1856 | return 0; |
1859 | return 0; |
1857 | } |
1860 | } |
… | |
… | |
1863 | return 0; |
1866 | return 0; |
1864 | } |
1867 | } |
1865 | |
1868 | |
1866 | left = arrow; /* these are arrows left to the player */ |
1869 | left = arrow; /* these are arrows left to the player */ |
1867 | arrow = get_split_ob (arrow, 1); |
1870 | arrow = get_split_ob (arrow, 1); |
1868 | if (arrow == NULL) |
1871 | if (!arrow) |
1869 | { |
1872 | { |
1870 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1873 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1871 | return 0; |
1874 | return 0; |
1872 | } |
1875 | } |
|
|
1876 | |
1873 | arrow->set_owner (op); |
1877 | arrow->set_owner (op); |
1874 | arrow->skill = bow->skill; |
1878 | arrow->skill = bow->skill; |
1875 | |
1879 | |
1876 | arrow->direction = dir; |
1880 | arrow->direction = dir; |
1877 | arrow->x = sx; |
1881 | arrow->x = sx; |
… | |
… | |
1920 | } |
1924 | } |
1921 | |
1925 | |
1922 | if (arrow->attacktype == AT_PHYSICAL) |
1926 | if (arrow->attacktype == AT_PHYSICAL) |
1923 | arrow->attacktype |= bow->attacktype; |
1927 | arrow->attacktype |= bow->attacktype; |
1924 | |
1928 | |
1925 | if (bow->slaying != NULL) |
1929 | if (bow->slaying) |
1926 | arrow->slaying = bow->slaying; |
1930 | arrow->slaying = bow->slaying; |
1927 | |
1931 | |
1928 | arrow->map = m; |
1932 | arrow->map = m; |
1929 | arrow->move_type = MOVE_FLY_LOW; |
1933 | arrow->move_type = MOVE_FLY_LOW; |
1930 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1934 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
… | |
… | |
2552 | |
2556 | |
2553 | /* call this here - we also will call this in do_ericserver, but |
2557 | /* call this here - we also will call this in do_ericserver, but |
2554 | * the players time has been increased when doericserver has been |
2558 | * the players time has been increased when doericserver has been |
2555 | * called, so we recheck it here. |
2559 | * called, so we recheck it here. |
2556 | */ |
2560 | */ |
2557 | op->contr->socket->handle_command (); |
2561 | //TODO: better than handling 8 commands, use some more intelligent rate-limiting |
|
|
2562 | for (int rep = 8; --rep && op->contr->socket->handle_command (); ) |
|
|
2563 | ; |
|
|
2564 | |
2558 | if (op->speed_left < 0) |
2565 | if (op->speed_left < 0) |
2559 | return 0; |
2566 | return 0; |
2560 | |
2567 | |
2561 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2568 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2562 | { |
2569 | { |