/*
==============================
ThunderWalker Base Zones Mojo
==============================
*/

.float 	ouchtime;
.float	basetime;
.float	basecount;

float	TW_ZONE_RADIUS;

void() PainSound;
void() PlayerDie;

void() basedefend =
{
local entity flag, flag2;
local entity marc, marc2;

if (world.model == "maps/ctf1.bsp")
	TW_ZONE_RADIUS = 450;
else if (world.model == "maps/ctf2.bsp")
	TW_ZONE_RADIUS = 150;
else if (world.model == "maps/ctf5.bsp")
	TW_ZONE_RADIUS = 450;
else if (world.model == "maps/ctf6.bsp")
	TW_ZONE_RADIUS = 650;
else if (world.model == "maps/ctf8.bsp")
	TW_ZONE_RADIUS = 450;
else if (world.model == "maps/ctf2m1.bsp")
	TW_ZONE_RADIUS = 450;
else if (world.model == "maps/ctf2m3.bsp")
	TW_ZONE_RADIUS = 700;
else if (world.model == "maps/ctf2m7.bsp")
	TW_ZONE_RADIUS = 300;
else if (world.model == "maps/twctf1.bsp")
	TW_ZONE_RADIUS = 380;
else if (world.model == "maps/twctf2.bsp")
	TW_ZONE_RADIUS = 450;
else if (world.model == "maps/twctf3.bsp")
	TW_ZONE_RADIUS = 525;
else if (world.model == "maps/twctf4.bsp")
	TW_ZONE_RADIUS = 270;
else if (world.model == "maps/twctf7.bsp")
	TW_ZONE_RADIUS = 450;
else if (world.model == "maps/twctf8.bsp")
	TW_ZONE_RADIUS = 250;
else 
	TW_ZONE_RADIUS = 500;

flag = find(world, classname, "item_flag_team1");
flag2 = find(world, classname, "item_flag_team2");

marc = findradius(flag.oldorigin, TW_ZONE_RADIUS);
marc2 = findradius(flag2.oldorigin, TW_ZONE_RADIUS);

while(marc != world)
{
if (marc == self)
{
if (marc.lastteam == flag.lastteam)
{
if (self.health < 100)
	self.ouchtime = 1;
}
if (marc.lastteam != flag.lastteam && !(marc.player_flag & ITEM_ENEMY_FLAG))
	self.ouchtime = 2;


}

self.basetime = time + 4;

marc = marc.chain;
}

while(marc2 != world)
{
if (marc2 == self)
{
if (marc2.lastteam == flag2.lastteam)
{
if (self.health < 100)
	self.ouchtime = 1;
}
if (marc2.lastteam != flag2.lastteam && !(marc.player_flag & ITEM_ENEMY_FLAG))
	self.ouchtime = 2;
}

self.basetime = time + 4;

marc2 = marc2.chain;
}

};