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,2011,2012 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. |
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, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
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 Affero GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * and the GNU General Public License along with this program. If not, see |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * <http://www.gnu.org/licenses/>. |
20 | * <http://www.gnu.org/licenses/>. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | /* This file contains all the code implementing diseases, |
25 | /* This file contains all the code implementing diseases, |
26 | * except for odds and ends in attack.c and in |
26 | * except for odds and ends in attack.c and in |
27 | * living.c |
27 | * living.c |
28 | */ |
28 | */ |
29 | |
29 | |
30 | /* |
30 | /* |
31 | |
31 | |
… | |
… | |
36 | other_arch Creation object created and dropped when symptom moved. |
36 | other_arch Creation object created and dropped when symptom moved. |
37 | title Message When the "disease" "infects" something, it will |
37 | title Message When the "disease" "infects" something, it will |
38 | print "title victim!!!" to the player who owns |
38 | print "title victim!!!" to the player who owns |
39 | the "disease". |
39 | the "disease". |
40 | wc+ Infectiousness How well the plague spreads person-to-person |
40 | wc+ Infectiousness How well the plague spreads person-to-person |
41 | magic+ Range range of infection |
41 | magic+ Range range of infection |
42 | Stats* Disability What stats are reduced by the disease (str con...) |
42 | Stats* Disability What stats are reduced by the disease (str con...) |
43 | maxhp+ Persistence How long the disease can last OUTSIDE the host. |
43 | maxhp+ Persistence How long the disease can last OUTSIDE the host. |
44 | value TimeLeft Counter for persistence |
44 | value TimeLeft Counter for persistence |
45 | dam^ Damage How much damage it does (%?). |
45 | dam^ Damage How much damage it does (%?). |
46 | maxgrace+ Duration How long before the disease is naturally cured. |
46 | maxgrace+ Duration How long before the disease is naturally cured. |
47 | food DurCount Counter for Duration |
47 | food DurCount Counter for Duration |
48 | |
48 | |
49 | speed Speed How often the disease moves. |
49 | speed Speed How often the disease moves. |
50 | last_sp^ Lethargy Percentage of max speed. 10 = 10% speed. |
50 | last_sp^ Lethargy Percentage of max speed. 10 = 10% speed. |
51 | |
51 | |
52 | maxsp^ Mana deplete Saps mana. |
52 | maxsp^ Mana deplete Saps mana. |
53 | ac^ Progressiveness How the diseases increases in severity. |
53 | ac^ Progressiveness How the diseases increases in severity. |
54 | last_eat*^ Deplete food saps food if negative |
54 | last_eat*^ Deplete food saps food if negative |
55 | last_heal GrantImmunity If nonzero, disease does NOT grant immunity |
55 | last_heal GrantImmunity If nonzero, disease does NOT grant immunity |
56 | when it runs out |
56 | when it runs out |
57 | |
57 | |
58 | exp experience experience awarded when plague cured |
58 | exp experience experience awarded when plague cured |
59 | hp*^ ReduceRegen reduces regeneration of disease-bearer |
59 | hp*^ ReduceRegen reduces regeneration of disease-bearer |
60 | sp*^ ReduceSpRegen reduces spellpoint regeneration |
60 | sp*^ ReduceSpRegen reduces spellpoint regeneration |
61 | |
61 | |
62 | name Name Name of the plague |
62 | name Name Name of the plague |
63 | msg message What the plague says when it strikes. |
63 | msg message What the plague says when it strikes. |
64 | race those affected species/race the plague strikes (* = everything) |
64 | race those affected species/race the plague strikes (* = everything) |
65 | level Plague Level General description of the plague's deadliness |
65 | level Plague Level General description of the plague's deadliness |
66 | armour Attenuation reduction in wc per generation of disease. |
66 | armour Attenuation reduction in wc per generation of disease. |
67 | This builds in a self-limiting factor. |
67 | This builds in a self-limiting factor. |
68 | |
|
|
69 | |
68 | |
70 | Explanations: |
69 | Explanations: |
71 | * means this # should be negative to cause adverse effect. |
70 | * means this # should be negative to cause adverse effect. |
72 | + means that this effect is modulated in spells by ldur |
71 | + means that this effect is modulated in spells by ldur |
73 | ^ means that this effect is modulated in spells by ldam |
72 | ^ means that this effect is modulated in spells by ldam |
… | |
… | |
151 | if (disease->last_heal) |
150 | if (disease->last_heal) |
152 | return 0; |
151 | return 0; |
153 | |
152 | |
154 | /* first, search for an immunity of the same name */ |
153 | /* first, search for an immunity of the same name */ |
155 | for (walk = disease->env->inv; walk; walk = walk->below) |
154 | for (walk = disease->env->inv; walk; walk = walk->below) |
156 | if (walk->type == 98 && disease->name == walk->name) |
155 | if (disease->name == walk->name && walk->is_immunity ()) |
157 | { |
156 | { |
158 | walk->level = disease->level; |
157 | walk->level = disease->level; |
159 | return 1; /* just update the existing immunity. */ |
158 | return 1; /* just update the existing immunity. */ |
160 | } |
159 | } |
161 | |
160 | |
162 | immunity = get_archetype ("immunity"); |
161 | immunity = archetype::get (shstr_immunity); |
163 | |
162 | |
164 | immunity->name = disease->name; |
163 | immunity->name = disease->name; |
165 | immunity->level = disease->level; |
164 | immunity->level = disease->level; |
166 | immunity->move_block = 0; |
165 | immunity->move_block = 0; |
167 | |
166 | |
… | |
… | |
216 | object *op = disease->outer_env_or_self (); |
215 | object *op = disease->outer_env_or_self (); |
217 | |
216 | |
218 | if (!op->is_on_map ()) |
217 | if (!op->is_on_map ()) |
219 | return 0; |
218 | return 0; |
220 | |
219 | |
|
|
220 | dynbuf buf; |
221 | unordered_mapwalk (op, -range, -range, range, range) |
221 | unordered_mapwalk (buf, op, -range, -range, range, range) |
222 | { |
222 | { |
223 | mapspace &ms = m->at (nx, ny); |
223 | mapspace &ms = m->at (nx, ny); |
224 | |
224 | |
225 | if (ms.flags () & P_IS_ALIVE) |
225 | if (ms.flags () & P_IS_ALIVE) |
226 | for (object *tmp = ms.bot; tmp; tmp = tmp->above) |
226 | for (object *tmp = ms.bot; tmp; tmp = tmp->above) |
… | |
… | |
232 | |
232 | |
233 | /* check if victim is susceptible to disease. */ |
233 | /* check if victim is susceptible to disease. */ |
234 | static int |
234 | static int |
235 | is_susceptible_to_disease (object *victim, object *disease) |
235 | is_susceptible_to_disease (object *victim, object *disease) |
236 | { |
236 | { |
237 | if (!QUERY_FLAG (victim, FLAG_ALIVE)) |
237 | if (!victim->flag [FLAG_ALIVE]) |
238 | return 0; |
238 | return 0; |
239 | |
239 | |
240 | if (victim->flag [FLAG_WIZ]) |
240 | if (victim->flag [FLAG_WIZ]) |
241 | return 0; |
241 | return 0; |
242 | |
242 | |
243 | if (disease->race.contains ("*") && !QUERY_FLAG (victim, FLAG_UNDEAD)) |
243 | if (disease->race.contains ("*") && !victim->flag [FLAG_UNDEAD]) |
244 | return 1; |
244 | return 1; |
245 | |
245 | |
246 | if ((disease->race == shstr_undead) && QUERY_FLAG (victim, FLAG_UNDEAD)) |
246 | if ((disease->race == shstr_undead) && victim->flag [FLAG_UNDEAD]) |
247 | return 1; |
247 | return 1; |
248 | |
248 | |
249 | if ((victim->race && disease->race.contains (victim->race)) || disease->race.contains (victim->name)) |
249 | if ((victim->race && disease->race.contains (victim->race)) || disease->race.contains (victim->name)) |
250 | return 1; |
250 | return 1; |
251 | |
251 | |
… | |
… | |
288 | return 0; |
288 | return 0; |
289 | |
289 | |
290 | /* check for an actual immunity */ |
290 | /* check for an actual immunity */ |
291 | /* do an immunity check */ |
291 | /* do an immunity check */ |
292 | for (tmp = victim->head_ ()->inv; tmp; tmp = tmp->below) |
292 | for (tmp = victim->head_ ()->inv; tmp; tmp = tmp->below) |
293 | if (tmp->type == SIGN) /* possibly an immunity, or diseased */ |
293 | if (tmp->name == disease->name && tmp->is_immunity ()) /* possibly an immunity, or diseased */ |
294 | if (tmp->name == disease->name && tmp->level >= disease->level) |
294 | if (tmp->level >= disease->level) |
295 | return 0; /* Immune! */ |
295 | return 0; /* Immune! */ |
296 | |
296 | |
297 | object *new_symptom = get_archetype ("symptom"); |
297 | object *new_symptom = archetype::get (shstr_symptom); |
298 | |
298 | |
299 | /* Something special done with dam. We want diseases to be more |
299 | /* 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 |
300 | * 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. |
301 | * do random, note, this has a weird effect with progressive diseases. |
302 | */ |
302 | */ |
… | |
… | |
317 | new_symptom->stats.food = new_symptom->stats.maxgrace; |
317 | new_symptom->stats.food = new_symptom->stats.maxgrace; |
318 | |
318 | |
319 | new_symptom->name = new_symptom->name_pl = disease->name; |
319 | new_symptom->name = new_symptom->name_pl = disease->name; |
320 | |
320 | |
321 | new_symptom->level = disease->level; |
321 | new_symptom->level = disease->level; |
322 | new_symptom->speed = disease->speed; |
|
|
323 | new_symptom->value = 0; |
322 | new_symptom->value = 0; |
|
|
323 | |
|
|
324 | new_symptom->set_speed (disease->speed); |
324 | |
325 | |
325 | for (int i = 0; i < NUM_STATS; ++i) |
326 | for (int i = 0; i < NUM_STATS; ++i) |
326 | new_symptom->stats.stat (i) = disease->stats.stat (i); |
327 | new_symptom->stats.stat (i) = disease->stats.stat (i); |
327 | |
328 | |
328 | new_symptom->stats.sp = disease->stats.sp; |
329 | new_symptom->stats.sp = disease->stats.sp; |
… | |
… | |
369 | symptom->msg = disease->msg; |
370 | symptom->msg = disease->msg; |
370 | symptom->attacktype = disease->attacktype; |
371 | symptom->attacktype = disease->attacktype; |
371 | symptom->other_arch = disease->other_arch; |
372 | symptom->other_arch = disease->other_arch; |
372 | } |
373 | } |
373 | |
374 | |
374 | SET_FLAG (symptom, FLAG_APPLIED); |
375 | symptom->set_flag (FLAG_APPLIED); |
375 | victim->update_stats (); |
376 | victim->update_stats (); |
376 | |
377 | |
377 | return 1; |
378 | return 1; |
378 | } |
379 | } |
379 | |
380 | |
… | |
… | |
434 | { |
435 | { |
435 | object *tmp; |
436 | object *tmp; |
436 | object *new_disease; |
437 | object *new_disease; |
437 | |
438 | |
438 | /* don't infect inanimate objects */ |
439 | /* don't infect inanimate objects */ |
439 | if (!QUERY_FLAG (victim, FLAG_MONSTER) && !(victim->type == PLAYER)) |
440 | if (!victim->flag [FLAG_MONSTER] && !(victim->type == PLAYER)) |
440 | return 0; |
441 | return 0; |
441 | |
442 | |
442 | /* check and see if victim can catch disease: diseases |
443 | /* check and see if victim can catch disease: diseases |
443 | * are specific |
444 | * are specific |
444 | */ |
445 | */ |
… | |
… | |
458 | * they were cast in that same order. Instead, change it so that |
459 | * they were cast in that same order. Instead, change it so that |
459 | * if you diseased, you can't get diseased more. |
460 | * if you diseased, you can't get diseased more. |
460 | */ |
461 | */ |
461 | |
462 | |
462 | for (tmp = victim->head_ ()->inv; tmp; tmp = tmp->below) |
463 | for (tmp = victim->head_ ()->inv; tmp; tmp = tmp->below) |
463 | if (tmp->type == SIGN && tmp->name == disease->name && tmp->level >= disease->level) |
464 | if (tmp->name == disease->name && tmp->is_immunity () && tmp->level >= disease->level) |
464 | return 0; /* Immune! */ |
465 | return 0; /* Immune! */ |
465 | else if (tmp->type == DISEASE && tmp->name == disease->name) |
466 | else if (tmp->type == DISEASE && tmp->name == disease->name) |
466 | return 0; /* already diseased */ |
467 | return 0; /* already diseased */ |
467 | |
468 | |
468 | /* If we've gotten this far, go ahead and infect the victim. */ |
469 | /* If we've gotten this far, go ahead and infect the victim. */ |
… | |
… | |
484 | if (disease->owner) |
485 | if (disease->owner) |
485 | new_disease->set_owner (disease->owner); |
486 | new_disease->set_owner (disease->owner); |
486 | else if (object *pl = disease->in_player ()) |
487 | else if (object *pl = disease->in_player ()) |
487 | /* for diseases which are passed by hitting, set owner and skill */ |
488 | /* for diseases which are passed by hitting, set owner and skill */ |
488 | new_disease->set_owner (pl); |
489 | new_disease->set_owner (pl); |
|
|
490 | |
|
|
491 | if (INVOKE_OBJECT (INFECT, victim, ARG_OBJECT (disease), ARG_OBJECT (new_disease))) |
|
|
492 | return 1; |
489 | |
493 | |
490 | if (new_disease->owner && new_disease->owner->type == PLAYER) |
494 | if (new_disease->owner && new_disease->owner->type == PLAYER) |
491 | { |
495 | { |
492 | const char *buf; |
496 | const char *buf; |
493 | |
497 | |
… | |
… | |
514 | /* make the symptom do the nasty things it does */ |
518 | /* make the symptom do the nasty things it does */ |
515 | int |
519 | int |
516 | move_symptom (object *symptom) |
520 | move_symptom (object *symptom) |
517 | { |
521 | { |
518 | object *victim = symptom->env; |
522 | object *victim = symptom->env; |
519 | object *new_ob; |
|
|
520 | int sp_reduce; |
|
|
521 | |
523 | |
522 | if (!victim || !victim->map) |
524 | if (!victim || !victim->map) |
523 | { /* outside a monster/player, die immediately */ |
525 | { /* outside a monster/player, die immediately */ |
524 | symptom->destroy (); |
526 | symptom->destroy (); |
525 | return 0; |
527 | return 0; |
526 | } |
528 | } |
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 | |
529 | |
540 | /* create the symptom "other arch" object and drop it here |
530 | /* create the symptom "other arch" object and drop it here |
541 | * under every part of the monster |
531 | * under every part of the monster |
542 | * The victim may well have died. |
532 | * The victim may well have died. |
543 | */ |
533 | */ |
… | |
… | |
546 | victim->play_sound (symptom->sound); |
536 | victim->play_sound (symptom->sound); |
547 | |
537 | |
548 | if (symptom->other_arch) |
538 | if (symptom->other_arch) |
549 | for (object *tmp = victim->head_ (); tmp; tmp = tmp->more) |
539 | for (object *tmp = victim->head_ (); tmp; tmp = tmp->more) |
550 | { |
540 | { |
551 | new_ob = arch_to_object (symptom->other_arch); |
541 | object *new_ob = symptom->other_arch->instance (); |
552 | new_ob->x = tmp->x; |
542 | new_ob->x = tmp->x; |
553 | new_ob->y = tmp->y; |
543 | new_ob->y = tmp->y; |
554 | new_ob->map = victim->map; |
544 | new_ob->map = victim->map; |
555 | insert_ob_in_map (new_ob, victim->map, victim, 0); |
545 | insert_ob_in_map (new_ob, victim->map, victim, 0); |
556 | } |
546 | } |
557 | } |
547 | } |
558 | |
548 | |
|
|
549 | int damage = |
|
|
550 | symptom->stats.dam > 0 |
|
|
551 | ? symptom->stats.dam |
|
|
552 | : max (1, victim->stats.maxhp * -symptom->stats.dam / 100); |
|
|
553 | |
|
|
554 | hit_player (victim, damage, symptom, symptom->attacktype, 1); |
|
|
555 | |
|
|
556 | int sp_reduce = |
|
|
557 | symptom->stats.maxsp > 0 |
|
|
558 | ? symptom->stats.maxsp |
|
|
559 | : max (1, victim->stats.maxsp * -symptom->stats.maxsp / 100); |
|
|
560 | |
|
|
561 | victim->stats.sp = max (0, victim->stats.sp - sp_reduce); |
|
|
562 | |
559 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, victim, symptom->msg); |
563 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, victim, symptom->msg); |
560 | |
564 | |
561 | return 1; |
565 | return 1; |
562 | } |
566 | } |
563 | |
567 | |
… | |
… | |
570 | for (object *disease = hitter->inv; disease; disease = disease->below) |
574 | for (object *disease = hitter->inv; disease; disease = disease->below) |
571 | if (disease->type == DISEASE) |
575 | if (disease->type == DISEASE) |
572 | infect_object (victim, disease, 0); |
576 | infect_object (victim, disease, 0); |
573 | |
577 | |
574 | return 1; |
578 | return 1; |
575 | } |
|
|
576 | |
|
|
577 | // find a disease in someone |
|
|
578 | 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 | } |
579 | } |
587 | |
580 | |
588 | /* do the cure disease stuff, from the spell "cure disease" */ |
581 | /* do the cure disease stuff, from the spell "cure disease" */ |
589 | int |
582 | int |
590 | cure_disease (object *sufferer, object *caster, object *spell) |
583 | cure_disease (object *sufferer, object *caster, object *spell) |
… | |
… | |
628 | } |
621 | } |
629 | |
622 | |
630 | return 1; |
623 | return 1; |
631 | } |
624 | } |
632 | |
625 | |
|
|
626 | #if 0 // unused, but seems interesting |
633 | /* reduces disease progression: reduce_symptoms |
627 | /* reduces disease progression: reduce_symptoms |
634 | * return true if we actually reduce a disease. |
628 | * return true if we actually reduce a disease. |
635 | */ |
629 | */ |
636 | int |
630 | static int |
637 | reduce_symptoms (object *sufferer, int reduction) |
631 | reduce_symptoms (object *sufferer, int reduction) |
638 | { |
632 | { |
639 | object *walk; |
633 | object *walk; |
640 | int success = 0; |
634 | int success = 0; |
641 | |
635 | |
… | |
… | |
657 | if (success) |
651 | if (success) |
658 | new_draw_info (NDI_UNIQUE, 0, sufferer, "Your illness seems less severe."); |
652 | new_draw_info (NDI_UNIQUE, 0, sufferer, "Your illness seems less severe."); |
659 | |
653 | |
660 | return success; |
654 | return success; |
661 | } |
655 | } |
|
|
656 | #endif |