|
|
Okay class, listen up. It's time for our 4th lesson today so all sit down and start pasting.
Today's lesson's about spawnpoints. Not just any spawnpoints but team specific spawnpoints.
You know how CounterStrike makes you spawn at specific spawnpoints? This lesson teaches you how.
Open up client.qc and find SelectSpawnPoint. Replace it with this one:
/*
============
SelectSpawnPoint
Returns the entity to spawn at
============
*/
entity() SelectSpawnPoint =
{
local entity spot;
local entity thing;
local float pcount;
// testinfo_player_start is only found in regioned levels
spot = find (world, classname, "testplayerstart");
if (spot)
return spot;
// choose a info_player_deathmatch point
//if (coop) Koolio, no coop play, we need coop starts for the counters
//{
// lastspawn = find(lastspawn, classname, "info_player_coop");
// if (lastspawn == world)
// lastspawn = find (lastspawn, classname, "info_player_start");
// if (lastspawn != world)
// return lastspawn;
//}
//else
if ((deathmatch) && (self.team == TERROR_TEAM)) // <-- changed that
{
spot = lastspawn;
while (1)
{
spot = find(spot, classname, "info_player_deathmatch");
if (spot != world)
{
if (spot == lastspawn)
return lastspawn;
pcount = 0;
thing = findradius(spot.origin, 32);
while(thing)
{
if (thing.classname == "player")
pcount = pcount + 1;
thing = thing.chain;
}
if (pcount == 0)
{
lastspawn = spot;
return spot;
}
}
}
}
else if ((deathmatch) && (self.team == COUNTER_TEAM)) // <-- changed that
{
spot = lastspawn;
while (1)
{
spot = find(spot, classname, "info_player_coop");
if (spot != world)
{
if (spot == lastspawn)
return lastspawn;
pcount = 0;
thing = findradius(spot.origin, 32);
while(thing)
{
if (thing.classname == "player")
pcount = pcount + 1;
thing = thing.chain;
}
if (pcount == 0)
{
lastspawn = spot;
return spot;
}
}
}
}
if (serverflags)
{ // return with a rune to start
spot = find (world, classname, "info_player_start2");
if (spot)
return spot;
}
spot = find (world, classname, "info_player_start");
if (!spot)
error ("PutClientInServer: no info_player_start on level");
return spot;
};
As you can see we use coop starts for Counters and Deathmatch starts for Terrors. I also disabled coop start because
Terrors and Counters would start next to eachothers in coop mode. This is almost the same like in normal counter-strike.
I did a check to see if we're in Deathmatch and what team we have (I explained these in the last tut) and if so it points
to the proper start.
I basically copied the normal function for this pasted it twice and added the proper if check.
This only works in Deathmatch, in singleplayer you'll just start on info_player_starts no matter what team.
That's all there is to it. Now download my fantastic de_dust map from here and see how it works.
Class dismissed.
All code not originally found and stuff changed written by Koolio.
Tutorial written by Koolio, koolio@mdqnet.net, and HTML-ized by Kryten, kryten@inside3d.com
You can use this tut in your mod provided you give me credit.
|