From 85703632b12462f84e828ea3952c5c675f2907d5 Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Fri, 29 Feb 2008 16:48:25 +0000 Subject: Add logic to allow the use of a character's religion in the speech files. For atheistic characters, "you" is used instead, so that the result looks like this: I like/hate Xom. ---- I like/hate you. Xom is mighty/stupid. ---- You are mighty/stupid. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3486 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/mon-util.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'crawl-ref/source/mon-util.cc') diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index fa3b93b271..6a85bd55cb 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -48,6 +48,7 @@ #include "mtransit.h" #include "player.h" #include "randart.h" +#include "religion.h" #include "spl-util.h" #include "stuff.h" #include "terrain.h" @@ -5383,6 +5384,22 @@ void mon_enchant::set_duration(const monsters *mons, const mon_enchant *added) maxduration = duration; } +// replaces @player_god@ and @god_is@ with player's god name +// special handling for atheists: use "you"/"You" instead +static std::string replace_god_name(bool need_verb = false, bool capital = false) +{ + std::string result = + (you.religion == GOD_NO_GOD ? (capital? "You" : "you") + : god_name(you.religion, false)); + if (need_verb) + { + result += + (you.religion == GOD_NO_GOD? " are" : " is"); + } + + return (result); +} + static std::string get_species_insult(const std::string type) { std::string lookup = "insult "; @@ -5493,6 +5510,14 @@ std::string do_mon_str_replacements(const std::string &in_msg, msg = replace_all(msg, "@possessive@", monster->pronoun(PRONOUN_NOCAP_POSSESSIVE)); + // replace with "you are" for atheists + msg = replace_all(msg, "@god_is@", replace_god_name(true, false)); + msg = replace_all(msg, "@God_is@", replace_god_name(true, true)); + + // no verb needed + msg = replace_all(msg, "@player_god@", replace_god_name(false, false)); + msg = replace_all(msg, "@Player_god@", replace_god_name(false, true)); + // replace with species specific insults msg = replace_all(msg, "@species_insult_adj1@", get_species_insult("adj1")); msg = replace_all(msg, "@species_insult_adj2@", get_species_insult("adj2")); -- cgit v1.2.3-54-g00ecf