ff_c_cnd_level
Compare the level of the speaking PC to a value.
The total character level (hit dice) of the PC speaker is compared to
LEVEL. The condition is FALSE when a parameter is invalid.
Parameters
OP: (string) Comparison operator: = (or ==), >, <,
<= (or =<), >= (or =>), !=. Required.
LEVEL: (int) Level to compare to, from 1 to 40. Required.
Scripts
TextAppearsWhen: ff_c_cnd_level
Source code
// @code
#include "ff_i_core"
const string LEVEL = "LEVEL";
const string OP = "OP";
// =============================================================================
int StartingConditional()
{
string sOp = GetScriptParam(OP);
sOp = GetStringTrim(sOp);
object oSpeaker = GetPCSpeaker();
int nHD = GetHitDice(oSpeaker);
int nLevel = StringToInt(GetScriptParam(LEVEL));
if (nLevel <= 0 || nLevel > 40)
{
LogError(__FILE__ + ": called with invalid 'LEVEL' value");
return FALSE;
}
if (sOp == "=" || sOp == "==")
return (nHD == nLevel);
if (sOp == ">")
return (nHD > nLevel);
if (sOp == ">=" || sOp == "=>")
return (nHD >= nLevel);
if (sOp == "<=" || sOp == "=<")
return (nHD <= nLevel);
if (sOp == "<")
return (nHD < nLevel);
if (sOp == "!=")
return (nHD != nLevel);
LogError(__FILE__ + ": called with invalid 'OP' value");
return FALSE;
}