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.37 by root, Thu Aug 23 18:55:02 2007 UTC vs.
Revision 1.44 by root, Sun Nov 25 13:27:11 2007 UTC

1/* 1/*
2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team 4 * Copyright (©) 2005,2006,2007 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 * Crossfire TRT is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify
9 * 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
10 * the Free Software Foundation, either version 3 of the License, or 10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version. 11 * (at your 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,
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 GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * 20 *
21 * The authors can be reached via e-mail to <crossfire@schmorp.de> 21 * The authors can be reached via e-mail to <support@deliantra.net>
22 */ 22 */
23 23
24/* This file contains all the code implementing diseases, 24/* This file contains all the code implementing diseases,
25 * except for odds and ends in attack.c and in 25 * except for odds and ends in attack.c and in
26 * living.c 26 * living.c
144is_susceptible_to_disease (object *victim, object *disease) 144is_susceptible_to_disease (object *victim, object *disease)
145{ 145{
146 if (!QUERY_FLAG (victim, FLAG_ALIVE)) 146 if (!QUERY_FLAG (victim, FLAG_ALIVE))
147 return 0; 147 return 0;
148 148
149 if (victim->flag [FLAG_WIZ])
150 return 0;
151
149 if (strstr (disease->race, "*") && !QUERY_FLAG (victim, FLAG_UNDEAD)) 152 if (strstr (disease->race, "*") && !QUERY_FLAG (victim, FLAG_UNDEAD))
150 return 1; 153 return 1;
151 154
152 if ((disease->race == shstr_undead) && QUERY_FLAG (victim, FLAG_UNDEAD)) 155 if ((disease->race == shstr_undead) && QUERY_FLAG (victim, FLAG_UNDEAD))
153 return 1; 156 return 1;
208 * Modified by MSW 2003-03-28 do try to find all the symptom the 211 * Modified by MSW 2003-03-28 do try to find all the symptom the
209 * player may have - I think through some odd interactoins with 212 * player may have - I think through some odd interactoins with
210 * disease level and player level and whatnot, a player could get 213 * disease level and player level and whatnot, a player could get
211 * more than one symtpom to a disease. 214 * more than one symtpom to a disease.
212 */ 215 */
213
214int 216int
215remove_symptoms (object *disease) 217remove_symptoms (object *disease)
216{ 218{
217 object *symptom, *victim = NULL; 219 object *symptom, *victim = NULL;
218 220
244 246
245/* searches around for more victims to infect */ 247/* searches around for more victims to infect */
246int 248int
247check_infection (object *disease) 249check_infection (object *disease)
248{ 250{
249 int x, y, range, mflags; 251 int x, y;
250 maptile *map, *map2; 252 maptile *map, *map2;
251 object *tmp; 253 object *tmp;
252 254
253 range = abs (disease->magic); 255 int range = abs (disease->magic);
254 256
255 if (disease->env) 257 if (disease->env)
256 { 258 {
257 x = disease->env->x; 259 x = disease->env->x;
258 y = disease->env->y; 260 y = disease->env->y;
270 272
271 for (int i = x - range; i <= x + range; i++) 273 for (int i = x - range; i <= x + range; i++)
272 for (int j = y - range; j <= y + range; j++) 274 for (int j = y - range; j <= y + range; j++)
273 { 275 {
274 sint16 i2, j2; 276 sint16 i2, j2;
275 mflags = get_map_flags (map, &map2, i, j, &i2, &j2); 277 int mflags = get_map_flags (map, &map2, i, j, &i2, &j2);
276 278
277 if (!(mflags & P_OUT_OF_MAP) && (mflags & P_IS_ALIVE)) 279 if (!(mflags & P_OUT_OF_MAP) && (mflags & P_IS_ALIVE))
278 for (tmp = GET_MAP_OB (map2, i2, j2); tmp; tmp = tmp->above) 280 for (tmp = GET_MAP_OB (map2, i2, j2); tmp; tmp = tmp->above)
279 infect_object (tmp, disease, 0); 281 infect_object (tmp, disease, 0);
280 } 282 }
540 } 542 }
541 543
542 if (symptom->stats.dam > 0) 544 if (symptom->stats.dam > 0)
543 hit_player (victim, symptom->stats.dam, symptom, symptom->attacktype, 1); 545 hit_player (victim, symptom->stats.dam, symptom, symptom->attacktype, 1);
544 else 546 else
545 hit_player (victim, max (1, -victim->stats.maxhp * symptom->stats.dam / 100.0), symptom, symptom->attacktype, 1); 547 hit_player (victim, max (1., -victim->stats.maxhp * symptom->stats.dam / 100.0), symptom, symptom->attacktype, 1);
546 548
547 if (symptom->stats.maxsp > 0) 549 if (symptom->stats.maxsp > 0)
548 sp_reduce = symptom->stats.maxsp; 550 sp_reduce = symptom->stats.maxsp;
549 else 551 else
550 sp_reduce = max (1, victim->stats.maxsp * symptom->stats.maxsp / 100.0); 552 sp_reduce = max (1, victim->stats.maxsp * symptom->stats.maxsp / 100.0);
553 555
554 /* create the symptom "other arch" object and drop it here 556 /* create the symptom "other arch" object and drop it here
555 * under every part of the monster 557 * under every part of the monster
556 * The victim may well have died. 558 * The victim may well have died.
557 */ 559 */
558 if (symptom->other_arch && victim->map) 560 if (victim->map)
561 {
562 victim->play_sound (symptom->sound);
563
564 if (symptom->other_arch)
559 for (object *tmp = victim->head_ (); tmp; tmp = tmp->more) 565 for (object *tmp = victim->head_ (); tmp; tmp = tmp->more)
560 { 566 {
561 new_ob = arch_to_object (symptom->other_arch); 567 new_ob = arch_to_object (symptom->other_arch);
562 new_ob->x = tmp->x; 568 new_ob->x = tmp->x;
563 new_ob->y = tmp->y; 569 new_ob->y = tmp->y;
564 new_ob->map = victim->map; 570 new_ob->map = victim->map;
565 insert_ob_in_map (new_ob, victim->map, victim, 0); 571 insert_ob_in_map (new_ob, victim->map, victim, 0);
572 }
566 } 573 }
567 574
568 new_draw_info (NDI_UNIQUE | NDI_RED, 0, victim, symptom->msg); 575 new_draw_info (NDI_UNIQUE | NDI_RED, 0, victim, symptom->msg);
569 576
570 return 1; 577 return 1;
571} 578}
594 return 0; 601 return 0;
595} 602}
596 603
597/* do the cure disease stuff, from the spell "cure disease" */ 604/* do the cure disease stuff, from the spell "cure disease" */
598int 605int
599cure_disease (object *sufferer, object *caster) 606cure_disease (object *sufferer, object *caster, object *spell)
600{ 607{
601 object *disease, *next; 608 object *disease, *next;
602 int casting_level;
603 int cure = 0; 609 int cure = 0;
604 610
605 if (caster)
606 casting_level = caster->level;
607 else
608 casting_level = 1000; /* if null caster, CURE all. */ 611 int casting_level = caster ? caster->level : 1000; /* if null caster, CURE all. */
609 612
610 for (disease = sufferer->inv; disease; disease = next) 613 for (disease = sufferer->inv; disease; disease = next)
611 { 614 {
612 next = disease->below; 615 next = disease->below;
613 616
621 if ((casting_level >= disease->level) || (!(random_roll (0, (disease->level - casting_level - 1), caster, PREFER_LOW)))) 624 if ((casting_level >= disease->level) || (!(random_roll (0, (disease->level - casting_level - 1), caster, PREFER_LOW))))
622 { 625 {
623 remove_symptoms (disease); 626 remove_symptoms (disease);
624 cure = 1; 627 cure = 1;
625 628
626 if (caster) 629 if (caster && spell)
627 change_exp (caster, disease->stats.exp, caster->chosen_skill ? caster->chosen_skill->skill : (const char *) 0, 0); 630 change_exp (caster, disease->stats.exp, spell->skill, SK_EXP_SKILL_ONLY);
628 631
629 disease->destroy (); 632 disease->destroy ();
630 } 633 }
631 } 634 }
632 } 635 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines