given keyword. Used for more varied recite speech, so that the same prechosen synonym can be used for all of start/continue/stop/finish reciting. The number of the entry is calculated in an embarassingly hacky way: (recite power + hp at beginning of recite + x_pos + y_pos) modulo total weight of the keyword.
This makes sure that different synonyms get used, though always the same one (plus its shorter variant) during one round of recite, but it's not as random as I'd like. It works well enough for now, though, and adds some much needed flavour to Zin.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3818 c06c8d41-db1a-0410-9941-cceddc491573
2P3IJKK547AOEFWKXEAL73QFKW423GGAZEZHW6OZ6QB7YUSDNC3AC
LM764EO6YIFOKMRXWZ5S4GYZB4BHZQDTEFP7MEVYO4NN4EDOFGNQC
K2MLPJIAXXZRWEWZCNSGICCBNIU2WAAPT7SPIMOH7FLLTOB4QFRAC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC
23PFLB2E4QHL5SF3Q2YV5FXRH6MFHENEU2ACVC572ZCYDXCBZVQAC
G4TVXOLIF5X2MWV7I4UPT3MSQHRMGME6QRIIFAQ64C45JGYK7SIAC
PAYI4UTJCR3XZSFOX5L35EURHRXQ6STO4Z7AQ3525QPNL3QYLNBAC
Y56C5OMUQ5XF2G6DKDV4R5MED44UOIUPTBBQVWQBUHYIXYA5MOZAC
ZIFFVCQ72K35WGIUMZYN3KOXIUXF2CNXWKG6ZWEZ6LT3NSF3XOQAC
7C62IQ3PLAE7RLZ2ZNA3G6Z7LPXWAMK2OEHSBNY4WEKJ42BPZYQAC
J6APXOT4QOGQFONWB7G546VTVF6QG42HVOROMHF7YBDJPR4K26OAC
RN2DSYJRJ55J7S2VBEYCOAINFU4VDBMWDJIYJG326BSLYOFDNHGAC
KR655YT3I3U5DMN5NS3FPUGMDNT4BI56K3SFF2FNJ77C45NFKL5AC
3ZNI2YMHYXRVEONY5CGWXSRMFSLOATZMKU7H6HRY3CC2W6OZAM7QC
EJKHYV2Z6UPRVYUAL4WRW33GBNHYBFPMPA57HMBX2LQKXHIUO5VQC
QHUJATUWL3I7TJOLOY55LPZSAU3EB5X2AKRKTBVN7VSZD527VAXQC
6GSGCC5JQJ5NOKX36UHRNOCXNHDBS2A2TDMAR34UBOGWE2DORXIQC
FUAUWKK3UMB5ZGMXFPEUTXO7VFX5XUB4IQWN434PBLBRXUKIMPPAC
NMZFCCM6O3KO2GJWKOSULN27B3QIZKWPBOB62PAILXMRQD4JMIMAC
static std::string getRandomizedStr(DBM *database, const std::string &key,
const std::string &suffix,
int &num_replacements,
int recursion_depth = 0)
static std::string _getWeightedString(DBM *database, const std::string &key,
const std::string &suffix,
int fixed_weight = -1)
str = chooseStrByWeight(str);
return _chooseStrByWeight(str, fixed_weight);
}
static void _call_recursive_replacement(std::string &str, DBM *database,
const std::string &suffix,
int &num_replacements,
int recursion_depth = 0);
std::string getWeightedSpeechString(const std::string &key,
const std::string &suffix,
const int weight)
{
if (!SpeakDB)
return ("");
std::string result = _getWeightedString(SpeakDB, key, suffix, weight);
if (result.empty())
return "";
int num_replacements = 0;
_call_recursive_replacement(result, SpeakDB, suffix, num_replacements);
return (result);
}
static std::string _getRandomizedStr(DBM *database, const std::string &key,
const std::string &suffix,
int &num_replacements,
int recursion_depth = 0)
{
recursion_depth++;
if (recursion_depth > MAX_RECURSION_DEPTH)
{
mpr("Too many nested replacements, bailing.", MSGCH_DIAGNOSTICS);
return "TOO MUCH RECURSION";
}
// Replace any "@foo@" markers that can be found in this database;
// those that can't be found are left alone for the caller to deal
// with.
std::string str = _getWeightedString(database, key, suffix);
_call_recursive_replacement(str, database, suffix, num_replacements,
recursion_depth);
return str;
}
// Replace any "@foo@" markers that can be found in this database.
// Those that can't be found are left alone for the caller to deal with
static void _call_recursive_replacement(std::string &str, DBM *database,
const std::string &suffix,
int &num_replacements,
int recursion_depth)
{
Zin's Axioms of Law
the Axioms of Law
the importance of the Law
%%%%