ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/player.C
(Generate patch)

Comparing deliantra/server/server/player.C (file contents):
Revision 1.134 by root, Sun May 13 08:43:12 2007 UTC vs.
Revision 1.139 by root, Fri May 18 01:01:02 2007 UTC

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
152float
153player::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. */
153static void 159static void
154set_first_map (object *op) 160set_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
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.
1632 if (arrow->slaying) 1642 if (arrow->slaying)
1633 arrow->spellarg = strdup (arrow->slaying); 1643 arrow->spellarg = strdup (arrow->slaying);
1634 1644
1635 if (player *pl = op->contr) 1645 if (player *pl = op->contr)
1636 { 1646 {
1647 if (!pl->has_hit)
1637 { 1648 {
1638 pl->has_hit = 1; 1649 pl->has_hit = 1;
1639 pl->ob->speed_left += pl->weapon_sp - pl->ob->speed; 1650 pl->ob->speed_left += pl->weapon_speed () - pl->ob->speed;
1640 } 1651 }
1641#if 0 1652#if 0
1642 float speed = pl->weapon_sp; 1653 float speed = pl->weapon_sp;
1643 1654
1644 /* penalize ROF for bestarrow */ 1655 /* penalize ROF for bestarrow */
1645 if (pl->bowtype == bow_bestarrow) 1656 if (pl->bowtype == bow_bestarrow)
1749 } 1760 }
1750 1761
1751 return ret; 1762 return ret;
1752} 1763}
1753 1764
1754
1755/* Fires a misc (wand/rod/horn) object in 'dir'. 1765/* Fires a misc (wand/rod/horn) object in 'dir'.
1756 * Broken apart from 'fire' to keep it more readable. 1766 * Broken apart from 'fire' to keep it more readable.
1757 */ 1767 */
1758void 1768void
1759fire_misc_object (object *op, int dir) 1769fire_misc_object (object *op, int dir)
1847 object *ob = pl->ranged_ob; 1857 object *ob = pl->ranged_ob;
1848 1858
1849 if (!ob) 1859 if (!ob)
1850 return; 1860 return;
1851 1861
1862 if (!op->change_weapon (ob))
1863 return;
1864
1852 switch (ob->type) 1865 switch (ob->type)
1853 { 1866 {
1854 case BOW: 1867 case BOW:
1855 player_fire_bow (op, dir); 1868 player_fire_bow (op, dir);
1856 break; 1869 break;
1862 case BUILDER: 1875 case BUILDER:
1863 apply_map_builder (op, dir); 1876 apply_map_builder (op, dir);
1864 break; 1877 break;
1865 1878
1866 case SKILL: 1879 case SKILL:
1867 case SKILL_TOOL:
1868 do_skill (op, op, ob, dir, 0); 1880 do_skill (op, op, ob, dir, 0);
1869 break; 1881 break;
1870 1882
1871 default: 1883 default:
1872 fire_misc_object (op, dir); 1884 fire_misc_object (op, dir);
2100 2112
2101 /* 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
2102 * peaceful. Our assumption is the creature is a pet if the 2114 * peaceful. Our assumption is the creature is a pet if the
2103 * player owns it and it is either friendly or unagressive. 2115 * player owns it and it is either friendly or unagressive.
2104 */ 2116 */
2105 if ((op->type == PLAYER) 2117 if (op->type == PLAYER
2106#if COZY_SERVER
2107 &&
2108 ((mon->owner && mon->owner->contr 2118 && ((mon->owner && mon->owner->contr
2109 && same_party (mon->owner->contr->party, op->contr->party)) || mon->owner == op) 2119 && same_party (mon->owner->contr->party, op->contr->party))
2110#else
2111 && mon->owner == op 2120 || mon->owner == op)
2112#endif
2113 && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) 2121 && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)))
2114 { 2122 {
2115 /* 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 */
2116 if (op->contr->braced) 2124 if (op->contr->braced)
2117 return; 2125 return;
2127 /* in certain circumstances, you shouldn't attack friendly 2135 /* in certain circumstances, you shouldn't attack friendly
2128 * creatures. Note that if you are braced, you can't push 2136 * creatures. Note that if you are braced, you can't push
2129 * 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
2130 * attack them either. 2138 * attack them either.
2131 */ 2139 */
2132 if ((mon->type == PLAYER || mon->enemy != op) && 2140 if ((mon->type == PLAYER || mon->enemy != op)
2133 (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))
2134#ifdef PROHIBIT_PLAYERKILL
2135 (op->contr->peaceful 2142 && ((op->contr->peaceful
2136 || (mon->type == PLAYER 2143 || (mon->type == PLAYER && mon->contr->peaceful))
2137 && mon->contr->
2138 peaceful)) &&
2139#else
2140 op->contr->peaceful &&
2141#endif
2142 !on_battleground)) 2144 && !on_battleground))
2143 { 2145 {
2144 if (!op->contr->braced) 2146 if (!op->contr->braced)
2145 { 2147 {
2146 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);
2147 push_ob (mon, dir, op); 2149 push_ob (mon, dir, op);
2170 * 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.
2171 */ 2173 */
2172 else if ((mon->stats.hp >= 0) && QUERY_FLAG (mon, FLAG_ALIVE) && 2174 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))) 2175 ((mon->type != PLAYER || op->contr->party == NULL || op->contr->party != mon->contr->party)))
2174 { 2176 {
2177 if (!op->contr->has_hit)
2178 {
2175 op->contr->has_hit = 1; 2179 op->contr->has_hit = 1;
2176 op->speed_left += op->contr->weapon_sp - op->speed; 2180 op->speed_left += op->contr->weapon_speed () - op->speed;
2181 }
2177 2182
2178 skill_attack (mon, op, 0, 0, 0); 2183 skill_attack (mon, op, 0, 0, 0);
2179 2184
2180 /* If attacking another player, that player gets automatic 2185 /* If attacking another player, that player gets automatic
2181 * hitback, and doesn't loose luck either. 2186 * hitback, and doesn't loose luck either.
2567 } 2572 }
2568 2573
2569 /* Digestion */ 2574 /* Digestion */
2570 if (--op->last_eat < 0) 2575 if (--op->last_eat < 0)
2571 { 2576 {
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; 2577 int bonus = op->contr->digestion > 0 ? op->contr->digestion : 0, penalty = op->contr->digestion < 0 ? -op->contr->digestion : 0;
2577#endif
2578 2578
2579 if (op->contr->gen_hp > 0) 2579 if (op->contr->gen_hp > 0)
2580 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);
2581 else 2581 else
2582 op->last_eat = 25 * (1 + bonus) / (penalty + 1); 2582 op->last_eat = 25 * (1 + bonus) / (penalty + 1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines