Attached Files |
0001-Non-binary-poison.patch [^] (11,965 bytes) 2011-10-14 08:25 [Show Content] [Hide Content]From f6647189897917df8cbe9898008b2fb79dbe055a Mon Sep 17 00:00:00 2001
From: Brendan Hickey <brendan@bhickey.net>
Date: Fri, 14 Oct 2011 06:19:13 +0000
Subject: [PATCH] Non-binary poison
---
crawl-ref/source/enum.h | 1 +
crawl-ref/source/itemname.cc | 2 +-
crawl-ref/source/mutation-data.h | 10 +++++
crawl-ref/source/mutation.cc | 4 ++-
crawl-ref/source/ng-setup.cc | 6 ++--
crawl-ref/source/ouch.cc | 2 +-
crawl-ref/source/output.cc | 2 +-
crawl-ref/source/player.cc | 75 +++++++++++++++++++++++++++-----------
crawl-ref/source/player.h | 1 +
crawl-ref/source/random.cc | 7 ++++
crawl-ref/source/random.h | 1 +
11 files changed, 82 insertions(+), 29 deletions(-)
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h
index c644905..7fabb69 100644
--- a/crawl-ref/source/enum.h
+++ b/crawl-ref/source/enum.h
@@ -2598,6 +2598,7 @@ enum mutation_type
MUT_PASSIVE_FREEZE,
MUT_PASSIVE_MAPPING,
MUT_POISON_RESISTANCE,
+ MUT_POISON_SUSCEPTIBILITY,
MUT_POWERED_BY_DEATH,
#if TAG_MAJOR_VERSION != 32
MUT_POWERED_BY_PAIN,
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc
index 564978f..2dd35c8 100644
--- a/crawl-ref/source/itemname.cc
+++ b/crawl-ref/source/itemname.cc
@@ -3056,7 +3056,7 @@ bool is_useless_item(const item_def &item, bool temp)
return (player_mutation_level(MUT_ACUTE_VISION));
case RING_POISON_RESISTANCE:
- return (player_res_poison(false, temp, false)
+ return ((player_res_poison(false, temp, false) > 2)
&& (temp || you.species != SP_VAMPIRE));
case AMU_CONTROLLED_FLIGHT:
diff --git a/crawl-ref/source/mutation-data.h b/crawl-ref/source/mutation-data.h
index d91bcec..f0bb1d4 100644
--- a/crawl-ref/source/mutation-data.h
+++ b/crawl-ref/source/mutation-data.h
@@ -70,6 +70,16 @@
"poison resistance"
},
+{ MUT_POISON_SUSCEPTIBILITY, 10, 1, true, false,
+ "poison susceptibility",
+
+ {"Your system is susceptible to poison.", "", ""},
+ {"You feel sickly.", "", ""},
+ {"You feel a little healthier.", "", ""},
+
+ "poison susceptibility"
+},
+
{ MUT_CARNIVOROUS, 5, 3, false, false,
"carnivore",
diff --git a/crawl-ref/source/mutation.cc b/crawl-ref/source/mutation.cc
index 6fb64c9..985a015 100644
--- a/crawl-ref/source/mutation.cc
+++ b/crawl-ref/source/mutation.cc
@@ -717,7 +717,8 @@ static mutation_type _get_random_xom_mutation()
const mutation_type bad_muts[] = {
MUT_WEAK, MUT_DOPEY,
MUT_CLUMSY, MUT_DEFORMED, MUT_SCREAM,
- MUT_DETERIORATION, MUT_BLURRY_VISION, MUT_FRAIL
+ MUT_DETERIORATION, MUT_BLURRY_VISION, MUT_FRAIL,
+ MUT_POISON_SUSCEPTIBILITY
};
mutation_type mutat = NUM_MUTATIONS;
@@ -810,6 +811,7 @@ static int _handle_conflicting_mutations(mutation_type mutation,
{ MUT_REGENERATION, MUT_SLOW_HEALING, 1},
{ MUT_ACUTE_VISION, MUT_BLURRY_VISION, 1},
{ MUT_FAST, MUT_SLOW, 1},
+ { MUT_POISON_RESISTANCE, MUT_POISON_SUSCEPTIBILITY, 1},
};
// If we have one of the pair, delete all levels of the other,
diff --git a/crawl-ref/source/ng-setup.cc b/crawl-ref/source/ng-setup.cc
index 1b814cb..af21e1d 100644
--- a/crawl-ref/source/ng-setup.cc
+++ b/crawl-ref/source/ng-setup.cc
@@ -263,13 +263,13 @@ void give_basic_mutations(species_type speci)
break;
case SP_NAGA:
you.mutation[MUT_ACUTE_VISION] = 1;
- you.mutation[MUT_POISON_RESISTANCE] = 1;
+ you.mutation[MUT_POISON_RESISTANCE] = 2;
you.mutation[MUT_DEFORMED] = 1;
you.mutation[MUT_SLOW] = 2;
break;
case SP_MUMMY:
you.mutation[MUT_TORMENT_RESISTANCE] = 1;
- you.mutation[MUT_POISON_RESISTANCE] = 1;
+ you.mutation[MUT_POISON_RESISTANCE] = 3;
you.mutation[MUT_COLD_RESISTANCE] = 1;
you.mutation[MUT_NEGATIVE_ENERGY_RESISTANCE] = 3;
you.mutation[MUT_UNBREATHING] = 1;
@@ -280,7 +280,7 @@ void give_basic_mutations(species_type speci)
break;
case SP_GHOUL:
you.mutation[MUT_TORMENT_RESISTANCE] = 1;
- you.mutation[MUT_POISON_RESISTANCE] = 1;
+ you.mutation[MUT_POISON_RESISTANCE] = 3;
you.mutation[MUT_COLD_RESISTANCE] = 1;
you.mutation[MUT_NEGATIVE_ENERGY_RESISTANCE] = 3;
you.mutation[MUT_SAPROVOROUS] = 3;
diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc
index cb6bda1..2365ce0 100644
--- a/crawl-ref/source/ouch.cc
+++ b/crawl-ref/source/ouch.cc
@@ -186,7 +186,7 @@ int check_your_resists(int hurted, beam_type flavour, std::string source,
hurted = resist_adjust_damage(&you, flavour, resist,
hurted, true);
- if (resist > 0 && doEffects)
+ if (resist > 0 && maybe_player_res_poison())
canned_msg(MSG_YOU_RESIST);
break;
diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc
index 14fcfe8..496e52a 100644
--- a/crawl-ref/source/output.cc
+++ b/crawl-ref/source/output.cc
@@ -1783,7 +1783,7 @@ static std::vector<formatted_string> _get_overview_resistances(
_determine_colour_string(rcold, 3), _itosym3(rcold),
_determine_colour_string(rlife, 3), _itosym3(rlife),
_determine_colour_string(racid, 3), _itosym3(racid),
- _determine_colour_string(rpois, 1), _itosym1(rpois),
+ _determine_colour_string(rpois, 3), _itosym3(rpois),
_determine_colour_string(relec, 1), _itosym1(relec),
_determine_colour_string(rsust, 2), _itosym2(rsust),
_determine_colour_string(rmuta, 1), _itosym1(rmuta),
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 3e294e6..11f7a5a 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -1738,68 +1738,99 @@ int player_res_torment(bool, bool temp)
> random2(100))));
}
+bool _poison_immune(bool temp) {
+ return (you.species == SP_GHOUL
+ || you.species == SP_MUMMY
+ || (temp && you.form == TRAN_LICH || you.form == TRAN_STATUE));
+
+
+}
+
// Funny that no races are susceptible to poisons. {dlb}
// If temp is set to false, temporary sources or resistance won't be counted.
int player_res_poison(bool calc_unid, bool temp, bool items)
{
- int rp = 0;
+ if (_poison_immune(temp))
+ return 3;
+
+ int item_rp = 0;
+ int intrinsic_rp = 0;
+ int magic_rp = 0;
if (items)
{
// rings of poison resistance
- rp += player_equip(EQ_RINGS, RING_POISON_RESISTANCE, calc_unid);
+ item_rp += player_equip(EQ_RINGS, RING_POISON_RESISTANCE, calc_unid);
// Staves
- rp += player_equip(EQ_STAFF, STAFF_POISON, calc_unid);
+ item_rp += player_equip(EQ_STAFF, STAFF_POISON, calc_unid);
// ego armour:
- rp += player_equip_ego_type(EQ_ALL_ARMOUR, SPARM_POISON_RESISTANCE);
+ item_rp += player_equip_ego_type(EQ_ALL_ARMOUR, SPARM_POISON_RESISTANCE);
// body armour:
- rp += player_equip(EQ_BODY_ARMOUR, ARM_GOLD_DRAGON_ARMOUR);
- rp += player_equip(EQ_BODY_ARMOUR, ARM_SWAMP_DRAGON_ARMOUR);
- rp += player_equip(EQ_BODY_ARMOUR, ARM_GOLD_DRAGON_HIDE);
- rp += player_equip(EQ_BODY_ARMOUR, ARM_SWAMP_DRAGON_HIDE);
+ item_rp += player_equip(EQ_BODY_ARMOUR, ARM_GOLD_DRAGON_ARMOUR);
+ item_rp += player_equip(EQ_BODY_ARMOUR, ARM_SWAMP_DRAGON_ARMOUR);
+ item_rp += player_equip(EQ_BODY_ARMOUR, ARM_GOLD_DRAGON_HIDE);
+ item_rp += player_equip(EQ_BODY_ARMOUR, ARM_SWAMP_DRAGON_HIDE);
// randart weapons:
- rp += scan_artefacts(ARTP_POISON, calc_unid);
+ item_rp += scan_artefacts(ARTP_POISON, calc_unid);
+
}
// mutations:
- rp += player_mutation_level(MUT_POISON_RESISTANCE);
- rp += player_mutation_level(MUT_SLIMY_GREEN_SCALES) == 3 ? 1 : 0;
+ intrinsic_rp += player_mutation_level(MUT_POISON_RESISTANCE);
+ intrinsic_rp -= player_mutation_level(MUT_POISON_SUSCEPTIBILITY);
+ intrinsic_rp += player_mutation_level(MUT_SLIMY_GREEN_SCALES) == 3 ? 1 : 0;
// Only thirsty vampires are naturally poison resistant.
if (you.species == SP_VAMPIRE && you.hunger_state < HS_SATIATED)
- rp++;
+ intrinsic_rp++;
if (temp)
{
// spells:
if (you.duration[DUR_RESIST_POISON] > 0)
- rp++;
+ magic_rp++;
// transformations:
switch (you.form)
{
- case TRAN_LICH:
case TRAN_ICE_BEAST:
- case TRAN_STATUE:
case TRAN_DRAGON:
- rp++;
+ magic_rp++;
+ break;
+ case TRAN_SPIDER:
+ magic_rp--;
break;
default:
break;
}
if (you.petrified())
- rp++;
+ magic_rp++;
}
- if (rp > 1)
- rp = 1;
+ item_rp = std::min(3, item_rp);
+ intrinsic_rp = std::min(3, intrinsic_rp);
+ magic_rp = std::min(3, magic_rp);
+
+ return std::min(3, item_rp + intrinsic_rp + magic_rp);
+
+}
+
+bool maybe_player_res_poison()
+{
+ if (_poison_immune(true))
+ return false;
+
+ int rp = player_res_poison(true, true, true);
+
+ if (rp <= 0)
+ return false;
- return (rp);
+ return random_sigmoid(rp);
}
int player_res_sticky_flame(bool calc_unid, bool temp, bool items)
@@ -4780,7 +4811,7 @@ bool curare_hits_player(int death_source, int amount, const bolt &beam)
{
ASSERT(!crawl_state.game_is_arena());
- if (player_res_poison() > 0)
+ if (maybe_player_res_poison())
return (false);
poison_player(amount, beam.get_source_name(), beam.name);
@@ -4818,7 +4849,7 @@ bool poison_player(int amount, std::string source, std::string source_aux,
{
ASSERT(!crawl_state.game_is_arena());
- if (!force && player_res_poison() > 0 || amount <= 0)
+ if (!force && maybe_player_res_poison() || amount <= 0)
return (false);
if (!force && you.duration[DUR_DIVINE_STAMINA] > 0)
diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h
index 09e16c0..83fb325 100644
--- a/crawl-ref/source/player.h
+++ b/crawl-ref/source/player.h
@@ -833,6 +833,7 @@ int player_res_steam(bool calc_unid = true, bool temp = true,
int player_res_poison(bool calc_unid = true, bool temp = true,
bool items = true);
+bool maybe_player_res_poison();
int player_res_magic(bool calc_unid = true, bool temp = true);
bool player_control_teleport(bool calc_unid = true, bool temp = true,
diff --git a/crawl-ref/source/random.cc b/crawl-ref/source/random.cc
index 59072a1..c78c4ae 100644
--- a/crawl-ref/source/random.cc
+++ b/crawl-ref/source/random.cc
@@ -319,6 +319,13 @@ bool x_chance_in_y(int x, int y)
return (random2(y) < x);
}
+// Given a sigmoid function with parameter t, is a uniform sample greater
+// than the value returned by the function?
+bool random_sigmoid(float t)
+{
+ return (random_real() > 1. / (1. + exp(t)));
+}
+
// [val - lowfuzz, val + highfuzz]
int fuzz_value(int val, int lowfuzz, int highfuzz, int naverage)
{
diff --git a/crawl-ref/source/random.h b/crawl-ref/source/random.h
index 6d7bf8f..626b2eb 100644
--- a/crawl-ref/source/random.h
+++ b/crawl-ref/source/random.h
@@ -29,6 +29,7 @@ int binomial_generator(unsigned n_trials, unsigned trial_prob);
bool bernoulli(double n_trials, double trial_prob);
int fuzz_value(int val, int lowfuzz, int highfuzz, int naverage = 2);
int roll_dice(int num, int size);
+bool random_sigmoid(float t);
struct dice_def
{
--
1.5.6.5
0001-rP-confers-90-poison-resistance.patch [^] (6,040 bytes) 2011-10-14 21:46 [Show Content] [Hide Content]From f52b768ac1ae75e522b7a8f20d7631fd1b82d736 Mon Sep 17 00:00:00 2001
From: Brendan Hickey <brendan@bhickey.net>
Date: Fri, 14 Oct 2011 19:45:47 +0000
Subject: [PATCH] rP confers 90% poison resistance
---
crawl-ref/source/ouch.cc | 17 +++++++++--------
crawl-ref/source/player.cc | 39 +++++++++++++++++++++++++++++++++------
crawl-ref/source/player.h | 1 +
crawl-ref/source/spl-damage.cc | 7 ++++---
4 files changed, 47 insertions(+), 17 deletions(-)
diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc
index cb6bda1..13202da 100644
--- a/crawl-ref/source/ouch.cc
+++ b/crawl-ref/source/ouch.cc
@@ -179,14 +179,13 @@ int check_your_resists(int hurted, beam_type flavour, std::string source,
break;
case BEAM_POISON:
- resist = player_res_poison();
- if (resist <= 0 && doEffects)
- poison_player(coinflip() ? 2 : 1, source, kaux);
+ if (doEffects)
+ resist = poison_player(coinflip() ? 2 : 1, source, kaux);
hurted = resist_adjust_damage(&you, flavour, resist,
hurted, true);
- if (resist > 0 && doEffects)
+ if (resist == 0 && doEffects)
canned_msg(MSG_YOU_RESIST);
break;
@@ -194,12 +193,14 @@ int check_your_resists(int hurted, beam_type flavour, std::string source,
// [dshaligram] NOT importing uber-poison arrow from 4.1. Giving no
// bonus to poison resistant players seems strange and unnecessarily
// arbitrary.
+
resist = player_res_poison();
- if (!resist && doEffects)
- poison_player(4 + random2(3), source, kaux, true);
- else if (!you.is_undead && doEffects)
- poison_player(2 + random2(3), source, kaux, true);
+ if (doEffects) {
+ int poison_amount = 2 + random2(3);
+ poison_amount += (resist ? 0 : 2);
+ poison_player(poison_amount, source, kaux, true);
+ }
hurted = resist_adjust_damage(&you, flavour, resist, hurted);
if (hurted < original && doEffects)
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 3e294e6..2425acc 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -1742,6 +1742,9 @@ int player_res_torment(bool, bool temp)
// If temp is set to false, temporary sources or resistance won't be counted.
int player_res_poison(bool calc_unid, bool temp, bool items)
{
+ if (you.are_currently_undead())
+ return 1;
+
int rp = 0;
if (items)
@@ -1763,6 +1766,7 @@ int player_res_poison(bool calc_unid, bool temp, bool items)
// randart weapons:
rp += scan_artefacts(ARTP_POISON, calc_unid);
+
}
// mutations:
@@ -1782,7 +1786,6 @@ int player_res_poison(bool calc_unid, bool temp, bool items)
// transformations:
switch (you.form)
{
- case TRAN_LICH:
case TRAN_ICE_BEAST:
case TRAN_STATUE:
case TRAN_DRAGON:
@@ -1796,10 +1799,18 @@ int player_res_poison(bool calc_unid, bool temp, bool items)
rp++;
}
- if (rp > 1)
- rp = 1;
+ return (rp > 0 ? 1 : 0);
+
+}
+
+int _maybe_reduce_poison(int amount)
+{
+ int rp = player_res_poison(true, true, true);
+
+ if (rp <= 0)
+ return amount;
- return (rp);
+ return (amount - binomial_generator(amount, 90));
}
int player_res_sticky_flame(bool calc_unid, bool temp, bool items)
@@ -4780,7 +4791,10 @@ bool curare_hits_player(int death_source, int amount, const bolt &beam)
{
ASSERT(!crawl_state.game_is_arena());
- if (player_res_poison() > 0)
+ if (you.are_currently_undead())
+ return (false);
+
+ if (!(amount = _maybe_reduce_poison(amount)))
return (false);
poison_player(amount, beam.get_source_name(), beam.name);
@@ -4818,7 +4832,10 @@ bool poison_player(int amount, std::string source, std::string source_aux,
{
ASSERT(!crawl_state.game_is_arena());
- if (!force && player_res_poison() > 0 || amount <= 0)
+ if (you.are_currently_undead())
+ return (false);
+
+ if (!force && !(amount = _maybe_reduce_poison(amount)))
return (false);
if (!force && you.duration[DUR_DIVINE_STAMINA] > 0)
@@ -4857,6 +4874,9 @@ void dec_poison_player()
&& coinflip())
return;
+ if (you.are_currently_undead())
+ return;
+
if (you.duration[DUR_POISONING] > 0)
{
if (x_chance_in_y(you.duration[DUR_POISONING], 5))
@@ -7004,6 +7024,13 @@ bool player::is_skeletal() const
return (false);
}
+bool player::are_currently_undead() const {
+ return (form == TRAN_LICH
+ || (is_undead == US_SEMI_UNDEAD && hunger_state == HS_STARVING)
+ || (is_undead == US_UNDEAD)
+ || (is_undead == US_HUNGRY_DEAD));
+}
+
void player::shiftto(const coord_def &c)
{
crawl_view.shift_player_to(c);
diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h
index 09e16c0..9cc60f2 100644
--- a/crawl-ref/source/player.h
+++ b/crawl-ref/source/player.h
@@ -434,6 +434,7 @@ public:
bool is_icy() const;
bool is_fiery() const;
bool is_skeletal() const;
+ bool are_currently_undead() const;
bool light_flight() const;
bool travelling_light() const;
diff --git a/crawl-ref/source/spl-damage.cc b/crawl-ref/source/spl-damage.cc
index 22d0028..52ea85d 100644
--- a/crawl-ref/source/spl-damage.cc
+++ b/crawl-ref/source/spl-damage.cc
@@ -345,10 +345,11 @@ spret_type cast_toxic_radiance(bool non_player, bool fail)
{
mpr("The light passes straight through your body.");
}
- else if (!player_res_poison())
+ else
{
- mpr("You feel rather sick.");
- poison_player(2, "", "toxic radiance");
+ int poison_amount = poison_player(2, "", "toxic radiance");
+ if (poison_amount)
+ mpr("You feel rather sick.");
}
counted_monster_list affected_monsters;
--
1.5.6.5
0001-Simplified-poisoning-rP-is-90-effective.patch [^] (12,038 bytes) 2011-10-15 22:59 [Show Content] [Hide Content]From b5003015b57a24d302c8fbe85690aece50b54193 Mon Sep 17 00:00:00 2001
From: Brendan Hickey <brendan@bhickey.net>
Date: Sat, 15 Oct 2011 20:49:27 +0000
Subject: [PATCH] Simplified poisoning, rP is 90% effective
---
crawl-ref/source/actor.h | 2 +-
crawl-ref/source/fight.cc | 29 +++++++++-----------
crawl-ref/source/monster.cc | 6 ++--
crawl-ref/source/monster.h | 2 +-
crawl-ref/source/ouch.cc | 17 ++++++-----
crawl-ref/source/player.cc | 56 ++++++++++++++++++++++++++++++++-------
crawl-ref/source/player.h | 3 +-
crawl-ref/source/spl-damage.cc | 7 +++--
8 files changed, 79 insertions(+), 43 deletions(-)
diff --git a/crawl-ref/source/actor.h b/crawl-ref/source/actor.h
index 32e971e..875db96 100644
--- a/crawl-ref/source/actor.h
+++ b/crawl-ref/source/actor.h
@@ -187,7 +187,7 @@ public:
virtual void teleport(bool right_now = false,
bool abyss_shift = false,
bool wizard_tele = false) = 0;
- virtual void poison(actor *attacker, int amount = 1, bool force = false) = 0;
+ virtual bool poison(actor *attacker, int amount = 1, bool force = false) = 0;
virtual bool sicken(int amount, bool allow_hint = true) = 0;
virtual void paralyse(actor *attacker, int strength,
std::string source = "") = 0;
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 5ef4072..7ea0a8a 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -4647,14 +4647,22 @@ void melee_attack::mons_set_weapon(const mon_attack_def &attk)
void melee_attack::mons_do_poison(const mon_attack_def &attk)
{
- if (defender->res_poison() > 0)
- return;
-
if (attk.flavour == AF_POISON_NASTY
|| one_chance_in(15 + 5 * (attk.flavour == AF_POISON ? 1 : 0))
|| (damage_done > 1
&& one_chance_in(attk.flavour == AF_POISON ? 4 : 3)))
{
+ int amount = 1;
+ if (attk.flavour == AF_POISON_NASTY)
+ amount++;
+ else if (attk.flavour == AF_POISON_MEDIUM)
+ amount += random2(3);
+ else if (attk.flavour == AF_POISON_STRONG)
+ amount += roll_dice(2, 5);
+
+ if(!defender->poison(attacker, amount))
+ return;
+
if (needs_message)
{
if (defender->atype() == ACT_PLAYER
@@ -4674,16 +4682,6 @@ void melee_attack::mons_do_poison(const mon_attack_def &attk)
mons_defender_name().c_str());
}
}
-
- int amount = 1;
- if (attk.flavour == AF_POISON_NASTY)
- amount++;
- else if (attk.flavour == AF_POISON_MEDIUM)
- amount += random2(3);
- else if (attk.flavour == AF_POISON_STRONG)
- amount += roll_dice(2, 5);
-
- defender->poison(attacker, amount);
}
}
@@ -4955,9 +4953,8 @@ void melee_attack::mons_apply_attack_flavour(const mon_attack_def &attk)
case AF_POISON_STR:
case AF_POISON_INT:
case AF_POISON_DEX:
- if (defender->res_poison() <= 0)
+ if (defender->poison(attacker, roll_dice(1, 3)))
{
- defender->poison(attacker, roll_dice(1, 3));
if (one_chance_in(4))
{
stat_type drained_stat = (flavour == AF_POISON_STR ? STAT_STR :
@@ -5138,7 +5135,7 @@ void melee_attack::mons_apply_attack_flavour(const mon_attack_def &attk)
break;
case AF_ACID:
- if (attacker->type == MONS_SPINY_WORM && defender->res_poison() <= 0)
+ if (attacker->type == MONS_SPINY_WORM)
defender->poison(attacker, 2 + random2(4));
splash_defender_with_acid(3);
break;
diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc
index fc73c42..4abcfd8 100644
--- a/crawl-ref/source/monster.cc
+++ b/crawl-ref/source/monster.cc
@@ -3565,16 +3565,16 @@ int monster::mons_species() const
return ::mons_species(type);
}
-void monster::poison(actor *agent, int amount, bool force)
+bool monster::poison(actor *agent, int amount, bool force)
{
if (amount <= 0)
- return;
+ return (false);
// Scale poison down for monsters.
if (!(amount /= 2))
amount = 1;
- poison_monster(this, agent, amount, force);
+ return poison_monster(this, agent, amount, force);
}
int monster::skill(skill_type sk, int scale, bool real) const
diff --git a/crawl-ref/source/monster.h b/crawl-ref/source/monster.h
index c96d558..0324995 100644
--- a/crawl-ref/source/monster.h
+++ b/crawl-ref/source/monster.h
@@ -370,7 +370,7 @@ public:
int armour_class() const;
int melee_evasion(const actor *attacker, ev_ignore_type evit) const;
- void poison(actor *agent, int amount = 1, bool force = false);
+ bool poison(actor *agent, int amount = 1, bool force = false);
bool sicken(int strength, bool unused = true);
bool bleed(const actor *agent, int amount, int degree);
void paralyse(actor *, int str, std::string source = "");
diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc
index cb6bda1..13202da 100644
--- a/crawl-ref/source/ouch.cc
+++ b/crawl-ref/source/ouch.cc
@@ -179,14 +179,13 @@ int check_your_resists(int hurted, beam_type flavour, std::string source,
break;
case BEAM_POISON:
- resist = player_res_poison();
- if (resist <= 0 && doEffects)
- poison_player(coinflip() ? 2 : 1, source, kaux);
+ if (doEffects)
+ resist = poison_player(coinflip() ? 2 : 1, source, kaux);
hurted = resist_adjust_damage(&you, flavour, resist,
hurted, true);
- if (resist > 0 && doEffects)
+ if (resist == 0 && doEffects)
canned_msg(MSG_YOU_RESIST);
break;
@@ -194,12 +193,14 @@ int check_your_resists(int hurted, beam_type flavour, std::string source,
// [dshaligram] NOT importing uber-poison arrow from 4.1. Giving no
// bonus to poison resistant players seems strange and unnecessarily
// arbitrary.
+
resist = player_res_poison();
- if (!resist && doEffects)
- poison_player(4 + random2(3), source, kaux, true);
- else if (!you.is_undead && doEffects)
- poison_player(2 + random2(3), source, kaux, true);
+ if (doEffects) {
+ int poison_amount = 2 + random2(3);
+ poison_amount += (resist ? 0 : 2);
+ poison_player(poison_amount, source, kaux, true);
+ }
hurted = resist_adjust_damage(&you, flavour, resist, hurted);
if (hurted < original && doEffects)
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 3e294e6..6d30a3f 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -1742,6 +1742,9 @@ int player_res_torment(bool, bool temp)
// If temp is set to false, temporary sources or resistance won't be counted.
int player_res_poison(bool calc_unid, bool temp, bool items)
{
+ if (you.are_currently_undead())
+ return 1;
+
int rp = 0;
if (items)
@@ -1763,6 +1766,7 @@ int player_res_poison(bool calc_unid, bool temp, bool items)
// randart weapons:
rp += scan_artefacts(ARTP_POISON, calc_unid);
+
}
// mutations:
@@ -1782,7 +1786,6 @@ int player_res_poison(bool calc_unid, bool temp, bool items)
// transformations:
switch (you.form)
{
- case TRAN_LICH:
case TRAN_ICE_BEAST:
case TRAN_STATUE:
case TRAN_DRAGON:
@@ -1796,10 +1799,26 @@ int player_res_poison(bool calc_unid, bool temp, bool items)
rp++;
}
- if (rp > 1)
- rp = 1;
+ return (rp > 0 ? 1 : 0);
+
+}
+
+int _maybe_reduce_poison(int amount)
+{
+ int rp = player_res_poison(true, true, true);
- return (rp);
+ if (rp <= 0)
+ return amount;
+
+ int reduction = binomial_generator(amount, 90);
+ int new_amount = amount - reduction;
+
+ if (amount != new_amount) {
+ dprf("Poison reduced (%d -> %d)", amount, new_amount);
+ } else {
+ dprf("Poison not reduced (%d)", amount);
+ }
+ return new_amount;
}
int player_res_sticky_flame(bool calc_unid, bool temp, bool items)
@@ -4780,10 +4799,11 @@ bool curare_hits_player(int death_source, int amount, const bolt &beam)
{
ASSERT(!crawl_state.game_is_arena());
- if (player_res_poison() > 0)
+ if (you.are_currently_undead())
return (false);
- poison_player(amount, beam.get_source_name(), beam.name);
+ if(!poison_player(amount, beam.get_source_name(), beam.name))
+ return (false);
int hurted = 0;
@@ -4818,7 +4838,13 @@ bool poison_player(int amount, std::string source, std::string source_aux,
{
ASSERT(!crawl_state.game_is_arena());
- if (!force && player_res_poison() > 0 || amount <= 0)
+ if (you.are_currently_undead())
+ {
+ dprf("Cannot poison, you are undead!");
+ return (false);
+ }
+
+ if (!force && !(amount = _maybe_reduce_poison(amount)))
return (false);
if (!force && you.duration[DUR_DIVINE_STAMINA] > 0)
@@ -4844,7 +4870,7 @@ bool poison_player(int amount, std::string source, std::string source_aux,
you.props["poisoner"] = source;
you.props["poison_aux"] = source_aux;
- return (true);
+ return amount;
}
void dec_poison_player()
@@ -4857,6 +4883,9 @@ void dec_poison_player()
&& coinflip())
return;
+ if (you.are_currently_undead())
+ return;
+
if (you.duration[DUR_POISONING] > 0)
{
if (x_chance_in_y(you.duration[DUR_POISONING], 5))
@@ -6392,9 +6421,9 @@ int player::mons_species() const
}
}
-void player::poison(actor *agent, int amount, bool force)
+bool player::poison(actor *agent, int amount, bool force)
{
- ::poison_player(amount, agent? agent->name(DESC_NOCAP_A, true) : "");
+ return ::poison_player(amount, agent? agent->name(DESC_NOCAP_A, true) : "");
}
void player::expose_to_element(beam_type element, int st)
@@ -7004,6 +7033,13 @@ bool player::is_skeletal() const
return (false);
}
+bool player::are_currently_undead() const {
+ return (form == TRAN_LICH
+ || (is_undead == US_SEMI_UNDEAD && hunger_state == HS_STARVING)
+ || (is_undead == US_UNDEAD)
+ || (is_undead == US_HUNGRY_DEAD));
+}
+
void player::shiftto(const coord_def &c)
{
crawl_view.shift_player_to(c);
diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h
index 09e16c0..81550b7 100644
--- a/crawl-ref/source/player.h
+++ b/crawl-ref/source/player.h
@@ -434,6 +434,7 @@ public:
bool is_icy() const;
bool is_fiery() const;
bool is_skeletal() const;
+ bool are_currently_undead() const;
bool light_flight() const;
bool travelling_light() const;
@@ -563,7 +564,7 @@ public:
int hunger_level() const { return hunger_state; }
void make_hungry(int nutrition, bool silent = true);
- void poison(actor *agent, int amount = 1, bool force = false);
+ bool poison(actor *agent, int amount = 1, bool force = false);
bool sicken(int amount, bool allow_hint = true);
void paralyse(actor *, int str, std::string source = "");
void petrify(actor *);
diff --git a/crawl-ref/source/spl-damage.cc b/crawl-ref/source/spl-damage.cc
index 22d0028..52ea85d 100644
--- a/crawl-ref/source/spl-damage.cc
+++ b/crawl-ref/source/spl-damage.cc
@@ -345,10 +345,11 @@ spret_type cast_toxic_radiance(bool non_player, bool fail)
{
mpr("The light passes straight through your body.");
}
- else if (!player_res_poison())
+ else
{
- mpr("You feel rather sick.");
- poison_player(2, "", "toxic radiance");
+ int poison_amount = poison_player(2, "", "toxic radiance");
+ if (poison_amount)
+ mpr("You feel rather sick.");
}
counted_monster_list affected_monsters;
--
1.5.6.5
|