… | |
… | |
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 | { |
… | |
… | |
1535 | */ |
1549 | */ |
1536 | int |
1550 | int |
1537 | 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) |
1538 | { |
1552 | { |
1539 | object *left, *bow; |
1553 | object *left, *bow; |
1540 | int bowspeed, mflags; |
1554 | int mflags; |
1541 | maptile *m; |
1555 | maptile *m; |
1542 | |
1556 | |
1543 | if (!dir) |
1557 | if (!dir) |
1544 | { |
1558 | { |
1545 | 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!"); |
1546 | return 0; |
1560 | return 0; |
1547 | } |
1561 | } |
1548 | |
1562 | |
1549 | if (player *pl = op->contr) |
1563 | if (op->contr) |
1550 | { |
1564 | bow = op->current_weapon; |
1551 | bow = pl->ranged_ob; |
|
|
1552 | if (!op->change_weapon (bow)) |
|
|
1553 | return 0; |
|
|
1554 | } |
|
|
1555 | else |
1565 | else |
1556 | { |
1566 | { |
1557 | for (bow = op->inv; bow; bow = bow->below) |
1567 | for (bow = op->inv; bow; bow = bow->below) |
1558 | /* 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 |
1559 | * 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. |
… | |
… | |
1580 | { |
1590 | { |
1581 | 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); |
1582 | return 0; |
1592 | return 0; |
1583 | } |
1593 | } |
1584 | |
1594 | |
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) |
1595 | if (arrow == NULL) |
1595 | { |
1596 | { |
1596 | if ((arrow = find_arrow (op, bow->race)) == NULL) |
1597 | if ((arrow = find_arrow (op, bow->race)) == NULL) |
1597 | { |
1598 | { |
1598 | if (op->type == PLAYER) |
1599 | if (op->type == PLAYER) |
… | |
… | |
1639 | arrow->stats.grace = arrow->attacktype; |
1640 | arrow->stats.grace = arrow->attacktype; |
1640 | |
1641 | |
1641 | if (arrow->slaying) |
1642 | if (arrow->slaying) |
1642 | arrow->spellarg = strdup (arrow->slaying); |
1643 | arrow->spellarg = strdup (arrow->slaying); |
1643 | |
1644 | |
1644 | if (op->type == PLAYER) |
1645 | if (player *pl = op->contr) |
1645 | { |
1646 | { |
1646 | op->speed_left = 0.01 - (float) FABS (op->speed) * 100 / bowspeed; |
1647 | if (!pl->has_hit) |
1647 | op->update_stats (); |
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 |
1648 | } |
1663 | } |
1649 | |
1664 | |
1650 | SET_ANIMATION (arrow, arrow->direction); |
1665 | SET_ANIMATION (arrow, arrow->direction); |
1651 | |
1666 | |
1652 | /* update the speed */ |
1667 | /* update the speed */ |
… | |
… | |
1745 | } |
1760 | } |
1746 | |
1761 | |
1747 | return ret; |
1762 | return ret; |
1748 | } |
1763 | } |
1749 | |
1764 | |
1750 | |
|
|
1751 | /* Fires a misc (wand/rod/horn) object in 'dir'. |
1765 | /* Fires a misc (wand/rod/horn) object in 'dir'. |
1752 | * Broken apart from 'fire' to keep it more readable. |
1766 | * Broken apart from 'fire' to keep it more readable. |
1753 | */ |
1767 | */ |
1754 | void |
1768 | void |
1755 | fire_misc_object (object *op, int dir) |
1769 | fire_misc_object (object *op, int dir) |
… | |
… | |
1843 | object *ob = pl->ranged_ob; |
1857 | object *ob = pl->ranged_ob; |
1844 | |
1858 | |
1845 | if (!ob) |
1859 | if (!ob) |
1846 | return; |
1860 | return; |
1847 | |
1861 | |
|
|
1862 | if (!op->change_weapon (ob)) |
|
|
1863 | return; |
|
|
1864 | |
1848 | switch (ob->type) |
1865 | switch (ob->type) |
1849 | { |
1866 | { |
1850 | case BOW: |
1867 | case BOW: |
1851 | player_fire_bow (op, dir); |
1868 | player_fire_bow (op, dir); |
1852 | break; |
1869 | break; |
… | |
… | |
1858 | case BUILDER: |
1875 | case BUILDER: |
1859 | apply_map_builder (op, dir); |
1876 | apply_map_builder (op, dir); |
1860 | break; |
1877 | break; |
1861 | |
1878 | |
1862 | case SKILL: |
1879 | case SKILL: |
1863 | case SKILL_TOOL: |
|
|
1864 | do_skill (op, op, ob, dir, 0); |
1880 | do_skill (op, op, ob, dir, 0); |
1865 | break; |
1881 | break; |
1866 | |
1882 | |
1867 | default: |
1883 | default: |
1868 | fire_misc_object (op, dir); |
1884 | fire_misc_object (op, dir); |
… | |
… | |
2096 | |
2112 | |
2097 | /* 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 |
2098 | * peaceful. Our assumption is the creature is a pet if the |
2114 | * peaceful. Our assumption is the creature is a pet if the |
2099 | * player owns it and it is either friendly or unagressive. |
2115 | * player owns it and it is either friendly or unagressive. |
2100 | */ |
2116 | */ |
2101 | if ((op->type == PLAYER) |
2117 | if (op->type == PLAYER |
2102 | #if COZY_SERVER |
|
|
2103 | && |
|
|
2104 | ((mon->owner && mon->owner->contr |
2118 | && ((mon->owner && mon->owner->contr |
2105 | && same_party (mon->owner->contr->party, op->contr->party)) || mon->owner == op) |
2119 | && same_party (mon->owner->contr->party, op->contr->party)) |
2106 | #else |
|
|
2107 | && mon->owner == op |
2120 | || mon->owner == op) |
2108 | #endif |
|
|
2109 | && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) |
2121 | && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) |
2110 | { |
2122 | { |
2111 | /* 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 */ |
2112 | if (op->contr->braced) |
2124 | if (op->contr->braced) |
2113 | return; |
2125 | return; |
… | |
… | |
2123 | /* in certain circumstances, you shouldn't attack friendly |
2135 | /* in certain circumstances, you shouldn't attack friendly |
2124 | * creatures. Note that if you are braced, you can't push |
2136 | * creatures. Note that if you are braced, you can't push |
2125 | * 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 |
2126 | * attack them either. |
2138 | * attack them either. |
2127 | */ |
2139 | */ |
2128 | if ((mon->type == PLAYER || mon->enemy != op) && |
2140 | if ((mon->type == PLAYER || mon->enemy != op) |
2129 | (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)) |
2130 | #ifdef PROHIBIT_PLAYERKILL |
|
|
2131 | (op->contr->peaceful |
2142 | && ((op->contr->peaceful |
2132 | || (mon->type == PLAYER |
2143 | || (mon->type == PLAYER && mon->contr->peaceful)) |
2133 | && mon->contr-> |
|
|
2134 | peaceful)) && |
|
|
2135 | #else |
|
|
2136 | op->contr->peaceful && |
|
|
2137 | #endif |
|
|
2138 | !on_battleground)) |
2144 | && !on_battleground)) |
2139 | { |
2145 | { |
2140 | if (!op->contr->braced) |
2146 | if (!op->contr->braced) |
2141 | { |
2147 | { |
2142 | 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); |
2143 | push_ob (mon, dir, op); |
2149 | push_ob (mon, dir, op); |
… | |
… | |
2166 | * 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. |
2167 | */ |
2173 | */ |
2168 | else if ((mon->stats.hp >= 0) && QUERY_FLAG (mon, FLAG_ALIVE) && |
2174 | 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))) |
2175 | ((mon->type != PLAYER || op->contr->party == NULL || op->contr->party != mon->contr->party))) |
2170 | { |
2176 | { |
2171 | |
|
|
2172 | /* If the player hasn't hit something this tick, and does |
|
|
2173 | * so, give them speed boost based on weapon speed. Doing |
|
|
2174 | * it here is better than process_players2, which basically |
|
|
2175 | * incurred a 1 tick offset. |
|
|
2176 | */ |
|
|
2177 | if (!op->contr->has_hit) |
2177 | if (!op->contr->has_hit) |
2178 | { |
2178 | { |
|
|
2179 | op->contr->has_hit = 1; |
2179 | op->speed_left += op->speed / op->contr->weapon_sp; |
2180 | op->speed_left += op->contr->weapon_speed () - op->speed; |
2180 | |
|
|
2181 | op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */ |
|
|
2182 | } |
2181 | } |
2183 | |
2182 | |
2184 | skill_attack (mon, op, 0, 0, 0); |
2183 | skill_attack (mon, op, 0, 0, 0); |
2185 | |
2184 | |
2186 | /* If attacking another player, that player gets automatic |
2185 | /* If attacking another player, that player gets automatic |
… | |
… | |
2264 | handle_newcs_player (object *op) |
2263 | handle_newcs_player (object *op) |
2265 | { |
2264 | { |
2266 | if (QUERY_FLAG (op, FLAG_SCARED)) |
2265 | if (QUERY_FLAG (op, FLAG_SCARED)) |
2267 | { |
2266 | { |
2268 | flee_player (op); |
2267 | flee_player (op); |
|
|
2268 | |
2269 | /* 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 */ |
2270 | if (QUERY_FLAG (op, FLAG_SCARED)) |
2270 | if (op->flag [FLAG_SCARED]) |
2271 | { |
2271 | { |
2272 | op->speed_left--; |
2272 | --op->speed_left; |
2273 | return 0; |
2273 | return 0; |
2274 | } |
2274 | } |
2275 | } |
2275 | } |
2276 | |
2276 | |
2277 | /* 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 |
… | |
… | |
2279 | * called, so we recheck it here. |
2279 | * called, so we recheck it here. |
2280 | */ |
2280 | */ |
2281 | if (op->contr->ns->handle_command ()) |
2281 | if (op->contr->ns->handle_command ()) |
2282 | return 1; |
2282 | return 1; |
2283 | |
2283 | |
2284 | if (op->speed_left > 0) |
2284 | if (op->speed_left > 0.f) |
2285 | { |
2285 | { |
2286 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2286 | if (op->direction && (op->contr->run_on || op->contr->fire_on)) |
2287 | { |
2287 | { |
2288 | /* All move commands take 1 tick, at least for now */ |
2288 | /* All move commands take 1 tick, at least for now */ |
2289 | op->speed_left--; |
2289 | --op->speed_left; |
2290 | |
2290 | |
2291 | /* Instead of all the stuff below, let move_player take care |
2291 | /* Instead of all the stuff below, let move_player take care |
2292 | * 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 |
2293 | * there, as well as the confusion stuff. |
2293 | * there, as well as the confusion stuff. |
2294 | */ |
2294 | */ |
2295 | move_player (op, op->direction); |
2295 | move_player (op, op->direction); |
2296 | |
2296 | |
2297 | return op->speed_left > 0; |
2297 | return op->speed_left > 0.f; |
2298 | } |
2298 | } |
2299 | } |
2299 | } |
2300 | |
2300 | |
2301 | return 0; |
2301 | return 0; |
2302 | } |
2302 | } |
… | |
… | |
2572 | } |
2572 | } |
2573 | |
2573 | |
2574 | /* Digestion */ |
2574 | /* Digestion */ |
2575 | if (--op->last_eat < 0) |
2575 | if (--op->last_eat < 0) |
2576 | { |
2576 | { |
2577 | #ifdef COZY_SERVER |
|
|
2578 | int dg = op->contr->digestion >= 0 && op->contr->digestion < 2 ? 2 : op->contr->digestion; |
|
|
2579 | int bonus = dg > 0 ? dg : 0, penalty = dg < 0 ? -dg : 0; |
|
|
2580 | #else |
|
|
2581 | 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; |
2582 | #endif |
|
|
2583 | |
2578 | |
2584 | if (op->contr->gen_hp > 0) |
2579 | if (op->contr->gen_hp > 0) |
2585 | 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); |
2586 | else |
2581 | else |
2587 | op->last_eat = 25 * (1 + bonus) / (penalty + 1); |
2582 | op->last_eat = 25 * (1 + bonus) / (penalty + 1); |
… | |
… | |
2932 | object *force; |
2927 | object *force; |
2933 | int at; |
2928 | int at; |
2934 | |
2929 | |
2935 | force = get_archetype (FORCE_NAME); |
2930 | force = get_archetype (FORCE_NAME); |
2936 | /* 50 ticks should be enough time for the spell to abate */ |
2931 | /* 50 ticks should be enough time for the spell to abate */ |
2937 | force->speed = 0.1; |
2932 | force->speed = 0.1f; |
2938 | force->speed_left = -5.0; |
2933 | force->speed_left = -5.f; |
2939 | SET_FLAG (force, FLAG_APPLIED); |
2934 | SET_FLAG (force, FLAG_APPLIED); |
2940 | for (at = 0; at < NROFATTACKS; at++) |
2935 | for (at = 0; at < NROFATTACKS; at++) |
2941 | if (will_kill_again & (1 << at)) |
2936 | if (will_kill_again & (1 << at)) |
2942 | force->resist[at] = 100; |
2937 | force->resist[at] = 100; |
2943 | |
2938 | |