1 | /* |
1 | /* |
2 | * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Crossfire TRT is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | * the Free Software Foundation, either version 3 of the License, or |
11 | * (at your option) any later version. |
11 | * (at your 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, |
… | |
… | |
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 GNU General Public License |
18 | * You should have received a copy of the GNU General Public License |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | * |
20 | * |
21 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
22 | */ |
23 | |
23 | |
24 | /* This file contains all the code implementing diseases, |
24 | /* This file contains all the code implementing diseases, |
25 | * except for odds and ends in attack.c and in |
25 | * except for odds and ends in attack.c and in |
26 | * living.c |
26 | * living.c |
… | |
… | |
144 | is_susceptible_to_disease (object *victim, object *disease) |
144 | is_susceptible_to_disease (object *victim, object *disease) |
145 | { |
145 | { |
146 | if (!QUERY_FLAG (victim, FLAG_ALIVE)) |
146 | if (!QUERY_FLAG (victim, FLAG_ALIVE)) |
147 | return 0; |
147 | return 0; |
148 | |
148 | |
|
|
149 | if (victim->flag [FLAG_WIZ]) |
|
|
150 | return 0; |
|
|
151 | |
149 | if (strstr (disease->race, "*") && !QUERY_FLAG (victim, FLAG_UNDEAD)) |
152 | if (strstr (disease->race, "*") && !QUERY_FLAG (victim, FLAG_UNDEAD)) |
150 | return 1; |
153 | return 1; |
151 | |
154 | |
152 | if ((disease->race == shstr_undead) && QUERY_FLAG (victim, FLAG_UNDEAD)) |
155 | if ((disease->race == shstr_undead) && QUERY_FLAG (victim, FLAG_UNDEAD)) |
153 | return 1; |
156 | return 1; |
… | |
… | |
159 | } |
162 | } |
160 | |
163 | |
161 | int |
164 | int |
162 | move_disease (object *disease) |
165 | move_disease (object *disease) |
163 | { |
166 | { |
164 | /* first task is to determine if the disease is inside or outside of someone. |
167 | /* First task is to determine if the disease is inside or outside of someone. |
165 | * If outside, we decrement 'value' until we're gone. |
168 | * If outside, we decrement 'value' until we're gone. |
166 | */ |
169 | */ |
167 | |
170 | |
168 | if (!disease->env) |
171 | if (!disease->env) |
169 | { /* we're outside of someone */ |
172 | { /* we're outside of someone */ |
170 | if (disease->stats.maxhp > 0) |
173 | if (disease->stats.maxhp > 0) |
171 | disease->value--; |
174 | disease->value--; |
172 | |
175 | |
173 | if (!disease->value) |
176 | if (!disease->value) |
174 | { |
177 | { |
175 | disease->destroy (); |
178 | disease->destroy (true); |
176 | return 1; |
179 | return 1; |
177 | } |
180 | } |
178 | } |
181 | } |
179 | else |
182 | else |
180 | { |
183 | { |
… | |
… | |
186 | |
189 | |
187 | if (!disease->stats.food) |
190 | if (!disease->stats.food) |
188 | { |
191 | { |
189 | remove_symptoms (disease); /* remove the symptoms of this disease */ |
192 | remove_symptoms (disease); /* remove the symptoms of this disease */ |
190 | grant_immunity (disease); |
193 | grant_immunity (disease); |
191 | disease->destroy (); |
194 | disease->destroy (true); |
192 | return 1; |
195 | return 1; |
193 | } |
196 | } |
194 | } |
197 | } |
195 | } |
198 | } |
196 | |
199 | |
… | |
… | |
208 | * Modified by MSW 2003-03-28 do try to find all the symptom the |
211 | * Modified by MSW 2003-03-28 do try to find all the symptom the |
209 | * player may have - I think through some odd interactoins with |
212 | * player may have - I think through some odd interactoins with |
210 | * disease level and player level and whatnot, a player could get |
213 | * disease level and player level and whatnot, a player could get |
211 | * more than one symtpom to a disease. |
214 | * more than one symtpom to a disease. |
212 | */ |
215 | */ |
213 | |
|
|
214 | int |
216 | int |
215 | remove_symptoms (object *disease) |
217 | remove_symptoms (object *disease) |
216 | { |
218 | { |
217 | object *symptom, *victim = NULL; |
219 | object *symptom, *victim = NULL; |
218 | |
220 | |
219 | while ((symptom = find_symptom (disease)) != NULL) |
221 | while ((symptom = find_symptom (disease)) != NULL) |
220 | { |
222 | { |
221 | if (!victim) |
223 | if (!victim) |
222 | victim = symptom->env; |
224 | victim = symptom->env; |
223 | |
225 | |
224 | symptom->destroy (); |
226 | symptom->destroy (true); |
225 | } |
227 | } |
226 | |
228 | |
227 | if (victim) |
229 | if (victim) |
228 | victim->update_stats (); |
230 | victim->update_stats (); |
229 | |
231 | |
… | |
… | |
244 | |
246 | |
245 | /* searches around for more victims to infect */ |
247 | /* searches around for more victims to infect */ |
246 | int |
248 | int |
247 | check_infection (object *disease) |
249 | check_infection (object *disease) |
248 | { |
250 | { |
249 | int x, y, range, mflags; |
251 | int x, y; |
250 | maptile *map, *map2; |
252 | maptile *map, *map2; |
251 | object *tmp; |
253 | object *tmp; |
252 | |
254 | |
253 | range = abs (disease->magic); |
255 | int range = abs (disease->magic); |
254 | |
256 | |
255 | if (disease->env) |
257 | if (disease->env) |
256 | { |
258 | { |
257 | x = disease->env->x; |
259 | x = disease->env->x; |
258 | y = disease->env->y; |
260 | y = disease->env->y; |
… | |
… | |
270 | |
272 | |
271 | for (int i = x - range; i <= x + range; i++) |
273 | for (int i = x - range; i <= x + range; i++) |
272 | for (int j = y - range; j <= y + range; j++) |
274 | for (int j = y - range; j <= y + range; j++) |
273 | { |
275 | { |
274 | sint16 i2, j2; |
276 | sint16 i2, j2; |
275 | mflags = get_map_flags (map, &map2, i, j, &i2, &j2); |
277 | int mflags = get_map_flags (map, &map2, i, j, &i2, &j2); |
276 | |
278 | |
277 | if (!(mflags & P_OUT_OF_MAP) && (mflags & P_IS_ALIVE)) |
279 | if (!(mflags & P_OUT_OF_MAP) && (mflags & P_IS_ALIVE)) |
278 | for (tmp = GET_MAP_OB (map2, i2, j2); tmp; tmp = tmp->above) |
280 | for (tmp = GET_MAP_OB (map2, i2, j2); tmp; tmp = tmp->above) |
279 | infect_object (tmp, disease, 0); |
281 | infect_object (tmp, disease, 0); |
280 | } |
282 | } |
… | |
… | |
533 | object *new_ob; |
535 | object *new_ob; |
534 | int sp_reduce; |
536 | int sp_reduce; |
535 | |
537 | |
536 | if (!victim || !victim->map) |
538 | if (!victim || !victim->map) |
537 | { /* outside a monster/player, die immediately */ |
539 | { /* outside a monster/player, die immediately */ |
538 | symptom->destroy (); |
540 | symptom->destroy (true); |
539 | return 0; |
541 | return 0; |
540 | } |
542 | } |
541 | |
543 | |
542 | if (symptom->stats.dam > 0) |
544 | if (symptom->stats.dam > 0) |
543 | hit_player (victim, symptom->stats.dam, symptom, symptom->attacktype, 1); |
545 | hit_player (victim, symptom->stats.dam, symptom, symptom->attacktype, 1); |
544 | else |
546 | else |
545 | hit_player (victim, max (1, -victim->stats.maxhp * symptom->stats.dam / 100.0), symptom, symptom->attacktype, 1); |
547 | hit_player (victim, max (1, -victim->stats.maxhp * symptom->stats.dam / 100), symptom, symptom->attacktype, 1); |
546 | |
548 | |
547 | if (symptom->stats.maxsp > 0) |
549 | if (symptom->stats.maxsp > 0) |
548 | sp_reduce = symptom->stats.maxsp; |
550 | sp_reduce = symptom->stats.maxsp; |
549 | else |
551 | else |
550 | sp_reduce = max (1, victim->stats.maxsp * symptom->stats.maxsp / 100.0); |
552 | sp_reduce = max (1, victim->stats.maxsp * symptom->stats.maxsp / 100); |
551 | |
553 | |
552 | victim->stats.sp = max (0, victim->stats.sp - sp_reduce); |
554 | victim->stats.sp = max (0, victim->stats.sp - sp_reduce); |
553 | |
555 | |
554 | /* create the symptom "other arch" object and drop it here |
556 | /* create the symptom "other arch" object and drop it here |
555 | * under every part of the monster |
557 | * under every part of the monster |
556 | * The victim may well have died. |
558 | * The victim may well have died. |
557 | */ |
559 | */ |
558 | if (symptom->other_arch && victim->map) |
560 | if (victim->map) |
|
|
561 | { |
|
|
562 | victim->play_sound (symptom->sound); |
|
|
563 | |
|
|
564 | if (symptom->other_arch) |
559 | for (object *tmp = victim->head_ (); tmp; tmp = tmp->more) |
565 | for (object *tmp = victim->head_ (); tmp; tmp = tmp->more) |
560 | { |
566 | { |
561 | new_ob = arch_to_object (symptom->other_arch); |
567 | new_ob = arch_to_object (symptom->other_arch); |
562 | new_ob->x = tmp->x; |
568 | new_ob->x = tmp->x; |
563 | new_ob->y = tmp->y; |
569 | new_ob->y = tmp->y; |
564 | new_ob->map = victim->map; |
570 | new_ob->map = victim->map; |
565 | insert_ob_in_map (new_ob, victim->map, victim, 0); |
571 | insert_ob_in_map (new_ob, victim->map, victim, 0); |
|
|
572 | } |
566 | } |
573 | } |
567 | |
574 | |
568 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, victim, symptom->msg); |
575 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, victim, symptom->msg); |
569 | |
576 | |
570 | return 1; |
577 | return 1; |
571 | } |
578 | } |
… | |
… | |
594 | return 0; |
601 | return 0; |
595 | } |
602 | } |
596 | |
603 | |
597 | /* do the cure disease stuff, from the spell "cure disease" */ |
604 | /* do the cure disease stuff, from the spell "cure disease" */ |
598 | int |
605 | int |
599 | cure_disease (object *sufferer, object *caster) |
606 | cure_disease (object *sufferer, object *caster, object *spell) |
600 | { |
607 | { |
601 | object *disease, *next; |
608 | object *disease, *next; |
602 | int casting_level; |
|
|
603 | int cure = 0; |
609 | int cure = 0; |
604 | |
610 | |
605 | if (caster) |
|
|
606 | casting_level = caster->level; |
|
|
607 | else |
|
|
608 | casting_level = 1000; /* if null caster, CURE all. */ |
611 | int casting_level = caster ? caster->level : 1000; /* if null caster, CURE all. */ |
609 | |
612 | |
610 | for (disease = sufferer->inv; disease; disease = next) |
613 | for (disease = sufferer->inv; disease; disease = next) |
611 | { |
614 | { |
612 | next = disease->below; |
615 | next = disease->below; |
613 | |
616 | |
… | |
… | |
621 | if ((casting_level >= disease->level) || (!(random_roll (0, (disease->level - casting_level - 1), caster, PREFER_LOW)))) |
624 | if ((casting_level >= disease->level) || (!(random_roll (0, (disease->level - casting_level - 1), caster, PREFER_LOW)))) |
622 | { |
625 | { |
623 | remove_symptoms (disease); |
626 | remove_symptoms (disease); |
624 | cure = 1; |
627 | cure = 1; |
625 | |
628 | |
626 | if (caster) |
629 | if (caster && spell) |
627 | change_exp (caster, disease->stats.exp, caster->chosen_skill ? caster->chosen_skill->skill : (const char *) 0, 0); |
630 | change_exp (caster, disease->stats.exp, spell->skill, SK_EXP_SKILL_ONLY); |
628 | |
631 | |
629 | disease->destroy (); |
632 | disease->destroy (true); |
630 | } |
633 | } |
631 | } |
634 | } |
632 | } |
635 | } |
633 | |
636 | |
634 | if (cure) |
637 | if (cure) |