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.7 by root, Thu Oct 5 16:50:07 2006 UTC vs.
Revision 1.13 by root, Fri Dec 22 16:34:00 2006 UTC

170 170
171 if (disease->env == NULL) 171 if (disease->env == NULL)
172 { /* we're outside of someone */ 172 { /* we're outside of someone */
173 if (disease->stats.maxhp > 0) 173 if (disease->stats.maxhp > 0)
174 disease->value--; 174 disease->value--;
175
175 if (disease->value == 0) 176 if (disease->value == 0)
176 { 177 {
177 remove_ob (disease); 178 disease->destroy ();
178 free_object (disease);
179 return 1; 179 return 1;
180 } 180 }
181 } 181 }
182 else 182 else
183 { 183 {
184 /* if we're inside a person, have the disease run its course */ 184 /* if we're inside a person, have the disease run its course */
185 /* negative foods denote "perpetual" diseases. */ 185 /* negative foods denote "perpetual" diseases. */
186 if (disease->stats.food > 0) 186 if (disease->stats.food > 0)
187 { 187 {
188 disease->stats.food--; 188 disease->stats.food--;
189
189 if (disease->stats.food == 0) 190 if (disease->stats.food == 0)
190 { 191 {
191 remove_symptoms (disease); /* remove the symptoms of this disease */ 192 remove_symptoms (disease); /* remove the symptoms of this disease */
192 grant_immunity (disease); 193 grant_immunity (disease);
193 remove_ob (disease); 194 disease->destroy ();
194 free_object (disease);
195 return 1; 195 return 1;
196 } 196 }
197 } 197 }
198 } 198 }
199
199 /* check to see if we infect others */ 200 /* check to see if we infect others */
200 check_infection (disease); 201 check_infection (disease);
201 202
202 /* impose or modify the symptoms of the disease */ 203 /* impose or modify the symptoms of the disease */
203 if (disease->env && is_susceptible_to_disease (disease->env, disease)) 204 if (disease->env && is_susceptible_to_disease (disease->env, disease))
220 221
221 while ((symptom = find_symptom (disease)) != NULL) 222 while ((symptom = find_symptom (disease)) != NULL)
222 { 223 {
223 if (!victim) 224 if (!victim)
224 victim = symptom->env; 225 victim = symptom->env;
225 remove_ob (symptom); 226
226 free_object (symptom); 227 symptom->destroy ();
227 } 228 }
229
228 if (victim) 230 if (victim)
229 fix_player (victim); 231 victim->update_stats ();
230 return 0; 232 return 0;
231} 233}
232 234
233/* argument is a disease */ 235/* argument is a disease */
234object * 236object *
274 { 276 {
275 sint16 i2, j2; 277 sint16 i2, j2;
276 mflags = get_map_flags (map, &map2, i, j, &i2, &j2); 278 mflags = get_map_flags (map, &map2, i, j, &i2, &j2);
277 279
278 if (!(mflags & P_OUT_OF_MAP) && (mflags & P_IS_ALIVE)) 280 if (!(mflags & P_OUT_OF_MAP) && (mflags & P_IS_ALIVE))
279 for (tmp = get_map_ob (map2, i2, j2); tmp; tmp = tmp->above) 281 for (tmp = GET_MAP_OB (map2, i2, j2); tmp; tmp = tmp->above)
280 infect_object (tmp, disease, 0); 282 infect_object (tmp, disease, 0);
281 } 283 }
282 284
283 return 1; 285 return 1;
284} 286}
331 else if (tmp->type == DISEASE && !strcmp (tmp->name, disease->name)) 333 else if (tmp->type == DISEASE && !strcmp (tmp->name, disease->name))
332 return 0; /* already diseased */ 334 return 0; /* already diseased */
333 } 335 }
334 336
335 /* If we've gotten this far, go ahead and infect the victim. */ 337 /* If we've gotten this far, go ahead and infect the victim. */
336 new_disease = get_object (); 338 new_disease = disease->clone ();
337 copy_object (disease, new_disease);
338 new_disease->stats.food = disease->stats.maxgrace; 339 new_disease->stats.food = disease->stats.maxgrace;
339 new_disease->value = disease->stats.maxhp; 340 new_disease->value = disease->stats.maxhp;
340 new_disease->stats.wc -= disease->last_grace; /* self-limiting factor */ 341 new_disease->stats.wc -= disease->last_grace; /* self-limiting factor */
341 342
342 /* Unfortunately, set_owner does the wrong thing to the skills pointers 343 /* Unfortunately, set_owner does the wrong thing to the skills pointers
343 * resulting in exp going into the owners *current* chosen skill. 344 * resulting in exp going into the owners *current* chosen skill.
344 */ 345 */
345 346
346 if (get_owner (disease)) 347 if (disease->owner)
347 { 348 {
348 set_owner (new_disease, disease->owner); 349 new_disease->set_owner (disease->owner);
349 350
350 /* Only need to update skill if different */ 351 /* Only need to update skill if different */
351 if (new_disease->skill != disease->skill) 352 if (new_disease->skill != disease->skill)
352 new_disease->skill = disease->skill; 353 new_disease->skill = disease->skill;
353 } 354 }
355 { /* for diseases which are passed by hitting, set owner and praying skill */ 356 { /* for diseases which are passed by hitting, set owner and praying skill */
356 if (disease->env && disease->env->type == PLAYER) 357 if (disease->env && disease->env->type == PLAYER)
357 { 358 {
358 object *player = disease->env; 359 object *player = disease->env;
359 360
360 set_owner (new_disease, player); 361 new_disease->set_owner (player);
361 362
362 /* the skill pointer for these diseases should already be set up - 363 /* the skill pointer for these diseases should already be set up -
363 * hardcoding in 'praying' is not the right approach. 364 * hardcoding in 'praying' is not the right approach.
364 */ 365 */
365 } 366 }
483 new_symptom->stats.hp = disease->stats.hp; 484 new_symptom->stats.hp = disease->stats.hp;
484 new_symptom->msg = disease->msg; 485 new_symptom->msg = disease->msg;
485 new_symptom->attacktype = disease->attacktype; 486 new_symptom->attacktype = disease->attacktype;
486 new_symptom->other_arch = disease->other_arch; 487 new_symptom->other_arch = disease->other_arch;
487 488
488 set_owner (new_symptom, disease->owner); 489 new_symptom->set_owner (disease->owner);
489 490
490 if (new_symptom->skill != disease->skill) 491 if (new_symptom->skill != disease->skill)
491 new_symptom->skill = disease->skill; 492 new_symptom->skill = disease->skill;
492 493
493 new_symptom->move_block = 0; 494 new_symptom->move_block = 0;
523 symptom->msg = disease->msg; 524 symptom->msg = disease->msg;
524 symptom->attacktype = disease->attacktype; 525 symptom->attacktype = disease->attacktype;
525 symptom->other_arch = disease->other_arch; 526 symptom->other_arch = disease->other_arch;
526 } 527 }
527 SET_FLAG (symptom, FLAG_APPLIED); 528 SET_FLAG (symptom, FLAG_APPLIED);
528 fix_player (victim); 529 victim->update_stats ();
529 return 1; 530 return 1;
530} 531}
531 532
532 533
533/* grants immunity to plagues we've seen before. */ 534/* grants immunity to plagues we've seen before. */
568 object *new_ob; 569 object *new_ob;
569 int sp_reduce; 570 int sp_reduce;
570 571
571 if (victim == NULL || victim->map == NULL) 572 if (victim == NULL || victim->map == NULL)
572 { /* outside a monster/player, die immediately */ 573 { /* outside a monster/player, die immediately */
573 remove_ob (symptom); 574 symptom->destroy ();
574 free_object (symptom);
575 return 0; 575 return 0;
576 } 576 }
577 577
578 if (symptom->stats.dam > 0) 578 if (symptom->stats.dam > 0)
579 hit_player (victim, symptom->stats.dam, symptom, symptom->attacktype, 1); 579 hit_player (victim, symptom->stats.dam, symptom, symptom->attacktype, 1);
669 */ 669 */
670 if ((casting_level >= disease->level) || (!(random_roll (0, (disease->level - casting_level - 1), caster, PREFER_LOW)))) 670 if ((casting_level >= disease->level) || (!(random_roll (0, (disease->level - casting_level - 1), caster, PREFER_LOW))))
671 { 671 {
672 672
673 remove_symptoms (disease); 673 remove_symptoms (disease);
674 remove_ob (disease);
675 cure = 1; 674 cure = 1;
675
676 if (caster) 676 if (caster)
677 change_exp (caster, disease->stats.exp, caster->chosen_skill ? &caster->chosen_skill->skill : (const char *) 0, 0); 677 change_exp (caster, disease->stats.exp, caster->chosen_skill ? &caster->chosen_skill->skill : (const char *) 0, 0);
678 free_object (disease); 678
679 disease->destroy ();
679 } 680 }
680 } 681 }
681 } 682 }
682 if (cure) 683 if (cure)
683 { 684 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines