ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/disease.C
(Generate patch)

Comparing deliantra/server/server/disease.C (file contents):
Revision 1.52 by root, Tue Sep 1 20:56:05 2009 UTC vs.
Revision 1.60 by root, Sun Nov 29 17:41:08 2009 UTC

3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * it under the terms of the GNU General Public License as published by 9 * the terms of the Affero GNU General Public License as published by the
10 * the Free Software Foundation, either version 3 of the License, or 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * (at your 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 GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.
20 * 21 *
21 * 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>
22 */ 23 */
23 24
24/* This file contains all the code implementing diseases, 25/* This file contains all the code implementing diseases,
156 { 157 {
157 walk->level = disease->level; 158 walk->level = disease->level;
158 return 1; /* just update the existing immunity. */ 159 return 1; /* just update the existing immunity. */
159 } 160 }
160 161
161 immunity = get_archetype ("immunity"); 162 immunity = get_archetype (shstr_immunity);
162 163
163 immunity->name = disease->name; 164 immunity->name = disease->name;
164 immunity->level = disease->level; 165 immunity->level = disease->level;
165 immunity->move_block = 0; 166 immunity->move_block = 0;
166 167
291 for (tmp = victim->head_ ()->inv; tmp; tmp = tmp->below) 292 for (tmp = victim->head_ ()->inv; tmp; tmp = tmp->below)
292 if (tmp->type == SIGN) /* possibly an immunity, or diseased */ 293 if (tmp->type == SIGN) /* possibly an immunity, or diseased */
293 if (tmp->name == disease->name && tmp->level >= disease->level) 294 if (tmp->name == disease->name && tmp->level >= disease->level)
294 return 0; /* Immune! */ 295 return 0; /* Immune! */
295 296
296 object *new_symptom = get_archetype ("symptom"); 297 object *new_symptom = get_archetype (shstr_symptom);
297 298
298 /* Something special done with dam. We want diseases to be more 299 /* Something special done with dam. We want diseases to be more
299 * random in what they'll kill, so we'll make the damage they 300 * random in what they'll kill, so we'll make the damage they
300 * do random, note, this has a weird effect with progressive diseases. 301 * do random, note, this has a weird effect with progressive diseases.
301 */ 302 */
513/* make the symptom do the nasty things it does */ 514/* make the symptom do the nasty things it does */
514int 515int
515move_symptom (object *symptom) 516move_symptom (object *symptom)
516{ 517{
517 object *victim = symptom->env; 518 object *victim = symptom->env;
518 object *new_ob;
519 int sp_reduce;
520 519
521 if (!victim || !victim->map) 520 if (!victim || !victim->map)
522 { /* outside a monster/player, die immediately */ 521 { /* outside a monster/player, die immediately */
523 symptom->destroy (); 522 symptom->destroy ();
524 return 0; 523 return 0;
525 } 524 }
526
527 if (symptom->stats.dam > 0)
528 hit_player (victim, symptom->stats.dam, symptom, symptom->attacktype, 1);
529 else
530 hit_player (victim, max (1, -victim->stats.maxhp * symptom->stats.dam / 100), symptom, symptom->attacktype, 1);
531
532 if (symptom->stats.maxsp > 0)
533 sp_reduce = symptom->stats.maxsp;
534 else
535 sp_reduce = max (1, victim->stats.maxsp * symptom->stats.maxsp / 100);
536
537 victim->stats.sp = max (0, victim->stats.sp - sp_reduce);
538 525
539 /* create the symptom "other arch" object and drop it here 526 /* create the symptom "other arch" object and drop it here
540 * under every part of the monster 527 * under every part of the monster
541 * The victim may well have died. 528 * The victim may well have died.
542 */ 529 */
545 victim->play_sound (symptom->sound); 532 victim->play_sound (symptom->sound);
546 533
547 if (symptom->other_arch) 534 if (symptom->other_arch)
548 for (object *tmp = victim->head_ (); tmp; tmp = tmp->more) 535 for (object *tmp = victim->head_ (); tmp; tmp = tmp->more)
549 { 536 {
550 new_ob = arch_to_object (symptom->other_arch); 537 object *new_ob = symptom->other_arch->instance ();
551 new_ob->x = tmp->x; 538 new_ob->x = tmp->x;
552 new_ob->y = tmp->y; 539 new_ob->y = tmp->y;
553 new_ob->map = victim->map; 540 new_ob->map = victim->map;
554 insert_ob_in_map (new_ob, victim->map, victim, 0); 541 insert_ob_in_map (new_ob, victim->map, victim, 0);
555 } 542 }
556 } 543 }
557 544
545 int damage =
546 symptom->stats.dam > 0
547 ? symptom->stats.dam
548 : max (1, victim->stats.maxhp * -symptom->stats.dam / 100);
549
550 hit_player (victim, damage, symptom, symptom->attacktype, 1);
551
552 int sp_reduce =
553 symptom->stats.maxsp > 0
554 ? symptom->stats.maxsp
555 : max (1, victim->stats.maxsp * -symptom->stats.maxsp / 100);
556
557 victim->stats.sp = max (0, victim->stats.sp - sp_reduce);
558
558 new_draw_info (NDI_UNIQUE | NDI_RED, 0, victim, symptom->msg); 559 new_draw_info (NDI_UNIQUE | NDI_RED, 0, victim, symptom->msg);
559 560
560 return 1; 561 return 1;
561} 562}
562 563
569 for (object *disease = hitter->inv; disease; disease = disease->below) 570 for (object *disease = hitter->inv; disease; disease = disease->below)
570 if (disease->type == DISEASE) 571 if (disease->type == DISEASE)
571 infect_object (victim, disease, 0); 572 infect_object (victim, disease, 0);
572 573
573 return 1; 574 return 1;
574}
575
576// find a disease in someone
577object *
578find_disease (object *victim)
579{
580 for (object *disease = victim->inv; disease; disease = disease->below)
581 if (disease->type == DISEASE)
582 return disease;
583
584 return 0;
585} 575}
586 576
587/* do the cure disease stuff, from the spell "cure disease" */ 577/* do the cure disease stuff, from the spell "cure disease" */
588int 578int
589cure_disease (object *sufferer, object *caster, object *spell) 579cure_disease (object *sufferer, object *caster, object *spell)
627 } 617 }
628 618
629 return 1; 619 return 1;
630} 620}
631 621
622#if 0 // unused, but seems interesting
632/* reduces disease progression: reduce_symptoms 623/* reduces disease progression: reduce_symptoms
633 * return true if we actually reduce a disease. 624 * return true if we actually reduce a disease.
634 */ 625 */
635int 626static int
636reduce_symptoms (object *sufferer, int reduction) 627reduce_symptoms (object *sufferer, int reduction)
637{ 628{
638 object *walk; 629 object *walk;
639 int success = 0; 630 int success = 0;
640 631
656 if (success) 647 if (success)
657 new_draw_info (NDI_UNIQUE, 0, sufferer, "Your illness seems less severe."); 648 new_draw_info (NDI_UNIQUE, 0, sufferer, "Your illness seems less severe.");
658 649
659 return success; 650 return success;
660} 651}
652#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines