summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/attitude-change.cc
diff options
context:
space:
mode:
authorSteve Melenchuk <smelenchuk@gmail.com>2014-05-05 15:34:59 -0600
committerSteve Melenchuk <smelenchuk@gmail.com>2014-05-07 18:23:32 -0600
commita9a44cf2848c743385d41895723180b0cce83255 (patch)
tree8c69e36ea8338c1d869f87ed3bc1e99a57cef0ac /crawl-ref/source/attitude-change.cc
parenta4fdc1954e59915d32eb3bb293020e54e167e641 (diff)
downloadcrawl-ref-a9a44cf2848c743385d41895723180b0cce83255.tar.gz
crawl-ref-a9a44cf2848c743385d41895723180b0cce83255.zip
Fixes for Gozag bugs related to level generation.
* Properly unmark off-level shops (#8498). * Don't deduct bribes for vetoed levels (if, say, Elf:3 vetoed a lot you'd notice your bribe running out immediately on entering the level).
Diffstat (limited to 'crawl-ref/source/attitude-change.cc')
-rw-r--r--crawl-ref/source/attitude-change.cc51
1 files changed, 51 insertions, 0 deletions
diff --git a/crawl-ref/source/attitude-change.cc b/crawl-ref/source/attitude-change.cc
index 4a12a40db8..31e934ff9c 100644
--- a/crawl-ref/source/attitude-change.cc
+++ b/crawl-ref/source/attitude-change.cc
@@ -10,6 +10,7 @@
#include <sstream>
#include "act-iter.h"
+#include "branch.h"
#include "coordit.h"
#include "database.h"
#include "env.h"
@@ -369,6 +370,56 @@ static void _jiyva_convert_slime(monster* slime)
mons_att_changed(slime);
}
+void gozag_set_bribe(monster* traitor)
+{
+ // Try to bribe the monster.
+ const int bribability = gozag_type_bribable(traitor->type);
+ if (bribability > 0 && x_chance_in_y(bribability,
+ GOZAG_MAX_BRIBABILITY))
+ {
+ const monster* leader =
+ traitor->props.exists("band_leader")
+ ? monster_by_mid(traitor->props["band_leader"].get_int())
+ : NULL;
+ const branch_type br = gozag_bribable_branch(traitor->type);
+ int cost = max(1, exper_value(traitor) / 20);
+
+ if (leader)
+ {
+ if (leader->has_ench(ENCH_PERMA_BRIBED)
+ || leader ->props.exists(GOZAG_PERMABRIBE_KEY))
+ {
+ gozag_deduct_bribe(br, 2*cost);
+ traitor->props[GOZAG_PERMABRIBE_KEY].get_bool() = true;
+ }
+ else if (leader->has_ench(ENCH_BRIBED)
+ || leader->props.exists(GOZAG_BRIBE_KEY))
+ {
+ gozag_deduct_bribe(br, cost);
+ // Don't continue if we exhausted our funds.
+ if (branch_bribe[br] > 0)
+ traitor->props[GOZAG_BRIBE_KEY].get_bool() = true;
+ }
+ }
+ else
+ {
+ // Sometimes get permanent followers at twice the cost.
+ if (branch_bribe[br] > 2*cost && one_chance_in(3))
+ {
+ gozag_deduct_bribe(br, 2*cost);
+ traitor->props[GOZAG_PERMABRIBE_KEY].get_bool() = true;
+ }
+ else
+ {
+ gozag_deduct_bribe(br, cost);
+ // Don't continue if we exhausted our funds.
+ if (branch_bribe[br] > 0)
+ traitor->props[GOZAG_BRIBE_KEY].get_bool() = true;
+ }
+ }
+ }
+}
+
void gozag_check_bribe(monster* traitor)
{
string msg;