… | |
… | |
224 | symptom->destroy (); |
224 | symptom->destroy (); |
225 | } |
225 | } |
226 | |
226 | |
227 | if (victim) |
227 | if (victim) |
228 | victim->update_stats (); |
228 | victim->update_stats (); |
|
|
229 | |
229 | return 0; |
230 | return 0; |
230 | } |
231 | } |
231 | |
232 | |
232 | /* argument is a disease */ |
233 | /* argument is a disease */ |
233 | object * |
234 | object * |
… | |
… | |
237 | |
238 | |
238 | /* check the inventory for symptoms */ |
239 | /* check the inventory for symptoms */ |
239 | for (walk = disease->env->inv; walk; walk = walk->below) |
240 | for (walk = disease->env->inv; walk; walk = walk->below) |
240 | if (walk->name == disease->name && walk->type == SYMPTOM) |
241 | if (walk->name == disease->name && walk->type == SYMPTOM) |
241 | return walk; |
242 | return walk; |
|
|
243 | |
242 | return NULL; |
244 | return NULL; |
243 | } |
245 | } |
244 | |
246 | |
245 | /* searches around for more victims to infect */ |
247 | /* searches around for more victims to infect */ |
246 | int |
248 | int |
… | |
… | |
383 | if (victim->type == PLAYER) |
385 | if (victim->type == PLAYER) |
384 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, new_disease->owner, buf); |
386 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, new_disease->owner, buf); |
385 | else |
387 | else |
386 | new_draw_info (0, 4, new_disease->owner, buf); |
388 | new_draw_info (0, 4, new_disease->owner, buf); |
387 | } |
389 | } |
|
|
390 | |
388 | if (victim->type == PLAYER) |
391 | if (victim->type == PLAYER) |
389 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, victim, "You suddenly feel ill."); |
392 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, victim, "You suddenly feel ill."); |
390 | |
393 | |
391 | return 1; |
394 | return 1; |
392 | |
395 | |
393 | } |
396 | } |
394 | |
|
|
395 | |
|
|
396 | |
397 | |
397 | /* this function monitors the symptoms caused by the disease (if any), |
398 | /* this function monitors the symptoms caused by the disease (if any), |
398 | causes symptoms, and modifies existing symptoms in the case of |
399 | causes symptoms, and modifies existing symptoms in the case of |
399 | existing diseases. */ |
400 | existing diseases. */ |
400 | |
|
|
401 | int |
401 | int |
402 | do_symptoms (object *disease) |
402 | do_symptoms (object *disease) |
403 | { |
403 | { |
404 | object *symptom; |
404 | object *symptom; |
405 | object *victim; |
405 | object *victim; |
406 | object *tmp; |
406 | object *tmp; |
407 | |
407 | |
408 | victim = disease->env; |
408 | victim = disease->env; |
|
|
409 | |
|
|
410 | if (!victim) |
|
|
411 | return 0; /* no-one to inflict symptoms on */ |
409 | |
412 | |
410 | /* This is a quick hack - for whatever reason, disease->env will point |
413 | /* This is a quick hack - for whatever reason, disease->env will point |
411 | * back to disease, causing endless loops. Why this happens really needs |
414 | * back to disease, causing endless loops. Why this happens really needs |
412 | * to be found, but this should at least prevent the infinite loops. |
415 | * to be found, but this should at least prevent the infinite loops. |
413 | */ |
416 | */ |
414 | |
417 | //TODO: should no longer be the case, monitor, and remove |
415 | if (victim == NULL || victim == disease) |
418 | if (victim == disease) |
416 | return 0; /* no-one to inflict symptoms on */ |
419 | { |
|
|
420 | LOG (llevError | logBacktrace, "%s: disease->env points to itself", disease->debug_desc ()); |
|
|
421 | return 0; |
|
|
422 | } |
417 | |
423 | |
418 | symptom = find_symptom (disease); |
424 | symptom = find_symptom (disease); |
419 | if (symptom == NULL) |
425 | if (!symptom) |
420 | { |
426 | { |
421 | /* no symptom? need to generate one! */ |
427 | /* no symptom? need to generate one! */ |
422 | object *new_symptom; |
428 | object *new_symptom; |
423 | |
429 | |
424 | /* first check and see if the carrier of the disease is immune. If so, no symptoms! */ |
430 | /* first check and see if the carrier of the disease is immune. If so, no symptoms! */ |
… | |
… | |
431 | tmp = victim->head->inv; |
437 | tmp = victim->head->inv; |
432 | else |
438 | else |
433 | tmp = victim->inv; |
439 | tmp = victim->inv; |
434 | |
440 | |
435 | for ( /* tmp initialised in if, above */ ; tmp; tmp = tmp->below) |
441 | for ( /* tmp initialised in if, above */ ; tmp; tmp = tmp->below) |
436 | { |
|
|
437 | if (tmp->type == SIGN) /* possibly an immunity, or diseased */ |
442 | if (tmp->type == SIGN) /* possibly an immunity, or diseased */ |
438 | if (tmp->name == disease->name && tmp->level >= disease->level) |
443 | if (tmp->name == disease->name && tmp->level >= disease->level) |
439 | return 0; /*Immune! */ |
444 | return 0; /*Immune! */ |
440 | } |
|
|
441 | |
445 | |
442 | new_symptom = get_archetype ("symptom"); |
446 | new_symptom = get_archetype ("symptom"); |
443 | |
447 | |
444 | /* Something special done with dam. We want diseases to be more |
448 | /* Something special done with dam. We want diseases to be more |
445 | * random in what they'll kill, so we'll make the damage they |
449 | * random in what they'll kill, so we'll make the damage they |
… | |
… | |
452 | /* reduce the damage, on average, 50%, and making things random. */ |
456 | /* reduce the damage, on average, 50%, and making things random. */ |
453 | |
457 | |
454 | dam = random_roll (1, abs (dam), victim, PREFER_LOW); |
458 | dam = random_roll (1, abs (dam), victim, PREFER_LOW); |
455 | if (disease->stats.dam < 0) |
459 | if (disease->stats.dam < 0) |
456 | dam = -dam; |
460 | dam = -dam; |
|
|
461 | |
457 | new_symptom->stats.dam = dam; |
462 | new_symptom->stats.dam = dam; |
458 | } |
463 | } |
459 | |
|
|
460 | |
464 | |
461 | new_symptom->stats.maxsp = disease->stats.maxsp; |
465 | new_symptom->stats.maxsp = disease->stats.maxsp; |
462 | new_symptom->stats.food = new_symptom->stats.maxgrace; |
466 | new_symptom->stats.food = new_symptom->stats.maxgrace; |
463 | |
467 | |
464 | new_symptom->name = new_symptom->name_pl = disease->name; |
468 | new_symptom->name = new_symptom->name_pl = disease->name; |