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.133 by root, Sat May 12 22:04:20 2007 UTC vs.
Revision 1.140 by root, Fri May 18 13:15:29 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 {
277 case SKILL:
278 ob->flag [FLAG_APPLIED] = false;
279 break;
280
267 case WAND: 281 case WAND:
268 case ROD: 282 case ROD:
269 case HORN: 283 case HORN:
270 case BOW: 284 case BOW:
271 case SKILL: 285 ranged_ob = op;
272 case SKILL_TOOL: 286 break;
287
273 case WEAPON: 288 case WEAPON:
274 apply_special (ob, op, AP_UNAPPLY); 289 combat_ob = op;
275 apply_special (ob, op, AP_APPLY);
276 break; 290 break;
277 } 291 }
278 292
293 ob->change_weapon (combat_ob ? combat_ob : ranged_ob);
279 ob->update_stats (); 294 ob->update_stats ();
295
280 ns->floorbox_update (); 296 ns->floorbox_update ();
281
282 esrv_send_inventory (ob, ob); 297 esrv_send_inventory (ob, ob);
283 esrv_add_spells (this, 0); 298 esrv_add_spells (this, 0);
284 299
285 activate (); 300 activate ();
286 301
1544 { 1559 {
1545 new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); 1560 new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!");
1546 return 0; 1561 return 0;
1547 } 1562 }
1548 1563
1549 if (player *pl = op->contr) 1564 if (op->contr)
1550 { 1565 bow = op->current_weapon;
1551 bow = pl->ranged_ob;
1552 if (!op->change_weapon (bow))
1553 return 0;
1554 }
1555 else 1566 else
1556 { 1567 {
1557 for (bow = op->inv; bow; bow = bow->below) 1568 for (bow = op->inv; bow; bow = bow->below)
1558 /* Don't check for applied - monsters don't apply bows - in that way, they 1569 /* 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. 1570 * don't need to switch back and forth between bows and weapons.
1632 if (arrow->slaying) 1643 if (arrow->slaying)
1633 arrow->spellarg = strdup (arrow->slaying); 1644 arrow->spellarg = strdup (arrow->slaying);
1634 1645
1635 if (player *pl = op->contr) 1646 if (player *pl = op->contr)
1636 { 1647 {
1648 if (!pl->has_hit)
1649 {
1637 pl->has_hit = 1; 1650 pl->has_hit = 1;
1651 pl->ob->speed_left += pl->weapon_speed () - pl->ob->speed;
1652 }
1638#if 0 1653#if 0
1639 float speed = pl->weapon_sp; 1654 float speed = pl->weapon_sp;
1640 1655
1641 /* penalize ROF for bestarrow */ 1656 /* penalize ROF for bestarrow */
1642 if (pl->bowtype == bow_bestarrow) 1657 if (pl->bowtype == bow_bestarrow)
1746 } 1761 }
1747 1762
1748 return ret; 1763 return ret;
1749} 1764}
1750 1765
1751
1752/* Fires a misc (wand/rod/horn) object in 'dir'. 1766/* Fires a misc (wand/rod/horn) object in 'dir'.
1753 * Broken apart from 'fire' to keep it more readable. 1767 * Broken apart from 'fire' to keep it more readable.
1754 */ 1768 */
1755void 1769void
1756fire_misc_object (object *op, int dir) 1770fire_misc_object (object *op, int dir)
1844 object *ob = pl->ranged_ob; 1858 object *ob = pl->ranged_ob;
1845 1859
1846 if (!ob) 1860 if (!ob)
1847 return; 1861 return;
1848 1862
1863 if (!op->change_weapon (ob))
1864 return;
1865
1849 switch (ob->type) 1866 switch (ob->type)
1850 { 1867 {
1851 case BOW: 1868 case BOW:
1852 player_fire_bow (op, dir); 1869 player_fire_bow (op, dir);
1853 break; 1870 break;
1859 case BUILDER: 1876 case BUILDER:
1860 apply_map_builder (op, dir); 1877 apply_map_builder (op, dir);
1861 break; 1878 break;
1862 1879
1863 case SKILL: 1880 case SKILL:
1864 case SKILL_TOOL:
1865 do_skill (op, op, ob, dir, 0); 1881 do_skill (op, op, ob, dir, 0);
1866 break; 1882 break;
1867 1883
1868 default: 1884 default:
1869 fire_misc_object (op, dir); 1885 fire_misc_object (op, dir);
2097 2113
2098 /* If the creature is a pet, push it even if the player is not 2114 /* 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 2115 * peaceful. Our assumption is the creature is a pet if the
2100 * player owns it and it is either friendly or unagressive. 2116 * player owns it and it is either friendly or unagressive.
2101 */ 2117 */
2102 if ((op->type == PLAYER) 2118 if (op->type == PLAYER
2103#if COZY_SERVER
2104 &&
2105 ((mon->owner && mon->owner->contr 2119 && ((mon->owner && mon->owner->contr
2106 && same_party (mon->owner->contr->party, op->contr->party)) || mon->owner == op) 2120 && same_party (mon->owner->contr->party, op->contr->party))
2107#else
2108 && mon->owner == op 2121 || mon->owner == op)
2109#endif
2110 && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) 2122 && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)))
2111 { 2123 {
2112 /* If we're braced, we don't want to switch places with it */ 2124 /* If we're braced, we don't want to switch places with it */
2113 if (op->contr->braced) 2125 if (op->contr->braced)
2114 return; 2126 return;
2124 /* in certain circumstances, you shouldn't attack friendly 2136 /* in certain circumstances, you shouldn't attack friendly
2125 * creatures. Note that if you are braced, you can't push 2137 * creatures. Note that if you are braced, you can't push
2126 * someone, but put it inside this loop so that you won't 2138 * someone, but put it inside this loop so that you won't
2127 * attack them either. 2139 * attack them either.
2128 */ 2140 */
2129 if ((mon->type == PLAYER || mon->enemy != op) && 2141 if ((mon->type == PLAYER || mon->enemy != op)
2130 (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) && ( 2142 && (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))
2131#ifdef PROHIBIT_PLAYERKILL
2132 (op->contr->peaceful 2143 && ((op->contr->peaceful
2133 || (mon->type == PLAYER 2144 || (mon->type == PLAYER && mon->contr->peaceful))
2134 && mon->contr->
2135 peaceful)) &&
2136#else
2137 op->contr->peaceful &&
2138#endif
2139 !on_battleground)) 2145 && !on_battleground))
2140 { 2146 {
2141 if (!op->contr->braced) 2147 if (!op->contr->braced)
2142 { 2148 {
2143 play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER); 2149 play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER);
2144 push_ob (mon, dir, op); 2150 push_ob (mon, dir, op);
2167 * that party_number -1 is no party, so attacks can still happen. 2173 * that party_number -1 is no party, so attacks can still happen.
2168 */ 2174 */
2169 else if ((mon->stats.hp >= 0) && QUERY_FLAG (mon, FLAG_ALIVE) && 2175 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))) 2176 ((mon->type != PLAYER || op->contr->party == NULL || op->contr->party != mon->contr->party)))
2171 { 2177 {
2178 if (!op->contr->has_hit)
2179 {
2172 op->contr->has_hit = 1; 2180 op->contr->has_hit = 1;
2181 op->speed_left += op->contr->weapon_speed () - op->speed;
2182 }
2173 2183
2174 skill_attack (mon, op, 0, 0, 0); 2184 skill_attack (mon, op, 0, 0, 0);
2175 2185
2176 /* If attacking another player, that player gets automatic 2186 /* If attacking another player, that player gets automatic
2177 * hitback, and doesn't loose luck either. 2187 * hitback, and doesn't loose luck either.
2563 } 2573 }
2564 2574
2565 /* Digestion */ 2575 /* Digestion */
2566 if (--op->last_eat < 0) 2576 if (--op->last_eat < 0)
2567 { 2577 {
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; 2578 int bonus = op->contr->digestion > 0 ? op->contr->digestion : 0, penalty = op->contr->digestion < 0 ? -op->contr->digestion : 0;
2573#endif
2574 2579
2575 if (op->contr->gen_hp > 0) 2580 if (op->contr->gen_hp > 0)
2576 op->last_eat = 25 * (1 + bonus) / (op->contr->gen_hp + penalty + 1); 2581 op->last_eat = 25 * (1 + bonus) / (op->contr->gen_hp + penalty + 1);
2577 else 2582 else
2578 op->last_eat = 25 * (1 + bonus) / (penalty + 1); 2583 op->last_eat = 25 * (1 + bonus) / (penalty + 1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines