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.63 by root, Fri Mar 26 01:04:44 2010 UTC vs.
Revision 1.74 by root, Sat Nov 17 23:40:03 2018 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 (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team
4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 5 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team 6 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 Frank Tore Johansen 7 * Copyright (©) 1992 Frank Tore Johansen
7 * 8 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 9 * 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 10 * 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 11 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 12 * option) any later version.
12 * 13 *
13 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 17 * GNU General Public License for more details.
17 * 18 *
18 * You should have received a copy of the Affero GNU General Public License 19 * You should have received a copy of the Affero GNU General Public License
19 * and the GNU General Public License along with this program. If not, see 20 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>. 21 * <http://www.gnu.org/licenses/>.
21 * 22 *
22 * The authors can be reached via e-mail to <support@deliantra.net> 23 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 24 */
24 25
25/* This file contains all the code implementing diseases, 26/* This file contains all the code implementing diseases,
26 * except for odds and ends in attack.c and in 27 * except for odds and ends in attack.c and in
27 * living.c 28 * living.c
28 */ 29 */
29 30
30/* 31/*
31 32
36other_arch Creation object created and dropped when symptom moved. 37other_arch Creation object created and dropped when symptom moved.
37title Message When the "disease" "infects" something, it will 38title Message When the "disease" "infects" something, it will
38 print "title victim!!!" to the player who owns 39 print "title victim!!!" to the player who owns
39 the "disease". 40 the "disease".
40wc+ Infectiousness How well the plague spreads person-to-person 41wc+ Infectiousness How well the plague spreads person-to-person
41magic+ Range range of infection 42magic+ Range range of infection
42Stats* Disability What stats are reduced by the disease (str con...) 43Stats* Disability What stats are reduced by the disease (str con...)
43maxhp+ Persistence How long the disease can last OUTSIDE the host. 44maxhp+ Persistence How long the disease can last OUTSIDE the host.
44value TimeLeft Counter for persistence 45value TimeLeft Counter for persistence
45dam^ Damage How much damage it does (%?). 46dam^ Damage How much damage it does (%?).
46maxgrace+ Duration How long before the disease is naturally cured. 47maxgrace+ Duration How long before the disease is naturally cured.
47food DurCount Counter for Duration 48food DurCount Counter for Duration
48 49
49speed Speed How often the disease moves. 50speed Speed How often the disease moves.
50last_sp^ Lethargy Percentage of max speed. 10 = 10% speed. 51last_sp^ Lethargy Percentage of max speed. 10 = 10% speed.
51 52
52maxsp^ Mana deplete Saps mana. 53maxsp^ Mana deplete Saps mana.
53ac^ Progressiveness How the diseases increases in severity. 54ac^ Progressiveness How the diseases increases in severity.
54last_eat*^ Deplete food saps food if negative 55last_eat*^ Deplete food saps food if negative
55last_heal GrantImmunity If nonzero, disease does NOT grant immunity 56last_heal GrantImmunity If nonzero, disease does NOT grant immunity
56 when it runs out 57 when it runs out
57 58
58exp experience experience awarded when plague cured 59exp experience experience awarded when plague cured
59hp*^ ReduceRegen reduces regeneration of disease-bearer 60hp*^ ReduceRegen reduces regeneration of disease-bearer
60sp*^ ReduceSpRegen reduces spellpoint regeneration 61sp*^ ReduceSpRegen reduces spellpoint regeneration
61 62
62name Name Name of the plague 63name Name Name of the plague
63msg message What the plague says when it strikes. 64msg message What the plague says when it strikes.
64race those affected species/race the plague strikes (* = everything) 65race those affected species/race the plague strikes (* = everything)
65level Plague Level General description of the plague's deadliness 66level Plague Level General description of the plague's deadliness
66armour Attenuation reduction in wc per generation of disease. 67armour Attenuation reduction in wc per generation of disease.
67 This builds in a self-limiting factor. 68 This builds in a self-limiting factor.
68
69 69
70Explanations: 70Explanations:
71* means this # should be negative to cause adverse effect. 71* means this # should be negative to cause adverse effect.
72+ means that this effect is modulated in spells by ldur 72+ means that this effect is modulated in spells by ldur
73^ means that this effect is modulated in spells by ldam 73^ means that this effect is modulated in spells by ldam
131#include <sproto.h> 131#include <sproto.h>
132#include <spells.h> 132#include <spells.h>
133#include <sounds.h> 133#include <sounds.h>
134#include <skills.h> 134#include <skills.h>
135 135
136/* IMPLEMENTATION NOTES 136/* IMPLEMENTATION NOTES
137 137
138 Diseases may be contageous. They are objects which exist in a player's 138 Diseases may be contageous. They are objects which exist in a player's
139inventory. They themselves do nothing, except modify Symptoms, or 139inventory. They themselves do nothing, except modify Symptoms, or
140spread to other live objects. Symptoms are what actually damage the player: 140spread to other live objects. Symptoms are what actually damage the player:
141these are their own object. */ 141these are their own object. */
142 142
143/* grants immunity to plagues we've seen before. */ 143/* grants immunity to plagues we've seen before. */
144static int 144static int
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
233 233
234/* check if victim is susceptible to disease. */ 234/* check if victim is susceptible to disease. */
235static int 235static int
236is_susceptible_to_disease (object *victim, object *disease) 236is_susceptible_to_disease (object *victim, object *disease)
237{ 237{
238 if (!QUERY_FLAG (victim, FLAG_ALIVE)) 238 if (!victim->flag [FLAG_ALIVE])
239 return 0; 239 return 0;
240 240
241 if (victim->flag [FLAG_WIZ]) 241 if (victim->flag [FLAG_WIZ])
242 return 0; 242 return 0;
243 243
244 if (disease->race.contains ("*") && !QUERY_FLAG (victim, FLAG_UNDEAD)) 244 if (disease->race.contains ("*") && !victim->flag [FLAG_UNDEAD])
245 return 1; 245 return 1;
246 246
247 if ((disease->race == shstr_undead) && QUERY_FLAG (victim, FLAG_UNDEAD)) 247 if ((disease->race == shstr_undead) && victim->flag [FLAG_UNDEAD])
248 return 1; 248 return 1;
249 249
250 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))
251 return 1; 251 return 1;
252 252
289 return 0; 289 return 0;
290 290
291 /* check for an actual immunity */ 291 /* check for an actual immunity */
292 /* do an immunity check */ 292 /* do an immunity check */
293 for (tmp = victim->head_ ()->inv; tmp; tmp = tmp->below) 293 for (tmp = victim->head_ ()->inv; tmp; tmp = tmp->below)
294 if (tmp->type == SIGN) /* possibly an immunity, or diseased */ 294 if (tmp->name == disease->name && tmp->is_immunity ()) /* possibly an immunity, or diseased */
295 if (tmp->name == disease->name && tmp->level >= disease->level) 295 if (tmp->level >= disease->level)
296 return 0; /* Immune! */ 296 return 0; /* Immune! */
297 297
298 object *new_symptom = get_archetype (shstr_symptom); 298 object *new_symptom = archetype::get (shstr_symptom);
299 299
300 /* Something special done with dam. We want diseases to be more 300 /* Something special done with dam. We want diseases to be more
301 * 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
302 * do random, note, this has a weird effect with progressive diseases. 302 * do random, note, this has a weird effect with progressive diseases.
303 */ 303 */
318 new_symptom->stats.food = new_symptom->stats.maxgrace; 318 new_symptom->stats.food = new_symptom->stats.maxgrace;
319 319
320 new_symptom->name = new_symptom->name_pl = disease->name; 320 new_symptom->name = new_symptom->name_pl = disease->name;
321 321
322 new_symptom->level = disease->level; 322 new_symptom->level = disease->level;
323 new_symptom->speed = disease->speed;
324 new_symptom->value = 0; 323 new_symptom->value = 0;
324
325 new_symptom->set_speed (disease->speed);
325 326
326 for (int i = 0; i < NUM_STATS; ++i) 327 for (int i = 0; i < NUM_STATS; ++i)
327 new_symptom->stats.stat (i) = disease->stats.stat (i); 328 new_symptom->stats.stat (i) = disease->stats.stat (i);
328 329
329 new_symptom->stats.sp = disease->stats.sp; 330 new_symptom->stats.sp = disease->stats.sp;
370 symptom->msg = disease->msg; 371 symptom->msg = disease->msg;
371 symptom->attacktype = disease->attacktype; 372 symptom->attacktype = disease->attacktype;
372 symptom->other_arch = disease->other_arch; 373 symptom->other_arch = disease->other_arch;
373 } 374 }
374 375
375 SET_FLAG (symptom, FLAG_APPLIED); 376 symptom->set_flag (FLAG_APPLIED);
376 victim->update_stats (); 377 victim->update_stats ();
377 378
378 return 1; 379 return 1;
379} 380}
380 381
381int 382int
382move_disease (object *disease) 383move_disease (object *disease)
383{ 384{
384 /* First task is to determine if the disease is inside or outside of someone. 385 /* First task is to determine if the disease is inside or outside of someone.
385 * If outside, we decrement 'value' until we're gone. 386 * If outside, we decrement 'value' until we're gone.
386 */ 387 */
387 388
388 if (!disease->env) 389 if (!disease->env)
389 { /* we're outside of someone */ 390 { /* we're outside of someone */
390 if (disease->stats.maxhp > 0) 391 if (disease->stats.maxhp > 0)
435{ 436{
436 object *tmp; 437 object *tmp;
437 object *new_disease; 438 object *new_disease;
438 439
439 /* don't infect inanimate objects */ 440 /* don't infect inanimate objects */
440 if (!QUERY_FLAG (victim, FLAG_MONSTER) && !(victim->type == PLAYER)) 441 if (!victim->flag [FLAG_MONSTER] && !(victim->type == PLAYER))
441 return 0; 442 return 0;
442 443
443 /* check and see if victim can catch disease: diseases 444 /* check and see if victim can catch disease: diseases
444 * are specific 445 * are specific
445 */ 446 */
446 if (!is_susceptible_to_disease (victim, disease)) 447 if (!is_susceptible_to_disease (victim, disease))
447 return 0; 448 return 0;
448 449
449 /* roll the dice on infection before doing the inventory check! */ 450 /* roll the dice on infection before doing the inventory check! */
459 * 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
460 * if you diseased, you can't get diseased more. 461 * if you diseased, you can't get diseased more.
461 */ 462 */
462 463
463 for (tmp = victim->head_ ()->inv; tmp; tmp = tmp->below) 464 for (tmp = victim->head_ ()->inv; tmp; tmp = tmp->below)
464 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)
465 return 0; /* Immune! */ 466 return 0; /* Immune! */
466 else if (tmp->type == DISEASE && tmp->name == disease->name) 467 else if (tmp->type == DISEASE && tmp->name == disease->name)
467 return 0; /* already diseased */ 468 return 0; /* already diseased */
468 469
469 /* 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. */
486 new_disease->set_owner (disease->owner); 487 new_disease->set_owner (disease->owner);
487 else if (object *pl = disease->in_player ()) 488 else if (object *pl = disease->in_player ())
488 /* for diseases which are passed by hitting, set owner and skill */ 489 /* for diseases which are passed by hitting, set owner and skill */
489 new_disease->set_owner (pl); 490 new_disease->set_owner (pl);
490 491
492 if (INVOKE_OBJECT (INFECT, victim, ARG_OBJECT (disease), ARG_OBJECT (new_disease)))
493 return 1;
494
491 if (new_disease->owner && new_disease->owner->type == PLAYER) 495 if (new_disease->owner && new_disease->owner->type == PLAYER)
492 { 496 {
493 const char *buf; 497 const char *buf;
494 498
495 /* if the disease has a title, it has a special infection message 499 /* if the disease has a title, it has a special infection message
496 * This messages is printed in the form MESSAGE victim 500 * This messages is printed in the form MESSAGE victim
497 */ 501 */
498 if (new_disease->title) 502 if (new_disease->title)
499 buf = format ("%s %s!!", &disease->title, &victim->name); 503 buf = format ("%s %s!!", &disease->title, &victim->name);
500 else 504 else
501 buf = format ("You infect %s with your disease, %s!", &victim->name, &new_disease->name); 505 buf = format ("You infect %s with your disease, %s!", &victim->name, &new_disease->name);
522 { /* outside a monster/player, die immediately */ 526 { /* outside a monster/player, die immediately */
523 symptom->destroy (); 527 symptom->destroy ();
524 return 0; 528 return 0;
525 } 529 }
526 530
527 /* create the symptom "other arch" object and drop it here 531 /* create the symptom "other arch" object and drop it here
528 * under every part of the monster 532 * under every part of the monster
529 * The victim may well have died. 533 * The victim may well have died.
530 */ 534 */
531 if (victim->map) 535 if (victim->map)
532 { 536 {
533 victim->play_sound (symptom->sound); 537 victim->play_sound (symptom->sound);
534 538
619 623
620 return 1; 624 return 1;
621} 625}
622 626
623#if 0 // unused, but seems interesting 627#if 0 // unused, but seems interesting
624/* reduces disease progression: reduce_symptoms 628/* reduces disease progression: reduce_symptoms
625 * return true if we actually reduce a disease. 629 * return true if we actually reduce a disease.
626 */ 630 */
627static int 631static int
628reduce_symptoms (object *sufferer, int reduction) 632reduce_symptoms (object *sufferer, int reduction)
629{ 633{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines