… | |
… | |
166 | op->x = -1; |
166 | op->x = -1; |
167 | op->y = -1; |
167 | op->y = -1; |
168 | enter_exit (op, 0); |
168 | enter_exit (op, 0); |
169 | } |
169 | } |
170 | |
170 | |
|
|
171 | // connect the player with a specific client |
|
|
172 | // also changed, rationalises, and fixes some incorrect settings |
171 | void |
173 | void |
172 | player::connect (client *ns) |
174 | player::connect (client *ns) |
173 | { |
175 | { |
174 | this->ns = ns; |
176 | this->ns = ns; |
175 | ns->pl = this; |
177 | ns->pl = this; |
… | |
… | |
182 | |
184 | |
183 | clear_los (ob); |
185 | clear_los (ob); |
184 | |
186 | |
185 | ob->type = PLAYER; // we are paranoid |
187 | ob->type = PLAYER; // we are paranoid |
186 | ob->race = ob->arch->clone.race; |
188 | ob->race = ob->arch->clone.race; |
|
|
189 | |
|
|
190 | if (!legal_range (ob, shoottype)) |
|
|
191 | shoottype = range_none; |
|
|
192 | |
|
|
193 | ob->carrying = sum_weight (ob); |
|
|
194 | link_player_skills (ob); |
187 | |
195 | |
188 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
196 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
189 | ob->update_stats (); |
197 | ob->update_stats (); |
190 | update_ob_speed (ob); |
198 | update_ob_speed (ob); |
191 | |
|
|
192 | ob->carrying = sum_weight (ob); |
|
|
193 | link_player_skills (ob); |
|
|
194 | |
|
|
195 | if (!legal_range (ob, shoottype)) |
|
|
196 | shoottype = range_none; |
|
|
197 | |
199 | |
198 | assign (title, ob->arch->clone.name); |
200 | assign (title, ob->arch->clone.name); |
199 | |
201 | |
200 | /* can_use_shield is a new flag. However, the can_use.. seems to largely come |
202 | /* can_use_shield is a new flag. However, the can_use.. seems to largely come |
201 | * from the class, and not race. I don't see any way to get the class information |
203 | * from the class, and not race. I don't see any way to get the class information |
… | |
… | |
2443 | |
2445 | |
2444 | op = next; |
2446 | op = next; |
2445 | } |
2447 | } |
2446 | } |
2448 | } |
2447 | |
2449 | |
2448 | |
|
|
2449 | /* |
2450 | /* |
2450 | * Returns pointer a static string containing gravestone text |
2451 | * Returns pointer a static string containing gravestone text |
2451 | * Moved from apply.c to player.c - player.c is what |
2452 | * Moved from apply.c to player.c - player.c is what |
2452 | * actually uses this function. player.c may not be quite the |
2453 | * actually uses this function. player.c may not be quite the |
2453 | * best, a misc file for object actions is probably better, |
2454 | * best, a misc file for object actions is probably better, |
… | |
… | |
2486 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2487 | strncat (buf2, " ", 20 - strlen (buf) / 2); |
2487 | strcat (buf2, buf); |
2488 | strcat (buf2, buf); |
2488 | |
2489 | |
2489 | return buf2; |
2490 | return buf2; |
2490 | } |
2491 | } |
2491 | |
|
|
2492 | |
|
|
2493 | |
2492 | |
2494 | void |
2493 | void |
2495 | do_some_living (object *op) |
2494 | do_some_living (object *op) |
2496 | { |
2495 | { |
2497 | int last_food = op->stats.food; |
2496 | int last_food = op->stats.food; |
… | |
… | |
2506 | const int max_grace = 1; |
2505 | const int max_grace = 1; |
2507 | |
2506 | |
2508 | if (op->contr->outputs_sync) |
2507 | if (op->contr->outputs_sync) |
2509 | { |
2508 | { |
2510 | for (i = 0; i < NUM_OUTPUT_BUFS; i++) |
2509 | for (i = 0; i < NUM_OUTPUT_BUFS; i++) |
2511 | if (op->contr->outputs[i].buf != NULL && (op->contr->outputs[i].first_update + op->contr->outputs_sync) < (uint16) pticks) |
2510 | if (op->contr->outputs[i].buf && (op->contr->outputs[i].first_update + op->contr->outputs_sync) < (uint16) pticks) |
2512 | flush_output_element (op, &op->contr->outputs[i]); |
2511 | flush_output_element (op, &op->contr->outputs[i]); |
2513 | } |
2512 | } |
2514 | |
2513 | |
2515 | if (op->contr->ns->state == ST_PLAYING) |
2514 | if (op->contr->ns->state == ST_PLAYING) |
2516 | { |
2515 | { |
2517 | |
|
|
2518 | /* these next three if clauses make it possible to SLOW DOWN |
2516 | /* these next three if clauses make it possible to SLOW DOWN |
2519 | hp/grace/spellpoint regeneration. */ |
2517 | hp/grace/spellpoint regeneration. */ |
2520 | if (op->contr->gen_hp >= 0) |
2518 | if (op->contr->gen_hp >= 0) |
2521 | gen_hp = (op->contr->gen_hp + 1) * op->stats.maxhp; |
2519 | gen_hp = (op->contr->gen_hp + 1) * op->stats.maxhp; |
2522 | else |
2520 | else |
2523 | { |
2521 | { |
2524 | gen_hp = op->stats.maxhp; |
2522 | gen_hp = op->stats.maxhp; |
2525 | rate_hp -= rate_hp / 2 * op->contr->gen_hp; |
2523 | rate_hp -= rate_hp / 2 * op->contr->gen_hp; |
2526 | } |
2524 | } |
|
|
2525 | |
2527 | if (op->contr->gen_sp >= 0) |
2526 | if (op->contr->gen_sp >= 0) |
2528 | gen_sp = (op->contr->gen_sp + 1) * op->stats.maxsp; |
2527 | gen_sp = (op->contr->gen_sp + 1) * op->stats.maxsp; |
2529 | else |
2528 | else |
2530 | { |
2529 | { |
2531 | gen_sp = op->stats.maxsp; |
2530 | gen_sp = op->stats.maxsp; |
2532 | rate_sp -= rate_sp / 2 * op->contr->gen_sp; |
2531 | rate_sp -= rate_sp / 2 * op->contr->gen_sp; |
2533 | } |
2532 | } |
|
|
2533 | |
2534 | if (op->contr->gen_grace >= 0) |
2534 | if (op->contr->gen_grace >= 0) |
2535 | gen_grace = (op->contr->gen_grace + 1) * op->stats.maxgrace; |
2535 | gen_grace = (op->contr->gen_grace + 1) * op->stats.maxgrace; |
2536 | else |
2536 | else |
2537 | { |
2537 | { |
2538 | gen_grace = op->stats.maxgrace; |
2538 | gen_grace = op->stats.maxgrace; |
… | |
… | |
2554 | op->stats.food += op->contr->digestion; |
2554 | op->stats.food += op->contr->digestion; |
2555 | else if (op->contr->digestion > 0 && random_roll (0, op->contr->digestion, op, PREFER_HIGH)) |
2555 | else if (op->contr->digestion > 0 && random_roll (0, op->contr->digestion, op, PREFER_HIGH)) |
2556 | op->stats.food = last_food; |
2556 | op->stats.food = last_food; |
2557 | } |
2557 | } |
2558 | } |
2558 | } |
|
|
2559 | |
2559 | if (max_sp > 1) |
2560 | if (max_sp > 1) |
2560 | { |
2561 | { |
2561 | over_sp = (gen_sp + 10) / rate_sp; |
2562 | over_sp = (gen_sp + 10) / rate_sp; |
2562 | if (over_sp > 0) |
2563 | if (over_sp > 0) |
2563 | { |
2564 | { |
2564 | if (op->stats.sp < op->stats.maxsp) |
2565 | if (op->stats.sp < op->stats.maxsp) |
2565 | { |
2566 | { |
2566 | op->stats.sp += over_sp > max_sp ? max_sp : over_sp; |
2567 | op->stats.sp += over_sp > max_sp ? max_sp : over_sp; |
|
|
2568 | |
2567 | if (random_roll (0, rate_sp - 1, op, PREFER_LOW) > ((gen_sp + 10) % rate_sp)) |
2569 | if (random_roll (0, rate_sp - 1, op, PREFER_LOW) > ((gen_sp + 10) % rate_sp)) |
2568 | op->stats.sp--; |
2570 | op->stats.sp--; |
|
|
2571 | |
2569 | if (op->stats.sp > op->stats.maxsp) |
2572 | if (op->stats.sp > op->stats.maxsp) |
2570 | op->stats.sp = op->stats.maxsp; |
2573 | op->stats.sp = op->stats.maxsp; |
2571 | } |
2574 | } |
2572 | op->last_sp = 0; |
2575 | op->last_sp = 0; |
2573 | } |
2576 | } |
2574 | else |
2577 | else |
2575 | { |
|
|
2576 | op->last_sp = rate_sp / (gen_sp < 20 ? 30 : gen_sp + 10); |
2578 | op->last_sp = rate_sp / (gen_sp < 20 ? 30 : gen_sp + 10); |
2577 | } |
|
|
2578 | } |
2579 | } |
2579 | else |
2580 | else |
2580 | { |
|
|
2581 | op->last_sp = rate_sp / (gen_sp < 20 ? 30 : gen_sp + 10); |
2581 | op->last_sp = rate_sp / (gen_sp < 20 ? 30 : gen_sp + 10); |
2582 | } |
|
|
2583 | } |
2582 | } |
2584 | |
2583 | |
2585 | /* Regenerate Grace */ |
2584 | /* Regenerate Grace */ |
2586 | /* I altered this a little - maximum grace is ony achieved through prayer -b.t. */ |
2585 | /* I altered this a little - maximum grace is ony achieved through prayer -b.t. */ |
2587 | if (--op->last_grace < 0) |
2586 | if (--op->last_grace < 0) |
2588 | { |
2587 | { |
2589 | if (op->stats.grace < op->stats.maxgrace / 2) |
2588 | if (op->stats.grace < op->stats.maxgrace / 2) |
2590 | op->stats.grace++; /* no penalty in food for regaining grace */ |
2589 | op->stats.grace++; /* no penalty in food for regaining grace */ |
|
|
2590 | |
2591 | if (max_grace > 1) |
2591 | if (max_grace > 1) |
2592 | { |
2592 | { |
2593 | over_grace = (gen_grace < 20 ? 30 : gen_grace + 10) / rate_grace; |
2593 | over_grace = (gen_grace < 20 ? 30 : gen_grace + 10) / rate_grace; |
2594 | if (over_grace > 0) |
2594 | if (over_grace > 0) |
2595 | { |
2595 | { |
… | |
… | |
2623 | op->stats.food += op->contr->digestion; |
2623 | op->stats.food += op->contr->digestion; |
2624 | else if (op->contr->digestion > 0 && random_roll (0, op->contr->digestion, op, PREFER_HIGH)) |
2624 | else if (op->contr->digestion > 0 && random_roll (0, op->contr->digestion, op, PREFER_HIGH)) |
2625 | op->stats.food = last_food; |
2625 | op->stats.food = last_food; |
2626 | } |
2626 | } |
2627 | } |
2627 | } |
|
|
2628 | |
2628 | if (max_hp > 1) |
2629 | if (max_hp > 1) |
2629 | { |
2630 | { |
2630 | over_hp = (gen_hp < 20 ? 30 : gen_hp + 10) / rate_hp; |
2631 | over_hp = (gen_hp < 20 ? 30 : gen_hp + 10) / rate_hp; |
2631 | if (over_hp > 0) |
2632 | if (over_hp > 0) |
2632 | { |
2633 | { |
… | |
… | |
2656 | |
2657 | |
2657 | if (op->contr->gen_hp > 0) |
2658 | if (op->contr->gen_hp > 0) |
2658 | op->last_eat = 25 * (1 + bonus) / (op->contr->gen_hp + penalty + 1); |
2659 | op->last_eat = 25 * (1 + bonus) / (op->contr->gen_hp + penalty + 1); |
2659 | else |
2660 | else |
2660 | op->last_eat = 25 * (1 + bonus) / (penalty + 1); |
2661 | op->last_eat = 25 * (1 + bonus) / (penalty + 1); |
|
|
2662 | |
2661 | /* dms do not consume food */ |
2663 | /* dms do not consume food */ |
2662 | if (!QUERY_FLAG (op, FLAG_WIZ)) |
2664 | if (!QUERY_FLAG (op, FLAG_WIZ)) |
2663 | op->stats.food--; |
2665 | op->stats.food--; |
2664 | } |
2666 | } |
2665 | } |
|
|
2666 | |
2667 | |
2667 | if (op->contr->ns->state == ST_PLAYING && op->stats.food < 0 && op->stats.hp >= 0) |
2668 | if (op->stats.food < 0 && op->stats.hp >= 0) |
2668 | { |
2669 | { |
2669 | object *tmp, *flesh = NULL; |
2670 | object *tmp, *flesh = 0; |
2670 | |
2671 | |
2671 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
2672 | for (tmp = op->inv; tmp; tmp = tmp->below) |
2672 | { |
2673 | { |
2673 | if (!QUERY_FLAG (tmp, FLAG_UNPAID)) |
2674 | if (!QUERY_FLAG (tmp, FLAG_UNPAID)) |
2674 | { |
|
|
2675 | if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) |
|
|
2676 | { |
2675 | { |
|
|
2676 | if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON) |
|
|
2677 | { |
2677 | new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); |
2678 | new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); |
2678 | manual_apply (op, tmp, 0); |
2679 | manual_apply (op, tmp, 0); |
2679 | if (op->stats.food >= 0 || op->stats.hp < 0) |
2680 | if (op->stats.food >= 0 || op->stats.hp < 0) |
2680 | break; |
2681 | break; |
2681 | } |
2682 | } |
2682 | else if (tmp->type == FLESH) |
2683 | else if (tmp->type == FLESH) |
2683 | flesh = tmp; |
2684 | flesh = tmp; |
2684 | } /* End if paid for object */ |
2685 | } /* End if paid for object */ |
2685 | } /* end of for loop */ |
2686 | } /* end of for loop */ |
|
|
2687 | |
2686 | /* If player is still starving, it means they don't have any food, so |
2688 | /* If player is still starving, it means they don't have any food, so |
2687 | * eat flesh instead. |
2689 | * eat flesh instead. |
2688 | */ |
2690 | */ |
2689 | if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) |
2691 | if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) |
2690 | { |
2692 | { |
2691 | new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); |
2693 | new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); |
2692 | manual_apply (op, flesh, 0); |
2694 | manual_apply (op, flesh, 0); |
2693 | } |
2695 | } |
2694 | } /* end if player is starving */ |
2696 | } |
2695 | |
2697 | |
2696 | while (op->stats.food < 0 && op->stats.hp > 0) |
2698 | while (op->stats.food < 0 && op->stats.hp >= 0) |
2697 | op->stats.food++, op->stats.hp--; |
2699 | op->stats.food++, op->stats.hp--; |
2698 | |
2700 | |
2699 | if (!op->contr->ns->state && !QUERY_FLAG (op, FLAG_WIZ) && (op->stats.hp < 0 || op->stats.food < 0)) |
2701 | if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ)) |
2700 | kill_player (op); |
2702 | kill_player (op); |
|
|
2703 | } |
2701 | } |
2704 | } |
2702 | |
|
|
2703 | |
|
|
2704 | |
2705 | |
2705 | /* If the player should die (lack of hp, food, etc), we call this. |
2706 | /* If the player should die (lack of hp, food, etc), we call this. |
2706 | * op is the player in jeopardy. If the player can not be saved (not |
2707 | * op is the player in jeopardy. If the player can not be saved (not |
2707 | * permadeath, no lifesave), this will take care of removing the player |
2708 | * permadeath, no lifesave), this will take care of removing the player |
2708 | * file. |
2709 | * file. |