Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Adding delay to for-loop
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#4
RE: Adding delay to for-loop

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.
11-06-2014, 10:10 PM
Find


Messages In This Thread
Adding delay to for-loop - by Neelke - 11-05-2014, 08:57 AM
RE: Adding delay to for-loop - by Mudbill - 11-05-2014, 12:23 PM
RE: Adding delay to for-loop - by burge4150 - 11-06-2014, 06:43 PM
RE: Adding delay to for-loop - by Neelke - 11-06-2014, 10:10 PM



Users browsing this thread: 1 Guest(s)