Considering I have around 20 spider eggs or something in this level, it would make the script quite long eventually. So I'm simplifying it this way. But either way, I got it working just recently. So I used Mudbill's suggestion with adding in a timer to control the spawning functions easier.
string gNameOfSpiderEggs = "organic_spider_egg_small_";
string gNameOfBrokenSpiderEggs = "organic_spider_egg_small_broken_";
string gNameOfSpiderExplodeSound = "enemy_spider_egg_open";
string gNameOfSpider = "necr_spider_";
void SetSpiderEggOff(string &in asTimer, int iMinimumValue, int iMaximumValue)
{
AddTimer(asTimer, RandFloat(0.6f, 1.0f), asTimer);
SetLocalVarInt("MaxValue", iMaximumValue);
SetLocalVarInt("MinValue", iMinimumValue);
}
void TimerSetSpiderEggOff(string &in asTimer)
{
if(GetLocalVarInt("MinValue") == GetLocalVarInt("MaxValue"))
{
SetLocalVarInt("MaxValue", 0);
SetLocalVarInt("MinValue", 0);
return;
}
AddLocalVarInt("MinValue", 1);
SetEntityActive(gNameOfSpiderEggs+""+GetLocalVarInt("MinValue"), false);
SetEntityActive(gNameOfSpider+""+GetLocalVarInt("MinValue"), true);
SetEntityActive(gNameOfBrokenSpiderEggs+""+GetLocalVarInt("MinValue"), true);
//CreateParticleSystemAtEntity(gNameOfSpiderEggs,
//"ps_spider_egg_splat",
//gNameOfSpiderEggs+""+GetLocalVarInt("MinValue"),
//false);
PlaySoundAtEntity(gNameOfSpiderEggs,
gNameOfSpiderExplodeSound,
gNameOfSpiderEggs+""+GetLocalVarInt("MinValue"),
0.0f,
false);
AddTimer(asTimer, RandFloat(0.6f, 1.0f), asTimer);
}
Either way, Mudbill solved most things. Thanks guys.
Derp.