ff_c_cnd_gold
Compare the gold of the speaking PC to a value.
Set as the Text Appears When script of a conversation node, with the
parameters below set on that node. The node is shown when the gold carried by
the PC speaker, compared to GOLD with OP, is true. For example,
OP = >= and GOLD = 100 shows the node only to a PC carrying
at least 100 gold. An invalid OP or GOLD hides the node and logs an
error.
Parameters
OP: (string) Comparison operator: = (or ==), >, <,
<= (or =<), >= (or =>), !=. Required.
GOLD: (int) Amount of gold to compare to. Required, must be greater than 0.
Scripts
TextAppearsWhen: ff_c_cnd_gold
Source code
// @code
#include "ff_i_core"
const string OP = "OP";
// =============================================================================
int StartingConditional()
{
string sOp = GetScriptParam(OP);
sOp = GetStringTrim(sOp);
object oSpeaker = GetPCSpeaker();
int nGold = GetGold(oSpeaker);
int nAmount = StringToInt(GetScriptParam("GOLD"));
if (nAmount <= 0)
{
LogError(__FILE__ + ": called with invalid 'GOLD' value");
return FALSE;
}
if (sOp == "=" || sOp == "==")
return (nGold == nAmount);
if (sOp == ">")
return (nGold > nAmount);
if (sOp == ">=" || sOp == "=>")
return (nGold >= nAmount);
if (sOp == "<=" || sOp == "=<")
return (nGold <= nAmount);
if (sOp == "<")
return (nGold < nAmount);
if (sOp == "!=")
return (nGold != nAmount);
LogError(__FILE__ + ": called with invalid 'OP' value");
return FALSE;
}