Skip to content

Commit

Permalink
Display odds for Confusing Touch/Fungus Form
Browse files Browse the repository at this point in the history
Resolves crawl#383.

Also, seeing these numbers makes me realize I should probably
re-nerf Confusing Touch.
  • Loading branch information
PleasingFungus authored and Hellmonk committed Nov 28, 2016
1 parent 2809437 commit 30a9938
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 11 deletions.
3 changes: 1 addition & 2 deletions crawl-ref/source/attack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1749,8 +1749,7 @@ bool attack::apply_damage_brand(const char *what)
break;
}

if (random2(30) < defender->get_hit_dice()
|| one_chance_in(5)
if (!x_chance_in_y(melee_confuse_chance(defender->get_hit_dice()), 100)
|| defender->as_monster()->check_clarity(false))
{
break;
Expand Down
8 changes: 8 additions & 0 deletions crawl-ref/source/directn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "describe.h"
#include "dungeon.h"
#include "english.h"
#include "fight.h" // melee_confuse_chance
#include "food.h"
#include "godabil.h"
#include "hints.h"
Expand Down Expand Up @@ -3010,6 +3011,13 @@ static vector<string> _get_monster_desc_vector(const monster_info& mi)

_append_container(descs, _get_monster_behaviour_vector(mi));

if (you.duration[DUR_CONFUSING_TOUCH] && !you.weapon()
|| you.form == TRAN_FUNGUS && !mons_is_unbreathing(mi.type))
{
descs.emplace_back(make_stringf("confuse odds on hit: %d%%",
melee_confuse_chance(mi.hd)));
}

if (mi.attitude == ATT_FRIENDLY)
descs.emplace_back("friendly");
else if (mi.attitude == ATT_GOOD_NEUTRAL)
Expand Down
13 changes: 13 additions & 0 deletions crawl-ref/source/fight.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@
#include "traps.h"
#include "travel.h"

/**
* What are the odds of an HD-checking confusion effect (e.g. Confusing Touch,
* Fungus Form, SPWPN_CHAOS maybe) to confuse a monster of the given HD?
*
* @param HD The current hit dice (level) of the monster to confuse.
* @return A percentage chance (0-100) of confusing that monster.
* (Except it tops out at 80%.)
*/
int melee_confuse_chance(int HD)
{
return 80 * (30 - HD) / 30;
}

/**
* Switch from a bad weapon to melee.
*
Expand Down
2 changes: 2 additions & 0 deletions crawl-ref/source/fight.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ int resist_adjust_damage(const actor *defender, beam_type flavour,

int apply_chunked_AC(int dam, int ac);

int melee_confuse_chance(int HD);

bool wielded_weapon_check(item_def *weapon);

stab_type find_stab_type(const actor *attacker,
Expand Down
13 changes: 13 additions & 0 deletions crawl-ref/source/mon-util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3340,6 +3340,19 @@ bool mons_is_seeking(const monster& m)
return m.behaviour == BEH_SEEK;
}

bool mons_is_unbreathing(monster_type mc)
{
const mon_holy_type holi = mons_class_holiness(mc);

if (holi & (MH_UNDEAD | MH_NONLIVING | MH_PLANT))
return true;

if (mons_class_is_slime(mc))
return true;

return mons_class_flag(mc, M_UNBREATHING);
}

// Either running in fear, or trapped and unable to do so (but still wishing to)
bool mons_is_fleeing(const monster& m)
{
Expand Down
1 change: 1 addition & 0 deletions crawl-ref/source/mon-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ bool mons_is_active_ballisto(const monster& mon);
bool mons_has_body(const monster& mon);
bool mons_has_flesh(const monster& mon);
bool mons_is_abyssal_only(monster_type mc);
bool mons_is_unbreathing(monster_type mc);

bool herd_monster(const monster& mon);

Expand Down
10 changes: 1 addition & 9 deletions crawl-ref/source/monster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3733,15 +3733,7 @@ int monster::how_chaotic(bool check_spells_god) const

bool monster::is_unbreathing() const
{
const mon_holy_type holi = holiness();

if (holi & (MH_UNDEAD | MH_NONLIVING | MH_PLANT))
return true;

if (mons_is_slime(*this))
return true;

return mons_class_flag(type, M_UNBREATHING);
return mons_is_unbreathing(type);
}

bool monster::is_insubstantial() const
Expand Down

0 comments on commit 30a9938

Please sign in to comment.