diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-04-02 19:25:19 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-04-02 19:25:19 +0000 |
commit | b9b92f995250e412eee9dbfcd529927a526a6e8e (patch) | |
tree | 2693ff76b5b0e03d555480a8c88f57c4af2ddc84 | |
parent | 9acf2085c7953fad9b11962b16168f3a2d078f5f (diff) | |
download | crawl-ref-b9b92f995250e412eee9dbfcd529927a526a6e8e.tar.gz crawl-ref-b9b92f995250e412eee9dbfcd529927a526a6e8e.zip |
Allow AF_DISEASE attacks to sicken monsters.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1195 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r-- | crawl-ref/source/direct.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/enum.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/externs.h | 3 | ||||
-rw-r--r-- | crawl-ref/source/fight.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/mon-util.cc | 30 | ||||
-rw-r--r-- | crawl-ref/source/monstuff.cc | 12 | ||||
-rw-r--r-- | crawl-ref/source/player.cc | 21 |
7 files changed, 61 insertions, 12 deletions
diff --git a/crawl-ref/source/direct.cc b/crawl-ref/source/direct.cc index 6cbc6a4120..d38f9dcbac 100644 --- a/crawl-ref/source/direct.cc +++ b/crawl-ref/source/direct.cc @@ -1398,6 +1398,9 @@ static void describe_mons_enchantment(const monsters &mons, case ENCH_POISON: strcat(info, " is poisoned."); break; + case ENCH_SICK: + strcat(info, " is sick."); + break; case ENCH_ROT: strcat(info, " is rotting away."); //jmf: "covered in sores"? break; diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 4223245ab6..fad67e73db 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -1185,6 +1185,7 @@ enum enchant_type ENCH_SUBMERGED, ENCH_SHORT_LIVED, ENCH_PARALYSIS, // 20 + ENCH_SICK, NUM_ENCHANTMENTS }; diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 0f74a1a22b..108a168057 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -149,6 +149,7 @@ public: virtual void blink() = 0; virtual void teleport(bool right_now = false, bool abyss_shift = false) = 0; virtual void poison(actor *attacker, int amount = 1) = 0; + virtual void sicken(int amount) = 0; virtual void paralyse(int strength) = 0; virtual void slow_down(int strength) = 0; virtual void confuse(int strength) = 0; @@ -757,6 +758,7 @@ public: int hunger_level() const { return hunger_state; } void make_hungry(int nutrition, bool silent = true); void poison(actor *agent, int amount = 1); + void sicken(int amount); void paralyse(int str); void slow_down(int str); void confuse(int strength); @@ -986,6 +988,7 @@ public: int melee_evasion(const actor *attacker) const; void poison(actor *agent, int amount = 1); + void sicken(int strength); void paralyse(int str); void slow_down(int str); void confuse(int strength); diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 05cd73127c..1e99499072 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -2727,8 +2727,7 @@ void melee_attack::mons_apply_attack_flavour(const mon_attack_def &attk) break; case AF_DISEASE: - if (defender->atype() == ACT_PLAYER) - disease_player( 50 + random2(100) ); + defender->sicken( 50 + random2(100) ); break; case AF_FIRE: diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index bb5e894e17..89a44c46a8 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -3275,6 +3275,7 @@ void monsters::timeout_enchantments(int levels) case ENCH_STICKY_FLAME: case ENCH_ABJ: case ENCH_SHORT_LIVED: case ENCH_SLOW: case ENCH_HASTE: case ENCH_FEAR: case ENCH_INVIS: case ENCH_CHARM: case ENCH_SLEEP_WARY: + case ENCH_SICK: lose_ench_levels(*cur, levels); break; @@ -3340,6 +3341,14 @@ void monsters::apply_enchantment(mon_enchant me, int spd) } break; + case ENCH_SICK: + { + const int lost = !spd? 1 : div_rand_round(10, spd); + if (lost > 0) + lose_ench_levels(me, lost); + break; + } + case ENCH_SUBMERGED: { // not even air elementals unsubmerge into clouds @@ -3585,6 +3594,21 @@ kill_category monsters::kill_alignment() const return (attitude == ATT_FRIENDLY? KC_FRIENDLY : KC_OTHER); } +void monsters::sicken(int amount) +{ + if (holiness() != MH_NATURAL || (amount /= 2) < 1) + return; + + if (!has_ench(ENCH_SICK) + && mons_near(this) && player_monster_visible(this)) + { + // Yes, could be confused with poisoning. + mprf("%s looks sick.", name(DESC_CAP_THE).c_str()); + } + + add_ench(mon_enchant(ENCH_SICK, amount)); +} + ///////////////////////////////////////////////////////////////////////// // mon_enchant @@ -3593,7 +3617,7 @@ static const char *enchant_names[] = "none", "slow", "haste", "fear", "conf", "inv", "pois", "bers", "rot", "summon", "abj", "backlit", "charm", "fire", "gloshifter", "shifter", "tp", "wary", "submerged", - "short lived", "paralysis", "bug" + "short lived", "paralysis", "sick", "bug" }; const char *mons_enchantment_name(enchant_type ench) @@ -3628,6 +3652,10 @@ void mon_enchant::merge_killer(kill_category k) void mon_enchant::cap_degree() { + // Sickness is not capped. + if (ench == ENCH_SICK) + return; + // Hard cap to simulate old enum behaviour, we should really throw this // out entirely. const int max = ench == ENCH_ABJ? 6 : 4; diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index d4e3e67354..94857775f1 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -2403,7 +2403,8 @@ static bool handle_potion(struct monsters *monster, bolt & beem) { bool imbibed = false; - switch (mitm[monster->inv[MSLOT_POTION]].sub_type) + const int potion_type = mitm[monster->inv[MSLOT_POTION]].sub_type; + switch (potion_type) { case POT_HEALING: case POT_HEAL_WOUNDS: @@ -2423,6 +2424,12 @@ static bool handle_potion(struct monsters *monster, bolt & beem) heal_monster(monster, 10 + random2avg(28, 3), false); } + if (potion_type == POT_HEALING) + { + monster->del_ench(ENCH_POISON); + monster->del_ench(ENCH_SICK); + } + imbibed = true; } break; @@ -3319,6 +3326,9 @@ static void monster_add_energy(monsters *monster) // Do natural regeneration for monster. static void monster_regenerate(monsters *monster) { + if (monster->has_ench(ENCH_SICK)) + return; + // regenerate: if (monster_descriptor(monster->type, MDSC_REGENERATES) diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 22f3339a03..abf7f089e0 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -4424,14 +4424,7 @@ void dec_haste_player( void ) void disease_player( int amount ) { - if (you.is_undead || amount <= 0) - return; - - mpr( "You feel ill." ); - - const int tmp = you.disease + amount; - you.disease = (tmp > 210) ? 210 : tmp; - learned_something_new(TUT_YOU_SICK); + you.sicken(amount); } void dec_disease_player( void ) @@ -5214,3 +5207,15 @@ kill_category player::kill_alignment() const { return (KC_YOU); } + +void player::sicken(int amount) +{ + if (is_undead || amount <= 0) + return; + + mpr( "You feel ill." ); + + const int tmp = disease + amount; + disease = (tmp > 210) ? 210 : tmp; + learned_something_new(TUT_YOU_SICK); +} |