Here's a quick small example using a conversation node. You'll just need to redefine object oPC if you use another method. The creatures appear at a waypoint tagged "SPAWNHERE". I generally use a half second delay in these type of scripts to limit chances of -invis bugs- on the NPCs spawning in too fast and close as well. Keep in mind that "GetChallengeRating" also returns a float and takes a little thought to apply at times.
Example A:
void CreateObjectVoid(int nObjectType, string sTemplate, location lLoc, int bUseAppearAnimation = FALSE)
{
object oVoid = CreateObject(nObjectType, sTemplate, lLoc, bUseAppearAnimation);
}
void main()
{
object oPC = GetPCSpeaker(); //or whatever else you define oPC as
if (!GetIsPC(oPC)) return;
object oTarget = GetNearestObjectByTag("SPAWNHERE");
location lTarget = GetLocation(oTarget);
float fPCCR = GetChallengeRating(oPC);
if (fPCCR <= 1.0)
{
CreateObjectVoid(OBJECT_TYPE_CREATURE, "nw_zombie01", lTarget);
return;
}
else if (fPCCR <= 2.0 && fPCCR >= 1.01)
{
CreateObjectVoid(OBJECT_TYPE_CREATURE, "nw_zombie01", lTarget);
DelayCommand(0.5, CreateObjectVoid(OBJECT_TYPE_CREATURE, "nw_zombie01", lTarget));
return;
}
else if (fPCCR <= 3.0 && fPCCR >= 2.01)
{
CreateObjectVoid(OBJECT_TYPE_CREATURE, "nw_zombie01", lTarget);
DelayCommand(0.5, CreateObjectVoid(OBJECT_TYPE_CREATURE, "nw_zombie01", lTarget));
DelayCommand(1.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "nw_zombie01", lTarget));
return;
}
////incomplete, fill in as desired
else if (fPCCR <= 40.0 && fPCCR >= 36.0)
{
CreateObjectVoid(OBJECT_TYPE_CREATURE, "nw_zombie01", lTarget);
DelayCommand(0.5, CreateObjectVoid(OBJECT_TYPE_CREATURE, "nw_zombie01", lTarget));
DelayCommand(1.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "nw_zombie01", lTarget));
DelayCommand(1.5, CreateObjectVoid(OBJECT_TYPE_CREATURE, "nw_zombie01", lTarget));
DelayCommand(2.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "nw_zombie01", lTarget));
return;
}
}
If you'd rather deal in whole numbers, we can round the float values to the nearest whole number and do something like below.
Example B:
void CreateObjectVoid(int nObjectType, string sTemplate, location lLoc, int bUseAppearAnimation = FALSE)
{
object oVoid = CreateObject(nObjectType, sTemplate, lLoc, bUseAppearAnimation);
}
void main()
{
object oPC = GetPCSpeaker(); //or whatever else you define oPC as
if (!GetIsPC(oPC)) return;
object oTarget = GetNearestObjectByTag("SPAWNHERE");
location lTarget = GetLocation(oTarget);
int iPCCR = FloatToInt(GetChallengeRating(oPC));
if (iPCCR <= 1)
{
CreateObjectVoid(OBJECT_TYPE_CREATURE, "nw_zombie01", lTarget);
return;
}
else if (iPCCR <= 3 && iPCCR >= 2)
{
CreateObjectVoid(OBJECT_TYPE_CREATURE, "nw_zombie01", lTarget);
DelayCommand(0.5, CreateObjectVoid(OBJECT_TYPE_CREATURE, "nw_zombie01", lTarget));
return;
}
else if (iPCCR <= 5 && iPCCR >= 4)
{
CreateObjectVoid(OBJECT_TYPE_CREATURE, "nw_zombie01", lTarget);
DelayCommand(0.5, CreateObjectVoid(OBJECT_TYPE_CREATURE, "nw_zombie01", lTarget));
DelayCommand(1.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "nw_zombie01", lTarget));
return;
}
////incomplete, fill in as desired
else if (iPCCR <= 40 && iPCCR >= 36)
{
CreateObjectVoid(OBJECT_TYPE_CREATURE, "nw_zombie01", lTarget);
DelayCommand(0.5, CreateObjectVoid(OBJECT_TYPE_CREATURE, "nw_zombie01", lTarget));
DelayCommand(1.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "nw_zombie01", lTarget));
DelayCommand(1.5, CreateObjectVoid(OBJECT_TYPE_CREATURE, "nw_zombie01", lTarget));
DelayCommand(2.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "nw_zombie01", lTarget));
return;
}
}
Lemme know if you need help with getting it to fire via something other than a convo.