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.128 by root, Sat May 12 18:40:40 2007 UTC vs.
Revision 1.133 by root, Sat May 12 22:04:20 2007 UTC

319player::set_object (object *op) 319player::set_object (object *op)
320{ 320{
321 ob = op; 321 ob = op;
322 ob->contr = this; /* this aren't yet in archetype */ 322 ob->contr = this; /* this aren't yet in archetype */
323 323
324 ob->speed_left = 0.5; 324 ob->speed_left = 0.5f;
325 ob->speed = 1.0; 325 ob->speed = 1.0f;
326 ob->direction = 5; /* So player faces south */ 326 ob->direction = 5; /* So player faces south */
327} 327}
328 328
329player::player () 329player::player ()
330{ 330{
1535 */ 1535 */
1536int 1536int
1537fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) 1537fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy)
1538{ 1538{
1539 object *left, *bow; 1539 object *left, *bow;
1540 int bowspeed, mflags; 1540 int mflags;
1541 maptile *m; 1541 maptile *m;
1542 1542
1543 if (!dir) 1543 if (!dir)
1544 { 1544 {
1545 new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); 1545 new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!");
1580 { 1580 {
1581 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); 1581 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name);
1582 return 0; 1582 return 0;
1583 } 1583 }
1584 1584
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) 1585 if (arrow == NULL)
1595 { 1586 {
1596 if ((arrow = find_arrow (op, bow->race)) == NULL) 1587 if ((arrow = find_arrow (op, bow->race)) == NULL)
1597 { 1588 {
1598 if (op->type == PLAYER) 1589 if (op->type == PLAYER)
1639 arrow->stats.grace = arrow->attacktype; 1630 arrow->stats.grace = arrow->attacktype;
1640 1631
1641 if (arrow->slaying) 1632 if (arrow->slaying)
1642 arrow->spellarg = strdup (arrow->slaying); 1633 arrow->spellarg = strdup (arrow->slaying);
1643 1634
1644 if (op->type == PLAYER) 1635 if (player *pl = op->contr)
1645 { 1636 {
1646 op->speed_left = 0.01 - (float) FABS (op->speed) * 100 / bowspeed; 1637 pl->has_hit = 1;
1647 op->update_stats (); 1638#if 0
1639 float speed = pl->weapon_sp;
1640
1641 /* penalize ROF for bestarrow */
1642 if (pl->bowtype == bow_bestarrow)
1643 speed *= .9f;
1644 else
1645 speed *= 1.f + dex_bonus[op->stats.Dex] * .2f;
1646
1647 op->speed_left += speed - op->speed;
1648#endif
1648 } 1649 }
1649 1650
1650 SET_ANIMATION (arrow, arrow->direction); 1651 SET_ANIMATION (arrow, arrow->direction);
1651
1652 arrow->stats.dam += op->stats.dam + arrow->magic;
1653 1652
1654 /* update the speed */ 1653 /* update the speed */
1655 arrow->speed = ((bow->flag [FLAG_NO_STRENGTH] ? 0 : dam_bonus[op->stats.Str]) + bow->magic + arrow->magic) / 5.0 1654 arrow->speed = ((bow->flag [FLAG_NO_STRENGTH] ? 0 : dam_bonus[op->stats.Str]) + bow->magic + arrow->magic) / 5.0
1656 + bow->stats.dam / 7.0; 1655 + bow->stats.dam / 7.0;
1657 1656
1658 arrow->set_speed (max (arrow->speed, 2.0)); 1657 arrow->set_speed (max (arrow->speed, 2.0));
1659 arrow->speed_left = 0; 1658 arrow->speed_left = 0;
1660 1659
1661 arrow->stats.wc = op->stats.wc + wc_mod - arrow->magic - arrow->stats.wc; 1660 int wc = op->stats.wc + wc_mod - arrow->magic - arrow->stats.wc;
1662 1661
1663 if (op->type == PLAYER) 1662 if (op->type == PLAYER)
1664 { 1663 {
1665 arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; 1664 arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level;
1666 arrow->stats.wc -= dex_bonus[op->stats.Dex]; 1665 wc -= dex_bonus[op->stats.Dex];
1667 1666
1668 if (!arrow->slaying) 1667 if (!arrow->slaying)
1669 arrow->slaying = op->slaying; 1668 arrow->slaying = op->slaying;
1670 1669
1671 arrow->attacktype |= op->attacktype; 1670 arrow->attacktype |= op->attacktype;
1679 arrow->slaying = bow->slaying; 1678 arrow->slaying = bow->slaying;
1680 1679
1681 arrow->attacktype |= bow->attacktype; 1680 arrow->attacktype |= bow->attacktype;
1682 } 1681 }
1683 1682
1684 arrow->stats.wc -= arrow->level; 1683 wc -= arrow->level;
1684 arrow->stats.dam = clamp (arrow->stats.dam + op->stats.dam + arrow->magic, MIN_DAM, MAX_DAM);
1685 1685
1686 arrow->stats.wc = clamp (wc, MIN_WC, MAX_WC);
1686 arrow->move_type = MOVE_FLY_LOW; 1687 arrow->move_type = MOVE_FLY_LOW;
1687 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; 1688 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK;
1688 1689
1689 play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); 1690 play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW);
1690 m->insert (arrow, sx, sy, op); 1691 m->insert (arrow, sx, sy, op);
2166 * 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.
2167 */ 2168 */
2168 else if ((mon->stats.hp >= 0) && QUERY_FLAG (mon, FLAG_ALIVE) && 2169 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))) 2170 ((mon->type != PLAYER || op->contr->party == NULL || op->contr->party != mon->contr->party)))
2170 { 2171 {
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) 2172 op->contr->has_hit = 1;
2178 {
2179 op->speed_left += op->speed / op->contr->weapon_sp;
2180
2181 op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */
2182 }
2183 2173
2184 skill_attack (mon, op, 0, 0, 0); 2174 skill_attack (mon, op, 0, 0, 0);
2185 2175
2186 /* If attacking another player, that player gets automatic 2176 /* If attacking another player, that player gets automatic
2187 * hitback, and doesn't loose luck either. 2177 * hitback, and doesn't loose luck either.
2264handle_newcs_player (object *op) 2254handle_newcs_player (object *op)
2265{ 2255{
2266 if (QUERY_FLAG (op, FLAG_SCARED)) 2256 if (QUERY_FLAG (op, FLAG_SCARED))
2267 { 2257 {
2268 flee_player (op); 2258 flee_player (op);
2259
2269 /* If player is still scared, that is his action for this tick */ 2260 /* If player is still scared, that is his action for this tick */
2270 if (QUERY_FLAG (op, FLAG_SCARED)) 2261 if (op->flag [FLAG_SCARED])
2271 { 2262 {
2272 op->speed_left--; 2263 --op->speed_left;
2273 return 0; 2264 return 0;
2274 } 2265 }
2275 } 2266 }
2276 2267
2277 /* call this here - we also will call this in do_ericserver, but 2268 /* call this here - we also will call this in do_ericserver, but
2279 * called, so we recheck it here. 2270 * called, so we recheck it here.
2280 */ 2271 */
2281 if (op->contr->ns->handle_command ()) 2272 if (op->contr->ns->handle_command ())
2282 return 1; 2273 return 1;
2283 2274
2284 if (op->speed_left > 0) 2275 if (op->speed_left > 0.f)
2285 { 2276 {
2286 if (op->direction && (op->contr->run_on || op->contr->fire_on)) 2277 if (op->direction && (op->contr->run_on || op->contr->fire_on))
2287 { 2278 {
2288 /* All move commands take 1 tick, at least for now */ 2279 /* All move commands take 1 tick, at least for now */
2289 op->speed_left--; 2280 --op->speed_left;
2290 2281
2291 /* Instead of all the stuff below, let move_player take care 2282 /* Instead of all the stuff below, let move_player take care
2292 * of it. Also, some of the skill stuff is only put in 2283 * of it. Also, some of the skill stuff is only put in
2293 * there, as well as the confusion stuff. 2284 * there, as well as the confusion stuff.
2294 */ 2285 */
2295 move_player (op, op->direction); 2286 move_player (op, op->direction);
2296 2287
2297 return op->speed_left > 0; 2288 return op->speed_left > 0.f;
2298 } 2289 }
2299 } 2290 }
2300 2291
2301 return 0; 2292 return 0;
2302} 2293}
2932 object *force; 2923 object *force;
2933 int at; 2924 int at;
2934 2925
2935 force = get_archetype (FORCE_NAME); 2926 force = get_archetype (FORCE_NAME);
2936 /* 50 ticks should be enough time for the spell to abate */ 2927 /* 50 ticks should be enough time for the spell to abate */
2937 force->speed = 0.1; 2928 force->speed = 0.1f;
2938 force->speed_left = -5.0; 2929 force->speed_left = -5.f;
2939 SET_FLAG (force, FLAG_APPLIED); 2930 SET_FLAG (force, FLAG_APPLIED);
2940 for (at = 0; at < NROFATTACKS; at++) 2931 for (at = 0; at < NROFATTACKS; at++)
2941 if (will_kill_again & (1 << at)) 2932 if (will_kill_again & (1 << at))
2942 force->resist[at] = 100; 2933 force->resist[at] = 100;
2943 2934

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines