Rune_PRC8/_module/nss/vtw_calccr.nss
Jaysyn904 d1c309ae63 Initial commit
Initial commit
2024-09-13 09:10:39 -04:00

40 lines
990 B
Plaintext

int StartingConditional()
{
//initialize variables
float fTotalCR = 0.0;
float fPreviousCR = 0.0;
float fCreatureCR = 0.0;
string sDisplayCR;
object oCreature = GetFirstObjectInArea(OBJECT_SELF);
//calculate total CR
while (GetIsObjectValid(oCreature))
{
if (
!GetIsPC(oCreature) &&
!GetIsDM(oCreature) &&
GetObjectType(oCreature) == OBJECT_TYPE_CREATURE
)
{
fCreatureCR = GetChallengeRating(oCreature);
fTotalCR = fCreatureCR + fPreviousCR;
fPreviousCR = fTotalCR;
}
oCreature = GetNextObjectInArea(OBJECT_SELF);
}
//set custom token
if (fTotalCR > 0.0)
{
sDisplayCR = "Total CR = " + GetSubString(FloatToString(fTotalCR), 5, 6);
}
else
sDisplayCR = " ";
SetCustomToken(102, sDisplayCR);
return TRUE;
}