void() flag_follow =
{
	if (self.enemy == world)
		return;
	setorigin(self,self.enemy.origin);
	self.nextthink = time+0.04;
	self.think = flag_follow;
};

void() flag_touch =
{
	if (other.classname != "player")
		return;
	if (other.team != 2)
		return;
	if (self.enemy == world)
	{
		other.enemy=self;
		self.enemy=other;
		sprint(other, "You have the flag!\n");
		self.nextthink=time+0.1;
		self.think=flag_follow;
	}
};

void() item_flag_team2 =
{
	precache_model ("progs/quaddama.mdl");
	setmodel (self, "progs/quaddama.mdl");
	self.netname = "Blue Flag";
	setsize (self, VEC_HULL_MIN, VEC_HULL_MAX);
	StartItem ();
	self.enemy=world;

	self.touch = flag_touch;
};

void() flag_capture_touch =
{
	if (other.enemy == world)
		return;
	if (self.impulse != other.enemy.impulse)
		return;
	if (self.impulse != world.impulse)
		return;
	world.impulse = world.impulse + 1;
	bprint(other.netname);
	bprintf(" secured the flag!\n");
	sprintf(other, "You secured the flag!");
};

void() trigger_capture =
{
	InitTrigger ();
	self.touch = flag_capture_touch;
};