… | |
… | |
44 | dam^ Damage How much damage it does (%?). |
44 | dam^ Damage How much damage it does (%?). |
45 | maxgrace+ Duration How long before the disease is naturally cured. |
45 | maxgrace+ Duration How long before the disease is naturally cured. |
46 | food DurCount Counter for Duration |
46 | food DurCount Counter for Duration |
47 | |
47 | |
48 | speed Speed How often the disease moves. |
48 | speed Speed How often the disease moves. |
49 | last_sp^ Lethargy Percentage of max speed--10 = 10% speed. |
49 | last_sp^ Lethargy Percentage of max speed. 10 = 10% speed. |
50 | |
50 | |
51 | maxsp^ Mana deplete Saps mana. |
51 | maxsp^ Mana deplete Saps mana. |
52 | ac^ Progressiveness How the diseases increases in severity. |
52 | ac^ Progressiveness How the diseases increases in severity. |
53 | last_eat*^ Deplete food saps food if negative |
53 | last_eat*^ Deplete food saps food if negative |
54 | last_heal GrantImmunity If nonzero, disease does NOT grant immunity |
54 | last_heal GrantImmunity If nonzero, disease does NOT grant immunity |
… | |
… | |
232 | |
232 | |
233 | /* argument is a disease */ |
233 | /* argument is a disease */ |
234 | object * |
234 | object * |
235 | find_symptom (object *disease) |
235 | find_symptom (object *disease) |
236 | { |
236 | { |
237 | object *walk; |
|
|
238 | |
|
|
239 | /* check the inventory for symptoms */ |
237 | /* check the inventory for symptoms */ |
240 | for (walk = disease->env->inv; walk; walk = walk->below) |
238 | for (object *walk = disease->env->inv; walk; walk = walk->below) |
241 | if (walk->name == disease->name && walk->type == SYMPTOM) |
239 | if (walk->name == disease->name && walk->type == SYMPTOM) |
242 | return walk; |
240 | return walk; |
243 | |
241 | |
244 | return NULL; |
242 | return NULL; |
245 | } |
243 | } |
… | |
… | |
309 | /* roll the dice on infection before doing the inventory check! */ |
307 | /* roll the dice on infection before doing the inventory check! */ |
310 | if (!force && (random_roll (0, 126, victim, PREFER_HIGH) >= disease->stats.wc)) |
308 | if (!force && (random_roll (0, 126, victim, PREFER_HIGH) >= disease->stats.wc)) |
311 | return 0; |
309 | return 0; |
312 | |
310 | |
313 | /* do an immunity check */ |
311 | /* do an immunity check */ |
314 | if (victim->head) |
|
|
315 | tmp = victim->head->inv; |
|
|
316 | else |
|
|
317 | tmp = victim->inv; |
|
|
318 | |
312 | |
319 | /* There used to (IMO) be a flaw in the below - it used to be the case |
313 | /* There used to (IMO) be a flaw in the below - it used to be the case |
320 | * that if level check was done for both immunity and disease. This could |
314 | * that if level check was done for both immunity and disease. This could |
321 | * result in a person with multiple afflictions of the same disease |
315 | * result in a person with multiple afflictions of the same disease |
322 | * (eg, level 1 cold, level 2 cold, level 3 cold, etc), as long as |
316 | * (eg, level 1 cold, level 2 cold, level 3 cold, etc), as long as |
323 | * they were cast in that same order. Instead, change it so that |
317 | * they were cast in that same order. Instead, change it so that |
324 | * if you diseased, you can't get diseased more. |
318 | * if you diseased, you can't get diseased more. |
325 | */ |
319 | */ |
326 | |
320 | |
327 | for ( /* tmp initialised in if, above */ ; tmp; tmp = tmp->below) |
321 | for (tmp = victim->head_ ()->inv; tmp; tmp = tmp->below) |
328 | { |
|
|
329 | if (tmp->type == SIGN && tmp->name == disease->name && tmp->level >= disease->level) |
322 | if (tmp->type == SIGN && tmp->name == disease->name && tmp->level >= disease->level) |
330 | return 0; /* Immune! */ |
323 | return 0; /* Immune! */ |
331 | else if (tmp->type == DISEASE && tmp->name == disease->name) |
324 | else if (tmp->type == DISEASE && tmp->name == disease->name) |
332 | return 0; /* already diseased */ |
325 | return 0; /* already diseased */ |
333 | } |
|
|
334 | |
326 | |
335 | /* If we've gotten this far, go ahead and infect the victim. */ |
327 | /* If we've gotten this far, go ahead and infect the victim. */ |
|
|
328 | |
336 | new_disease = disease->clone (); |
329 | new_disease = disease->clone (); |
|
|
330 | |
337 | new_disease->stats.food = disease->stats.maxgrace; |
331 | new_disease->stats.food = disease->stats.maxgrace; |
338 | new_disease->value = disease->stats.maxhp; |
332 | new_disease->value = disease->stats.maxhp; |
339 | new_disease->stats.wc -= disease->last_grace; /* self-limiting factor */ |
333 | new_disease->stats.wc -= disease->last_grace; /* self-limiting factor */ |
340 | |
334 | |
341 | /* Unfortunately, set_owner does the wrong thing to the skills pointers |
|
|
342 | * resulting in exp going into the owners *current* chosen skill. |
|
|
343 | */ |
|
|
344 | |
|
|
345 | if (disease->owner) |
|
|
346 | { |
|
|
347 | new_disease->set_owner (disease->owner); |
|
|
348 | |
|
|
349 | /* Only need to update skill if different */ |
|
|
350 | if (new_disease->skill != disease->skill) |
|
|
351 | new_disease->skill = disease->skill; |
|
|
352 | } |
|
|
353 | else |
|
|
354 | { /* for diseases which are passed by hitting, set owner and praying skill */ |
|
|
355 | if (disease->env && disease->env->type == PLAYER) |
|
|
356 | { |
|
|
357 | object *player = disease->env; |
|
|
358 | |
|
|
359 | new_disease->set_owner (player); |
|
|
360 | |
|
|
361 | /* the skill pointer for these diseases should already be set up - |
|
|
362 | * hardcoding in 'praying' is not the right approach. |
|
|
363 | */ |
|
|
364 | } |
|
|
365 | } |
|
|
366 | |
|
|
367 | insert_ob_in_ob (new_disease, victim->head_ ()); |
|
|
368 | /* This appears to be a horrible case of overloading 'NO_PASS' |
335 | /* This appears to be a horrible case of overloading 'NO_PASS' |
369 | * for meaning in the diseases. |
336 | * for meaning in the diseases. |
370 | */ |
337 | */ |
371 | new_disease->move_block = 0; |
338 | new_disease->move_block = 0; |
|
|
339 | |
|
|
340 | // insert before setting the owner |
|
|
341 | victim->head_ ()->insert (new_disease); |
|
|
342 | |
|
|
343 | if (disease->owner) |
|
|
344 | new_disease->set_owner (disease->owner); |
|
|
345 | else if (object *pl = disease->in_player ()) |
|
|
346 | /* for diseases which are passed by hitting, set owner and skill */ |
|
|
347 | new_disease->set_owner (pl); |
|
|
348 | |
372 | if (new_disease->owner && new_disease->owner->type == PLAYER) |
349 | if (new_disease->owner && new_disease->owner->type == PLAYER) |
373 | { |
350 | { |
374 | char buf[128]; |
351 | const char *buf; |
375 | |
352 | |
376 | /* if the disease has a title, it has a special infection message |
353 | /* if the disease has a title, it has a special infection message |
377 | * This messages is printed in the form MESSAGE victim |
354 | * This messages is printed in the form MESSAGE victim |
378 | */ |
355 | */ |
379 | if (new_disease->title) |
356 | if (new_disease->title) |
380 | sprintf (buf, "%s %s!!", &disease->title, &victim->name); |
357 | buf = format ("%s %s!!", &disease->title, &victim->name); |
381 | else |
358 | else |
382 | sprintf (buf, "You infect %s with your disease, %s!", &victim->name, &new_disease->name); |
359 | buf = format ("You infect %s with your disease, %s!", &victim->name, &new_disease->name); |
383 | |
360 | |
384 | if (victim->type == PLAYER) |
361 | if (victim->type == PLAYER) |
385 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, new_disease->owner, buf); |
362 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, new_disease->owner, buf); |
386 | else |
363 | else |
387 | new_draw_info (0, 4, new_disease->owner, buf); |
364 | new_draw_info (0, 4, new_disease->owner, buf); |
… | |
… | |
389 | |
366 | |
390 | if (victim->type == PLAYER) |
367 | if (victim->type == PLAYER) |
391 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, victim, "You suddenly feel ill."); |
368 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, victim, "You suddenly feel ill."); |
392 | |
369 | |
393 | return 1; |
370 | return 1; |
394 | |
|
|
395 | } |
371 | } |
396 | |
372 | |
397 | /* this function monitors the symptoms caused by the disease (if any), |
373 | /* this function monitors the symptoms caused by the disease (if any), |
398 | causes symptoms, and modifies existing symptoms in the case of |
374 | causes symptoms, and modifies existing symptoms in the case of |
399 | existing diseases. */ |
375 | existing diseases. */ |
… | |
… | |
422 | |
398 | |
423 | symptom = find_symptom (disease); |
399 | symptom = find_symptom (disease); |
424 | if (!symptom) |
400 | if (!symptom) |
425 | { |
401 | { |
426 | /* no symptom? need to generate one! */ |
402 | /* no symptom? need to generate one! */ |
427 | object *new_symptom; |
|
|
428 | |
403 | |
429 | /* first check and see if the carrier of the disease is immune. If so, no symptoms! */ |
404 | /* first check and see if the carrier of the disease is immune. If so, no symptoms! */ |
430 | if (!is_susceptible_to_disease (victim, disease)) |
405 | if (!is_susceptible_to_disease (victim, disease)) |
431 | return 0; |
406 | return 0; |
432 | |
407 | |
433 | /* check for an actual immunity */ |
408 | /* check for an actual immunity */ |
434 | /* do an immunity check */ |
409 | /* do an immunity check */ |
435 | if (victim->head) |
410 | for (tmp = victim->head_ ()->inv; tmp; tmp = tmp->below) |
436 | tmp = victim->head->inv; |
|
|
437 | else |
|
|
438 | tmp = victim->inv; |
|
|
439 | |
|
|
440 | for ( /* tmp initialised in if, above */ ; tmp; tmp = tmp->below) |
|
|
441 | if (tmp->type == SIGN) /* possibly an immunity, or diseased */ |
411 | if (tmp->type == SIGN) /* possibly an immunity, or diseased */ |
442 | if (tmp->name == disease->name && tmp->level >= disease->level) |
412 | if (tmp->name == disease->name && tmp->level >= disease->level) |
443 | return 0; /*Immune! */ |
413 | return 0; /* Immune! */ |
444 | |
414 | |
445 | new_symptom = get_archetype ("symptom"); |
415 | object *new_symptom = get_archetype ("symptom"); |
446 | |
416 | |
447 | /* Something special done with dam. We want diseases to be more |
417 | /* Something special done with dam. We want diseases to be more |
448 | * random in what they'll kill, so we'll make the damage they |
418 | * random in what they'll kill, so we'll make the damage they |
449 | * do random, note, this has a weird effect with progressive diseases. |
419 | * do random, note, this has a weird effect with progressive diseases. |
450 | */ |
420 | */ |
451 | if (disease->stats.dam != 0) |
421 | if (disease->stats.dam) |
452 | { |
422 | { |
453 | int dam = disease->stats.dam; |
423 | int dam = disease->stats.dam; |
454 | |
424 | |
455 | /* reduce the damage, on average, 50%, and making things random. */ |
425 | /* reduce the damage, on average, 50%, and making things random. */ |
456 | |
426 | |
… | |
… | |
480 | new_symptom->stats.exp = 0; |
450 | new_symptom->stats.exp = 0; |
481 | new_symptom->stats.hp = disease->stats.hp; |
451 | new_symptom->stats.hp = disease->stats.hp; |
482 | new_symptom->msg = disease->msg; |
452 | new_symptom->msg = disease->msg; |
483 | new_symptom->attacktype = disease->attacktype; |
453 | new_symptom->attacktype = disease->attacktype; |
484 | new_symptom->other_arch = disease->other_arch; |
454 | new_symptom->other_arch = disease->other_arch; |
|
|
455 | new_symptom->skill = disease->skill; |
485 | |
456 | |
|
|
457 | new_symptom->move_block = 0; |
|
|
458 | |
|
|
459 | victim->head_ ()->insert (new_symptom); |
|
|
460 | |
|
|
461 | // ste owner last, as insert clears owner |
486 | new_symptom->set_owner (disease->owner); |
462 | new_symptom->set_owner (disease->owner); |
487 | |
463 | |
488 | if (new_symptom->skill != disease->skill) |
|
|
489 | new_symptom->skill = disease->skill; |
|
|
490 | |
|
|
491 | new_symptom->move_block = 0; |
|
|
492 | insert_ob_in_ob (new_symptom, victim); |
|
|
493 | return 1; |
464 | return 1; |
494 | } |
465 | } |
495 | |
466 | |
496 | /* now deal with progressing diseases: we increase the debility |
467 | /* now deal with progressing diseases: we increase the debility |
497 | * caused by the symptoms. |
468 | * caused by the symptoms. |
… | |
… | |
532 | object *walk; |
503 | object *walk; |
533 | |
504 | |
534 | /* Don't give immunity to this disease if last_heal is set. */ |
505 | /* Don't give immunity to this disease if last_heal is set. */ |
535 | if (disease->last_heal) |
506 | if (disease->last_heal) |
536 | return 0; |
507 | return 0; |
|
|
508 | |
537 | /* first, search for an immunity of the same name */ |
509 | /* first, search for an immunity of the same name */ |
538 | for (walk = disease->env->inv; walk; walk = walk->below) |
510 | for (walk = disease->env->inv; walk; walk = walk->below) |
539 | { |
|
|
540 | if (walk->type == 98 && disease->name == walk->name) |
511 | if (walk->type == 98 && disease->name == walk->name) |
541 | { |
512 | { |
542 | walk->level = disease->level; |
513 | walk->level = disease->level; |
543 | return 1; /* just update the existing immunity. */ |
514 | return 1; /* just update the existing immunity. */ |
544 | } |
515 | } |
545 | } |
516 | |
546 | immunity = get_archetype ("immunity"); |
517 | immunity = get_archetype ("immunity"); |
|
|
518 | |
547 | immunity->name = disease->name; |
519 | immunity->name = disease->name; |
548 | immunity->level = disease->level; |
520 | immunity->level = disease->level; |
549 | immunity->move_block = 0; |
521 | immunity->move_block = 0; |
|
|
522 | |
550 | insert_ob_in_ob (immunity, disease->env); |
523 | insert_ob_in_ob (immunity, disease->env); |
|
|
524 | |
551 | return 1; |
525 | return 1; |
552 | |
|
|
553 | } |
526 | } |
554 | |
527 | |
555 | |
528 | |
556 | /* make the symptom do the nasty things it does */ |
529 | /* make the symptom do the nasty things it does */ |
557 | |
530 | |
… | |
… | |
575 | |
548 | |
576 | if (symptom->stats.maxsp > 0) |
549 | if (symptom->stats.maxsp > 0) |
577 | sp_reduce = symptom->stats.maxsp; |
550 | sp_reduce = symptom->stats.maxsp; |
578 | else |
551 | else |
579 | sp_reduce = (int) MAX (1, victim->stats.maxsp * symptom->stats.maxsp / 100.0); |
552 | sp_reduce = (int) MAX (1, victim->stats.maxsp * symptom->stats.maxsp / 100.0); |
|
|
553 | |
580 | victim->stats.sp = MAX (0, victim->stats.sp - sp_reduce); |
554 | victim->stats.sp = MAX (0, victim->stats.sp - sp_reduce); |
581 | |
555 | |
582 | /* create the symptom "other arch" object and drop it here |
556 | /* create the symptom "other arch" object and drop it here |
583 | * under every part of the monster |
557 | * under every part of the monster |
584 | * The victim may well have died. |
558 | * The victim may well have died. |
585 | */ |
559 | */ |
586 | |
|
|
587 | if (victim->map == NULL) |
560 | if (victim->map) |
588 | return 0; |
561 | return 0; |
|
|
562 | |
589 | if (symptom->other_arch) |
563 | if (symptom->other_arch) |
590 | { |
564 | for (object *tmp = victim->head_ (); tmp; tmp = tmp->more) |
591 | object *tmp; |
|
|
592 | |
|
|
593 | tmp = victim; |
|
|
594 | if (tmp->head != NULL) |
|
|
595 | tmp = tmp->head; |
|
|
596 | for ( /*tmp initialised above */ ; tmp != NULL; tmp = tmp->more) |
|
|
597 | { |
565 | { |
598 | new_ob = arch_to_object (symptom->other_arch); |
566 | new_ob = arch_to_object (symptom->other_arch); |
599 | new_ob->x = tmp->x; |
567 | new_ob->x = tmp->x; |
600 | new_ob->y = tmp->y; |
568 | new_ob->y = tmp->y; |
601 | new_ob->map = victim->map; |
569 | new_ob->map = victim->map; |
602 | insert_ob_in_map (new_ob, victim->map, victim, 0); |
570 | insert_ob_in_map (new_ob, victim->map, victim, 0); |
603 | } |
571 | } |
604 | } |
572 | |
605 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, victim, symptom->msg); |
573 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, victim, symptom->msg); |
606 | |
574 | |
607 | return 1; |
575 | return 1; |
608 | } |
576 | } |
609 | |
577 | |