Example #1
0
void PreCalculate_Flag_Spawnpoints( int flagnum, vec3_t angles, vec3_t origin )
{
	vec3_t fwd, point;
	int tries = 0, tries2 = 0;
	qboolean visible = qfalse;

	VectorCopy(origin, point);
		
	AngleVectors( angles, fwd, NULL, NULL );

	while (1)//visible == qfalse)
	{// In case we need to try a second spawnpoint.
		int wp = -1;
		vec3_t	playerMins = {-15, -15, DEFAULT_MINS_2};
		vec3_t	playerMaxs = {15, 15, DEFAULT_MAXS_2};

		playerMins[0] = -15;
		playerMins[1] = -15;
		playerMins[2] = -1;
		playerMaxs[0] = 15;
		playerMaxs[1] = 15;
		playerMaxs[2] = 96;//1;

		while (tries < 16)
		{
			tries++;
			tries2 = 0;

			while (tries2 < 64)
			{
				int num_tries; // For secondary spawns. (Behind point).

				tries2++;

				num_tries = tries2;
				if (tries2 <= 16)
				{
				}
				else if (tries2 <= 32)
				{
					num_tries-=16;
				}
				else if (tries2 <= 48)
				{
					num_tries-=32;
				}
				else
				{
					num_tries-=48;
				}
				
				if (wp == -1)
					VectorCopy(origin, point);
				else
					VectorCopy(gWPArray[wp]->origin, point);

				if (tries2 <= 8)
				{
					point[0] += 1+(tries*64);
					point[1] += 1+(num_tries*64);
				}
				else if (tries2 <= 16)
				{
					point[0] += 1+(tries*64);
					point[1] += 1-(num_tries*64);
				}
				else if (tries2 <= 24)
				{
					point[0] += 1-(tries*64);
					point[1] += 1+(num_tries*64);
				}
				else
				{
					point[0] -= 1+(tries*64);
					point[1] -= 1+(num_tries*64);
				}

				//if (CheckAboveOK_Player(point))
				//	point[2] += 32;
				//else
				//	continue;

				point[2] += 16;

				if (wp == -1)
				{
					if (OrgVisibleBox(origin, playerMins, playerMaxs, point, flag_list[flagnum].flagentity->s.number)
						&& CheckBelowOK(point)
						&& !CheckEntitiesInSpot(point) 
						&& VectorDistance(point, origin) > 128
						&& !TooCloseToOtherSpawnpoint(flagnum, point))
					{
						//G_Printf("Adding spawn at %f %f %f.\n", point[0], point[1], point[2]);
						AddFlag_Spawn(flagnum, point, angles);
						//G_Printf("Adding spawn %f %f %f\n", point[0], point[1], point[2]);
						visible = qtrue;
					}
					//else
					//	G_Printf("Not adding spawn at %f %f %f.\n", point[0], point[1], point[2]);
				}
				else
				{
					if (OrgVisibleBox(gWPArray[wp]->origin, playerMins, playerMaxs, point, -1)
						&& CheckBelowOK(point)
						&& !CheckEntitiesInSpot(point) 
						&& VectorDistance(point, origin) > 128
						&& !TooCloseToOtherSpawnpoint(flagnum, point))
					{
						//G_Printf("Adding spawn at %f %f %f.\n", point[0], point[1], point[2]);
						AddFlag_Spawn(flagnum, point, angles);
						//G_Printf("Adding wp spawn %f %f %f\n", point[0], point[1], point[2]);
						visible = qtrue;
					}
				}
			}
		}

		if (visible != qfalse)
			break;
		else
		{
			//if (wp == -1)
				wp = GetNearestVisibleWP(flag_list[flagnum].flagentity->s.origin, flag_list[flagnum].flagentity->s.number);//NAV_FindClosestWaypointForPoint2( flag_list[flagnum].flagentity->s.origin );
			//else
			//	wp = GetNearestVisibleWP(flag_list[flagnum].flagentity->s.origin, flag_list[flagnum].flagentity->s.number);//NAV_FindClosestWaypointForPoint( flag_list[flagnum].flagentity, flag_list[flagnum].flagentity->s.origin );
		}
	}

	G_Printf("^3*** ^3DominancE^5: Added ^7%i^5 spawnpoints at flag #^7%i^5.\n", flag_list[flagnum].num_spawnpoints, flagnum);
}
void PreCalculate_Flag_Spawnpoints( int flagnum, vec3_t angles, vec3_t origin )
{
#ifdef __UNUSED__
	vec3_t fwd, point;
	int tries = 0, tries2 = 0;
	//qboolean visible = qfalse;
	qboolean alt = qfalse;

	origin[2]+=32;
	VectorCopy(origin, point);
		
	AngleVectors( angles, fwd, NULL, NULL );

	while (1)//visible == qfalse)
	{// In case we need to try a second spawnpoint.
		vec3_t playerMins, playerMaxs;

		playerMins[0] = -15;
		playerMins[1] = -15;
		playerMins[2] = -1;
		playerMaxs[0] = 15;
		playerMaxs[1] = 15;
		playerMaxs[2] = 64;//96;//1;

		tries = 0;
		tries2 = 0;

		while (tries < 16)
		{
			tries++;
			tries2 = 0;

			while (tries2 < 128)
			{
				int num_tries; // For secondary spawns. (Behind point).

				tries2++;

				num_tries = tries2;

				if (tries2 <= 16)
				{
				}
				else if (tries2 <= 32)
				{
					num_tries-=16;
				}
				else if (tries2 <= 48)
				{
					num_tries-=32;
				}
				else
				{
					num_tries-=48;
				}
				
				VectorCopy(origin, point);

				if (alt)
				{
					if (tries2 <= 8)
					{
						point[0] -= 1+(tries*64);
						point[1] -= 1+(num_tries*64);
					}
					else if (tries2 <= 16)
					{
						point[0] -= 1+(tries*64);
						point[1] -= 1-(num_tries*64);
					}
					else if (tries2 <= 24)
					{
						point[0] -= 1-(tries*64);
						point[1] -= 1+(num_tries*64);
					}
					else
					{
						point[0] -= 1-(tries*64);
						point[1] -= 1-(num_tries*64);
					}
				}
				else
				{
					if (tries2 <= 8)
					{
						point[0] += 1+(tries*64);
						point[1] += 1+(num_tries*64);
					}
					else if (tries2 <= 16)
					{
						point[0] += 1+(tries*64);
						point[1] += 1-(num_tries*64);
					}
					else if (tries2 <= 24)
					{
						point[0] += 1-(tries*64);
						point[1] += 1+(num_tries*64);
					}
					else
					{
						point[0] += 1-(tries*64);
						point[1] += 1-(num_tries*64);
					}
				}

				//if (CheckAboveOK_Player(point))
				//	point[2] += 32;
				//else
				//	continue;

				//point[2] += 16;

				if (OrgVisibleBox(origin, playerMins, playerMaxs, point, flag_list[flagnum].flagentity->s.number)
					&& CheckBelowOK(point)
					&& !AdvancedWouldTelefrag(point) 
					&& !CheckEntitiesInSpot(point) 
					&& VectorDistance(point, origin) > 128
					&& !TooCloseToOtherSpawnpoint(flagnum, point))
				{
					//G_Printf("Adding spawn at %f %f %f.\n", point[0], point[1], point[2]);
					AddFlag_Spawn(flagnum, point, angles);
					//visible = qtrue;

					if (flag_list[flagnum].num_spawnpoints >= 64)
					{
						//G_Printf("Have 64 spawns!\n");
						G_Printf("^3*** ^3Warzone^5: Added ^7%i^5 spawnpoints at flag #^7%i^5.\n", flag_list[flagnum].num_spawnpoints, flagnum);
						return;
					}
				}
			}
		}

		if (alt)
			break;
		else
			alt = qtrue;
	}

	G_Printf("^3*** ^3Warzone^5: Added ^7%i^5 spawnpoints at flag #^7%i^5.\n", flag_list[flagnum].num_spawnpoints, flagnum);
#endif //__UNUSED__
}