ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/disease.C
(Generate patch)

Comparing deliantra/server/server/disease.C (file contents):
Revision 1.35 by root, Mon Aug 20 19:13:10 2007 UTC vs.
Revision 1.41 by root, Mon Aug 27 05:10:51 2007 UTC

144is_susceptible_to_disease (object *victim, object *disease) 144is_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;
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
214int 216int
215remove_symptoms (object *disease) 217remove_symptoms (object *disease)
216{ 218{
217 object *symptom, *victim = NULL; 219 object *symptom, *victim = NULL;
218 220
244 246
245/* searches around for more victims to infect */ 247/* searches around for more victims to infect */
246int 248int
247check_infection (object *disease) 249check_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 }
456 458
457 new_symptom->move_block = 0; 459 new_symptom->move_block = 0;
458 460
459 victim->head_ ()->insert (new_symptom); 461 victim->head_ ()->insert (new_symptom);
460 462
461 // ste owner last, as insert clears owner 463 // set owner last, as insert clears owner
462 new_symptom->set_owner (disease->owner); 464 new_symptom->set_owner (disease->owner);
463 465
464 return 1; 466 return 1;
465 } 467 }
466 468
523 insert_ob_in_ob (immunity, disease->env); 525 insert_ob_in_ob (immunity, disease->env);
524 526
525 return 1; 527 return 1;
526} 528}
527 529
528
529/* make the symptom do the nasty things it does */ 530/* make the symptom do the nasty things it does */
530
531int 531int
532move_symptom (object *symptom) 532move_symptom (object *symptom)
533{ 533{
534 object *victim = symptom->env; 534 object *victim = symptom->env;
535 object *new_ob; 535 object *new_ob;
536 int sp_reduce; 536 int sp_reduce;
537 537
538 if (victim == NULL || victim->map == NULL) 538 if (!victim || !victim->map)
539 { /* outside a monster/player, die immediately */ 539 { /* outside a monster/player, die immediately */
540 symptom->destroy (); 540 symptom->destroy ();
541 return 0; 541 return 0;
542 } 542 }
543 543
544 if (symptom->stats.dam > 0) 544 if (symptom->stats.dam > 0)
545 hit_player (victim, symptom->stats.dam, symptom, symptom->attacktype, 1); 545 hit_player (victim, symptom->stats.dam, symptom, symptom->attacktype, 1);
546 else 546 else
547 hit_player (victim, (int) 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.0), symptom, symptom->attacktype, 1);
548 548
549 if (symptom->stats.maxsp > 0) 549 if (symptom->stats.maxsp > 0)
550 sp_reduce = symptom->stats.maxsp; 550 sp_reduce = symptom->stats.maxsp;
551 else 551 else
552 sp_reduce = (int) MAX (1, victim->stats.maxsp * symptom->stats.maxsp / 100.0); 552 sp_reduce = max (1, victim->stats.maxsp * symptom->stats.maxsp / 100.0);
553 553
554 victim->stats.sp = MAX (0, victim->stats.sp - sp_reduce); 554 victim->stats.sp = max (0, victim->stats.sp - sp_reduce);
555 555
556 /* create the symptom "other arch" object and drop it here 556 /* create the symptom "other arch" object and drop it here
557 * under every part of the monster 557 * under every part of the monster
558 * The victim may well have died. 558 * The victim may well have died.
559 */ 559 */
560 if (victim->map)
561 return 0;
562
563 if (symptom->other_arch) 560 if (symptom->other_arch && victim->map)
564 for (object *tmp = victim->head_ (); tmp; tmp = tmp->more) 561 for (object *tmp = victim->head_ (); tmp; tmp = tmp->more)
565 { 562 {
566 new_ob = arch_to_object (symptom->other_arch); 563 new_ob = arch_to_object (symptom->other_arch);
567 new_ob->x = tmp->x; 564 new_ob->x = tmp->x;
568 new_ob->y = tmp->y; 565 new_ob->y = tmp->y;
599 return 0; 596 return 0;
600} 597}
601 598
602/* do the cure disease stuff, from the spell "cure disease" */ 599/* do the cure disease stuff, from the spell "cure disease" */
603int 600int
604cure_disease (object *sufferer, object *caster) 601cure_disease (object *sufferer, object *caster, object *spell)
605{ 602{
606 object *disease, *next; 603 object *disease, *next;
607 int casting_level;
608 int cure = 0; 604 int cure = 0;
609 605
610 if (caster)
611 casting_level = caster->level;
612 else
613 casting_level = 1000; /* if null caster, CURE all. */ 606 int casting_level = caster ? caster->level : 1000; /* if null caster, CURE all. */
614 607
615 for (disease = sufferer->inv; disease; disease = next) 608 for (disease = sufferer->inv; disease; disease = next)
616 { 609 {
617 next = disease->below; 610 next = disease->below;
618 611
626 if ((casting_level >= disease->level) || (!(random_roll (0, (disease->level - casting_level - 1), caster, PREFER_LOW)))) 619 if ((casting_level >= disease->level) || (!(random_roll (0, (disease->level - casting_level - 1), caster, PREFER_LOW))))
627 { 620 {
628 remove_symptoms (disease); 621 remove_symptoms (disease);
629 cure = 1; 622 cure = 1;
630 623
631 if (caster) 624 if (caster && spell)
632 change_exp (caster, disease->stats.exp, caster->chosen_skill ? caster->chosen_skill->skill : (const char *) 0, 0); 625 change_exp (caster, disease->stats.exp, spell->skill, SK_EXP_SKILL_ONLY);
633 626
634 disease->destroy (); 627 disease->destroy ();
635 } 628 }
636 } 629 }
637 } 630 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines