… | |
… | |
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; |
… | |
… | |
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. |
… | |
… | |
1632 | if (arrow->slaying) |
1634 | if (arrow->slaying) |
1633 | arrow->spellarg = strdup (arrow->slaying); |
1635 | arrow->spellarg = strdup (arrow->slaying); |
1634 | |
1636 | |
1635 | if (player *pl = op->contr) |
1637 | if (player *pl = op->contr) |
1636 | { |
1638 | { |
|
|
1639 | if (!pl->has_hit) |
1637 | { |
1640 | { |
1638 | pl->has_hit = 1; |
1641 | pl->has_hit = 1; |
1639 | pl->ob->speed_left += pl->weapon_sp - pl->ob->speed; |
1642 | pl->ob->speed_left += pl->weapon_speed () - pl->ob->speed; |
1640 | } |
1643 | } |
1641 | #if 0 |
1644 | #if 0 |
1642 | float speed = pl->weapon_sp; |
1645 | float speed = pl->weapon_sp; |
1643 | |
1646 | |
1644 | /* penalize ROF for bestarrow */ |
1647 | /* penalize ROF for bestarrow */ |
1645 | if (pl->bowtype == bow_bestarrow) |
1648 | if (pl->bowtype == bow_bestarrow) |
… | |
… | |
1749 | } |
1752 | } |
1750 | |
1753 | |
1751 | return ret; |
1754 | return ret; |
1752 | } |
1755 | } |
1753 | |
1756 | |
1754 | |
|
|
1755 | /* Fires a misc (wand/rod/horn) object in 'dir'. |
1757 | /* Fires a misc (wand/rod/horn) object in 'dir'. |
1756 | * Broken apart from 'fire' to keep it more readable. |
1758 | * Broken apart from 'fire' to keep it more readable. |
1757 | */ |
1759 | */ |
1758 | void |
1760 | void |
1759 | fire_misc_object (object *op, int dir) |
1761 | fire_misc_object (object *op, int dir) |
… | |
… | |
1847 | object *ob = pl->ranged_ob; |
1849 | object *ob = pl->ranged_ob; |
1848 | |
1850 | |
1849 | if (!ob) |
1851 | if (!ob) |
1850 | return; |
1852 | return; |
1851 | |
1853 | |
|
|
1854 | if (!op->change_weapon (ob)) |
|
|
1855 | return; |
|
|
1856 | |
1852 | switch (ob->type) |
1857 | switch (ob->type) |
1853 | { |
1858 | { |
1854 | case BOW: |
1859 | case BOW: |
1855 | player_fire_bow (op, dir); |
1860 | player_fire_bow (op, dir); |
1856 | break; |
1861 | break; |
… | |
… | |
1862 | case BUILDER: |
1867 | case BUILDER: |
1863 | apply_map_builder (op, dir); |
1868 | apply_map_builder (op, dir); |
1864 | break; |
1869 | break; |
1865 | |
1870 | |
1866 | case SKILL: |
1871 | case SKILL: |
1867 | case SKILL_TOOL: |
|
|
1868 | do_skill (op, op, ob, dir, 0); |
1872 | do_skill (op, op, ob, dir, 0); |
1869 | break; |
1873 | break; |
1870 | |
1874 | |
1871 | default: |
1875 | default: |
1872 | fire_misc_object (op, dir); |
1876 | fire_misc_object (op, dir); |
… | |
… | |
2100 | |
2104 | |
2101 | /* If the creature is a pet, push it even if the player is not |
2105 | /* If the creature is a pet, push it even if the player is not |
2102 | * peaceful. Our assumption is the creature is a pet if the |
2106 | * peaceful. Our assumption is the creature is a pet if the |
2103 | * player owns it and it is either friendly or unagressive. |
2107 | * player owns it and it is either friendly or unagressive. |
2104 | */ |
2108 | */ |
2105 | if ((op->type == PLAYER) |
2109 | if (op->type == PLAYER |
2106 | #if COZY_SERVER |
|
|
2107 | && |
|
|
2108 | ((mon->owner && mon->owner->contr |
2110 | && ((mon->owner && mon->owner->contr |
2109 | && same_party (mon->owner->contr->party, op->contr->party)) || mon->owner == op) |
2111 | && same_party (mon->owner->contr->party, op->contr->party)) |
2110 | #else |
|
|
2111 | && mon->owner == op |
2112 | || mon->owner == op) |
2112 | #endif |
|
|
2113 | && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) |
2113 | && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) |
2114 | { |
2114 | { |
2115 | /* If we're braced, we don't want to switch places with it */ |
2115 | /* If we're braced, we don't want to switch places with it */ |
2116 | if (op->contr->braced) |
2116 | if (op->contr->braced) |
2117 | return; |
2117 | return; |
… | |
… | |
2127 | /* in certain circumstances, you shouldn't attack friendly |
2127 | /* in certain circumstances, you shouldn't attack friendly |
2128 | * creatures. Note that if you are braced, you can't push |
2128 | * creatures. Note that if you are braced, you can't push |
2129 | * someone, but put it inside this loop so that you won't |
2129 | * someone, but put it inside this loop so that you won't |
2130 | * attack them either. |
2130 | * attack them either. |
2131 | */ |
2131 | */ |
2132 | if ((mon->type == PLAYER || mon->enemy != op) && |
2132 | if ((mon->type == PLAYER || mon->enemy != op) |
2133 | (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) && ( |
2133 | && (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) |
2134 | #ifdef PROHIBIT_PLAYERKILL |
|
|
2135 | (op->contr->peaceful |
2134 | && ((op->contr->peaceful |
2136 | || (mon->type == PLAYER |
2135 | || (mon->type == PLAYER && mon->contr->peaceful)) |
2137 | && mon->contr-> |
|
|
2138 | peaceful)) && |
|
|
2139 | #else |
|
|
2140 | op->contr->peaceful && |
|
|
2141 | #endif |
|
|
2142 | !on_battleground)) |
2136 | && !on_battleground)) |
2143 | { |
2137 | { |
2144 | if (!op->contr->braced) |
2138 | if (!op->contr->braced) |
2145 | { |
2139 | { |
2146 | play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER); |
2140 | play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER); |
2147 | push_ob (mon, dir, op); |
2141 | push_ob (mon, dir, op); |
… | |
… | |
2170 | * that party_number -1 is no party, so attacks can still happen. |
2164 | * that party_number -1 is no party, so attacks can still happen. |
2171 | */ |
2165 | */ |
2172 | else if ((mon->stats.hp >= 0) && QUERY_FLAG (mon, FLAG_ALIVE) && |
2166 | else if ((mon->stats.hp >= 0) && QUERY_FLAG (mon, FLAG_ALIVE) && |
2173 | ((mon->type != PLAYER || op->contr->party == NULL || op->contr->party != mon->contr->party))) |
2167 | ((mon->type != PLAYER || op->contr->party == NULL || op->contr->party != mon->contr->party))) |
2174 | { |
2168 | { |
|
|
2169 | if (!op->contr->has_hit) |
|
|
2170 | { |
2175 | op->contr->has_hit = 1; |
2171 | op->contr->has_hit = 1; |
2176 | op->speed_left += op->contr->weapon_sp - op->speed; |
2172 | op->speed_left += op->contr->weapon_speed () - op->speed; |
|
|
2173 | } |
2177 | |
2174 | |
2178 | skill_attack (mon, op, 0, 0, 0); |
2175 | skill_attack (mon, op, 0, 0, 0); |
2179 | |
2176 | |
2180 | /* If attacking another player, that player gets automatic |
2177 | /* If attacking another player, that player gets automatic |
2181 | * hitback, and doesn't loose luck either. |
2178 | * hitback, and doesn't loose luck either. |
… | |
… | |
2567 | } |
2564 | } |
2568 | |
2565 | |
2569 | /* Digestion */ |
2566 | /* Digestion */ |
2570 | if (--op->last_eat < 0) |
2567 | if (--op->last_eat < 0) |
2571 | { |
2568 | { |
2572 | #ifdef COZY_SERVER |
|
|
2573 | int dg = op->contr->digestion >= 0 && op->contr->digestion < 2 ? 2 : op->contr->digestion; |
|
|
2574 | int bonus = dg > 0 ? dg : 0, penalty = dg < 0 ? -dg : 0; |
|
|
2575 | #else |
|
|
2576 | int bonus = op->contr->digestion > 0 ? op->contr->digestion : 0, penalty = op->contr->digestion < 0 ? -op->contr->digestion : 0; |
2569 | int bonus = op->contr->digestion > 0 ? op->contr->digestion : 0, penalty = op->contr->digestion < 0 ? -op->contr->digestion : 0; |
2577 | #endif |
|
|
2578 | |
2570 | |
2579 | if (op->contr->gen_hp > 0) |
2571 | if (op->contr->gen_hp > 0) |
2580 | op->last_eat = 25 * (1 + bonus) / (op->contr->gen_hp + penalty + 1); |
2572 | op->last_eat = 25 * (1 + bonus) / (op->contr->gen_hp + penalty + 1); |
2581 | else |
2573 | else |
2582 | op->last_eat = 25 * (1 + bonus) / (penalty + 1); |
2574 | op->last_eat = 25 * (1 + bonus) / (penalty + 1); |