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.28 by root, Tue Jul 10 05:51:38 2007 UTC vs.
Revision 1.29 by root, Tue Aug 7 21:58:25 2007 UTC

163{ 163{
164 /* first task is to determine if the disease is inside or outside of someone. 164 /* first task is to determine if the disease is inside or outside of someone.
165 * If outside, we decrement 'value' until we're gone. 165 * If outside, we decrement 'value' until we're gone.
166 */ 166 */
167 167
168 if (disease->env == NULL) 168 if (!disease->env)
169 { /* we're outside of someone */ 169 { /* we're outside of someone */
170 if (disease->stats.maxhp > 0) 170 if (disease->stats.maxhp > 0)
171 disease->value--; 171 disease->value--;
172 172
173 if (disease->value == 0) 173 if (!disease->value)
174 { 174 {
175 disease->destroy (); 175 disease->destroy ();
176 return 1; 176 return 1;
177 } 177 }
178 } 178 }
179 else 179 else
180 { 180 {
181 /* if we're inside a person, have the disease run its course */ 181 /* if we're inside a person, have the disease run its course */
182 /* negative foods denote "perpetual" diseases. */ 182 /* negative/zero food denotes "perpetual" diseases. */
183 if (disease->stats.food > 0) 183 if (disease->stats.food > 0)
184 { 184 {
185 disease->stats.food--; 185 disease->stats.food--;
186 186
187 if (disease->stats.food == 0) 187 if (!disease->stats.food)
188 { 188 {
189 remove_symptoms (disease); /* remove the symptoms of this disease */ 189 remove_symptoms (disease); /* remove the symptoms of this disease */
190 grant_immunity (disease); 190 grant_immunity (disease);
191 disease->destroy (); 191 disease->destroy ();
192 return 1; 192 return 1;
457 new_symptom->stats.dam = dam; 457 new_symptom->stats.dam = dam;
458 } 458 }
459 459
460 460
461 new_symptom->stats.maxsp = disease->stats.maxsp; 461 new_symptom->stats.maxsp = disease->stats.maxsp;
462 new_symptom->stats.food = new_symptom->stats.maxgrace; 462 new_symptom->stats.food = new_symptom->stats.maxgrace;
463 463
464 new_symptom->name = new_symptom->name_pl = disease->name; 464 new_symptom->name = new_symptom->name_pl = disease->name;
465 465
466 new_symptom->level = disease->level; 466 new_symptom->level = disease->level;
467 new_symptom->speed = disease->speed; 467 new_symptom->speed = disease->speed;
468 new_symptom->value = 0; 468 new_symptom->value = 0;
469 469
470 for (int i = 0; i < NUM_STATS; ++i) 470 for (int i = 0; i < NUM_STATS; ++i)
471 new_symptom->stats.stat (i) = disease->stats.stat (i); 471 new_symptom->stats.stat (i) = disease->stats.stat (i);
472 472
473 new_symptom->stats.sp = disease->stats.sp; 473 new_symptom->stats.sp = disease->stats.sp;
474 new_symptom->stats.food = disease->last_eat; 474 new_symptom->stats.food = disease->last_eat;
475 new_symptom->stats.maxsp = disease->stats.maxsp; 475 new_symptom->stats.maxsp = disease->stats.maxsp;
476 new_symptom->last_sp = disease->last_sp; 476 new_symptom->last_sp = disease->last_sp;
477 new_symptom->stats.exp = 0; 477 new_symptom->stats.exp = 0;
478 new_symptom->stats.hp = disease->stats.hp; 478 new_symptom->stats.hp = disease->stats.hp;
479 new_symptom->msg = disease->msg; 479 new_symptom->msg = disease->msg;
480 new_symptom->attacktype = disease->attacktype; 480 new_symptom->attacktype = disease->attacktype;
481 new_symptom->other_arch = disease->other_arch; 481 new_symptom->other_arch = disease->other_arch;
482 482
483 new_symptom->set_owner (disease->owner); 483 new_symptom->set_owner (disease->owner);
484 484
485 if (new_symptom->skill != disease->skill) 485 if (new_symptom->skill != disease->skill)
486 new_symptom->skill = disease->skill; 486 new_symptom->skill = disease->skill;
491 } 491 }
492 492
493 /* now deal with progressing diseases: we increase the debility 493 /* now deal with progressing diseases: we increase the debility
494 * caused by the symptoms. 494 * caused by the symptoms.
495 */ 495 */
496 if (disease->stats.ac != 0) 496 if (disease->stats.ac)
497 { 497 {
498 symptom->value += disease->stats.ac; 498 symptom->value = clamp (symptom->value + disease->stats.ac, 0, 100*100);
499 499
500 float scale = 1.f + symptom->value / 100.f; 500 float scale = 1.f + symptom->value / 100.f;
501 501
502 /* now rescale all the debilities */ 502 /* now rescale all the debilities */
503 for (int i = 0; i < NUM_STATS; ++i) 503 for (int i = 0; i < NUM_STATS; ++i)
504 symptom->stats.stat (i) = scale * disease->stats.stat (i); 504 symptom->stats.stat (i) = clamp (scale * disease->stats.stat (i), -MAX_STAT, MAX_STAT);
505 505
506 symptom->stats.dam = scale * disease->stats.dam; 506 symptom->stats.dam = clamp (scale * disease->stats.dam , -1024, 1024);
507 symptom->stats.sp = scale * disease->stats.sp;
508 symptom->stats.food = scale * disease->last_eat; 507 symptom->stats.food = clamp (scale * disease->last_eat , -1024, 1024);
509 symptom->stats.maxsp = scale * disease->stats.maxsp; 508 symptom->stats.maxsp = clamp (scale * disease->stats.maxsp, -1024, 1024);
510 symptom->last_sp = scale * disease->last_sp; 509 symptom->last_sp = clamp (scale * disease->last_sp , -1024, 1024);
510 symptom->stats.sp = clamp (scale * disease->stats.sp , -1024, 1024);
511 symptom->stats.hp = clamp (scale * disease->stats.hp , -1024, 1024);
511 symptom->stats.exp = 0; 512 symptom->stats.exp = 0;
512 symptom->stats.hp = scale * disease->stats.hp;
513 513
514 symptom->msg = disease->msg; 514 symptom->msg = disease->msg;
515 symptom->attacktype = disease->attacktype; 515 symptom->attacktype = disease->attacktype;
516 symptom->other_arch = disease->other_arch; 516 symptom->other_arch = disease->other_arch;
517 } 517 }
518 518
519 SET_FLAG (symptom, FLAG_APPLIED); 519 SET_FLAG (symptom, FLAG_APPLIED);
520 victim->update_stats (); 520 victim->update_stats ();
521 521
679} 679}
680 680
681/* reduces disease progression: reduce_symptoms 681/* reduces disease progression: reduce_symptoms
682 * return true if we actually reduce a disease. 682 * return true if we actually reduce a disease.
683 */ 683 */
684
685int 684int
686reduce_symptoms (object *sufferer, int reduction) 685reduce_symptoms (object *sufferer, int reduction)
687{ 686{
688 object *walk; 687 object *walk;
689 int success = 0; 688 int success = 0;
693 if (walk->type == SYMPTOM) 692 if (walk->type == SYMPTOM)
694 { 693 {
695 if (walk->value > 0) 694 if (walk->value > 0)
696 { 695 {
697 success = 1; 696 success = 1;
698 walk->value = MAX (0, walk->value - 2 * reduction); 697 walk->value = max (0, walk->value - 2 * reduction);
699 /* give the disease time to modify this symptom, 698 /* give the disease time to modify this symptom,
700 * and reduce its severity. */ 699 * and reduce its severity. */
701 walk->speed_left = 0; 700 walk->speed_left = 0;
702 } 701 }
703 } 702 }
704 } 703 }
704
705 if (success) 705 if (success)
706 new_draw_info (NDI_UNIQUE, 0, sufferer, "Your illness seems less severe."); 706 new_draw_info (NDI_UNIQUE, 0, sufferer, "Your illness seems less severe.");
707
707 return success; 708 return success;
708} 709}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines