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.59 by root, Mon Nov 23 14:09:05 2009 UTC vs.
Revision 1.68 by root, Sun May 1 16:58:17 2011 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 11 * option) any later version.
151 if (disease->last_heal) 151 if (disease->last_heal)
152 return 0; 152 return 0;
153 153
154 /* first, search for an immunity of the same name */ 154 /* first, search for an immunity of the same name */
155 for (walk = disease->env->inv; walk; walk = walk->below) 155 for (walk = disease->env->inv; walk; walk = walk->below)
156 if (walk->type == 98 && disease->name == walk->name) 156 if (disease->name == walk->name && walk->is_immunity ())
157 { 157 {
158 walk->level = disease->level; 158 walk->level = disease->level;
159 return 1; /* just update the existing immunity. */ 159 return 1; /* just update the existing immunity. */
160 } 160 }
161 161
162 immunity = get_archetype (shstr_immunity); 162 immunity = archetype::get (shstr_immunity);
163 163
164 immunity->name = disease->name; 164 immunity->name = disease->name;
165 immunity->level = disease->level; 165 immunity->level = disease->level;
166 immunity->move_block = 0; 166 immunity->move_block = 0;
167 167
216 object *op = disease->outer_env_or_self (); 216 object *op = disease->outer_env_or_self ();
217 217
218 if (!op->is_on_map ()) 218 if (!op->is_on_map ())
219 return 0; 219 return 0;
220 220
221 dynbuf buf;
221 unordered_mapwalk (op, -range, -range, range, range) 222 unordered_mapwalk (buf, op, -range, -range, range, range)
222 { 223 {
223 mapspace &ms = m->at (nx, ny); 224 mapspace &ms = m->at (nx, ny);
224 225
225 if (ms.flags () & P_IS_ALIVE) 226 if (ms.flags () & P_IS_ALIVE)
226 for (object *tmp = ms.bot; tmp; tmp = tmp->above) 227 for (object *tmp = ms.bot; tmp; tmp = tmp->above)
232 233
233/* check if victim is susceptible to disease. */ 234/* check if victim is susceptible to disease. */
234static int 235static int
235is_susceptible_to_disease (object *victim, object *disease) 236is_susceptible_to_disease (object *victim, object *disease)
236{ 237{
237 if (!QUERY_FLAG (victim, FLAG_ALIVE)) 238 if (!victim->flag [FLAG_ALIVE])
238 return 0; 239 return 0;
239 240
240 if (victim->flag [FLAG_WIZ]) 241 if (victim->flag [FLAG_WIZ])
241 return 0; 242 return 0;
242 243
243 if (disease->race.contains ("*") && !QUERY_FLAG (victim, FLAG_UNDEAD)) 244 if (disease->race.contains ("*") && !victim->flag [FLAG_UNDEAD])
244 return 1; 245 return 1;
245 246
246 if ((disease->race == shstr_undead) && QUERY_FLAG (victim, FLAG_UNDEAD)) 247 if ((disease->race == shstr_undead) && victim->flag [FLAG_UNDEAD])
247 return 1; 248 return 1;
248 249
249 if ((victim->race && disease->race.contains (victim->race)) || disease->race.contains (victim->name)) 250 if ((victim->race && disease->race.contains (victim->race)) || disease->race.contains (victim->name))
250 return 1; 251 return 1;
251 252
288 return 0; 289 return 0;
289 290
290 /* check for an actual immunity */ 291 /* check for an actual immunity */
291 /* do an immunity check */ 292 /* do an immunity check */
292 for (tmp = victim->head_ ()->inv; tmp; tmp = tmp->below) 293 for (tmp = victim->head_ ()->inv; tmp; tmp = tmp->below)
293 if (tmp->type == SIGN) /* possibly an immunity, or diseased */ 294 if (tmp->name == disease->name && tmp->is_immunity ()) /* possibly an immunity, or diseased */
294 if (tmp->name == disease->name && tmp->level >= disease->level) 295 if (tmp->level >= disease->level)
295 return 0; /* Immune! */ 296 return 0; /* Immune! */
296 297
297 object *new_symptom = get_archetype (shstr_symptom); 298 object *new_symptom = archetype::get (shstr_symptom);
298 299
299 /* Something special done with dam. We want diseases to be more 300 /* Something special done with dam. We want diseases to be more
300 * random in what they'll kill, so we'll make the damage they 301 * random in what they'll kill, so we'll make the damage they
301 * do random, note, this has a weird effect with progressive diseases. 302 * do random, note, this has a weird effect with progressive diseases.
302 */ 303 */
317 new_symptom->stats.food = new_symptom->stats.maxgrace; 318 new_symptom->stats.food = new_symptom->stats.maxgrace;
318 319
319 new_symptom->name = new_symptom->name_pl = disease->name; 320 new_symptom->name = new_symptom->name_pl = disease->name;
320 321
321 new_symptom->level = disease->level; 322 new_symptom->level = disease->level;
322 new_symptom->speed = disease->speed;
323 new_symptom->value = 0; 323 new_symptom->value = 0;
324
325 new_symptom->set_speed (disease->speed);
324 326
325 for (int i = 0; i < NUM_STATS; ++i) 327 for (int i = 0; i < NUM_STATS; ++i)
326 new_symptom->stats.stat (i) = disease->stats.stat (i); 328 new_symptom->stats.stat (i) = disease->stats.stat (i);
327 329
328 new_symptom->stats.sp = disease->stats.sp; 330 new_symptom->stats.sp = disease->stats.sp;
369 symptom->msg = disease->msg; 371 symptom->msg = disease->msg;
370 symptom->attacktype = disease->attacktype; 372 symptom->attacktype = disease->attacktype;
371 symptom->other_arch = disease->other_arch; 373 symptom->other_arch = disease->other_arch;
372 } 374 }
373 375
374 SET_FLAG (symptom, FLAG_APPLIED); 376 symptom->set_flag (FLAG_APPLIED);
375 victim->update_stats (); 377 victim->update_stats ();
376 378
377 return 1; 379 return 1;
378} 380}
379 381
434{ 436{
435 object *tmp; 437 object *tmp;
436 object *new_disease; 438 object *new_disease;
437 439
438 /* don't infect inanimate objects */ 440 /* don't infect inanimate objects */
439 if (!QUERY_FLAG (victim, FLAG_MONSTER) && !(victim->type == PLAYER)) 441 if (!victim->flag [FLAG_MONSTER] && !(victim->type == PLAYER))
440 return 0; 442 return 0;
441 443
442 /* check and see if victim can catch disease: diseases 444 /* check and see if victim can catch disease: diseases
443 * are specific 445 * are specific
444 */ 446 */
458 * they were cast in that same order. Instead, change it so that 460 * they were cast in that same order. Instead, change it so that
459 * if you diseased, you can't get diseased more. 461 * if you diseased, you can't get diseased more.
460 */ 462 */
461 463
462 for (tmp = victim->head_ ()->inv; tmp; tmp = tmp->below) 464 for (tmp = victim->head_ ()->inv; tmp; tmp = tmp->below)
463 if (tmp->type == SIGN && tmp->name == disease->name && tmp->level >= disease->level) 465 if (tmp->name == disease->name && tmp->is_immunity () && tmp->level >= disease->level)
464 return 0; /* Immune! */ 466 return 0; /* Immune! */
465 else if (tmp->type == DISEASE && tmp->name == disease->name) 467 else if (tmp->type == DISEASE && tmp->name == disease->name)
466 return 0; /* already diseased */ 468 return 0; /* already diseased */
467 469
468 /* If we've gotten this far, go ahead and infect the victim. */ 470 /* If we've gotten this far, go ahead and infect the victim. */
532 victim->play_sound (symptom->sound); 534 victim->play_sound (symptom->sound);
533 535
534 if (symptom->other_arch) 536 if (symptom->other_arch)
535 for (object *tmp = victim->head_ (); tmp; tmp = tmp->more) 537 for (object *tmp = victim->head_ (); tmp; tmp = tmp->more)
536 { 538 {
537 object *new_ob = arch_to_object (symptom->other_arch); 539 object *new_ob = symptom->other_arch->instance ();
538 new_ob->x = tmp->x; 540 new_ob->x = tmp->x;
539 new_ob->y = tmp->y; 541 new_ob->y = tmp->y;
540 new_ob->map = victim->map; 542 new_ob->map = victim->map;
541 insert_ob_in_map (new_ob, victim->map, victim, 0); 543 insert_ob_in_map (new_ob, victim->map, victim, 0);
542 } 544 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines