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,2009 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 it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
… | |
… | |
157 | { |
157 | { |
158 | walk->level = disease->level; |
158 | walk->level = disease->level; |
159 | return 1; /* just update the existing immunity. */ |
159 | return 1; /* just update the existing immunity. */ |
160 | } |
160 | } |
161 | |
161 | |
162 | immunity = get_archetype ("immunity"); |
162 | immunity = get_archetype (shstr_immunity); |
163 | |
163 | |
164 | immunity->name = disease->name; |
164 | immunity->name = disease->name; |
165 | immunity->level = disease->level; |
165 | immunity->level = disease->level; |
166 | immunity->move_block = 0; |
166 | immunity->move_block = 0; |
167 | |
167 | |
… | |
… | |
216 | object *op = disease->outer_env_or_self (); |
216 | object *op = disease->outer_env_or_self (); |
217 | |
217 | |
218 | if (!op->is_on_map ()) |
218 | if (!op->is_on_map ()) |
219 | return 0; |
219 | return 0; |
220 | |
220 | |
|
|
221 | dynbuf buf; |
221 | unordered_mapwalk (op, -range, -range, range, range) |
222 | unordered_mapwalk (buf, op, -range, -range, range, range) |
222 | { |
223 | { |
223 | mapspace &ms = m->at (nx, ny); |
224 | mapspace &ms = m->at (nx, ny); |
224 | |
225 | |
225 | if (ms.flags () & P_IS_ALIVE) |
226 | if (ms.flags () & P_IS_ALIVE) |
226 | for (object *tmp = ms.bot; tmp; tmp = tmp->above) |
227 | for (object *tmp = ms.bot; tmp; tmp = tmp->above) |
… | |
… | |
292 | for (tmp = victim->head_ ()->inv; tmp; tmp = tmp->below) |
293 | for (tmp = victim->head_ ()->inv; tmp; tmp = tmp->below) |
293 | if (tmp->type == SIGN) /* possibly an immunity, or diseased */ |
294 | if (tmp->type == SIGN) /* possibly an immunity, or diseased */ |
294 | if (tmp->name == disease->name && tmp->level >= disease->level) |
295 | if (tmp->name == disease->name && tmp->level >= disease->level) |
295 | return 0; /* Immune! */ |
296 | return 0; /* Immune! */ |
296 | |
297 | |
297 | object *new_symptom = get_archetype ("symptom"); |
298 | object *new_symptom = get_archetype (shstr_symptom); |
298 | |
299 | |
299 | /* Something special done with dam. We want diseases to be more |
300 | /* Something special done with dam. We want diseases to be more |
300 | * 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 |
301 | * do random, note, this has a weird effect with progressive diseases. |
302 | * do random, note, this has a weird effect with progressive diseases. |
302 | */ |
303 | */ |
… | |
… | |
514 | /* make the symptom do the nasty things it does */ |
515 | /* make the symptom do the nasty things it does */ |
515 | int |
516 | int |
516 | move_symptom (object *symptom) |
517 | move_symptom (object *symptom) |
517 | { |
518 | { |
518 | object *victim = symptom->env; |
519 | object *victim = symptom->env; |
519 | object *new_ob; |
|
|
520 | int sp_reduce; |
|
|
521 | |
520 | |
522 | if (!victim || !victim->map) |
521 | if (!victim || !victim->map) |
523 | { /* outside a monster/player, die immediately */ |
522 | { /* outside a monster/player, die immediately */ |
524 | symptom->destroy (); |
523 | symptom->destroy (); |
525 | return 0; |
524 | return 0; |
526 | } |
525 | } |
527 | |
|
|
528 | if (symptom->stats.dam > 0) |
|
|
529 | hit_player (victim, symptom->stats.dam, symptom, symptom->attacktype, 1); |
|
|
530 | else |
|
|
531 | hit_player (victim, max (1, -victim->stats.maxhp * symptom->stats.dam / 100), symptom, symptom->attacktype, 1); |
|
|
532 | |
|
|
533 | if (symptom->stats.maxsp > 0) |
|
|
534 | sp_reduce = symptom->stats.maxsp; |
|
|
535 | else |
|
|
536 | sp_reduce = max (1, victim->stats.maxsp * symptom->stats.maxsp / 100); |
|
|
537 | |
|
|
538 | victim->stats.sp = max (0, victim->stats.sp - sp_reduce); |
|
|
539 | |
526 | |
540 | /* create the symptom "other arch" object and drop it here |
527 | /* create the symptom "other arch" object and drop it here |
541 | * under every part of the monster |
528 | * under every part of the monster |
542 | * The victim may well have died. |
529 | * The victim may well have died. |
543 | */ |
530 | */ |
… | |
… | |
546 | victim->play_sound (symptom->sound); |
533 | victim->play_sound (symptom->sound); |
547 | |
534 | |
548 | if (symptom->other_arch) |
535 | if (symptom->other_arch) |
549 | for (object *tmp = victim->head_ (); tmp; tmp = tmp->more) |
536 | for (object *tmp = victim->head_ (); tmp; tmp = tmp->more) |
550 | { |
537 | { |
551 | new_ob = arch_to_object (symptom->other_arch); |
538 | object *new_ob = symptom->other_arch->instance (); |
552 | new_ob->x = tmp->x; |
539 | new_ob->x = tmp->x; |
553 | new_ob->y = tmp->y; |
540 | new_ob->y = tmp->y; |
554 | new_ob->map = victim->map; |
541 | new_ob->map = victim->map; |
555 | insert_ob_in_map (new_ob, victim->map, victim, 0); |
542 | insert_ob_in_map (new_ob, victim->map, victim, 0); |
556 | } |
543 | } |
557 | } |
544 | } |
558 | |
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 | |
559 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, victim, symptom->msg); |
560 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, victim, symptom->msg); |
560 | |
561 | |
561 | return 1; |
562 | return 1; |
562 | } |
563 | } |
563 | |
564 | |
… | |
… | |
570 | for (object *disease = hitter->inv; disease; disease = disease->below) |
571 | for (object *disease = hitter->inv; disease; disease = disease->below) |
571 | if (disease->type == DISEASE) |
572 | if (disease->type == DISEASE) |
572 | infect_object (victim, disease, 0); |
573 | infect_object (victim, disease, 0); |
573 | |
574 | |
574 | return 1; |
575 | return 1; |
575 | } |
|
|
576 | |
|
|
577 | // find a disease in someone |
|
|
578 | static object * |
|
|
579 | find_disease (object *victim) |
|
|
580 | { |
|
|
581 | for (object *disease = victim->inv; disease; disease = disease->below) |
|
|
582 | if (disease->type == DISEASE) |
|
|
583 | return disease; |
|
|
584 | |
|
|
585 | return 0; |
|
|
586 | } |
576 | } |
587 | |
577 | |
588 | /* do the cure disease stuff, from the spell "cure disease" */ |
578 | /* do the cure disease stuff, from the spell "cure disease" */ |
589 | int |
579 | int |
590 | cure_disease (object *sufferer, object *caster, object *spell) |
580 | cure_disease (object *sufferer, object *caster, object *spell) |
… | |
… | |
628 | } |
618 | } |
629 | |
619 | |
630 | return 1; |
620 | return 1; |
631 | } |
621 | } |
632 | |
622 | |
|
|
623 | #if 0 // unused, but seems interesting |
633 | /* reduces disease progression: reduce_symptoms |
624 | /* reduces disease progression: reduce_symptoms |
634 | * return true if we actually reduce a disease. |
625 | * return true if we actually reduce a disease. |
635 | */ |
626 | */ |
636 | static int |
627 | static int |
637 | reduce_symptoms (object *sufferer, int reduction) |
628 | reduce_symptoms (object *sufferer, int reduction) |
… | |
… | |
657 | if (success) |
648 | if (success) |
658 | 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."); |
659 | |
650 | |
660 | return success; |
651 | return success; |
661 | } |
652 | } |
|
|
653 | #endif |