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.5 2006/02/10 04:35:33 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 | #ifdef COZY_SERVER |
|
|
44 | extern int same_party (partylist *a, partylist *b); |
|
|
45 | #endif |
42 | |
46 | |
43 | player *find_player(const char *plname) |
47 | player *find_player(const char *plname) |
44 | { |
48 | { |
45 | player *pl; |
49 | player *pl; |
46 | for(pl=first_player;pl!=NULL;pl=pl->next) |
50 | for(pl=first_player;pl!=NULL;pl=pl->next) |
… | |
… | |
396 | op=ol->ob; |
400 | op=ol->ob; |
397 | lastdist=rv.distance; |
401 | lastdist=rv.distance; |
398 | } |
402 | } |
399 | } |
403 | } |
400 | for (pl=first_player; pl != NULL; pl=pl->next) { |
404 | for (pl=first_player; pl != NULL; pl=pl->next) { |
401 | if (on_same_map(mon, pl->ob)&& can_detect_enemy(mon, pl->ob,&rv)) { |
405 | if (can_detect_enemy(mon, pl->ob,&rv)) { |
402 | |
406 | |
403 | if(lastdist>rv.distance) { |
407 | if(lastdist>rv.distance) { |
404 | op=pl->ob; |
408 | op=pl->ob; |
405 | lastdist=rv.distance; |
409 | lastdist=rv.distance; |
406 | } |
410 | } |
… | |
… | |
2052 | |
2056 | |
2053 | /* If the creature is a pet, push it even if the player is not |
2057 | /* 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 |
2058 | * peaceful. Our assumption is the creature is a pet if the |
2055 | * player owns it and it is either friendly or unagressive. |
2059 | * player owns it and it is either friendly or unagressive. |
2056 | */ |
2060 | */ |
2057 | if ((op->type==PLAYER) && get_owner(mon)==op && |
2061 | if ((op->type==PLAYER) |
|
|
2062 | #if COZY_SERVER |
|
|
2063 | && |
|
|
2064 | ( |
|
|
2065 | (get_owner(mon) && get_owner(mon)->contr |
|
|
2066 | && same_party (get_owner(mon)->contr->party, op->contr->party)) |
|
|
2067 | || get_owner(mon) == op |
|
|
2068 | ) |
|
|
2069 | #else |
|
|
2070 | && get_owner(mon)==op |
|
|
2071 | #endif |
2058 | (QUERY_FLAG(mon,FLAG_UNAGGRESSIVE) || QUERY_FLAG(mon, FLAG_FRIENDLY))) |
2072 | && (QUERY_FLAG(mon,FLAG_UNAGGRESSIVE) || QUERY_FLAG(mon, FLAG_FRIENDLY))) |
2059 | { |
2073 | { |
2060 | /* If we're braced, we don't want to switch places with it */ |
2074 | /* If we're braced, we don't want to switch places with it */ |
2061 | if (op->contr->braced) return; |
2075 | if (op->contr->braced) return; |
2062 | play_sound_map(op->map, op->x, op->y, SOUND_PUSH_PLAYER); |
2076 | play_sound_map(op->map, op->x, op->y, SOUND_PUSH_PLAYER); |
2063 | (void) push_ob(mon,dir,op); |
2077 | (void) push_ob(mon,dir,op); |
… | |
… | |
2184 | */ |
2198 | */ |
2185 | int handle_newcs_player(object *op) |
2199 | int handle_newcs_player(object *op) |
2186 | { |
2200 | { |
2187 | if (op->contr->hidden) { |
2201 | if (op->contr->hidden) { |
2188 | op->invisible = 1000; |
2202 | op->invisible = 1000; |
2189 | /* the socket code flasehs the player visible/invisible |
2203 | /* the socket code flashes the player visible/invisible |
2190 | * depending on the value if invisible, so we need to |
2204 | * depending on the value of invisible, so we need to |
2191 | * alternate it here for it to work correctly. |
2205 | * alternate it here for it to work correctly. |
2192 | */ |
2206 | */ |
2193 | if (pticks & 2) op->invisible--; |
2207 | if (pticks & 2) op->invisible--; |
2194 | } |
2208 | } |
2195 | else if(op->invisible&&!(QUERY_FLAG(op,FLAG_MAKE_INVIS))) { |
2209 | else if(op->invisible&&!(QUERY_FLAG(op,FLAG_MAKE_INVIS))) { |
… | |
… | |
2463 | } |
2477 | } |
2464 | } |
2478 | } |
2465 | |
2479 | |
2466 | /* Digestion */ |
2480 | /* Digestion */ |
2467 | if(--op->last_eat<0) { |
2481 | if(--op->last_eat<0) { |
|
|
2482 | #ifdef COZY_SERVER |
|
|
2483 | int dg = op->contr->digestion>=0 && op->contr->digestion<2 ? 2 : op->contr->digestion; |
|
|
2484 | int bonus=dg>0?dg:0, |
|
|
2485 | penalty=dg<0?-dg:0; |
|
|
2486 | #else |
2468 | int bonus=op->contr->digestion>0?op->contr->digestion:0, |
2487 | int bonus=op->contr->digestion>0?op->contr->digestion:0, |
2469 | penalty=op->contr->digestion<0?-op->contr->digestion:0; |
2488 | penalty=op->contr->digestion<0?-op->contr->digestion:0; |
|
|
2489 | #endif |
|
|
2490 | |
2470 | if(op->contr->gen_hp > 0) |
2491 | if(op->contr->gen_hp > 0) |
2471 | op->last_eat=25*(1+bonus)/(op->contr->gen_hp+penalty+1); |
2492 | op->last_eat=25*(1+bonus)/(op->contr->gen_hp+penalty+1); |
2472 | else |
2493 | else |
2473 | op->last_eat=25*(1+bonus)/(penalty +1); |
2494 | op->last_eat=25*(1+bonus)/(penalty +1); |
2474 | /* dms do not consume food */ |
2495 | /* dms do not consume food */ |
… | |
… | |
2624 | |
2645 | |
2625 | /* Basically two ways to go - remove a stat permanently, or just |
2646 | /* Basically two ways to go - remove a stat permanently, or just |
2626 | * make it depletion. This bunch of code deals with that aspect |
2647 | * make it depletion. This bunch of code deals with that aspect |
2627 | * of death. |
2648 | * of death. |
2628 | */ |
2649 | */ |
2629 | |
2650 | #ifndef COZY_SERVER |
2630 | if (settings.balanced_stat_loss) { |
2651 | if (settings.balanced_stat_loss) { |
2631 | /* If stat loss is permanent, lose one stat only. */ |
2652 | /* If stat loss is permanent, lose one stat only. */ |
2632 | /* Lower level chars don't lose as many stats because they suffer |
2653 | /* Lower level chars don't lose as many stats because they suffer |
2633 | more if they do. */ |
2654 | more if they do. */ |
2634 | /* Higher level characters can afford things such as potions of |
2655 | /* Higher level characters can afford things such as potions of |
… | |
… | |
2725 | " you.", god); |
2746 | " you.", god); |
2726 | else |
2747 | else |
2727 | new_draw_info(NDI_UNIQUE, 0, op, "For a brief moment you" |
2748 | new_draw_info(NDI_UNIQUE, 0, op, "For a brief moment you" |
2728 | " feel a holy presence protecting you."); |
2749 | " feel a holy presence protecting you."); |
2729 | } |
2750 | } |
|
|
2751 | #endif |
|
|
2752 | new_draw_info(NDI_UNIQUE, 0, op, "For a brief moment you" |
|
|
2753 | " feel a holy presence protecting you from losing yourself completely."); |
2730 | |
2754 | |
2731 | /* Put a gravestone up where the character 'almost' died. List the |
2755 | /* Put a gravestone up where the character 'almost' died. List the |
2732 | * exp loss on the stone. |
2756 | * exp loss on the stone. |
2733 | */ |
2757 | */ |
2734 | tmp=arch_to_object(find_archetype("gravestone")); |
2758 | tmp=arch_to_object(find_archetype("gravestone")); |