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.10 by root, Wed Dec 13 00:42:04 2006 UTC vs.
Revision 1.18 by root, Sat Jan 20 22:09:54 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game for X-windows
3 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
6 7 *
7 This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
8 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
9 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 11 * (at your option) any later version.
11 12 *
12 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,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 16 * GNU General Public License for more details.
16 17 *
17 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
18 along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 21 *
21 The authors can be reached via e-mail to <crossfire@schmorp.de> 22 * The authors can be reached via e-mail to <crossfire@schmorp.de>
22*/ 23 */
23 24
24/* This file contains all the code implementing diseases, 25/* This file contains all the code implementing diseases,
25 except for odds and ends in attack.c and in 26 except for odds and ends in attack.c and in
26 living.c*/ 27 living.c*/
27 28
126 127
127 128
128#include <global.h> 129#include <global.h>
129#include <object.h> 130#include <object.h>
130#include <living.h> 131#include <living.h>
131#ifndef __CEXTRACT__
132# include <sproto.h> 132#include <sproto.h>
133#endif
134#include <spells.h> 133#include <spells.h>
135#include <sounds.h> 134#include <sounds.h>
136#include <skills.h> 135#include <skills.h>
137 136
138/* IMPLEMENTATION NOTES 137/* IMPLEMENTATION NOTES
226 225
227 symptom->destroy (); 226 symptom->destroy ();
228 } 227 }
229 228
230 if (victim) 229 if (victim)
231 fix_player (victim); 230 victim->update_stats ();
232 return 0; 231 return 0;
233} 232}
234 233
235/* argument is a disease */ 234/* argument is a disease */
236object * 235object *
276 { 275 {
277 sint16 i2, j2; 276 sint16 i2, j2;
278 mflags = get_map_flags (map, &map2, i, j, &i2, &j2); 277 mflags = get_map_flags (map, &map2, i, j, &i2, &j2);
279 278
280 if (!(mflags & P_OUT_OF_MAP) && (mflags & P_IS_ALIVE)) 279 if (!(mflags & P_OUT_OF_MAP) && (mflags & P_IS_ALIVE))
281 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)
282 infect_object (tmp, disease, 0); 281 infect_object (tmp, disease, 0);
283 } 282 }
284 283
285 return 1; 284 return 1;
286} 285}
324 * (eg, level 1 cold, level 2 cold, level 3 cold, etc), as long as 323 * (eg, level 1 cold, level 2 cold, level 3 cold, etc), as long as
325 * they were cast in that same order. Instead, change it so that 324 * they were cast in that same order. Instead, change it so that
326 * if you diseased, you can't get diseased more. 325 * if you diseased, you can't get diseased more.
327 */ 326 */
328 327
329 for ( /* tmp initialized in if, above */ ; tmp; tmp = tmp->below) 328 for ( /* tmp initialised in if, above */ ; tmp; tmp = tmp->below)
330 { 329 {
331 if (tmp->type == SIGN && !strcmp (tmp->name, disease->name) && tmp->level >= disease->level) 330 if (tmp->type == SIGN && !strcmp (tmp->name, disease->name) && tmp->level >= disease->level)
332 return 0; /*Immune! */ 331 return 0; /* Immune! */
333 else if (tmp->type == DISEASE && !strcmp (tmp->name, disease->name)) 332 else if (tmp->type == DISEASE && !strcmp (tmp->name, disease->name))
334 return 0; /* already diseased */ 333 return 0; /* already diseased */
335 } 334 }
336 335
337 /* If we've gotten this far, go ahead and infect the victim. */ 336 /* If we've gotten this far, go ahead and infect the victim. */
342 341
343 /* Unfortunately, set_owner does the wrong thing to the skills pointers 342 /* Unfortunately, set_owner does the wrong thing to the skills pointers
344 * resulting in exp going into the owners *current* chosen skill. 343 * resulting in exp going into the owners *current* chosen skill.
345 */ 344 */
346 345
347 if (get_owner (disease)) 346 if (disease->owner)
348 { 347 {
349 set_owner (new_disease, disease->owner); 348 new_disease->set_owner (disease->owner);
350 349
351 /* Only need to update skill if different */ 350 /* Only need to update skill if different */
352 if (new_disease->skill != disease->skill) 351 if (new_disease->skill != disease->skill)
353 new_disease->skill = disease->skill; 352 new_disease->skill = disease->skill;
354 } 353 }
356 { /* for diseases which are passed by hitting, set owner and praying skill */ 355 { /* for diseases which are passed by hitting, set owner and praying skill */
357 if (disease->env && disease->env->type == PLAYER) 356 if (disease->env && disease->env->type == PLAYER)
358 { 357 {
359 object *player = disease->env; 358 object *player = disease->env;
360 359
361 set_owner (new_disease, player); 360 new_disease->set_owner (player);
362 361
363 /* the skill pointer for these diseases should already be set up - 362 /* the skill pointer for these diseases should already be set up -
364 * hardcoding in 'praying' is not the right approach. 363 * hardcoding in 'praying' is not the right approach.
365 */ 364 */
366 } 365 }
433 if (victim->head) 432 if (victim->head)
434 tmp = victim->head->inv; 433 tmp = victim->head->inv;
435 else 434 else
436 tmp = victim->inv; 435 tmp = victim->inv;
437 436
438 for ( /* tmp initialized in if, above */ ; tmp; tmp = tmp->below) 437 for ( /* tmp initialised in if, above */ ; tmp; tmp = tmp->below)
439 { 438 {
440 if (tmp->type == SIGN) /* possibly an immunity, or diseased */ 439 if (tmp->type == SIGN) /* possibly an immunity, or diseased */
441 if (!strcmp (tmp->name, disease->name) && tmp->level >= disease->level) 440 if (!strcmp (tmp->name, disease->name) && tmp->level >= disease->level)
442 return 0; /*Immune! */ 441 return 0; /*Immune! */
443 } 442 }
452 { 451 {
453 int dam = disease->stats.dam; 452 int dam = disease->stats.dam;
454 453
455 /* reduce the damage, on average, 50%, and making things random. */ 454 /* reduce the damage, on average, 50%, and making things random. */
456 455
457 dam = random_roll (1, FABS (dam), victim, PREFER_LOW); 456 dam = random_roll (1, abs (dam), victim, PREFER_LOW);
458 if (disease->stats.dam < 0) 457 if (disease->stats.dam < 0)
459 dam = -dam; 458 dam = -dam;
460 new_symptom->stats.dam = dam; 459 new_symptom->stats.dam = dam;
461 } 460 }
462 461
484 new_symptom->stats.hp = disease->stats.hp; 483 new_symptom->stats.hp = disease->stats.hp;
485 new_symptom->msg = disease->msg; 484 new_symptom->msg = disease->msg;
486 new_symptom->attacktype = disease->attacktype; 485 new_symptom->attacktype = disease->attacktype;
487 new_symptom->other_arch = disease->other_arch; 486 new_symptom->other_arch = disease->other_arch;
488 487
489 set_owner (new_symptom, disease->owner); 488 new_symptom->set_owner (disease->owner);
490 489
491 if (new_symptom->skill != disease->skill) 490 if (new_symptom->skill != disease->skill)
492 new_symptom->skill = disease->skill; 491 new_symptom->skill = disease->skill;
493 492
494 new_symptom->move_block = 0; 493 new_symptom->move_block = 0;
524 symptom->msg = disease->msg; 523 symptom->msg = disease->msg;
525 symptom->attacktype = disease->attacktype; 524 symptom->attacktype = disease->attacktype;
526 symptom->other_arch = disease->other_arch; 525 symptom->other_arch = disease->other_arch;
527 } 526 }
528 SET_FLAG (symptom, FLAG_APPLIED); 527 SET_FLAG (symptom, FLAG_APPLIED);
529 fix_player (victim); 528 victim->update_stats ();
530 return 1; 529 return 1;
531} 530}
532 531
533 532
534/* grants immunity to plagues we've seen before. */ 533/* grants immunity to plagues we've seen before. */
598 object *tmp; 597 object *tmp;
599 598
600 tmp = victim; 599 tmp = victim;
601 if (tmp->head != NULL) 600 if (tmp->head != NULL)
602 tmp = tmp->head; 601 tmp = tmp->head;
603 for ( /*tmp initialized above */ ; tmp != NULL; tmp = tmp->more) 602 for ( /*tmp initialised above */ ; tmp != NULL; tmp = tmp->more)
604 { 603 {
605 new_ob = arch_to_object (symptom->other_arch); 604 new_ob = arch_to_object (symptom->other_arch);
606 new_ob->x = tmp->x; 605 new_ob->x = tmp->x;
607 new_ob->y = tmp->y; 606 new_ob->y = tmp->y;
608 new_ob->map = victim->map; 607 new_ob->map = victim->map;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines