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.51 by root, Thu Jan 1 15:43:34 2009 UTC vs.
Revision 1.63 by root, Fri Mar 26 01:04:44 2010 UTC

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 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992 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
210static int 211static int
211check_infection (object *disease) 212check_infection (object *disease)
212{ 213{
213 int range = abs (disease->magic); 214 int range = abs (disease->magic);
214 215
215 object *op = disease->outer_env (); 216 object *op = disease->outer_env_or_self ();
216 217
217 if (!op->is_on_map ()) 218 if (!op->is_on_map ())
218 return 0; 219 return 0;
219 220
221 dynbuf buf;
220 unordered_mapwalk (op, -range, -range, range, range) 222 unordered_mapwalk (buf, op, -range, -range, range, range)
221 { 223 {
222 mapspace &ms = m->at (nx, ny); 224 mapspace &ms = m->at (nx, ny);
223 225
224 if (ms.flags () & P_IS_ALIVE) 226 if (ms.flags () & P_IS_ALIVE)
225 for (object *tmp = ms.bot; tmp; tmp = tmp->above) 227 for (object *tmp = ms.bot; tmp; tmp = tmp->above)
291 for (tmp = victim->head_ ()->inv; tmp; tmp = tmp->below) 293 for (tmp = victim->head_ ()->inv; tmp; tmp = tmp->below)
292 if (tmp->type == SIGN) /* possibly an immunity, or diseased */ 294 if (tmp->type == SIGN) /* possibly an immunity, or diseased */
293 if (tmp->name == disease->name && tmp->level >= disease->level) 295 if (tmp->name == disease->name && tmp->level >= disease->level)
294 return 0; /* Immune! */ 296 return 0; /* Immune! */
295 297
296 object *new_symptom = get_archetype ("symptom"); 298 object *new_symptom = get_archetype (shstr_symptom);
297 299
298 /* Something special done with dam. We want diseases to be more 300 /* 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 301 * 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. 302 * do random, note, this has a weird effect with progressive diseases.
301 */ 303 */
513/* make the symptom do the nasty things it does */ 515/* make the symptom do the nasty things it does */
514int 516int
515move_symptom (object *symptom) 517move_symptom (object *symptom)
516{ 518{
517 object *victim = symptom->env; 519 object *victim = symptom->env;
518 object *new_ob;
519 int sp_reduce;
520 520
521 if (!victim || !victim->map) 521 if (!victim || !victim->map)
522 { /* outside a monster/player, die immediately */ 522 { /* outside a monster/player, die immediately */
523 symptom->destroy (); 523 symptom->destroy ();
524 return 0; 524 return 0;
525 } 525 }
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 526
539 /* create the symptom "other arch" object and drop it here 527 /* create the symptom "other arch" object and drop it here
540 * under every part of the monster 528 * under every part of the monster
541 * The victim may well have died. 529 * The victim may well have died.
542 */ 530 */
545 victim->play_sound (symptom->sound); 533 victim->play_sound (symptom->sound);
546 534
547 if (symptom->other_arch) 535 if (symptom->other_arch)
548 for (object *tmp = victim->head_ (); tmp; tmp = tmp->more) 536 for (object *tmp = victim->head_ (); tmp; tmp = tmp->more)
549 { 537 {
550 new_ob = arch_to_object (symptom->other_arch); 538 object *new_ob = symptom->other_arch->instance ();
551 new_ob->x = tmp->x; 539 new_ob->x = tmp->x;
552 new_ob->y = tmp->y; 540 new_ob->y = tmp->y;
553 new_ob->map = victim->map; 541 new_ob->map = victim->map;
554 insert_ob_in_map (new_ob, victim->map, victim, 0); 542 insert_ob_in_map (new_ob, victim->map, victim, 0);
555 } 543 }
556 } 544 }
557 545
546 int damage =
547 symptom->stats.dam > 0
548 ? symptom->stats.dam
549 : max (1, victim->stats.maxhp * -symptom->stats.dam / 100);
550
551 hit_player (victim, damage, symptom, symptom->attacktype, 1);
552
553 int sp_reduce =
554 symptom->stats.maxsp > 0
555 ? symptom->stats.maxsp
556 : max (1, victim->stats.maxsp * -symptom->stats.maxsp / 100);
557
558 victim->stats.sp = max (0, victim->stats.sp - sp_reduce);
559
558 new_draw_info (NDI_UNIQUE | NDI_RED, 0, victim, symptom->msg); 560 new_draw_info (NDI_UNIQUE | NDI_RED, 0, victim, symptom->msg);
559 561
560 return 1; 562 return 1;
561} 563}
562 564
569 for (object *disease = hitter->inv; disease; disease = disease->below) 571 for (object *disease = hitter->inv; disease; disease = disease->below)
570 if (disease->type == DISEASE) 572 if (disease->type == DISEASE)
571 infect_object (victim, disease, 0); 573 infect_object (victim, disease, 0);
572 574
573 return 1; 575 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} 576}
586 577
587/* do the cure disease stuff, from the spell "cure disease" */ 578/* do the cure disease stuff, from the spell "cure disease" */
588int 579int
589cure_disease (object *sufferer, object *caster, object *spell) 580cure_disease (object *sufferer, object *caster, object *spell)
627 } 618 }
628 619
629 return 1; 620 return 1;
630} 621}
631 622
623#if 0 // unused, but seems interesting
632/* reduces disease progression: reduce_symptoms 624/* reduces disease progression: reduce_symptoms
633 * return true if we actually reduce a disease. 625 * return true if we actually reduce a disease.
634 */ 626 */
635int 627static int
636reduce_symptoms (object *sufferer, int reduction) 628reduce_symptoms (object *sufferer, int reduction)
637{ 629{
638 object *walk; 630 object *walk;
639 int success = 0; 631 int success = 0;
640 632
656 if (success) 648 if (success)
657 new_draw_info (NDI_UNIQUE, 0, sufferer, "Your illness seems less severe."); 649 new_draw_info (NDI_UNIQUE, 0, sufferer, "Your illness seems less severe.");
658 650
659 return success; 651 return success;
660} 652}
653#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines