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.54 by root, Fri Dec 22 16:34:00 2006 UTC vs.
Revision 1.55 by root, Sat Dec 23 03:38:43 2006 UTC

2443 2443
2444 op = next; 2444 op = next;
2445 } 2445 }
2446} 2446}
2447 2447
2448
2449/* 2448/*
2450 * Returns pointer a static string containing gravestone text 2449 * Returns pointer a static string containing gravestone text
2451 * Moved from apply.c to player.c - player.c is what 2450 * Moved from apply.c to player.c - player.c is what
2452 * actually uses this function. player.c may not be quite the 2451 * actually uses this function. player.c may not be quite the
2453 * best, a misc file for object actions is probably better, 2452 * best, a misc file for object actions is probably better,
2486 strncat (buf2, " ", 20 - strlen (buf) / 2); 2485 strncat (buf2, " ", 20 - strlen (buf) / 2);
2487 strcat (buf2, buf); 2486 strcat (buf2, buf);
2488 2487
2489 return buf2; 2488 return buf2;
2490} 2489}
2491
2492
2493 2490
2494void 2491void
2495do_some_living (object *op) 2492do_some_living (object *op)
2496{ 2493{
2497 int last_food = op->stats.food; 2494 int last_food = op->stats.food;
2506 const int max_grace = 1; 2503 const int max_grace = 1;
2507 2504
2508 if (op->contr->outputs_sync) 2505 if (op->contr->outputs_sync)
2509 { 2506 {
2510 for (i = 0; i < NUM_OUTPUT_BUFS; i++) 2507 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) 2508 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]); 2509 flush_output_element (op, &op->contr->outputs[i]);
2513 } 2510 }
2514 2511
2515 if (op->contr->ns->state == ST_PLAYING) 2512 if (op->contr->ns->state == ST_PLAYING)
2516 { 2513 {
2517
2518 /* these next three if clauses make it possible to SLOW DOWN 2514 /* these next three if clauses make it possible to SLOW DOWN
2519 hp/grace/spellpoint regeneration. */ 2515 hp/grace/spellpoint regeneration. */
2520 if (op->contr->gen_hp >= 0) 2516 if (op->contr->gen_hp >= 0)
2521 gen_hp = (op->contr->gen_hp + 1) * op->stats.maxhp; 2517 gen_hp = (op->contr->gen_hp + 1) * op->stats.maxhp;
2522 else 2518 else
2523 { 2519 {
2524 gen_hp = op->stats.maxhp; 2520 gen_hp = op->stats.maxhp;
2525 rate_hp -= rate_hp / 2 * op->contr->gen_hp; 2521 rate_hp -= rate_hp / 2 * op->contr->gen_hp;
2526 } 2522 }
2523
2527 if (op->contr->gen_sp >= 0) 2524 if (op->contr->gen_sp >= 0)
2528 gen_sp = (op->contr->gen_sp + 1) * op->stats.maxsp; 2525 gen_sp = (op->contr->gen_sp + 1) * op->stats.maxsp;
2529 else 2526 else
2530 { 2527 {
2531 gen_sp = op->stats.maxsp; 2528 gen_sp = op->stats.maxsp;
2532 rate_sp -= rate_sp / 2 * op->contr->gen_sp; 2529 rate_sp -= rate_sp / 2 * op->contr->gen_sp;
2533 } 2530 }
2531
2534 if (op->contr->gen_grace >= 0) 2532 if (op->contr->gen_grace >= 0)
2535 gen_grace = (op->contr->gen_grace + 1) * op->stats.maxgrace; 2533 gen_grace = (op->contr->gen_grace + 1) * op->stats.maxgrace;
2536 else 2534 else
2537 { 2535 {
2538 gen_grace = op->stats.maxgrace; 2536 gen_grace = op->stats.maxgrace;
2554 op->stats.food += op->contr->digestion; 2552 op->stats.food += op->contr->digestion;
2555 else if (op->contr->digestion > 0 && random_roll (0, op->contr->digestion, op, PREFER_HIGH)) 2553 else if (op->contr->digestion > 0 && random_roll (0, op->contr->digestion, op, PREFER_HIGH))
2556 op->stats.food = last_food; 2554 op->stats.food = last_food;
2557 } 2555 }
2558 } 2556 }
2557
2559 if (max_sp > 1) 2558 if (max_sp > 1)
2560 { 2559 {
2561 over_sp = (gen_sp + 10) / rate_sp; 2560 over_sp = (gen_sp + 10) / rate_sp;
2562 if (over_sp > 0) 2561 if (over_sp > 0)
2563 { 2562 {
2564 if (op->stats.sp < op->stats.maxsp) 2563 if (op->stats.sp < op->stats.maxsp)
2565 { 2564 {
2566 op->stats.sp += over_sp > max_sp ? max_sp : over_sp; 2565 op->stats.sp += over_sp > max_sp ? max_sp : over_sp;
2566
2567 if (random_roll (0, rate_sp - 1, op, PREFER_LOW) > ((gen_sp + 10) % rate_sp)) 2567 if (random_roll (0, rate_sp - 1, op, PREFER_LOW) > ((gen_sp + 10) % rate_sp))
2568 op->stats.sp--; 2568 op->stats.sp--;
2569
2569 if (op->stats.sp > op->stats.maxsp) 2570 if (op->stats.sp > op->stats.maxsp)
2570 op->stats.sp = op->stats.maxsp; 2571 op->stats.sp = op->stats.maxsp;
2571 } 2572 }
2572 op->last_sp = 0; 2573 op->last_sp = 0;
2573 } 2574 }
2574 else 2575 else
2575 {
2576 op->last_sp = rate_sp / (gen_sp < 20 ? 30 : gen_sp + 10); 2576 op->last_sp = rate_sp / (gen_sp < 20 ? 30 : gen_sp + 10);
2577 }
2578 } 2577 }
2579 else 2578 else
2580 {
2581 op->last_sp = rate_sp / (gen_sp < 20 ? 30 : gen_sp + 10); 2579 op->last_sp = rate_sp / (gen_sp < 20 ? 30 : gen_sp + 10);
2582 }
2583 } 2580 }
2584 2581
2585 /* Regenerate Grace */ 2582 /* Regenerate Grace */
2586 /* I altered this a little - maximum grace is ony achieved through prayer -b.t. */ 2583 /* I altered this a little - maximum grace is ony achieved through prayer -b.t. */
2587 if (--op->last_grace < 0) 2584 if (--op->last_grace < 0)
2588 { 2585 {
2589 if (op->stats.grace < op->stats.maxgrace / 2) 2586 if (op->stats.grace < op->stats.maxgrace / 2)
2590 op->stats.grace++; /* no penalty in food for regaining grace */ 2587 op->stats.grace++; /* no penalty in food for regaining grace */
2588
2591 if (max_grace > 1) 2589 if (max_grace > 1)
2592 { 2590 {
2593 over_grace = (gen_grace < 20 ? 30 : gen_grace + 10) / rate_grace; 2591 over_grace = (gen_grace < 20 ? 30 : gen_grace + 10) / rate_grace;
2594 if (over_grace > 0) 2592 if (over_grace > 0)
2595 { 2593 {
2623 op->stats.food += op->contr->digestion; 2621 op->stats.food += op->contr->digestion;
2624 else if (op->contr->digestion > 0 && random_roll (0, op->contr->digestion, op, PREFER_HIGH)) 2622 else if (op->contr->digestion > 0 && random_roll (0, op->contr->digestion, op, PREFER_HIGH))
2625 op->stats.food = last_food; 2623 op->stats.food = last_food;
2626 } 2624 }
2627 } 2625 }
2626
2628 if (max_hp > 1) 2627 if (max_hp > 1)
2629 { 2628 {
2630 over_hp = (gen_hp < 20 ? 30 : gen_hp + 10) / rate_hp; 2629 over_hp = (gen_hp < 20 ? 30 : gen_hp + 10) / rate_hp;
2631 if (over_hp > 0) 2630 if (over_hp > 0)
2632 { 2631 {
2656 2655
2657 if (op->contr->gen_hp > 0) 2656 if (op->contr->gen_hp > 0)
2658 op->last_eat = 25 * (1 + bonus) / (op->contr->gen_hp + penalty + 1); 2657 op->last_eat = 25 * (1 + bonus) / (op->contr->gen_hp + penalty + 1);
2659 else 2658 else
2660 op->last_eat = 25 * (1 + bonus) / (penalty + 1); 2659 op->last_eat = 25 * (1 + bonus) / (penalty + 1);
2660
2661 /* dms do not consume food */ 2661 /* dms do not consume food */
2662 if (!QUERY_FLAG (op, FLAG_WIZ)) 2662 if (!QUERY_FLAG (op, FLAG_WIZ))
2663 op->stats.food--; 2663 op->stats.food--;
2664 } 2664 }
2665 }
2666 2665
2667 if (op->contr->ns->state == ST_PLAYING && op->stats.food < 0 && op->stats.hp >= 0) 2666 if (op->stats.food < 0 && op->stats.hp >= 0)
2668 { 2667 {
2669 object *tmp, *flesh = NULL; 2668 object *tmp, *flesh = 0;
2670 2669
2671 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 2670 for (tmp = op->inv; tmp; tmp = tmp->below)
2672 { 2671 {
2673 if (!QUERY_FLAG (tmp, FLAG_UNPAID)) 2672 if (!QUERY_FLAG (tmp, FLAG_UNPAID))
2674 {
2675 if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON)
2676 { 2673 {
2674 if (tmp->type == FOOD || tmp->type == DRINK || tmp->type == POISON)
2675 {
2677 new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); 2676 new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food.");
2678 manual_apply (op, tmp, 0); 2677 manual_apply (op, tmp, 0);
2679 if (op->stats.food >= 0 || op->stats.hp < 0) 2678 if (op->stats.food >= 0 || op->stats.hp < 0)
2680 break; 2679 break;
2681 } 2680 }
2682 else if (tmp->type == FLESH) 2681 else if (tmp->type == FLESH)
2683 flesh = tmp; 2682 flesh = tmp;
2684 } /* End if paid for object */ 2683 } /* End if paid for object */
2685 } /* end of for loop */ 2684 } /* end of for loop */
2685
2686 /* If player is still starving, it means they don't have any food, so 2686 /* If player is still starving, it means they don't have any food, so
2687 * eat flesh instead. 2687 * eat flesh instead.
2688 */ 2688 */
2689 if (op->stats.food < 0 && op->stats.hp >= 0 && flesh) 2689 if (op->stats.food < 0 && op->stats.hp >= 0 && flesh)
2690 { 2690 {
2691 new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food."); 2691 new_draw_info (NDI_UNIQUE, 0, op, "You blindly grab for a bite of food.");
2692 manual_apply (op, flesh, 0); 2692 manual_apply (op, flesh, 0);
2693 } 2693 }
2694 } /* end if player is starving */ 2694 }
2695 2695
2696 while (op->stats.food < 0 && op->stats.hp > 0) 2696 while (op->stats.food < 0 && op->stats.hp >= 0)
2697 op->stats.food++, op->stats.hp--; 2697 op->stats.food++, op->stats.hp--;
2698 2698
2699 if (!op->contr->ns->state && !QUERY_FLAG (op, FLAG_WIZ) && (op->stats.hp < 0 || op->stats.food < 0)) 2699 if (op->stats.hp < 0 && !QUERY_FLAG (op, FLAG_WIZ))
2700 kill_player (op); 2700 kill_player (op);
2701 }
2701} 2702}
2702
2703
2704 2703
2705/* If the player should die (lack of hp, food, etc), we call this. 2704/* 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 2705 * 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 2706 * permadeath, no lifesave), this will take care of removing the player
2708 * file. 2707 * file.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines