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


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
limit number of dynamically created entities
darksky Offline
Member

Posts: 52
Threads: 8
Joined: Nov 2012
Reputation: 2
#9
RE: limit number of dynamically created entities

Apjjm, that's actually a nice idea using resetProp and it is working. thank you.
I did not think about ResetProp because I thought it does not work on things which are created after the map is loaded because in the wiki it says
"Resets a prop's state to the original one when the map was loaded."

the working code now looks like this:
int stonecount = 0;
float timerInterval = 2;
const int maxStones = 100;

void spawnstone(string &in asTimer){
    stonecount++;
    stonecount = stonecount % maxStones;
    if (GetEntityExists("stone_"+stonecount)){
        ResetProp("stone_"+stonecount);
    }else{
        CreateEntityAtArea("stone_"+stonecount, "stone_small01.ent", "SpawnArea_"+x+"_"+z, false);
    }    
    AddPropImpulse("stone_"+stonecount, RandFloat(-2, 2), 0, RandFloat(-2, 2), "world");
    if (!(timerInterval<0)){
        AddTimer(asTimer,timerInterval,"spawnstone");
    }
}

fyi, I track the player position using scriptareas and let the stones spawn above the player and the stones will cause damage if they hit the player.
02-11-2013, 11:13 PM
Find


Messages In This Thread
RE: limit number of dynamically created entities - by darksky - 02-11-2013, 11:13 PM



Users browsing this thread: 1 Guest(s)