Debian Codegraph @

server/disease.c

raw symbols SCIP
1 /*
2 * Crossfire -- cooperative multi-player graphical RPG and adventure game
3 *
4 * Copyright (c) 1999-2014 Mark Wedel and the Crossfire Development Team
5 * Copyright (c) 1992 Frank Tore Johansen
6 *
7 * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
8 * welcome to redistribute it under certain conditions. For details, please
9 * see COPYING and LICENSE.
10 *
11 * The authors can be reached via e-mail at <[email protected]>.
12 */
13
14 /**
15 * @file
16 * This file contains all the code implementing diseases,
17 * except for odds and ends in attack.c and in living.c
18 */
19
20 /*
21 * For DISEASES:
22 * Stat Property Definition
23 *
24 * attacktype Attack effects Attacktype of the disease. usu. AT_GODPOWER.
25 * other_arch Creation object created and dropped when symptom moved.
26 * title Message When the "disease" "infects" something, it will
27 * print "title victim!!!" to the player who owns
28 * the "disease".
29 * wc+ Infectiousness How well the plague spreads person-to-person
30 * magic+ Range range of infection
31 * Stats* Disability What stats are reduced by the disease (str con...)
32 * maxhp+ Persistence How long the disease can last OUTSIDE the host.
33 * * value TimeLeft Counter for persistence
34 * dam^ Damage How much damage it does (%?).
35 * maxgrace+ Duration How long before the disease is naturally cured.
36 * food DurCount Counter for Duration
37 *
38 * speed Speed How often the disease moves.
39 * last_sp^ Lethargy Percentage of max speed--10 = 10% speed.
40 *
41 * maxsp^ Mana deplete Saps mana.
42 * ac^ Progressiveness How the diseases increases in severity.
43 * last_eat*^ Deplete food saps food if negative
44 * last_heal GrantImmunity If nonzero, disease does NOT grant immunity
45 * when it runs out
46 *
47 * exp experience experience awarded when plague cured
48 * hp*^ ReduceRegen reduces regeneration of disease-bearer
49 * sp*^ ReduceSpRegen reduces spellpoint regeneration
50 *
51 * name Name Name of the plague
52 * msg message What the plague says when it strikes.
53 * race those affected species/race the plague strikes (* = everything)
54 * level Plague Level General description of the plague's deadliness
55 * armour Attenuation reduction in wc per generation of disease.
56 * This builds in a self-limiting factor.
57 *
58 *
59 * Explanations:
60 * * means this # should be negative to cause adverse effect.
61 * + means that this effect is modulated in spells by ldur
62 * ^ means that this effect is modulated in spells by ldam
63 *
64 * attacktype is the attacktype used by the disease to smite "dam" damage with.
65 *
66 * wc/127 is the chance of someone in range catching it.
67 *
68 * magic is the range at which infection may occur. If negative, the range is
69 * NOT level dependent.
70 *
71 * Stats are stat modifications. These should typically be negative.
72 *
73 * maxhp is how long the disease will persist if the host dies and "drops" it,
74 * in "disease moves", i.e., moves of the disease. If negative, permanent.
75 *
76 * value is the counter for maxhp, it starts at maxhp and drops...
77 *
78 * dam if positive, it is straight damage. if negative, a %-age.
79 *
80 * maxgrace how long in "disease moves" the disease lasts in the host, if negative,
81 * permanent until cured.
82 *
83 * food if negative, disease is permanent. otherwise, decreases at <speed>,
84 * disease goes away at food=0, set to "maxgrace" on infection.
85 *
86 * speed is the speed of the disease, how fast "disease moves" occur.
87 *
88 * last_sp is the lethargy imposed on the player by the disease. A lethargy
89 * of "1" reduces the players speed to 1% of its normal value.
90 *
91 * maxsp how much mana is sapped per "disease move". if negative, a %-age is
92 * taken.
93 *
94 * ac every "disease move" the severity of the symptoms are increased by
95 * ac/100. (severity = 1 + (accumlated_progression)/100)
96 *
97 * last_eat increases food usage if negative.
98 *
99 *
100 *
101 * For SYMPTOMS:
102 *
103 * Stats modify stats
104 * hp modify regen
105 * value progression counter (multiplier = value/100)
106 * food modify food use (from last_eat in DISEASE)
107 * maxsp suck mana ( as noted for DISEASE)
108 * last_sp Lethargy
109 * msg What to say
110 * speed speed of movement, from DISEASE
111 */
112
113 #include "global.h"
114
115 #include <assert.h>
116 #include <stdlib.h>
117 #include <string.h>
118
119 #include "living.h"
120 #include "object.h"
121 #include "skills.h"
122 #include "sounds.h"
123 #include "spells.h"
124 #include "sproto.h"
125
126 static void remove_symptoms(object *disease);
127 static object *find_symptom(object *disease);
128 static void check_infection(object *disease);
129 static void do_symptoms(object *disease);
130 static void grant_immunity(object *disease);
131
132
133
134 /* IMPLEMENTATION NOTES
135
136 Diseases may be contageous. They are objects which exist in a player's
137 inventory. They themselves do nothing, except modify Symptoms, or
138 spread to other live objects. Symptoms are what actually damage the player:
139 these are their own object. */
140
141 /**
142 * Check if victim is susceptible to disease. Does not check for immunity.
143 *
144 * @param victim
145 * potential victim.
146 * @param disease
147 * disease to check.
148 * @retval 1
149 * victim can be infected
150 * @retval 0
151 * victim doesn't care for the disease.
152 */
153 static int is_susceptible_to_disease(object *victim, object *disease) {
154 /* Non living and DMs are immune. */
155 if (!QUERY_FLAG(victim, FLAG_ALIVE) || QUERY_FLAG(victim, FLAG_WIZ))
156 return 0;
157
158 if (strstr(disease->race, "*") && !QUERY_FLAG(victim, FLAG_UNDEAD))
159 return 1;
160
161 if ((disease->race == undead_name) && QUERY_FLAG(victim, FLAG_UNDEAD))
162 return 1;
163
164 if ((victim->race && strstr(disease->race, victim->race))
165 || strstr(disease->race, victim->name))
166 return 1;
167
168 return 0;
169 }
170
171 /**
172 * Ticks the clock for disease: infect, aggravate symptoms, ...
173 * @param disease
174 * disease to move. Can be removed during processing.
175 * @retval 1
176 * if disease was removed.
177 * @retval 0
178 * disease just moved.
179 */
180 int move_disease(object *disease) {
181 /* first task is to determine if the disease is inside or outside of someone.
182 * If outside, we decrement 'value' until we're gone.
183 */
184
185 /* DMs don't infect, and don't suffer either. */
186 if (disease->env && QUERY_FLAG(disease->env, FLAG_WIZ))
187 return 0;
188
189 if (disease->env == NULL) { /* we're outside of someone */
190 if (disease->stats.maxhp > 0)
191 disease->value--;
192 if (disease->value == 0) {
193 object_remove(disease);
194 object_free_drop_inventory(disease);
195 return 1;
196 }
197 } else {
198 /* if we're inside a person, have the disease run its course */
199 /* negative foods denote "perpetual" diseases. */
200 if (disease->stats.food > 0) {
201 disease->stats.food--;
202 if (disease->stats.food == 0) {
203 remove_symptoms(disease); /* remove the symptoms of this disease */
204 grant_immunity(disease);
205 object_remove(disease);
206 object_free_drop_inventory(disease);
207 return 1;
208 }
209 }
210 }
211 /* check to see if we infect others */
212 check_infection(disease);
213
214 /* impose or modify the symptoms of the disease */
215 if (disease->env && is_susceptible_to_disease(disease->env, disease))
216 do_symptoms(disease);
217
218 return 0;
219 }
220
221 /**
222 * Remove any symptoms of disease.
223 *
224 * Modified by MSW 2003-03-28 do try to find all the symptom the
225 * player may have - I think through some odd interactoins with
226 * disease level and player level and whatnot, a player could get
227 * more than one symtpom to a disease.
228 *
229 * @param disease
230 * disease to remove. Must be in a living object.
231 */
232 static void remove_symptoms(object *disease) {
233 object *symptom, *victim = NULL;
234
235 assert(disease != NULL);
236
237 while ((symptom = find_symptom(disease)) != NULL) {
238 if (!victim)
239 victim = symptom->env;
240 object_remove(symptom);
241 object_free_drop_inventory(symptom);
242 }
243 if (victim)
244 fix_object(victim);
245 }
246
247 /**
248 * Find a symptom for a disease in disease's env.
249 *
250 * @param disease
251 * disease to search symptom of. Must be in another object.
252 * @return
253 * matching symptom object, NULL if none found.
254 */
255 static object *find_symptom(object *disease) {
256 assert(disease->env != NULL);
257
258 /* check the inventory for symptoms */
259 return object_find_by_type_and_name(disease->env, SYMPTOM, disease->name);
260 }
261
262 /**
263 * Searches around for more victims to infect.
264 *
265 * @param disease
266 * disease infecting. Can be either on a map or inside another object.
267 */
268 static void check_infection(object *disease) {
269 int x, y, range, mflags;
270 mapstruct *map, *map2;
271 int16_t i, j, i2, j2;
272
273 range = abs(disease->magic);
274 if (disease->env) {
275 x = disease->env->x;
276 y = disease->env->y;
277 map = disease->env->map;
278 } else {
279 x = disease->x;
280 y = disease->y;
281 map = disease->map;
282 }
283
284 if (map == NULL)
285 return;
286 for (i = x-range; i <= x+range; i++) {
287 for (j = y-range; j <= y+range; j++) {
288 mflags = get_map_flags(map, &map2, i, j, &i2, &j2);
289 if (!(mflags&P_OUT_OF_MAP) && (mflags&P_IS_ALIVE)) {
290 FOR_MAP_PREPARE(map2, i2, j2, tmp)
291 infect_object(tmp, disease, 0);
292 FOR_MAP_FINISH();
293 }
294 }
295 }
296 }
297
298 /**
299 * Try to infect something with a disease. Rules:
300 * - objects with immunity aren't infectable.
301 * - objects already infected aren't infectable.
302 * - dead objects aren't infectable.
303 * - undead objects are infectible only if specifically named.
304 *
305 * @param victim
306 * potential victim to infect.
307 * @param disease
308 * what could infect.
309 * @param force
310 * don't do a random check for infection. Other checks (susceptible to disease,
311 * not immune, and so on) are still done.
312 * @retval 0
313 * victim wasn't infected.
314 * @retval 1
315 * victim was infected.
316 */
317 int infect_object(object *victim, object *disease, int force) {
318 object *tmp;
319 object *new_disease;
320 object *owner;
321
322 victim = HEAD(victim);
323
324 /* don't infect inanimate objects */
325 if (!QUERY_FLAG(victim, FLAG_MONSTER) && !(victim->type == PLAYER))
326 return 0;
327
328 /* check and see if victim can catch disease: diseases
329 * are specific
330 */
331 if (!is_susceptible_to_disease(victim, disease))
332 return 0;
333
334 /* If disease is on battleground, only infect other victims on battleground.
335 Not checking results in spectators being infected, which could lead to PK. */
336 if ((disease->map && op_on_battleground(disease, NULL, NULL, NULL))
337 || (disease->env && op_on_battleground(disease->env, NULL, NULL, NULL)))
338 if (!op_on_battleground(victim, NULL, NULL, NULL))
339 return 0;
340
341 /* roll the dice on infection before doing the inventory check! */
342 if (!force && (random_roll(0, 126, victim, PREFER_HIGH) >= disease->stats.wc))
343 return 0;
344
345 /* do an immunity check */
346
347 /* There used to (IMO) be a flaw in the below - it used to be the case
348 * that if level check was done for both immunity and disease. This could
349 * result in a person with multiple afflictions of the same disease
350 * (eg, level 1 cold, level 2 cold, level 3 cold, etc), as long as
351 * they were cast in that same order. Instead, change it so that
352 * if you diseased, you can't get diseased more.
353 */
354 tmp = object_find_by_type_and_name(HEAD(victim), SIGN, disease->name);
355 if (tmp != NULL && tmp->level >= disease->level)
356 return 0; /*Immune! */
357 tmp = object_find_by_type_and_name(HEAD(victim), DISEASE, disease->name);
358 if (tmp != NULL)
359 return 0; /* already diseased; XXX: increase disease level? */
360
361 /* If we've gotten this far, go ahead and infect the victim. */
362 new_disease = object_new();
363 object_copy(disease, new_disease);
364 new_disease->stats.food = disease->stats.maxgrace;
365 new_disease->value = disease->stats.maxhp;
366 new_disease->stats.wc -= disease->last_grace; /* self-limiting factor */
367
368 /* Unfortunately, object_set_owner does the wrong thing to the skills pointers
369 * resulting in exp going into the owners *current *chosen skill.
370 */
371 owner = object_get_owner(disease);
372 if (owner) {
373 object_set_owner(new_disease, owner);
374
375 /* Only need to update skill if different */
376 if (new_disease->skill != disease->skill) {
377 if (new_disease->skill)
378 free_string(new_disease->skill);
379 if (disease->skill)
380 new_disease->skill = add_refcount(disease->skill);
381 }
382 } else { /* for diseases which are passed by hitting, set owner and praying skill*/
383 if (disease->env && disease->env->type == PLAYER) {
384 object *player = disease->env;
385
386 object_set_owner(new_disease, player);
387 /* the skill pointer for these diseases should already be set up -
388 * hardcoding in 'praying' is not the right approach.
389 */
390 }
391 }
392
393 object_insert_in_ob(new_disease, victim);
394 /* This appears to be a horrible case of overloading 'NO_PASS'
395 * for meaning in the diseases.
396 */
397 new_disease->move_block = 0;
398 owner = object_get_owner(new_disease);
399 if (owner && owner->type == PLAYER) {
400 char buf[128];
401
402 /* if the disease has a title, it has a special infection message
403 * This messages is printed in the form MESSAGE victim
404 */
405 if (new_disease->title)
406 snprintf(buf, sizeof(buf), "%s %s!!", disease->title, victim->name);
407 else
408 snprintf(buf, sizeof(buf), "You infect %s with your disease, %s!", victim->name, new_disease->name);
409
410 if (victim->type == PLAYER)
411 draw_ext_info(NDI_UNIQUE|NDI_RED, 0, owner, MSG_TYPE_ATTACK, MSG_TYPE_ATTACK_DID_HIT,
412 buf);
413 else
414 draw_ext_info(0, 4, owner, MSG_TYPE_ATTACK, MSG_TYPE_ATTACK_DID_HIT,
415 buf);
416 }
417 if (victim->type == PLAYER)
418 draw_ext_info(NDI_UNIQUE|NDI_RED, 0, victim, MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_BAD_EFFECT_START,
419 "You suddenly feel ill.");
420
421 return 1;
422 }
423
424 /**
425 * This function monitors the symptoms caused by the disease (if any),
426 * causes symptoms, and modifies existing symptoms in the case of
427 * existing diseases.
428 *
429 * @param disease
430 * disease acting. Should be in a living object.
431 */
432 static void do_symptoms(object *disease) {
433 object *symptom;
434 object *victim;
435 object *tmp;
436 victim = disease->env;
437
438 /* This is a quick hack - for whatever reason, disease->env will point
439 * back to disease, causing endless loops. Why this happens really needs
440 * to be found, but this should at least prevent the infinite loops.
441 */
442
443 if (victim == NULL || victim == disease)
444 return;/* no-one to inflict symptoms on */
445
446 /* DMs don't suffer from diseases. */
447 if (QUERY_FLAG(victim, FLAG_WIZ))
448 return;
449
450 symptom = find_symptom(disease);
451 if (symptom == NULL) {
452 /* no symptom? need to generate one! */
453 object *new_symptom;
454 int reduce_level = 0;
455
456 /* first check and see if the carrier of the disease is immune. If so, no symptoms! */
457 if (!is_susceptible_to_disease(victim, disease))
458 return;
459
460 /* check for an actual immunity */
461 /* do an immunity check */
462 tmp = object_find_by_type_and_name(HEAD(victim), SIGN, disease->name);
463 if (tmp != NULL) {
464 if (tmp->level >= disease->level)
465 return; /*Immune! */
466 /* partially immune */
467 reduce_level = tmp->level;
468 }
469
470 new_symptom = create_archetype(ARCH_SYMPTOM);
471
472 /* Something special done with dam. We want diseases to be more
473 * random in what they'll kill, so we'll make the damage they
474 * do random, note, this has a weird effect with progressive diseases.
475 */
476 if (disease->stats.dam != 0) {
477 int dam = disease->stats.dam;
478
479 /* reduce the damage, on average, 50%, and making things random. */
480
481 dam = random_roll(1, FABS(dam), victim, PREFER_LOW);
482 if (disease->stats.dam < 0)
483 dam = -dam;
484 new_symptom->stats.dam = dam;
485 }
486
487 new_symptom->stats.maxsp = disease->stats.maxsp;
488 new_symptom->stats.food = new_symptom->stats.maxgrace;
489
490 FREE_AND_COPY(new_symptom->name, disease->name);
491 FREE_AND_COPY(new_symptom->name_pl, disease->name);
492 new_symptom->level = disease->level - reduce_level;
493 new_symptom->speed = disease->speed;
494 new_symptom->value = 0;
495 new_symptom->stats.Str = disease->stats.Str;
496 new_symptom->stats.Dex = disease->stats.Dex;
497 new_symptom->stats.Con = disease->stats.Con;
498 new_symptom->stats.Wis = disease->stats.Wis;
499 new_symptom->stats.Int = disease->stats.Int;
500 new_symptom->stats.Pow = disease->stats.Pow;
501 new_symptom->stats.Cha = disease->stats.Cha;
502 new_symptom->stats.sp = disease->stats.sp;
503 new_symptom->stats.food = disease->last_eat;
504 new_symptom->stats.maxsp = disease->stats.maxsp;
505 new_symptom->last_sp = disease->last_sp;
506 new_symptom->stats.exp = 0;
507 new_symptom->stats.hp = disease->stats.hp;
508 object_set_msg(new_symptom, disease->msg);
509 new_symptom->attacktype = disease->attacktype;
510 new_symptom->other_arch = disease->other_arch;
511
512 object_set_owner(new_symptom, object_get_owner(disease));
513 if (new_symptom->skill != disease->skill) {
514 if (new_symptom->skill)
515 free_string(new_symptom->skill);
516 if (disease->skill)
517 new_symptom->skill = add_refcount(disease->skill);
518 }
519 new_symptom->move_block = 0;
520 object_insert_in_ob(new_symptom, victim);
521 return;
522 }
523
524 /* now deal with progressing diseases: we increase the debility
525 * caused by the symptoms.
526 */
527
528 if (disease->stats.ac != 0) {
529 float scale;
530 int i;
531 int8_t cur_stat;
532
533 symptom->value += disease->stats.ac;
534 scale = 1.0+symptom->value/100.0;
535 /* now rescale all the debilities */
536 for (i = 0; i<NUM_STATS; i++) {
537 cur_stat = get_attr_value(&disease->stats, i);
538 cur_stat = (int)(scale * cur_stat);
539 set_attr_value(&symptom->stats, i, cur_stat);
540 }
541 check_stat_bounds(&symptom->stats, -settings.max_stat, settings.max_stat);
542
543 symptom->stats.dam = (int)(scale*disease->stats.dam);
544 symptom->stats.sp = (int)(scale*disease->stats.sp);
545 symptom->stats.food = (int)(scale*disease->last_eat);
546 symptom->stats.maxsp = (int)(scale*disease->stats.maxsp);
547 symptom->last_sp = (int)(scale*disease->last_sp);
548 symptom->stats.exp = 0;
549 symptom->stats.hp = (int)(scale*disease->stats.hp);
550 object_set_msg(symptom, disease->msg);
551 symptom->attacktype = disease->attacktype;
552 symptom->other_arch = disease->other_arch;
553 }
554 SET_FLAG(symptom, FLAG_APPLIED);
555 fix_object(victim);
556 }
557
558 /**
559 * Grants immunity to a disease.
560 *
561 * @param disease
562 * disease to grant immunity to. Must be in another object.
563 */
564 static void grant_immunity(object *disease) {
565 object *immunity;
566
567 /* Don't give immunity to this disease if last_heal is set. */
568 if (disease->last_heal)
569 return;
570
571 assert(disease->env != NULL);
572
573 /* first, search for an immunity of the same name */
574 immunity = object_find_by_type_and_name(disease->env, SIGN, disease->name);
575 if (immunity != NULL) {
576 immunity->level = disease->level;
577 return; /* just update the existing immunity. */
578 }
579 immunity = create_archetype("immunity");
580 immunity->name = add_string(disease->name);
581 immunity->level = disease->level;
582 immunity->move_block = 0;
583 object_insert_in_ob(immunity, disease->env);
584 }
585
586 /**
587 * Make the symptom do the nasty things it does.
588 *
589 * @param symptom
590 * symptom to move.
591 */
592 void move_symptom(object *symptom) {
593 object *victim = symptom->env;
594 object *new_ob;
595 int sp_reduce;
596 tag_t tag = symptom->count;
597
598 if (victim == NULL || victim->map == NULL) { /* outside a monster/player, die immediately */
599 object_remove(symptom);
600 object_free_drop_inventory(symptom);
601 return;
602 }
603
604 if (symptom->stats.dam > 0)
605 hit_player(victim, symptom->stats.dam, symptom, symptom->attacktype, 1);
606 else
607 hit_player(victim, MAX(1, -victim->stats.maxhp*symptom->stats.dam/100.0), symptom, symptom->attacktype, 1);
608
609 /* In most cases, if the victim has been freed, the logic that
610 * does that will also free the symptom, so check for that.
611 */
612 if (QUERY_FLAG(victim, FLAG_FREED)) {
613 if (!object_was_destroyed(symptom, tag)) {
614 object_remove(symptom);
615 object_free_drop_inventory(symptom);
616 }
617 return;
618 }
619
620 if (symptom->stats.maxsp > 0)
621 sp_reduce = symptom->stats.maxsp;
622 else
623 sp_reduce = MAX(1, victim->stats.maxsp*symptom->stats.maxsp/100.0);
624 victim->stats.sp = MAX(0, victim->stats.sp-sp_reduce);
625
626 /* create the symptom "other arch" object and drop it here
627 * under every part of the monster
628 * The victim may well have died.
629 */
630
631 if (symptom->other_arch) {
632 object *tmp;
633
634 for (tmp = HEAD(victim); tmp != NULL; tmp = tmp->more) {
635 char name[MAX_BUF];
636
637 new_ob = arch_to_object(symptom->other_arch);
638 snprintf(name, sizeof(name), "%s's %s", victim->name, new_ob->name);
639 FREE_AND_COPY(new_ob->name, name);
640 if (new_ob->name_pl != NULL) {
641 snprintf(name, sizeof(name), "%s's %s", victim->name, new_ob->name_pl);
642 FREE_AND_COPY(new_ob->name_pl, name);
643 }
644 object_insert_in_map_at(new_ob, tmp->map, victim, 0, tmp->x, tmp->y);
645 }
646 }
647 if (!symptom->msg) {
648 LOG(llevError, "BUG: move_symptom(): symptom %d (%s) without message!\n", symptom->count, symptom->name);
649 return;
650 }
651 draw_ext_info(NDI_UNIQUE|NDI_RED, 0, victim, MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_BAD_EFFECT_START,
652 symptom->msg);
653 }
654
655 /**
656 * Possibly infect due to direct physical contact i.e., AT_PHYSICAL.
657 *
658 * @param victim
659 * potential victim.
660 * @param hitter
661 * who is hitting.
662 */
663 void check_physically_infect(object *victim, object *hitter) {
664 /* search for diseases, give every disease a chance to infect */
665 FOR_INV_PREPARE(hitter, walk)
666 if (walk->type == DISEASE)
667 infect_object(victim, walk, 0);
668 FOR_INV_FINISH();
669 }
670
671 /**
672 * Do the cure disease stuff, from the spell "cure disease".
673 * @param sufferer
674 * who is getting cured.
675 * @param caster
676 * spell object used for curing. If NULL all diseases are removed, else only those of lower level than
677 * caster or randomly chosen.
678 * @param skill
679 * skill to give experience to, can be NULL.
680 * @retval 0
681 * no disease was cured.
682 * @retval 1
683 * at least one disease was cured.
684 */
685 int cure_disease(object *sufferer, object *caster, sstring skill) {
686 int casting_level;
687 int cure = 0;
688
689 if (caster)
690 casting_level = caster->level;
691 else
692 casting_level = 1000; /* if null caster, CURE all. */
693
694 FOR_INV_PREPARE(sufferer, disease) {
695 if (disease->type == DISEASE && !QUERY_FLAG(disease, FLAG_STARTEQUIP)) {
696 /* attempt to cure this disease. God-given diseases are given by the god, so don't remove them */
697 /* If caster lvel is higher than disease level, cure chance
698 * is automatic. If lower, then the chance is basically
699 * 1 in level_diff - if there is a 5 level difference, chance
700 * is 1 in 5.
701 */
702 if ((casting_level >= disease->level)
703 || (!(random_roll(0, (disease->level-casting_level-1), caster, PREFER_LOW)))) {
704 remove_symptoms(disease);
705 object_remove(disease);
706 cure = 1;
707 if (caster)
708 change_exp(caster, disease->stats.exp, skill, 0);
709 object_free_drop_inventory(disease);
710 }
711 }
712 } FOR_INV_FINISH();
713 if (cure) {
714 /* Only draw these messages once */
715 if (caster)
716 draw_ext_info_format(NDI_UNIQUE, 0, caster, MSG_TYPE_SPELL, MSG_TYPE_SPELL_HEAL,
717 "You cure a disease!");
718
719 draw_ext_info(NDI_UNIQUE, 0, sufferer, MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_BAD_EFFECT_END,
720 "You no longer feel diseased.");
721 }
722 return cure;
723 }