1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game for X-windows |
3 | |
3 | * |
|
|
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | |
7 | * |
7 | This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. |
11 | * (at your option) any later version. |
11 | |
12 | * |
12 | 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, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
16 | |
17 | * |
17 | You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software |
19 | * along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | |
21 | * |
21 | 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> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | /* This file contains all the code implementing diseases, |
25 | /* This file contains all the code implementing diseases, |
25 | except for odds and ends in attack.c and in |
26 | except for odds and ends in attack.c and in |
26 | living.c*/ |
27 | living.c*/ |
27 | |
28 | |
… | |
… | |
126 | |
127 | |
127 | |
128 | |
128 | #include <global.h> |
129 | #include <global.h> |
129 | #include <object.h> |
130 | #include <object.h> |
130 | #include <living.h> |
131 | #include <living.h> |
131 | #ifndef __CEXTRACT__ |
|
|
132 | # include <sproto.h> |
132 | #include <sproto.h> |
133 | #endif |
|
|
134 | #include <spells.h> |
133 | #include <spells.h> |
135 | #include <sounds.h> |
134 | #include <sounds.h> |
136 | #include <skills.h> |
135 | #include <skills.h> |
137 | |
136 | |
138 | /* IMPLEMENTATION NOTES |
137 | /* IMPLEMENTATION NOTES |
… | |
… | |
226 | |
225 | |
227 | symptom->destroy (); |
226 | symptom->destroy (); |
228 | } |
227 | } |
229 | |
228 | |
230 | if (victim) |
229 | if (victim) |
231 | fix_player (victim); |
230 | victim->update_stats (); |
232 | return 0; |
231 | return 0; |
233 | } |
232 | } |
234 | |
233 | |
235 | /* argument is a disease */ |
234 | /* argument is a disease */ |
236 | object * |
235 | object * |
… | |
… | |
324 | * (eg, level 1 cold, level 2 cold, level 3 cold, etc), as long as |
323 | * (eg, level 1 cold, level 2 cold, level 3 cold, etc), as long as |
325 | * they were cast in that same order. Instead, change it so that |
324 | * they were cast in that same order. Instead, change it so that |
326 | * if you diseased, you can't get diseased more. |
325 | * if you diseased, you can't get diseased more. |
327 | */ |
326 | */ |
328 | |
327 | |
329 | for ( /* tmp initialized in if, above */ ; tmp; tmp = tmp->below) |
328 | for ( /* tmp initialised in if, above */ ; tmp; tmp = tmp->below) |
330 | { |
329 | { |
331 | if (tmp->type == SIGN && !strcmp (tmp->name, disease->name) && tmp->level >= disease->level) |
330 | if (tmp->type == SIGN && !strcmp (tmp->name, disease->name) && tmp->level >= disease->level) |
332 | return 0; /*Immune! */ |
331 | return 0; /* Immune! */ |
333 | else if (tmp->type == DISEASE && !strcmp (tmp->name, disease->name)) |
332 | else if (tmp->type == DISEASE && !strcmp (tmp->name, disease->name)) |
334 | return 0; /* already diseased */ |
333 | return 0; /* already diseased */ |
335 | } |
334 | } |
336 | |
335 | |
337 | /* If we've gotten this far, go ahead and infect the victim. */ |
336 | /* If we've gotten this far, go ahead and infect the victim. */ |
… | |
… | |
433 | if (victim->head) |
432 | if (victim->head) |
434 | tmp = victim->head->inv; |
433 | tmp = victim->head->inv; |
435 | else |
434 | else |
436 | tmp = victim->inv; |
435 | tmp = victim->inv; |
437 | |
436 | |
438 | for ( /* tmp initialized in if, above */ ; tmp; tmp = tmp->below) |
437 | for ( /* tmp initialised in if, above */ ; tmp; tmp = tmp->below) |
439 | { |
438 | { |
440 | if (tmp->type == SIGN) /* possibly an immunity, or diseased */ |
439 | if (tmp->type == SIGN) /* possibly an immunity, or diseased */ |
441 | if (!strcmp (tmp->name, disease->name) && tmp->level >= disease->level) |
440 | if (!strcmp (tmp->name, disease->name) && tmp->level >= disease->level) |
442 | return 0; /*Immune! */ |
441 | return 0; /*Immune! */ |
443 | } |
442 | } |
… | |
… | |
452 | { |
451 | { |
453 | int dam = disease->stats.dam; |
452 | int dam = disease->stats.dam; |
454 | |
453 | |
455 | /* reduce the damage, on average, 50%, and making things random. */ |
454 | /* reduce the damage, on average, 50%, and making things random. */ |
456 | |
455 | |
457 | dam = random_roll (1, FABS (dam), victim, PREFER_LOW); |
456 | dam = random_roll (1, abs (dam), victim, PREFER_LOW); |
458 | if (disease->stats.dam < 0) |
457 | if (disease->stats.dam < 0) |
459 | dam = -dam; |
458 | dam = -dam; |
460 | new_symptom->stats.dam = dam; |
459 | new_symptom->stats.dam = dam; |
461 | } |
460 | } |
462 | |
461 | |
… | |
… | |
524 | symptom->msg = disease->msg; |
523 | symptom->msg = disease->msg; |
525 | symptom->attacktype = disease->attacktype; |
524 | symptom->attacktype = disease->attacktype; |
526 | symptom->other_arch = disease->other_arch; |
525 | symptom->other_arch = disease->other_arch; |
527 | } |
526 | } |
528 | SET_FLAG (symptom, FLAG_APPLIED); |
527 | SET_FLAG (symptom, FLAG_APPLIED); |
529 | fix_player (victim); |
528 | victim->update_stats (); |
530 | return 1; |
529 | return 1; |
531 | } |
530 | } |
532 | |
531 | |
533 | |
532 | |
534 | /* grants immunity to plagues we've seen before. */ |
533 | /* grants immunity to plagues we've seen before. */ |
… | |
… | |
598 | object *tmp; |
597 | object *tmp; |
599 | |
598 | |
600 | tmp = victim; |
599 | tmp = victim; |
601 | if (tmp->head != NULL) |
600 | if (tmp->head != NULL) |
602 | tmp = tmp->head; |
601 | tmp = tmp->head; |
603 | for ( /*tmp initialized above */ ; tmp != NULL; tmp = tmp->more) |
602 | for ( /*tmp initialised above */ ; tmp != NULL; tmp = tmp->more) |
604 | { |
603 | { |
605 | new_ob = arch_to_object (symptom->other_arch); |
604 | new_ob = arch_to_object (symptom->other_arch); |
606 | new_ob->x = tmp->x; |
605 | new_ob->x = tmp->x; |
607 | new_ob->y = tmp->y; |
606 | new_ob->y = tmp->y; |
608 | new_ob->map = victim->map; |
607 | new_ob->map = victim->map; |