1 | /* |
1 | /* |
2 | * CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game |
3 | * |
3 | * |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
7 | * |
7 | * |
… | |
… | |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | /* This file contains all the code implementing diseases, |
25 | /* This file contains all the code implementing diseases, |
26 | except for odds and ends in attack.c and in |
26 | * except for odds and ends in attack.c and in |
27 | living.c*/ |
27 | * living.c |
28 | |
28 | */ |
29 | |
|
|
30 | |
29 | |
31 | /* |
30 | /* |
32 | |
31 | |
33 | For DISEASES: |
32 | For DISEASES: |
34 | Stat Property Definition |
33 | Stat Property Definition |
… | |
… | |
237 | { |
236 | { |
238 | object *walk; |
237 | object *walk; |
239 | |
238 | |
240 | /* check the inventory for symptoms */ |
239 | /* check the inventory for symptoms */ |
241 | for (walk = disease->env->inv; walk; walk = walk->below) |
240 | for (walk = disease->env->inv; walk; walk = walk->below) |
242 | if (!strcmp (walk->name, disease->name) && walk->type == SYMPTOM) |
241 | if (walk->name == disease->name && walk->type == SYMPTOM) |
243 | return walk; |
242 | return walk; |
244 | return NULL; |
243 | return NULL; |
245 | } |
244 | } |
246 | |
245 | |
247 | /* searches around for more victims to infect */ |
246 | /* searches around for more victims to infect */ |
… | |
… | |
325 | * if you diseased, you can't get diseased more. |
324 | * if you diseased, you can't get diseased more. |
326 | */ |
325 | */ |
327 | |
326 | |
328 | for ( /* tmp initialised in if, above */ ; tmp; tmp = tmp->below) |
327 | for ( /* tmp initialised in if, above */ ; tmp; tmp = tmp->below) |
329 | { |
328 | { |
330 | if (tmp->type == SIGN && !strcmp (tmp->name, disease->name) && tmp->level >= disease->level) |
329 | if (tmp->type == SIGN && tmp->name == disease->name && tmp->level >= disease->level) |
331 | return 0; /* Immune! */ |
330 | return 0; /* Immune! */ |
332 | else if (tmp->type == DISEASE && !strcmp (tmp->name, disease->name)) |
331 | else if (tmp->type == DISEASE && tmp->name == disease->name) |
333 | return 0; /* already diseased */ |
332 | return 0; /* already diseased */ |
334 | } |
333 | } |
335 | |
334 | |
336 | /* If we've gotten this far, go ahead and infect the victim. */ |
335 | /* If we've gotten this far, go ahead and infect the victim. */ |
337 | new_disease = disease->clone (); |
336 | new_disease = disease->clone (); |
… | |
… | |
435 | tmp = victim->inv; |
434 | tmp = victim->inv; |
436 | |
435 | |
437 | for ( /* tmp initialised in if, above */ ; tmp; tmp = tmp->below) |
436 | for ( /* tmp initialised in if, above */ ; tmp; tmp = tmp->below) |
438 | { |
437 | { |
439 | if (tmp->type == SIGN) /* possibly an immunity, or diseased */ |
438 | if (tmp->type == SIGN) /* possibly an immunity, or diseased */ |
440 | if (!strcmp (tmp->name, disease->name) && tmp->level >= disease->level) |
439 | if (tmp->name == disease->name && tmp->level >= disease->level) |
441 | return 0; /*Immune! */ |
440 | return 0; /*Immune! */ |
442 | } |
441 | } |
443 | |
442 | |
444 | new_symptom = get_archetype (ARCH_SYMPTOM); |
443 | new_symptom = get_archetype (ARCH_SYMPTOM); |
445 | |
444 | |
… | |
… | |
541 | if (disease->last_heal) |
540 | if (disease->last_heal) |
542 | return 0; |
541 | return 0; |
543 | /* first, search for an immunity of the same name */ |
542 | /* first, search for an immunity of the same name */ |
544 | for (walk = disease->env->inv; walk; walk = walk->below) |
543 | for (walk = disease->env->inv; walk; walk = walk->below) |
545 | { |
544 | { |
546 | if (walk->type == 98 && !strcmp (disease->name, walk->name)) |
545 | if (walk->type == 98 && disease->name == walk->name) |
547 | { |
546 | { |
548 | walk->level = disease->level; |
547 | walk->level = disease->level; |
549 | return 1; /* just update the existing immunity. */ |
548 | return 1; /* just update the existing immunity. */ |
550 | } |
549 | } |
551 | } |
550 | } |
… | |
… | |
611 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, victim, symptom->msg); |
610 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, victim, symptom->msg); |
612 | |
611 | |
613 | return 1; |
612 | return 1; |
614 | } |
613 | } |
615 | |
614 | |
616 | |
|
|
617 | /* possibly infect due to direct physical contact |
615 | /* possibly infect due to direct physical contact |
618 | i.e., AT_PHYSICAL-- called from "hit_player_attacktype" */ |
616 | * i.e., AT_PHYSICAL-- called from "hit_player_attacktype" */ |
619 | |
|
|
620 | int |
617 | int |
621 | check_physically_infect (object *victim, object *hitter) |
618 | check_physically_infect (object *victim, object *hitter) |
622 | { |
619 | { |
623 | object *walk; |
|
|
624 | |
|
|
625 | /* search for diseases, give every disease a chance to infect */ |
620 | /* search for diseases, give every disease a chance to infect */ |
626 | for (walk = hitter->inv; walk != NULL; walk = walk->below) |
621 | for (object *disease = hitter->inv; disease; disease = disease->below) |
627 | if (walk->type == DISEASE) |
622 | if (disease->type == DISEASE) |
628 | infect_object (victim, walk, 0); |
623 | infect_object (victim, disease, 0); |
|
|
624 | |
629 | return 1; |
625 | return 1; |
630 | } |
626 | } |
631 | |
627 | |
632 | /* find a disease in someone*/ |
628 | // find a disease in someone |
633 | object * |
629 | object * |
634 | find_disease (object *victim) |
630 | find_disease (object *victim) |
635 | { |
631 | { |
636 | object *walk; |
632 | for (object *disease = victim->inv; disease; disease = disease->below) |
637 | |
|
|
638 | for (walk = victim->inv; walk; walk = walk->below) |
|
|
639 | if (walk->type == DISEASE) |
633 | if (disease->type == DISEASE) |
640 | return walk; |
634 | return disease; |
|
|
635 | |
641 | return NULL; |
636 | return 0; |
642 | } |
637 | } |
643 | |
638 | |
644 | /* do the cure disease stuff, from the spell "cure disease" */ |
639 | /* do the cure disease stuff, from the spell "cure disease" */ |
645 | |
|
|
646 | int |
640 | int |
647 | cure_disease (object *sufferer, object *caster) |
641 | cure_disease (object *sufferer, object *caster) |
648 | { |
642 | { |
649 | object *disease, *next; |
643 | object *disease, *next; |
650 | int casting_level; |
644 | int casting_level; |
… | |
… | |
659 | { |
653 | { |
660 | next = disease->below; |
654 | next = disease->below; |
661 | |
655 | |
662 | if (disease->type == DISEASE) |
656 | if (disease->type == DISEASE) |
663 | { /* attempt to cure this disease */ |
657 | { /* attempt to cure this disease */ |
664 | /* If caster lvel is higher than disease level, cure chance |
658 | /* If caster level is higher than disease level, cure chance |
665 | * is automatic. If lower, then the chance is basically |
659 | * is automatic. If lower, then the chance is basically |
666 | * 1 in level_diff - if there is a 5 level difference, chance |
660 | * 1 in level_diff - if there is a 5 level difference, chance |
667 | * is 1 in 5. |
661 | * is 1 in 5. |
668 | */ |
662 | */ |
669 | if ((casting_level >= disease->level) || (!(random_roll (0, (disease->level - casting_level - 1), caster, PREFER_LOW)))) |
663 | if ((casting_level >= disease->level) || (!(random_roll (0, (disease->level - casting_level - 1), caster, PREFER_LOW)))) |
670 | { |
664 | { |
671 | |
|
|
672 | remove_symptoms (disease); |
665 | remove_symptoms (disease); |
673 | cure = 1; |
666 | cure = 1; |
674 | |
667 | |
675 | if (caster) |
668 | if (caster) |
676 | change_exp (caster, disease->stats.exp, caster->chosen_skill ? &caster->chosen_skill->skill : (const char *) 0, 0); |
669 | change_exp (caster, disease->stats.exp, caster->chosen_skill ? caster->chosen_skill->skill : (const char *) 0, 0); |
677 | |
670 | |
678 | disease->destroy (); |
671 | disease->destroy (); |
679 | } |
672 | } |
680 | } |
673 | } |
681 | } |
674 | } |
|
|
675 | |
682 | if (cure) |
676 | if (cure) |
683 | { |
677 | { |
684 | /* Only draw these messages once */ |
678 | /* Only draw these messages once */ |
685 | if (caster) |
679 | if (caster) |
686 | new_draw_info_format (NDI_UNIQUE, 0, caster, "You cure a disease!"); |
680 | new_draw_info_format (NDI_UNIQUE, 0, caster, "You cure a disease!"); |
|
|
681 | |
687 | new_draw_info (NDI_UNIQUE, 0, sufferer, "You no longer feel diseased."); |
682 | new_draw_info (NDI_UNIQUE, 0, sufferer, "You no longer feel diseased."); |
688 | } |
683 | } |
|
|
684 | |
689 | return 1; |
685 | return 1; |
690 | } |
686 | } |
691 | |
687 | |
692 | /* reduces disease progression: reduce_symptoms |
688 | /* reduces disease progression: reduce_symptoms |
693 | * return true if we actually reduce a disease. |
689 | * return true if we actually reduce a disease. |