Borked Teleports in Deathmatch

Discuss programming in the QuakeC language.
Post Reply
r00k
Posts: 1111
Joined: Sat Nov 13, 2004 10:39 pm

Borked Teleports in Deathmatch

Post by r00k »

Ok so I went to dm.clanhdz.com:26001 and couple old timers having a dm game on E2M6. I was spec and they started talking aobut the teleport in the bottom room u cant get out of that room.
When you try to walk thru the teleport it just plays the water sound, BUT if u rj to the top center edge it triggers a teleport back to itself so u spawn nearby, same room.

So this will fix that.

But the player just needs to know to rj on top of the teleporter,,,

In triggers.qc
find

Code: Select all

void() teleport_touch =
just above that add

Code: Select all

entity(string cname) SelectSpawnPoint;
Add..

Code: Select all

		//-----[Hacks for broken teleporters in deathmatch 1 mode]---------<<<<
		if ((world.model == "maps/e2m6.bsp") && (other.origin_z < -827))
			t = SelectSpawnPoint("info_player_deathmatch");
		
		if ((world.model == "maps/e1m7.bsp") && (other.origin_z < -827))
			t = SelectSpawnPoint("info_player_deathmatch");
		//--------------------------end


above this line...same function.

Code: Select all

		setorigin (other, t.origin);
		other.angles = t.mangle;
...

in client.qc define

as

Code: Select all

/*
============
SelectSpawnPoint

Returns the entity to spawn at
============
*/
entity(string cname) SelectSpawnPoint =
{
	local entity spot, e;
	local float f, n;

	spot = lastspawn;
	
	// counter bumped in void() info_player_deathmatch = 
	n = dm_spawns; 

	if (n < 1)//at least do once
		n = 1;
						
	while (n)
	{		
		spot = find(spot, classname, cname);
	
		f = 0;		
		n = n - 1;		
		
		if (spot != world)
		{
			if (spot != self.trigger_field)
			{
				e = findradius (spot.origin, 32);			
				while (e)
				{
					if ((e.classname == "player") && (e != self))
					{
						e = world;
						f = 1;
					}
					else
					{
						e = e.chain;
					}
				}
			}
			else
			{
				f = 1;
			}
			
			if (f == 0)
			{
				lastspawn = spot;
				return (spot);
			}
		}		
	}	
	return (lastspawn);
};
Now u jump to a random dm spawnpoint :D
Seven
Posts: 301
Joined: Sat Oct 06, 2007 8:49 pm
Location: Germany

Re: Borked Teleports in Deathmatch

Post by Seven »

Hello r00k,

I bet you wrote this code on a small paper beside your keyboard, while playing :)
Very good hack, r00k.

Using your own words from another thread, which I will never forget:
"These kind of things keeps us old guys in shape"

Thank you
Seven
r00k
Posts: 1111
Joined: Sat Nov 13, 2004 10:39 pm

Re: Borked Teleports in Deathmatch

Post by r00k »

Thanks Seven,
Though it's not robust at all. I chucked this into CAx, knowing that deathmatch 1 will always be set, though if one uese this in a mod that handles coop it might break the exits without testing for maxplayers > 1 or deathmatch or teamplay ...
a better fix might to create dynamic spawnflags for the exits themselves.
Post Reply