Hey, thats not too bad. I tried it, but it cast a runaway loop, and my compiler dont like -=
I hacked up your code a little, and merged it with some of mine, and seems to be working pretty well.
I am counting the number of each spawn entity class in a global, as well as carryng that incremented value to its self.cnt value.
A new routine I made called : MultiSpawnSelect () will pick the classname randomly, then ask Pickspawn() to look through that list.
I am using it too for the Runes to randomly spawn if not picked up, and so far its looking good. I have seen that findradius used in I think the old
telefragselectspawnpoint() code, but I want to experiment assigning the spawn entity a self.spawn_time equal maybe to time + 5 , and if
we scan the entity and its spawn_time < time, we will figure its safe and clear. I might decide to later use both, not sure yet.
Code: Select all
entity(string className) Pickspawn =
{
local entity p;
local float pcount,scount;
if (className == "info_player_deathmatch")
scount = DMSPAWNS;
if (className == "info_player_start")
scount = STARTSPAWNS;
if (className == "info_player_start2")
scount = START2SPAWNS;
if (className == "info_player_coop")
scount = COPPSPAWNS;
if (className == "info_teleport_destination")
scount = TELESPAWNS;
if (className == "info_player_team2")
scount = BLUESPAWNS;
if (className == "info_player_team1")
scount = REDSPAWNS;
dprint (self.classname);
dprint (" Pickspawn");
dprint (className);
dprint ("\n");
pcount = rint (random() * scount);
p = find (world, classname, className);
while ((p != world))
{
if (p.cnt == pcount)
{
lastspawn = p;
return (p);
}
p = find (p, classname, className);
}
};