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.127 by root, Sat May 12 18:14:48 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{
784} 784}
785 785
786void 786void
787object::roll_stats () 787object::roll_stats ()
788{ 788{
789 int statsort [7]; 789 int statsort [NUM_STATS];
790 790
791 for (;;) 791 for (;;)
792 { 792 {
793 int sum = 0; 793 int sum = 0;
794 for (int i = 7; i--; ) 794 for (int i = NUM_STATS; i--; )
795 sum += statsort [i] = roll_stat (); 795 sum += statsort [i] = roll_stat ();
796 796
797 if (sum >= 82 && sum <= 116) 797 if (sum >= 82 && sum <= 116)
798 break; 798 break;
799 } 799 }
800 800
801 // Sort the stats so that rerolling is easier... 801 // Sort the stats so that rerolling is easier...
802 std::sort (statsort, statsort + 7, std::greater<int>()); 802 std::sort (statsort, statsort + NUM_STATS, std::greater<int>());
803 803
804 for (int i = 0; i < NUM_STATS; ++i)
804 stats.Str = statsort[0]; 805 stats.stat (i) = statsort [i];
805 stats.Dex = statsort[1];
806 stats.Con = statsort[2];
807 stats.Int = statsort[3];
808 stats.Wis = statsort[4];
809 stats.Pow = statsort[5];
810 stats.Cha = statsort[6];
811 806
812 stats.exp = 0; 807 stats.exp = 0;
813 stats.ac = 0; 808 stats.ac = 0;
814 809
815 stats.hp = stats.maxhp; 810 stats.hp = stats.maxhp;
1540 */ 1535 */
1541int 1536int
1542fire_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)
1543{ 1538{
1544 object *left, *bow; 1539 object *left, *bow;
1545 int bowspeed, mflags; 1540 int mflags;
1546 maptile *m; 1541 maptile *m;
1547 1542
1548 if (!dir) 1543 if (!dir)
1549 { 1544 {
1550 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!");
1585 { 1580 {
1586 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);
1587 return 0; 1582 return 0;
1588 } 1583 }
1589 1584
1590 bowspeed = bow->stats.sp + dex_bonus[op->stats.Dex];
1591
1592 /* penalize ROF for bestarrow */
1593 if (op->type == PLAYER && op->contr->bowtype == bow_bestarrow)
1594 bowspeed -= dex_bonus[op->stats.Dex] + 5;
1595
1596 if (bowspeed < 1)
1597 bowspeed = 1;
1598
1599 if (arrow == NULL) 1585 if (arrow == NULL)
1600 { 1586 {
1601 if ((arrow = find_arrow (op, bow->race)) == NULL) 1587 if ((arrow = find_arrow (op, bow->race)) == NULL)
1602 { 1588 {
1603 if (op->type == PLAYER) 1589 if (op->type == PLAYER)
1644 arrow->stats.grace = arrow->attacktype; 1630 arrow->stats.grace = arrow->attacktype;
1645 1631
1646 if (arrow->slaying) 1632 if (arrow->slaying)
1647 arrow->spellarg = strdup (arrow->slaying); 1633 arrow->spellarg = strdup (arrow->slaying);
1648 1634
1649 if (op->type == PLAYER) 1635 if (player *pl = op->contr)
1650 { 1636 {
1651 op->speed_left = 0.01 - (float) FABS (op->speed) * 100 / bowspeed; 1637 pl->has_hit = 1;
1652 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
1653 } 1649 }
1654 1650
1655 SET_ANIMATION (arrow, arrow->direction); 1651 SET_ANIMATION (arrow, arrow->direction);
1656
1657 arrow->stats.dam += op->stats.dam + arrow->magic;
1658 1652
1659 /* update the speed */ 1653 /* update the speed */
1660 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
1661 + bow->stats.dam / 7.0; 1655 + bow->stats.dam / 7.0;
1662 1656
1663 arrow->set_speed (max (arrow->speed, 2.0)); 1657 arrow->set_speed (max (arrow->speed, 2.0));
1664 arrow->speed_left = 0; 1658 arrow->speed_left = 0;
1665 1659
1666 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;
1667 1661
1668 if (op->type == PLAYER) 1662 if (op->type == PLAYER)
1669 { 1663 {
1670 arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; 1664 arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level;
1671 arrow->stats.wc -= dex_bonus[op->stats.Dex]; 1665 wc -= dex_bonus[op->stats.Dex];
1672 1666
1673 if (!arrow->slaying) 1667 if (!arrow->slaying)
1674 arrow->slaying = op->slaying; 1668 arrow->slaying = op->slaying;
1675 1669
1676 arrow->attacktype |= op->attacktype; 1670 arrow->attacktype |= op->attacktype;
1684 arrow->slaying = bow->slaying; 1678 arrow->slaying = bow->slaying;
1685 1679
1686 arrow->attacktype |= bow->attacktype; 1680 arrow->attacktype |= bow->attacktype;
1687 } 1681 }
1688 1682
1689 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);
1690 1685
1686 arrow->stats.wc = clamp (wc, MIN_WC, MAX_WC);
1691 arrow->move_type = MOVE_FLY_LOW; 1687 arrow->move_type = MOVE_FLY_LOW;
1692 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; 1688 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK;
1693 1689
1694 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);
1695 m->insert (arrow, sx, sy, op); 1691 m->insert (arrow, sx, sy, op);
2171 * 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.
2172 */ 2168 */
2173 else if ((mon->stats.hp >= 0) && QUERY_FLAG (mon, FLAG_ALIVE) && 2169 else if ((mon->stats.hp >= 0) && QUERY_FLAG (mon, FLAG_ALIVE) &&
2174 ((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)))
2175 { 2171 {
2176
2177 /* If the player hasn't hit something this tick, and does
2178 * so, give them speed boost based on weapon speed. Doing
2179 * it here is better than process_players2, which basically
2180 * incurred a 1 tick offset.
2181 */
2182 if (!op->contr->has_hit) 2172 op->contr->has_hit = 1;
2183 {
2184 op->speed_left += op->speed / op->contr->weapon_sp;
2185
2186 op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */
2187 }
2188 2173
2189 skill_attack (mon, op, 0, 0, 0); 2174 skill_attack (mon, op, 0, 0, 0);
2190 2175
2191 /* If attacking another player, that player gets automatic 2176 /* If attacking another player, that player gets automatic
2192 * hitback, and doesn't loose luck either. 2177 * hitback, and doesn't loose luck either.
2269handle_newcs_player (object *op) 2254handle_newcs_player (object *op)
2270{ 2255{
2271 if (QUERY_FLAG (op, FLAG_SCARED)) 2256 if (QUERY_FLAG (op, FLAG_SCARED))
2272 { 2257 {
2273 flee_player (op); 2258 flee_player (op);
2259
2274 /* 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 */
2275 if (QUERY_FLAG (op, FLAG_SCARED)) 2261 if (op->flag [FLAG_SCARED])
2276 { 2262 {
2277 op->speed_left--; 2263 --op->speed_left;
2278 return 0; 2264 return 0;
2279 } 2265 }
2280 } 2266 }
2281 2267
2282 /* 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
2284 * called, so we recheck it here. 2270 * called, so we recheck it here.
2285 */ 2271 */
2286 if (op->contr->ns->handle_command ()) 2272 if (op->contr->ns->handle_command ())
2287 return 1; 2273 return 1;
2288 2274
2289 if (op->speed_left > 0) 2275 if (op->speed_left > 0.f)
2290 { 2276 {
2291 if (op->direction && (op->contr->run_on || op->contr->fire_on)) 2277 if (op->direction && (op->contr->run_on || op->contr->fire_on))
2292 { 2278 {
2293 /* All move commands take 1 tick, at least for now */ 2279 /* All move commands take 1 tick, at least for now */
2294 op->speed_left--; 2280 --op->speed_left;
2295 2281
2296 /* Instead of all the stuff below, let move_player take care 2282 /* Instead of all the stuff below, let move_player take care
2297 * 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
2298 * there, as well as the confusion stuff. 2284 * there, as well as the confusion stuff.
2299 */ 2285 */
2300 move_player (op, op->direction); 2286 move_player (op, op->direction);
2301 2287
2302 return op->speed_left > 0; 2288 return op->speed_left > 0.f;
2303 } 2289 }
2304 } 2290 }
2305 2291
2306 return 0; 2292 return 0;
2307} 2293}
2937 object *force; 2923 object *force;
2938 int at; 2924 int at;
2939 2925
2940 force = get_archetype (FORCE_NAME); 2926 force = get_archetype (FORCE_NAME);
2941 /* 50 ticks should be enough time for the spell to abate */ 2927 /* 50 ticks should be enough time for the spell to abate */
2942 force->speed = 0.1; 2928 force->speed = 0.1f;
2943 force->speed_left = -5.0; 2929 force->speed_left = -5.f;
2944 SET_FLAG (force, FLAG_APPLIED); 2930 SET_FLAG (force, FLAG_APPLIED);
2945 for (at = 0; at < NROFATTACKS; at++) 2931 for (at = 0; at < NROFATTACKS; at++)
2946 if (will_kill_again & (1 << at)) 2932 if (will_kill_again & (1 << at))
2947 force->resist[at] = 100; 2933 force->resist[at] = 100;
2948 2934

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines