.qc (dot qc) - the group for quake c coders of all denominations. If you make quake one mods and write code in quake c, join our group! I'll try to answer any quake c questions - please post your inquiry in the forums...

Forum Thread
  Posts  
coop protected spawns (Groups : qc : Forum : vault() : coop protected spawns) Locked
Thread Options
numbersix
numbersix quake-c coder++
Aug 17 2020 Anchor

Request: reduce spawn frag in coop games

Any time a player spawns this function is called by PutClientInServer:

spawn_tdeath (self.origin, self);

the effect is a touch field that frags any player or monster it touches
unless the touched player has invulnerable - this reflects the frag

in coop play this is not desired

the following code will delay spawn up to 30 seconds to allow the first player to exit the spawn area

.float		coopnosp;
entity e0__;

void() PutClientInServer =
{
	local	entity spot;

	spot = SelectSpawnPoint ();

// coop spawn protect
// delays spawn frag on occupied spot for ~30 secs so players can exit spawn area
	if (coop)
	{
		e0__ = findradius(spot.origin, 40); // search all ents in 40 unit radius
		while(e0__)
		{
			if (e0__.classname == "player")  // if a player is found
			{
				self.coopnosp++;   // and counter is < 42
				if (self.coopnosp < 42) // appx 30 secs
				{
					self.think = PutClientInServer;  // bounce back into this in 1 sec
					self.nextthink = time + 1;
					return;
				}
			}
			e0__ = e0__.chain;
		}
		self.coopnosp = 0;  // if point is not cleared in 42 count, spawn frag will fire
	}
/// rest of put client in follows this

};

I might update the pause here with a push option to move a player off the spawn area

please enjoy coding with quake-c
watch my late night live show for more Quake code and dev: Twitch.tv

Edited by: numbersix

Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.