… | |
… | |
258 | |
258 | |
259 | new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!"); |
259 | new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!"); |
260 | |
260 | |
261 | esrv_new_player (this, ob->weight + ob->carrying); |
261 | esrv_new_player (this, ob->weight + ob->carrying); |
262 | |
262 | |
|
|
263 | ob->flag [FLAG_READY_WEAPON] = false; |
|
|
264 | ob->flag [FLAG_READY_SKILL] = false; |
|
|
265 | ob->flag [FLAG_READY_BOW] = false; |
|
|
266 | |
263 | for (object *op = ob->inv; op; op = op->below) |
267 | for (object *op = ob->inv; op; op = op->below) |
264 | if (op->flag [FLAG_APPLIED]) |
268 | if (op->flag [FLAG_APPLIED]) |
265 | switch (op->type) |
269 | switch (op->type) |
266 | { |
270 | { |
|
|
271 | case SKILL: |
|
|
272 | ob->flag [FLAG_APPLIED] = false; |
|
|
273 | break; |
|
|
274 | |
267 | case WAND: |
275 | case WAND: |
268 | case ROD: |
276 | case ROD: |
269 | case HORN: |
277 | case HORN: |
270 | case BOW: |
278 | case BOW: |
271 | case SKILL: |
279 | ranged_ob = op; |
272 | case SKILL_TOOL: |
280 | break; |
|
|
281 | |
273 | case WEAPON: |
282 | case WEAPON: |
274 | apply_special (ob, op, AP_UNAPPLY); |
283 | combat_ob = op; |
275 | apply_special (ob, op, AP_APPLY); |
|
|
276 | break; |
284 | break; |
277 | } |
285 | } |
278 | |
286 | |
|
|
287 | ob->change_weapon (combat_ob ? combat_ob : ranged_ob); |
279 | ob->update_stats (); |
288 | ob->update_stats (); |
|
|
289 | |
280 | ns->floorbox_update (); |
290 | ns->floorbox_update (); |
281 | |
|
|
282 | esrv_send_inventory (ob, ob); |
291 | esrv_send_inventory (ob, ob); |
283 | esrv_add_spells (this, 0); |
292 | esrv_add_spells (this, 0); |
284 | |
293 | |
285 | activate (); |
294 | activate (); |
286 | |
295 | |
… | |
… | |
1544 | { |
1553 | { |
1545 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1554 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1546 | return 0; |
1555 | return 0; |
1547 | } |
1556 | } |
1548 | |
1557 | |
1549 | if (player *pl = op->contr) |
1558 | if (op->contr) |
1550 | { |
1559 | bow = op->current_weapon; |
1551 | bow = pl->ranged_ob; |
|
|
1552 | if (!op->change_weapon (bow)) |
|
|
1553 | return 0; |
|
|
1554 | } |
|
|
1555 | else |
1560 | else |
1556 | { |
1561 | { |
1557 | for (bow = op->inv; bow; bow = bow->below) |
1562 | for (bow = op->inv; bow; bow = bow->below) |
1558 | /* Don't check for applied - monsters don't apply bows - in that way, they |
1563 | /* 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. |
1564 | * don't need to switch back and forth between bows and weapons. |
… | |
… | |
1632 | if (arrow->slaying) |
1637 | if (arrow->slaying) |
1633 | arrow->spellarg = strdup (arrow->slaying); |
1638 | arrow->spellarg = strdup (arrow->slaying); |
1634 | |
1639 | |
1635 | if (player *pl = op->contr) |
1640 | if (player *pl = op->contr) |
1636 | { |
1641 | { |
|
|
1642 | if (!pl->has_hit) |
|
|
1643 | { |
1637 | pl->has_hit = 1; |
1644 | pl->has_hit = 1; |
|
|
1645 | pl->ob->speed_left += pl->weapon_sp - pl->ob->speed; |
|
|
1646 | } |
1638 | #if 0 |
1647 | #if 0 |
1639 | float speed = pl->weapon_sp; |
1648 | float speed = pl->weapon_sp; |
1640 | |
1649 | |
1641 | /* penalize ROF for bestarrow */ |
1650 | /* penalize ROF for bestarrow */ |
1642 | if (pl->bowtype == bow_bestarrow) |
1651 | if (pl->bowtype == bow_bestarrow) |
… | |
… | |
1746 | } |
1755 | } |
1747 | |
1756 | |
1748 | return ret; |
1757 | return ret; |
1749 | } |
1758 | } |
1750 | |
1759 | |
1751 | |
|
|
1752 | /* Fires a misc (wand/rod/horn) object in 'dir'. |
1760 | /* Fires a misc (wand/rod/horn) object in 'dir'. |
1753 | * Broken apart from 'fire' to keep it more readable. |
1761 | * Broken apart from 'fire' to keep it more readable. |
1754 | */ |
1762 | */ |
1755 | void |
1763 | void |
1756 | fire_misc_object (object *op, int dir) |
1764 | fire_misc_object (object *op, int dir) |
… | |
… | |
1844 | object *ob = pl->ranged_ob; |
1852 | object *ob = pl->ranged_ob; |
1845 | |
1853 | |
1846 | if (!ob) |
1854 | if (!ob) |
1847 | return; |
1855 | return; |
1848 | |
1856 | |
|
|
1857 | if (!op->change_weapon (ob)) |
|
|
1858 | return; |
|
|
1859 | |
1849 | switch (ob->type) |
1860 | switch (ob->type) |
1850 | { |
1861 | { |
1851 | case BOW: |
1862 | case BOW: |
1852 | player_fire_bow (op, dir); |
1863 | player_fire_bow (op, dir); |
1853 | break; |
1864 | break; |
… | |
… | |
1859 | case BUILDER: |
1870 | case BUILDER: |
1860 | apply_map_builder (op, dir); |
1871 | apply_map_builder (op, dir); |
1861 | break; |
1872 | break; |
1862 | |
1873 | |
1863 | case SKILL: |
1874 | case SKILL: |
1864 | case SKILL_TOOL: |
|
|
1865 | do_skill (op, op, ob, dir, 0); |
1875 | do_skill (op, op, ob, dir, 0); |
1866 | break; |
1876 | break; |
1867 | |
1877 | |
1868 | default: |
1878 | default: |
1869 | fire_misc_object (op, dir); |
1879 | fire_misc_object (op, dir); |
… | |
… | |
2097 | |
2107 | |
2098 | /* If the creature is a pet, push it even if the player is not |
2108 | /* If the creature is a pet, push it even if the player is not |
2099 | * peaceful. Our assumption is the creature is a pet if the |
2109 | * peaceful. Our assumption is the creature is a pet if the |
2100 | * player owns it and it is either friendly or unagressive. |
2110 | * player owns it and it is either friendly or unagressive. |
2101 | */ |
2111 | */ |
2102 | if ((op->type == PLAYER) |
2112 | if (op->type == PLAYER |
2103 | #if COZY_SERVER |
|
|
2104 | && |
|
|
2105 | ((mon->owner && mon->owner->contr |
2113 | && ((mon->owner && mon->owner->contr |
2106 | && same_party (mon->owner->contr->party, op->contr->party)) || mon->owner == op) |
2114 | && same_party (mon->owner->contr->party, op->contr->party)) |
2107 | #else |
|
|
2108 | && mon->owner == op |
2115 | || mon->owner == op) |
2109 | #endif |
|
|
2110 | && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) |
2116 | && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) |
2111 | { |
2117 | { |
2112 | /* If we're braced, we don't want to switch places with it */ |
2118 | /* If we're braced, we don't want to switch places with it */ |
2113 | if (op->contr->braced) |
2119 | if (op->contr->braced) |
2114 | return; |
2120 | return; |
… | |
… | |
2124 | /* in certain circumstances, you shouldn't attack friendly |
2130 | /* in certain circumstances, you shouldn't attack friendly |
2125 | * creatures. Note that if you are braced, you can't push |
2131 | * creatures. Note that if you are braced, you can't push |
2126 | * someone, but put it inside this loop so that you won't |
2132 | * someone, but put it inside this loop so that you won't |
2127 | * attack them either. |
2133 | * attack them either. |
2128 | */ |
2134 | */ |
2129 | if ((mon->type == PLAYER || mon->enemy != op) && |
2135 | if ((mon->type == PLAYER || mon->enemy != op) |
2130 | (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) && ( |
2136 | && (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) |
2131 | #ifdef PROHIBIT_PLAYERKILL |
|
|
2132 | (op->contr->peaceful |
2137 | && ((op->contr->peaceful |
2133 | || (mon->type == PLAYER |
2138 | || (mon->type == PLAYER && mon->contr->peaceful)) |
2134 | && mon->contr-> |
|
|
2135 | peaceful)) && |
|
|
2136 | #else |
|
|
2137 | op->contr->peaceful && |
|
|
2138 | #endif |
|
|
2139 | !on_battleground)) |
2139 | && !on_battleground)) |
2140 | { |
2140 | { |
2141 | if (!op->contr->braced) |
2141 | if (!op->contr->braced) |
2142 | { |
2142 | { |
2143 | play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER); |
2143 | play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER); |
2144 | push_ob (mon, dir, op); |
2144 | push_ob (mon, dir, op); |
… | |
… | |
2167 | * 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. |
2168 | */ |
2168 | */ |
2169 | else if ((mon->stats.hp >= 0) && QUERY_FLAG (mon, FLAG_ALIVE) && |
2169 | else if ((mon->stats.hp >= 0) && QUERY_FLAG (mon, FLAG_ALIVE) && |
2170 | ((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))) |
2171 | { |
2171 | { |
|
|
2172 | if (!op->contr->has_hit) |
|
|
2173 | { |
2172 | op->contr->has_hit = 1; |
2174 | op->contr->has_hit = 1; |
|
|
2175 | op->speed_left += op->contr->weapon_sp - op->speed; |
|
|
2176 | } |
2173 | |
2177 | |
2174 | skill_attack (mon, op, 0, 0, 0); |
2178 | skill_attack (mon, op, 0, 0, 0); |
2175 | |
2179 | |
2176 | /* If attacking another player, that player gets automatic |
2180 | /* If attacking another player, that player gets automatic |
2177 | * hitback, and doesn't loose luck either. |
2181 | * hitback, and doesn't loose luck either. |
… | |
… | |
2563 | } |
2567 | } |
2564 | |
2568 | |
2565 | /* Digestion */ |
2569 | /* Digestion */ |
2566 | if (--op->last_eat < 0) |
2570 | if (--op->last_eat < 0) |
2567 | { |
2571 | { |
2568 | #ifdef COZY_SERVER |
|
|
2569 | int dg = op->contr->digestion >= 0 && op->contr->digestion < 2 ? 2 : op->contr->digestion; |
|
|
2570 | int bonus = dg > 0 ? dg : 0, penalty = dg < 0 ? -dg : 0; |
|
|
2571 | #else |
|
|
2572 | int bonus = op->contr->digestion > 0 ? op->contr->digestion : 0, penalty = op->contr->digestion < 0 ? -op->contr->digestion : 0; |
2572 | int bonus = op->contr->digestion > 0 ? op->contr->digestion : 0, penalty = op->contr->digestion < 0 ? -op->contr->digestion : 0; |
2573 | #endif |
|
|
2574 | |
2573 | |
2575 | if (op->contr->gen_hp > 0) |
2574 | if (op->contr->gen_hp > 0) |
2576 | op->last_eat = 25 * (1 + bonus) / (op->contr->gen_hp + penalty + 1); |
2575 | op->last_eat = 25 * (1 + bonus) / (op->contr->gen_hp + penalty + 1); |
2577 | else |
2576 | else |
2578 | op->last_eat = 25 * (1 + bonus) / (penalty + 1); |
2577 | op->last_eat = 25 * (1 + bonus) / (penalty + 1); |