1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the Affero GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * and the GNU General Public License along with this program. If not, see |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * <http://www.gnu.org/licenses/>. |
20 | * <http://www.gnu.org/licenses/>. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
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 |
… | |
… | |
130 | #include <sproto.h> |
130 | #include <sproto.h> |
131 | #include <spells.h> |
131 | #include <spells.h> |
132 | #include <sounds.h> |
132 | #include <sounds.h> |
133 | #include <skills.h> |
133 | #include <skills.h> |
134 | |
134 | |
135 | /* IMPLEMENTATION NOTES |
135 | /* IMPLEMENTATION NOTES |
136 | |
136 | |
137 | Diseases may be contageous. They are objects which exist in a player's |
137 | Diseases may be contageous. They are objects which exist in a player's |
138 | inventory. They themselves do nothing, except modify Symptoms, or |
138 | inventory. They themselves do nothing, except modify Symptoms, or |
139 | spread to other live objects. Symptoms are what actually damage the player: |
139 | spread to other live objects. Symptoms are what actually damage the player: |
140 | these are their own object. */ |
140 | these are their own object. */ |
141 | |
141 | |
142 | /* grants immunity to plagues we've seen before. */ |
142 | /* grants immunity to plagues we've seen before. */ |
143 | static int |
143 | static int |
… | |
… | |
380 | |
380 | |
381 | int |
381 | int |
382 | move_disease (object *disease) |
382 | move_disease (object *disease) |
383 | { |
383 | { |
384 | /* First task is to determine if the disease is inside or outside of someone. |
384 | /* First task is to determine if the disease is inside or outside of someone. |
385 | * If outside, we decrement 'value' until we're gone. |
385 | * If outside, we decrement 'value' until we're gone. |
386 | */ |
386 | */ |
387 | |
387 | |
388 | if (!disease->env) |
388 | if (!disease->env) |
389 | { /* we're outside of someone */ |
389 | { /* we're outside of someone */ |
390 | if (disease->stats.maxhp > 0) |
390 | if (disease->stats.maxhp > 0) |
… | |
… | |
439 | /* don't infect inanimate objects */ |
439 | /* don't infect inanimate objects */ |
440 | if (!victim->flag [FLAG_MONSTER] && !(victim->type == PLAYER)) |
440 | if (!victim->flag [FLAG_MONSTER] && !(victim->type == PLAYER)) |
441 | return 0; |
441 | return 0; |
442 | |
442 | |
443 | /* check and see if victim can catch disease: diseases |
443 | /* check and see if victim can catch disease: diseases |
444 | * are specific |
444 | * are specific |
445 | */ |
445 | */ |
446 | if (!is_susceptible_to_disease (victim, disease)) |
446 | if (!is_susceptible_to_disease (victim, disease)) |
447 | return 0; |
447 | return 0; |
448 | |
448 | |
449 | /* roll the dice on infection before doing the inventory check! */ |
449 | /* roll the dice on infection before doing the inventory check! */ |
… | |
… | |
494 | if (new_disease->owner && new_disease->owner->type == PLAYER) |
494 | if (new_disease->owner && new_disease->owner->type == PLAYER) |
495 | { |
495 | { |
496 | const char *buf; |
496 | const char *buf; |
497 | |
497 | |
498 | /* if the disease has a title, it has a special infection message |
498 | /* if the disease has a title, it has a special infection message |
499 | * This messages is printed in the form MESSAGE victim |
499 | * This messages is printed in the form MESSAGE victim |
500 | */ |
500 | */ |
501 | if (new_disease->title) |
501 | if (new_disease->title) |
502 | buf = format ("%s %s!!", &disease->title, &victim->name); |
502 | buf = format ("%s %s!!", &disease->title, &victim->name); |
503 | else |
503 | else |
504 | buf = format ("You infect %s with your disease, %s!", &victim->name, &new_disease->name); |
504 | buf = format ("You infect %s with your disease, %s!", &victim->name, &new_disease->name); |
… | |
… | |
525 | { /* outside a monster/player, die immediately */ |
525 | { /* outside a monster/player, die immediately */ |
526 | symptom->destroy (); |
526 | symptom->destroy (); |
527 | return 0; |
527 | return 0; |
528 | } |
528 | } |
529 | |
529 | |
530 | /* create the symptom "other arch" object and drop it here |
530 | /* create the symptom "other arch" object and drop it here |
531 | * under every part of the monster |
531 | * under every part of the monster |
532 | * The victim may well have died. |
532 | * The victim may well have died. |
533 | */ |
533 | */ |
534 | if (victim->map) |
534 | if (victim->map) |
535 | { |
535 | { |
536 | victim->play_sound (symptom->sound); |
536 | victim->play_sound (symptom->sound); |
537 | |
537 | |
… | |
… | |
622 | |
622 | |
623 | return 1; |
623 | return 1; |
624 | } |
624 | } |
625 | |
625 | |
626 | #if 0 // unused, but seems interesting |
626 | #if 0 // unused, but seems interesting |
627 | /* reduces disease progression: reduce_symptoms |
627 | /* reduces disease progression: reduce_symptoms |
628 | * return true if we actually reduce a disease. |
628 | * return true if we actually reduce a disease. |
629 | */ |
629 | */ |
630 | static int |
630 | static int |
631 | reduce_symptoms (object *sufferer, int reduction) |
631 | reduce_symptoms (object *sufferer, int reduction) |
632 | { |
632 | { |