1 | /* |
1 | /* |
2 | * static char *rcsid_player_c = |
2 | * static char *rcsid_player_c = |
3 | * "$Id: player.c,v 1.1 2006/02/03 07:14:35 root Exp $"; |
3 | * "$Id: player.c,v 1.3 2006/02/08 04:32:19 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
37 | #include <living.h> |
37 | #include <living.h> |
38 | #include <object.h> |
38 | #include <object.h> |
39 | #include <spells.h> |
39 | #include <spells.h> |
40 | #include <skills.h> |
40 | #include <skills.h> |
41 | #include <newclient.h> |
41 | #include <newclient.h> |
|
|
42 | |
|
|
43 | extern int same_party (partylist *a, partylist *b); |
42 | |
44 | |
43 | player *find_player(const char *plname) |
45 | player *find_player(const char *plname) |
44 | { |
46 | { |
45 | player *pl; |
47 | player *pl; |
46 | for(pl=first_player;pl!=NULL;pl=pl->next) |
48 | for(pl=first_player;pl!=NULL;pl=pl->next) |
… | |
… | |
396 | op=ol->ob; |
398 | op=ol->ob; |
397 | lastdist=rv.distance; |
399 | lastdist=rv.distance; |
398 | } |
400 | } |
399 | } |
401 | } |
400 | for (pl=first_player; pl != NULL; pl=pl->next) { |
402 | for (pl=first_player; pl != NULL; pl=pl->next) { |
401 | if (on_same_map(mon, pl->ob)&& can_detect_enemy(mon, pl->ob,&rv)) { |
403 | if (can_detect_enemy(mon, pl->ob,&rv)) { |
402 | |
404 | |
403 | if(lastdist>rv.distance) { |
405 | if(lastdist>rv.distance) { |
404 | op=pl->ob; |
406 | op=pl->ob; |
405 | lastdist=rv.distance; |
407 | lastdist=rv.distance; |
406 | } |
408 | } |
… | |
… | |
2052 | |
2054 | |
2053 | /* If the creature is a pet, push it even if the player is not |
2055 | /* If the creature is a pet, push it even if the player is not |
2054 | * peaceful. Our assumption is the creature is a pet if the |
2056 | * peaceful. Our assumption is the creature is a pet if the |
2055 | * player owns it and it is either friendly or unagressive. |
2057 | * player owns it and it is either friendly or unagressive. |
2056 | */ |
2058 | */ |
2057 | if ((op->type==PLAYER) && get_owner(mon)==op && |
2059 | if ((op->type==PLAYER) |
|
|
2060 | && |
|
|
2061 | ( |
|
|
2062 | (get_owner(mon) && get_owner(mon)->contr |
|
|
2063 | && same_party (get_owner(mon)->contr->party, op->contr->party)) |
|
|
2064 | || get_owner(mon) == op |
|
|
2065 | ) |
2058 | (QUERY_FLAG(mon,FLAG_UNAGGRESSIVE) || QUERY_FLAG(mon, FLAG_FRIENDLY))) |
2066 | && (QUERY_FLAG(mon,FLAG_UNAGGRESSIVE) || QUERY_FLAG(mon, FLAG_FRIENDLY))) |
2059 | { |
2067 | { |
2060 | /* If we're braced, we don't want to switch places with it */ |
2068 | /* If we're braced, we don't want to switch places with it */ |
2061 | if (op->contr->braced) return; |
2069 | if (op->contr->braced) return; |
2062 | play_sound_map(op->map, op->x, op->y, SOUND_PUSH_PLAYER); |
2070 | play_sound_map(op->map, op->x, op->y, SOUND_PUSH_PLAYER); |
2063 | (void) push_ob(mon,dir,op); |
2071 | (void) push_ob(mon,dir,op); |
… | |
… | |
2463 | } |
2471 | } |
2464 | } |
2472 | } |
2465 | |
2473 | |
2466 | /* Digestion */ |
2474 | /* Digestion */ |
2467 | if(--op->last_eat<0) { |
2475 | if(--op->last_eat<0) { |
2468 | int bonus=op->contr->digestion>0?op->contr->digestion:0, |
2476 | int dg = op->contr->digestion>=0 && op->contr->digestion<2 ? 2 : op->contr->digestion; |
2469 | penalty=op->contr->digestion<0?-op->contr->digestion:0; |
2477 | int bonus=dg>0?dg:0, |
|
|
2478 | penalty=dg<0?-dg:0; |
2470 | if(op->contr->gen_hp > 0) |
2479 | if(op->contr->gen_hp > 0) |
2471 | op->last_eat=25*(1+bonus)/(op->contr->gen_hp+penalty+1); |
2480 | op->last_eat=25*(1+bonus)/(op->contr->gen_hp+penalty+1); |
2472 | else |
2481 | else |
2473 | op->last_eat=25*(1+bonus)/(penalty +1); |
2482 | op->last_eat=25*(1+bonus)/(penalty +1); |
2474 | /* dms do not consume food */ |
2483 | /* dms do not consume food */ |
… | |
… | |
2624 | |
2633 | |
2625 | /* Basically two ways to go - remove a stat permanently, or just |
2634 | /* Basically two ways to go - remove a stat permanently, or just |
2626 | * make it depletion. This bunch of code deals with that aspect |
2635 | * make it depletion. This bunch of code deals with that aspect |
2627 | * of death. |
2636 | * of death. |
2628 | */ |
2637 | */ |
2629 | |
2638 | #if 0 |
2630 | if (settings.balanced_stat_loss) { |
2639 | if (settings.balanced_stat_loss) { |
2631 | /* If stat loss is permanent, lose one stat only. */ |
2640 | /* If stat loss is permanent, lose one stat only. */ |
2632 | /* Lower level chars don't lose as many stats because they suffer |
2641 | /* Lower level chars don't lose as many stats because they suffer |
2633 | more if they do. */ |
2642 | more if they do. */ |
2634 | /* Higher level characters can afford things such as potions of |
2643 | /* Higher level characters can afford things such as potions of |
… | |
… | |
2725 | " you.", god); |
2734 | " you.", god); |
2726 | else |
2735 | else |
2727 | new_draw_info(NDI_UNIQUE, 0, op, "For a brief moment you" |
2736 | new_draw_info(NDI_UNIQUE, 0, op, "For a brief moment you" |
2728 | " feel a holy presence protecting you."); |
2737 | " feel a holy presence protecting you."); |
2729 | } |
2738 | } |
|
|
2739 | #endif |
|
|
2740 | new_draw_info(NDI_UNIQUE, 0, op, "For a brief moment you" |
|
|
2741 | " feel a holy presence protecting you from losing yourself completely."); |
2730 | |
2742 | |
2731 | /* Put a gravestone up where the character 'almost' died. List the |
2743 | /* Put a gravestone up where the character 'almost' died. List the |
2732 | * exp loss on the stone. |
2744 | * exp loss on the stone. |
2733 | */ |
2745 | */ |
2734 | tmp=arch_to_object(find_archetype("gravestone")); |
2746 | tmp=arch_to_object(find_archetype("gravestone")); |