PDA

View Full Version : Auto Checkpoints for my new K~PortalMap



STAUFFi
2nd November 2012, 09:12
Hey Guys,
I need help :)
I want make Checkpoints in my Map.
i think my map is rly hard :o.
Lots of killtriggers and more :DD.
(The Killtrigger starting on Level 28 behind the rotations door)
The First Release comming next Week on my xf page :D
I hope you like then my Map :)


Map Infos
mp_stauffi_kportal_v1
40 Traps and Fun :D
3,5 MB ( map iwd)
greet stauffi

DisSle
2nd November 2012, 11:03
Hey,

you have many ways to add cp's. I think you want that the players will spawn at the reached cp? Then I would replace the killtrigger with teleporter, i think it's the best way for the players, because nobody like killtrigger. :P

But it's your choice what to do, I will show you one way without triggers, only with script.



main()
{
// Add it where ever you need
initCheckpoints();
}

initCheckpoints()
{

/************************************************** *********************
Copy "loadCheckpoint" how many you want...

The first value is the cp number, first must be 0 (zero).

Replace "X, Y, Z" with coordinates of the cp location
where the cp need to work.

The 150 value is for the radius, and 100 for the
height where the cp will work.
************************************************** *********************/

loadCheckpoint(0,(X, Y, Z),150,100);
loadCheckpoint(1,(X, Y, Z),150,100);
loadCheckpoint(2,(X, Y, Z),150,100);
loadCheckpoint(3,(X, Y, Z),150,100);
loadCheckpoint(4,(X, Y, Z),150,100);

// It will check every cp (load it only one time)
thread onCheckpoint();
}

loadCheckpoint(num,coordinates,radius,height)
{
level.cpTrig[num]=spawnstruct();
level.cpTrig[num].origin=coordinates;
level.cpTrig[num].radius=radius;
level.cpTrig[num].height=height;
}

onCheckpoint()
{
if(isDefined(level.cpTrig))
{
for(i=0;i<level.cpTrig.size;i++)
{
cp=level.cpTrig[i];
cp.origin=(cp.origin[0],cp.origin[1],(cp.origin[2]-16));
}
count=0;

while(1)
{
players=getEntArray("player","classname");
count=0;

for(i=0;i<players.size;i++)
{
player=players[i];
if(isDefined(player) && isDefined(player.pers["team"]) && player.pers["team"]!="spectator" && player.sessionstate=="playing")
{
player _checkCp();

count++;
if(!(count%4))
{
wait .05;
count=0;
}
}
}
wait .05;
}
}
}

_checkCp()
{
for(i=0;i<level.cpTrig.size;i++)
{
cp=level.cpTrig[i];
diff=cp.origin-self.origin;
if(self.origin[2]>=cp.origin[2] && self.origin[2]<=cp.origin[2]+cp.height)
{
diff2=(diff[0],diff[1],0);
if(length(diff2)<cp.radius+16)
{
if(self.pers["team"]!="spectator" && self isOnGround() && isAlive(self))
{
if(!isDefined(self.spawnCp) || (isDefined(self.spawnCp) && self.spawnCp<i))
{
self.spawnCp=i;
self.spawnAng=self getPlayerAngles();
self.spawnOrg=self getOrigin();
self iPrintLnBold("^2Checkpoint "+(i+1)+"/"+level.cpTrig.size+" reached!");
}
if(!isDefined(self.playerSpawnCheck))
self thread onPlayerSpawn();
}
return;
}
}
}
}

onPlayerSpawn()
{
self endon("disconnect");

self.playerSpawnCheck=true;
while(1)
{
self waittill("spawned");
self thread doPlayerSpawn();
}
}

doPlayerSpawn()
{
if(!isDefined(self.spawnCp) || !isDefined(self.spawnAng) || !isDefined(self.spawnOrg))
return;

if(self.pers["team"]!="spectator" && isAlive(self))
{
self setOrigin(self.spawnOrg);
self setPlayerAngles((0,self.spawnAng[1],self.spawnAng[2]));
self iPrintLnBold("^2Checkpoint loaded!");
}
}

STAUFFi
2nd November 2012, 11:10
English: Really big Thanks :D
German: Danke dir ;)