/*
GENERAL ITEM NOTES

1) goal_respawn_time holds time of respawn (including in past)
2) nextthink == 0 for item sitting there
3) nextthink > 0 && think == SUB_regen for item soon to respawn
4) nextthink < 0 for nontouch items
5) nextthink > 0 && think != SUB_regen for item doing some other activity (eg. megahealth rot)

*/

void() W_SetCurrentAmmo;
void() check_marker;
void() AddToQue;
void() UpdateGoalEntity;
entity(vector org) LocateMarker;
void() MatchStartItem;
void() AssignVirtualGoal;
void(entity marker) G19;
void(entity marker) G20;
void(entity marker) G21;
void(entity marker) G22;
void(entity marker) G23;
void(entity marker) G24;

/*
============
bf

============
*/
void() bf =
{
	if (msg_entity.preferences & PREF_FLASH)
		stuffcmd("bf\n");
};


/* ALL LIGHTS SHOULD BE 0 1 0 IN COLOR ALL OTHER ITEMS SHOULD
BE .8 .3 .4 IN COLOR */

void() SUB_regen =
{
	self.model = self.mdl;		// restore original model
	msg_entity = self;
	sound (CHAN_VOICE, "items/itembk2.wav", 1, ATTN_NORM);	// play respawn sound
	AssignVirtualGoal();
};

void() goal_NULL =
{
	goal_desire = 0;
};

/*
============
PlaceItem

plants the object on the floor
============
*/
void() PlaceItem =
{
	self.flags = self.flags | FL_ITEM;		// make extra wide
	self.mdl = self.model;		// so it can be restored on respawn
	self.solid = SOLID_TRIGGER;
	self.movetype = MOVETYPE_TOSS;	
//	self.velocity = '0 0 0';
	self.origin_z = self.origin_z + 6;
	if (droptofloor())
	{
		self.view_ofs = '31 31 25';

		self.flags = self.flags | FL_MARKER;

		if (self.flags & FL_REMOVE)
		{
			self.model = "";
			self.nextthink = -1;
		}
		else
		{
			if (pre_game)
			{
				self.nextthink = -1;
				self.think = MatchStartItem;
				first_item = AddToList(first_item);
			}
			else
				self.think = SUB_regen;
		}

		AssignVirtualGoal();
	}
	else
	{
		remove();
	}
};

/*
============
StartItem

Sets the clipping size and plants the object on the floor
============
*/
void() StartItem =
{
// put on save que
	AddToQue();
	self.view_ofs = '17 17 25';
	self.nextthink = time + 0.2;	// items start after other solids
	self.think = PlaceItem;
};

/*
=========================================================================

HEALTH BOX

=========================================================================
*/

/*QUAKED item_health (.3 .3 1) (0 0 0) (32 32 32) rotten megahealth
Health box. Normally gives 25 points.
Rotten box heals 5-10 points,
megahealth will add 100 health, then 
rot you down to your maximum health limit, 
one point per second.
*/

float	H_ROTTEN = 1;
float	H_MEGA = 2;
void() health_touch;
void() item_megahealth_rot;

void() goal_health0 =
{
	goal_desire = self.desire_health0;
};

void() goal_health2 =
{
	goal_desire = self.desire_health2;
};

void() item_health =
{
	if (deathmatch > 5)
		self.flags = self.flags | FL_REMOVE;

	self.touch = health_touch;

	if (self.spawnflags & H_MEGA)
	{
		precache_model("maps/b_bh100.bsp");
		precache_sound("items/r_item2.wav");
		setmodel(self, "maps/b_bh100.bsp");
		self.noise = "items/r_item2.wav";
		self.healamount = 100;
		self.healtype = 2;
		self.desire = goal_health2;
	}
	else
	{
		if (self.spawnflags & H_ROTTEN)
		{
			precache_model("maps/b_bh10.bsp");
			precache_sound("items/r_item1.wav");
			setmodel(self, "maps/b_bh10.bsp");
			self.noise = "items/r_item1.wav";
			self.healamount = 15;
			self.healtype = 0;
		}
		else
		{
			precache_model("maps/b_bh25.bsp");
			precache_sound("items/health1.wav");
			setmodel(self, "maps/b_bh25.bsp");
			self.noise = "items/health1.wav";
			self.healamount = 25;
			self.healtype = 1;
		}
		self.desire = goal_health0;
	}
	setsize (self, '0 0 0', '32 32 56');
	StartItem ();
};

void() health_touch =
{
	if (other.client_)
	{
		if (marker_time)
			check_marker();

	#ifdef MANUAL
		if (manual_mode)
			return;
	#endif // MANUAL

		if (self.nextthink)
			return;
		if (other.takedamage)
		{
			if (other.goalentity == self)
				other.goal_refresh_time = 0;

			// Megahealth = rot down the player's super health
			if (self.healtype == 2) // Megahealth
			{
				if (other.health >= 250)
					return;
				if (other.health < 150)
					other.health = other.health + 100;
				else
					other.health = 250;

				if (deathmatch != 4)
				{
					self.nextthink = time + 5;
					self.think = item_megahealth_rot;
				}
				else
					self.nextthink = -1;
				self.owner = other;
			}
			else
			{
				if (other.health >= 100)
					return;
				other.health = other.health + self.healamount;
				if (other.health > 100)
					other.health = 100;

				if (deathmatch != 2)		// deathmatch 2 is the silly old rules
					self.nextthink = self.goal_respawn_time = time + 20;
				else
					self.nextthink = -1;
			}
			AssignVirtualGoal();

			msg_entity = other;
			msg_level = PRINT_LOW;

			sprint("You receive ");
			sprint_ftos(self.healamount);
			sprint(" health\n");
	
		// health touch sound
			sound(CHAN_ITEM, self.noise, 1, ATTN_NORM);

			bf();

			self.model = "";

			UpdateTotalDamage(other);
			UpdateGoalEntity();
		}
	}
};	

void() item_megahealth_rot =
{
	other = self.owner;
	
	if (other.health > 100)
// CTF ->
	//ZOID: player doesn't rot if they have Elder Magic rune
		if (!(other.player_flag & ITEM_RUNE4_FLAG))
// CTF <-
		{
			other.health = other.health - 1;
			self.nextthink = time + 1;
			UpdateTotalDamage(other);
			return;
		}

	if (deathmatch != 2)	// deathmatch 2 is silly old rules
	{
		self.nextthink = self.goal_respawn_time = time + 20;
		self.think = SUB_regen;
	}
	else
		self.nextthink = -1;
	AssignVirtualGoal();
};

/*
===============================================================================

ARMOR

===============================================================================
*/

void() armor_touch =
{
	if (other.client_)
	{
		if (marker_time)
			check_marker();

	#ifdef MANUAL
		if (manual_mode)
			return;
	#endif // MANUAL

		if (self.nextthink)
			return;
		if (other.takedamage)
		{
			if (other.goalentity == self)
				other.goal_refresh_time = 0;

			if (other.total_armor >= self.total_armor)
			{
				if (marker_time)
				if (other.goalentity == self)
				if (!other.look_object.client_)
				if (other.movetarget.owner != other)	// no rocket active
				if (!other.button0_)
				{
					other.state = other.state | HURT_SELF;
					other.linked_marker = self;
					other.path_state = 0;
					other.linked_marker_time = time + 0.5;
				}
				return;
			}

			other.armortype = self.armortype;
			other.armorvalue = self.armorvalue;
			other.items = (other.items & IT_NOT_ARMOR) + self.items;

			self.model = "";
			if (deathmatch != 2)
				self.nextthink = self.goal_respawn_time = time + 20;
			else
				self.nextthink = -1;
			AssignVirtualGoal();

			msg_entity = other;
			msg_level = PRINT_LOW;

			sprint("You got armor\n");

		// armor touch sound
			sound(CHAN_ITEM, "items/armor1.wav", 1, ATTN_NORM);

			bf();

			UpdateTotalDamage(other);
			UpdateGoalEntity();
		}
	}
};


/*QUAKED item_armor1 (0 .5 .8) (-16 -16 0) (16 16 32)
*/
void() goal_armor1 =
{
	goal_desire = self.desire_armor1;
};

void() item_armor1 =
{
	if (deathmatch > 5)
		self.flags = self.flags | FL_REMOVE;

	self.touch = armor_touch;
	precache_model ("progs/armor.mdl");
	setmodel (self, "progs/armor.mdl");
	self.skin = 0;
	setsize (self, '-16 -16 0', '16 16 56');
	self.armortype = 0.3;
	self.armorvalue = 100;
	self.total_armor = 30;
	self.items = IT_ARMOR1;
	self.desire = goal_armor1;
	StartItem ();
};

/*QUAKED item_armor2 (0 .5 .8) (-16 -16 0) (16 16 32)
*/
void() goal_armor2 =
{
	if (self.desire_armor2)
		goal_desire = (self.desire_armor2 + virtual_enemy.desire_armor2);	
	else
	{
		if (self.total_armor <= 100)
		if (items_ & IT_ROCKET_LAUNCHER)
		if (self.ammo_rockets)
		if (self.health >= 50)
		if (self.super_damage_finished <= time)
		{
			goal_desire = virtual_enemy.desire_armor2;
			return;
		}
		goal_desire = 0;
	}
};

void() item_armor2 =
{
	if (deathmatch > 5)
		self.flags = self.flags | FL_REMOVE;

	self.touch = armor_touch;
	precache_model ("progs/armor.mdl");
	setmodel (self, "progs/armor.mdl");
	self.skin = 1;
	setsize (self, '-16 -16 0', '16 16 56');
	self.armortype = 0.6;
	self.armorvalue = 150;
	self.total_armor = 90;
	self.items = IT_ARMOR2;
	self.desire = goal_armor2;
	StartItem ();
};

/*QUAKED item_armorInv (0 .5 .8) (-16 -16 0) (16 16 32)
*/
void() goal_armorInv =
{
	if (self.desire_armorInv)
		goal_desire = (self.desire_armorInv + virtual_enemy.desire_armorInv);
	else
	{
		if (items_ & IT_ROCKET_LAUNCHER)
		if (self.ammo_rockets)
		if (self.health >= 50)
		if (self.super_damage_finished <= time)
		{
			goal_desire = virtual_enemy.desire_armorInv;
			return;
		}
		goal_desire = 0;
	}
};

void() item_armorInv =
{
	if (deathmatch > 5)
		self.flags = self.flags | FL_REMOVE;

	self.touch = armor_touch;
	precache_model ("progs/armor.mdl");
	setmodel (self, "progs/armor.mdl");
	self.skin = 2;
	setsize (self, '-16 -16 0', '16 16 56');
	self.armortype = 0.8;
	self.armorvalue = 200;
	self.total_armor = 160;
	self.items = IT_ARMOR3;
	self.desire = goal_armorInv;
	StartItem ();
};

/*
===============================================================================

WEAPONS

===============================================================================
*/

void() bound_ammo =
{
	if (other.ammo_shells > 100)
		other.ammo_shells = 100;
	if (other.ammo_nails > 200)
		other.ammo_nails = 200;
	if (other.ammo_rockets > 100)
		other.ammo_rockets = 100;		
	if (other.ammo_cells > 100)
		other.ammo_cells = 100;		
};


float(float w) RankForWeapon =
{
	if (w == IT_LIGHTNING)
		return 1;
	if (w == IT_ROCKET_LAUNCHER)
		return 2;
	if (w == IT_SUPER_NAILGUN)
		return 3;
	if (w == IT_GRENADE_LAUNCHER)
		return 4;
	if (w == IT_SUPER_SHOTGUN)
		return 5;
	if (w == IT_NAILGUN)
		return 6;
	return 7;
};

/*
=============
Deathmatch_Weapon

Deathmatch weapon change rules for picking up a weapon
=============
*/
void(float new) Deathmatch_Weapon =
{
// change other.weapon if desired
	or = RankForWeapon (other.weapon);
	nr = RankForWeapon (new);
	if ( nr < or )
		other.weapon = new;
};

/*
=============
weapon_touch

=============
*/
void() weapon_touch =
{
	if (other.client_)
	{
		if (marker_time)
			check_marker();

	#ifdef MANUAL
		if (manual_mode)
			return;
	#endif // MANUAL

		if (self.nextthink)
			return;
		if (other.takedamage)
		{
			if (other.goalentity == self)
				other.goal_refresh_time = 0;

			leave = FALSE;

			if (deathmatch != 1)
			{
				if (deathmatch != 4)
				{
					if (other.items & self.weapon)
						return;
					leave = TRUE;
				}
			}

			if (self.weapon == IT_NAILGUN)
				other.ammo_nails = other.ammo_nails + 30;
			else if (self.weapon == IT_SUPER_NAILGUN)
				other.ammo_nails = other.ammo_nails + 30;
			else if (self.weapon == IT_SUPER_SHOTGUN)
				other.ammo_shells = other.ammo_shells + 5;
			else if (self.weapon == IT_ROCKET_LAUNCHER)
				other.ammo_rockets = other.ammo_rockets + 5;
			else if (self.weapon == IT_GRENADE_LAUNCHER)
				other.ammo_rockets = other.ammo_rockets + 5;
			else if (self.weapon == IT_LIGHTNING)
				other.ammo_cells = other.ammo_cells + 15;

			other.state = other.state | UPDATE_WEAPONS;

			msg_entity = other;
			msg_level = PRINT_LOW;

			sprint ("You got the ");
			sprint (self.netname);
			sprint ("\n");

		// weapon touch sound
			sound (CHAN_ITEM, "weapons/pkup.wav", 1, ATTN_NORM);

			bf();

			bound_ammo ();

		// change to the weapon
			other.items = other.items | self.weapon;
	
			Deathmatch_Weapon (self.weapon);

			if (!leave)
			{
				UpdateGoalEntity();

			// setup for respawning
				self.model = "";

				self.nextthink = self.goal_respawn_time = time + 30;
				AssignVirtualGoal();
			}

			self = other;
			W_SetCurrentAmmo();
		}
	}
};


/*QUAKED weapon_supershotgun (0 .5 .8) (-16 -16 0) (16 16 32)
*/

void() goal_supershotgun1 =
{
	goal_desire = (self.desire_supershotgun + (virtual_enemy.desire_supershotgun * 0.5));
};

void() goal_supershotgun2 =
{
	if (items_ & IT_SUPER_SHOTGUN)
		goal_desire = 0;
	else
		goal_desire = (self.desire_supershotgun + (virtual_enemy.desire_supershotgun * 0.5));
};

void() weapon_supershotgun =
{
	G21(self);

	if (deathmatch <= 3)
		available_weapons = available_weapons | IT_SUPER_SHOTGUN;
	else
		self.flags = self.flags | FL_REMOVE;

	precache_model ("progs/g_shot.mdl");
	setmodel (self, "progs/g_shot.mdl");
	self.weapon = IT_SUPER_SHOTGUN;
	self.netname = "Double-barrelled Shotgun";
	self.touch = weapon_touch;
	setsize (self, '-16 -16 0', '16 16 56');
	if (deathmatch == 1)
		self.desire = goal_supershotgun1;
	else
		self.desire = goal_supershotgun2;
	StartItem ();
};

/*QUAKED weapon_nailgun (0 .5 .8) (-16 -16 0) (16 16 32)
*/

void() goal_nailgun1 =
{
	goal_desire = (self.desire_nailgun + (virtual_enemy.desire_nailgun * 0.5));
};

void() goal_nailgun2 =
{
	if (items_ & IT_NAILGUN)
		goal_desire = 0;
	else
		goal_desire = (self.desire_nailgun + (virtual_enemy.desire_nailgun * 0.5));
};

void() weapon_nailgun =
{
	G22(self);

	if (deathmatch <= 3)
		available_weapons = available_weapons | IT_NAILGUN;
	else
		self.flags = self.flags | FL_REMOVE;

	precache_model ("progs/g_nail.mdl");
	setmodel (self, "progs/g_nail.mdl");
	self.weapon = IT_NAILGUN;
	self.netname = "nailgun";
	self.touch = weapon_touch;
	setsize (self, '-16 -16 0', '16 16 56');
	if (deathmatch == 1)
		self.desire = goal_nailgun1;
	else
		self.desire = goal_nailgun2;
	StartItem ();
};

/*QUAKED weapon_supernailgun (0 .5 .8) (-16 -16 0) (16 16 32)
*/

void() goal_supernailgun1 =
{
	goal_desire = (self.desire_supernailgun + (virtual_enemy.desire_supernailgun * 0.5));
};

void() goal_supernailgun2 =
{
	if (items_ & IT_SUPER_NAILGUN)
		goal_desire = 0;
	else
		goal_desire = (self.desire_supernailgun + (virtual_enemy.desire_supernailgun * 0.5));
};

void() weapon_supernailgun =
{
	G20(self);

	if (deathmatch <= 3)
		available_weapons = available_weapons | IT_SUPER_NAILGUN;
	else
		self.flags = self.flags | FL_REMOVE;

	precache_model ("progs/g_nail2.mdl");
	setmodel (self, "progs/g_nail2.mdl");
	self.weapon = IT_SUPER_NAILGUN;
	self.netname = "Super Nailgun";
	self.touch = weapon_touch;
	setsize (self, '-16 -16 0', '16 16 56');
	if (deathmatch == 1)
		self.desire = goal_supernailgun1;
	else
		self.desire = goal_supernailgun2;
	StartItem ();
};

/*QUAKED weapon_grenadelauncher (0 .5 .8) (-16 -16 0) (16 16 32)
*/

void() goal_grenadelauncher1 =
{
	goal_desire = (self.desire_grenadelauncher + virtual_enemy.desire_grenadelauncher);
};

void() goal_grenadelauncher2 =
{
	if (items_ & IT_GRENADE_LAUNCHER)
		goal_desire = 0;
	else
		goal_desire = (self.desire_grenadelauncher + virtual_enemy.desire_grenadelauncher);
};

void() weapon_grenadelauncher =
{
	if (deathmatch <= 3)
		available_weapons = available_weapons | IT_GRENADE_LAUNCHER;
	else
		self.flags = self.flags | FL_REMOVE;

	precache_model ("progs/g_rock.mdl");
	setmodel (self, "progs/g_rock.mdl");
	self.weapon = IT_GRENADE_LAUNCHER;
	self.netname = "Grenade Launcher";
	self.touch = weapon_touch;
	setsize (self, '-16 -16 0', '16 16 56');
	if (deathmatch == 1)
		self.desire = goal_grenadelauncher1;
	else
		self.desire = goal_grenadelauncher2;
	StartItem ();
};

/*QUAKED weapon_rocketlauncher (0 .5 .8) (-16 -16 0) (16 16 32)
*/

void() goal_rocketlauncher1 =
{
	goal_desire = (self.desire_rocketlauncher + virtual_enemy.desire_rocketlauncher);
};

void() goal_rocketlauncher2 =
{
	if (items_ & IT_ROCKET_LAUNCHER)
		goal_desire = 0;
	else
		goal_desire = (self.desire_rocketlauncher + virtual_enemy.desire_rocketlauncher);
};

void() weapon_rocketlauncher =
{
	if (deathmatch <= 3)
		available_weapons = available_weapons | IT_ROCKET_LAUNCHER;
	else
		self.flags = self.flags | FL_REMOVE;

	precache_model ("progs/g_rock2.mdl");
	setmodel (self, "progs/g_rock2.mdl");
	self.weapon = IT_ROCKET_LAUNCHER;
	self.netname = "Rocket Launcher";
	self.touch = weapon_touch;
	setsize (self, '-16 -16 0', '16 16 56');
	if (deathmatch == 1)
		self.desire = goal_rocketlauncher1;
	else
		self.desire = goal_rocketlauncher2;
	StartItem ();
};


/*QUAKED weapon_lightning (0 .5 .8) (-16 -16 0) (16 16 32)
*/

void() goal_lightning1 =
{
	goal_desire = (self.desire_lightning + (virtual_enemy.desire_lightning * 0.5));
};

void() goal_lightning2 =
{
	if (items_ & IT_LIGHTNING)
		goal_desire = 0;
	else
		goal_desire = (self.desire_lightning + (virtual_enemy.desire_lightning * 0.5));
};

void() weapon_lightning =
{
	if (deathmatch <= 3)
		available_weapons = available_weapons | IT_LIGHTNING;
	else
		self.flags = self.flags | FL_REMOVE;

	precache_model ("progs/g_light.mdl");
	setmodel (self, "progs/g_light.mdl");
	self.weapon = IT_LIGHTNING;
	self.netname = "Thunderbolt";
	self.touch = weapon_touch;
	setsize (self, '-16 -16 0', '16 16 56');
	if (deathmatch == 1)
		self.desire = goal_lightning1;
	else
		self.desire = goal_lightning2;
	StartItem ();
};


/*
===============================================================================

AMMO

===============================================================================
*/

void() ammo_touch =
{
	if (other.client_)
	{
		if (marker_time)
			check_marker();

	#ifdef MANUAL
		if (manual_mode)
			return;
	#endif // MANUAL

		if (self.nextthink)
			return;
		if (other.takedamage)
		{
			if (other.goalentity == self)
				other.goal_refresh_time = 0;

		// shotgun
			if (self.weapon == 1)
			{
				if (other.ammo_shells >= 100)
					return;
				other.ammo_shells = other.ammo_shells + self.aflag;
			}

		// spikes
			else if (self.weapon == 2)
			{
				if (other.ammo_nails >= 200)
					return;
				other.ammo_nails = other.ammo_nails + self.aflag;
			}

		// rockets
			else if (self.weapon == 3)
			{
				if (other.ammo_rockets >= 100)
					return;
				other.ammo_rockets = other.ammo_rockets + self.aflag;
			}

		//	cells
			else if (self.weapon == 4)
			{
				if (other.ammo_cells >= 100)
					return;
				other.ammo_cells = other.ammo_cells + self.aflag;
			}

			other.state = other.state | UPDATE_WEAPONS;

			bound_ammo ();

			msg_entity = other;
			msg_level = PRINT_LOW;

			sprint ("You got the ");
			sprint (self.netname);
			sprint ("\n");	

		// ammo touch sound
			sound (CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);

			bf();

			UpdateGoalEntity();

		// setup for respawning
			self.model = "";

			if (deathmatch != 2)
			{
				if (deathmatch == 3 || deathmatch == 5)
					self.nextthink = self.goal_respawn_time = time + 15;
				else
					self.nextthink = self.goal_respawn_time = time + 30;
			}
			else
				self.nextthink = -1;
			AssignVirtualGoal();

			self = other;
			W_SetCurrentAmmo();
		}
	}
};

float WEAPON_BIG2 = 1;

/*QUAKED item_shells (0 .5 .8) (0 0 0) (32 32 32) big
*/

void() goal_shells =
{
	if (self.ammo_shells < 100)
		goal_desire = self.desire_shells;
	else
		goal_desire = 0;
};

void() item_shells =
{
	G24(self);

	if ((deathmatch == 4) || (deathmatch == 6))
		self.flags = self.flags | FL_REMOVE;

	self.touch = ammo_touch;

	if (self.spawnflags & WEAPON_BIG2)
	{
		precache_model ("maps/b_shell1.bsp");
		setmodel (self, "maps/b_shell1.bsp");
		self.aflag = 40;
	}
	else
	{
		precache_model ("maps/b_shell0.bsp");
		setmodel (self, "maps/b_shell0.bsp");
		self.aflag = 20;
	}

	self.weapon = 1;
	self.netname = "shells";
	setsize (self, '0 0 0', '32 32 56');
	self.desire = goal_shells;
	StartItem ();
};

/*QUAKED item_spikes (0 .5 .8) (0 0 0) (32 32 32) big
*/

void() goal_spikes =
{
	if (self.ammo_nails < 200)
		goal_desire = self.desire_nails;
	else
		goal_desire = 0;
};

void() item_spikes =
{
	G23(self);

	if ((deathmatch == 4) || (deathmatch == 6))
		self.flags = self.flags | FL_REMOVE;

	self.touch = ammo_touch;

	if (self.spawnflags & WEAPON_BIG2)
	{
		precache_model ("maps/b_nail1.bsp");
		setmodel (self, "maps/b_nail1.bsp");
		self.aflag = 50;
	}
	else
	{
		precache_model ("maps/b_nail0.bsp");
		setmodel (self, "maps/b_nail0.bsp");
		self.aflag = 25;
	}

	self.weapon = 2;
	self.netname = "nails";
	setsize (self, '0 0 0', '32 32 56');
	self.desire = goal_spikes;
	StartItem ();
};

/*QUAKED item_rockets (0 .5 .8) (0 0 0) (32 32 32) big
*/

void() goal_rockets =
{
	if (self.ammo_rockets < 100)
		goal_desire = (self.desire_rockets + virtual_enemy.desire_rockets);
	else
		goal_desire = 0;

};

void() item_rockets =
{
	if ((deathmatch == 4) || (deathmatch == 6))
		self.flags = self.flags | FL_REMOVE;

	self.touch = ammo_touch;

	if (self.spawnflags & WEAPON_BIG2)
	{
		precache_model ("maps/b_rock1.bsp");
		setmodel (self, "maps/b_rock1.bsp");
		self.aflag = 10;
	}
	else
	{
		precache_model ("maps/b_rock0.bsp");
		setmodel (self, "maps/b_rock0.bsp");
		self.aflag = 5;
	}

	self.weapon = 3;
	self.netname = "rockets";
	setsize (self, '0 0 0', '32 32 56');
	self.desire = goal_rockets;
	StartItem ();
};


/*QUAKED item_cells (0 .5 .8) (0 0 0) (32 32 32) big
*/

void() goal_cells =
{
	if (self.ammo_cells < 100)
		goal_desire = (self.desire_cells + (virtual_enemy.desire_cells * 0.5));
	else
		goal_desire = 0;
};

void() item_cells =
{
	G19(self);

	if ((deathmatch == 4) || (deathmatch == 6))
		self.flags = self.flags | FL_REMOVE;

	self.touch = ammo_touch;

	if (self.spawnflags & WEAPON_BIG2)
	{
		precache_model ("maps/b_batt1.bsp");
		setmodel (self, "maps/b_batt1.bsp");
		self.aflag = 12;
	}
	else
	{
		precache_model ("maps/b_batt0.bsp");
		setmodel (self, "maps/b_batt0.bsp");
		self.aflag = 6;
	}

	self.weapon = 4;
	self.netname = "cells";
	setsize (self, '0 0 0', '32 32 56');
	self.desire = goal_cells;
	StartItem ();
};


/*QUAKED item_weapon (0 .5 .8) (0 0 0) (32 32 32) shotgun rocket spikes big
DO NOT USE THIS!!!! IT WILL BE REMOVED!
*/

float WEAPON_SHOTGUN = 1;
float WEAPON_ROCKET = 2;
float WEAPON_SPIKES = 4;
float WEAPON_BIG = 8;
void() item_weapon =
{
	if ((deathmatch == 4) || (deathmatch == 6))
		self.flags = self.flags | FL_REMOVE;

	self.touch = ammo_touch;

	if (self.spawnflags & WEAPON_SHOTGUN)
	{
		self.classname = "item_shells";
		G24(self);

		if (self.spawnflags & WEAPON_BIG)
		{
			precache_model ("maps/b_shell1.bsp");
			setmodel (self, "maps/b_shell1.bsp");
			self.aflag = 40;
		}
		else
		{
			precache_model ("maps/b_shell0.bsp");
			setmodel (self, "maps/b_shell0.bsp");
			self.aflag = 20;
		}

		self.weapon = 1;
		self.netname = "shells";
		self.desire = goal_shells;
	}
	else if (self.spawnflags & WEAPON_SPIKES)
	{
		self.classname = "item_spikes";
		G23(self);

		if (self.spawnflags & WEAPON_BIG)
		{
			precache_model ("maps/b_nail1.bsp");
			setmodel (self, "maps/b_nail1.bsp");
			self.aflag = 40;
		}
		else
		{
			precache_model ("maps/b_nail0.bsp");
			setmodel (self, "maps/b_nail0.bsp");
			self.aflag = 20;
		}

		self.weapon = 2;
		self.netname = "spikes";
		self.desire = goal_spikes;
	}
	else if (self.spawnflags & WEAPON_ROCKET)
	{
		self.classname = "item_rockets";

		if (self.spawnflags & WEAPON_BIG)
		{
			precache_model ("maps/b_rock1.bsp");
			setmodel (self, "maps/b_rock1.bsp");
			self.aflag = 10;
		}
		else
		{
			precache_model ("maps/b_rock0.bsp");
			setmodel (self, "maps/b_rock0.bsp");
			self.aflag = 5;
		}

		self.weapon = 3;
		self.netname = "rockets";
		self.desire = goal_rockets;
	}

	setsize (self, '0 0 0', '32 32 56');
	StartItem ();
};

/*
===============================================================================

KEYS

===============================================================================
*/
void() item_key1 = {remove();};

void() item_key2 = {remove();};

/*
===============================================================================

END OF LEVEL RUNES

===============================================================================
*/
void() item_sigil = {remove();};

/*
===============================================================================

POWERUPS

===============================================================================
*/

void() powerup_touch =
{
	if (other.client_)
	{
		if (marker_time)
			check_marker();

	#ifdef MANUAL
		if (manual_mode)
			return;
	#endif // MANUAL

		if (self.nextthink)
			return;
		if (other.takedamage)
		{
			if (other.goalentity == self)
				other.goal_refresh_time = 0;

			self.nextthink = self.goal_respawn_time = time + self.aflag;
			AssignVirtualGoal();

			msg_entity = other;
			msg_level = PRINT_LOW;

			sprint ("You got the ");
			sprint (self.netname);
			sprint ("\n");

			sound (CHAN_VOICE, self.noise, 1, ATTN_NORM);

			bf();

			self.model = "";

			items_ = self.items;

		// do the apropriate action
			if (items_ == IT_INVISIBILITY)
			{
			// use the eyes
			#ifdef QUAKE
				if (other.flags & FL_PLAYER)
				{
					if (game_skinfix)
					{
						other.modelindex = 0;
						other.aiment.modelindex = modelindex_eyes;
						msg_entity = other;
						WriteByte(MSG_ONE, SVC_SETVIEWPORT);
						WriteEntity(MSG_ONE, other.aiment);
					}
					else
						other.modelindex = modelindex_eyes;
				}
				else
				{
					other.aiment.modelindex = 0;
					other.modelindex = modelindex_eyes;
				}
			#endif // QUAKE

			#ifdef QUAKEWORLD
				other.modelindex = modelindex_eyes;
			#endif // QUAKEWORLD

				other.invisible_time = 1;
				other.invisible_finished = time + 30;
			}
			else if (items_ == IT_SUIT)
			{
				other.rad_time = 1;
				other.radsuit_finished = time + 30;
			}
			else if (items_ == IT_INVULNERABILITY)
			{
				other.invincible_time = 1;
				other.invincible_finished = time + 30;

			#ifdef QUAKE
				other.effects = other.aiment.effects = other.effects | EF_DIMLIGHT;
			#endif // QUAKE

			#ifdef QUAKEWORLD
				other.effects = other.effects | EF_DIMLIGHT_RED;
			#endif // QUAKEWORLD
			}
			else if (items_ == IT_QUAD)
			{
				other.super_time = 1;
				other.super_damage_finished = time + 30;

			#ifdef QUAKE
				other.effects = other.aiment.effects = other.effects | EF_DIMLIGHT;
			#endif // QUAKE

			#ifdef QUAKEWORLD
				other.effects = other.effects | EF_DIMLIGHT_BLUE;
			#endif // QUAKEWORLD
			}

			other.items = other.items | items_;

			UpdateGoalEntity();
		}
	}
};


/*QUAKED item_artifact_invulnerability (0 .5 .8) (-16 -16 -24) (16 16 32)
Player is invulnerable for 30 seconds
*/
void() item_artifact_invulnerability =
{
	if (game_disable_powerups)
		self.flags = self.flags | FL_REMOVE;

	self.touch = powerup_touch;
	precache_model ("progs/invulner.mdl");
	self.noise = "items/protect.wav";
	setmodel (self, "progs/invulner.mdl");
	self.netname = "Pentagram of Protection";
#ifdef QUAKEWORLD
	self.effects = self.effects | EF_RED;
#endif // QUAKEWORLD
	self.items = IT_INVULNERABILITY;
	setsize (self, '-16 -16 -24', '16 16 32');
	self.aflag = 300;
	self.desire = goal_NULL;
	StartItem ();
};

void() lose_artifact_invulnerability =
{
	self.items = self.items & IT_NOT_INVULNERABILITY;
	self.invincible_time = 0;
	self.invincible_finished = 0;
	if (!self.super_damage_finished)
	if (!(self.player_flag & ITEM_ENEMY_FLAG))
	{
	#ifdef QUAKE
		self.effects = self.aiment.effects = self.effects & NOT_EF_DIMLIGHT;
	#endif // QUAKE

	#ifdef QUAKEWORLD
		self.effects = self.effects & NOT_EF_DIMLIGHT;
	#endif // QUAKEWORLD
	}
#ifdef QUAKEWORLD
	self.effects = self.effects & NOT_EF_RED;
#endif // QUAKEWORLD
};

/*QUAKED item_artifact_envirosuit (0 .5 .8) (-16 -16 -24) (16 16 32)
Player takes no damage from water or slime for 30 seconds
*/
void() item_artifact_envirosuit =
{
	self.touch = powerup_touch;

	precache_model ("progs/suit.mdl");
	precache_sound ("items/suit.wav");
	precache_sound ("items/suit2.wav");
	self.noise = "items/suit.wav";
	setmodel (self, "progs/suit.mdl");
	self.netname = "Biosuit";
	self.items = IT_SUIT;
	setsize (self, '-16 -16 -24', '16 16 32');
	self.aflag = 60;
	self.desire = goal_NULL;
	StartItem ();
};

void() lose_artifact_envirosuit =
{
	self.items = self.items & IT_NOT_SUIT;
	self.rad_time = 0;
	self.radsuit_finished = 0;
};

/*QUAKED item_artifact_invisibility (0 .5 .8) (-16 -16 -24) (16 16 32)
Player is invisible for 30 seconds
*/

void() goal_artifact_invisibility =
{
	goal_desire = 200 + self.total_damage;
};

void() item_artifact_invisibility =
{
	if (game_disable_powerups)
		self.flags = self.flags | FL_REMOVE;

	self.touch = powerup_touch;
	precache_model ("progs/invisibl.mdl");
	precache_sound ("items/inv1.wav");
	precache_sound ("items/inv2.wav");
	precache_sound ("items/inv3.wav");
	self.noise = "items/inv1.wav";
	setmodel (self, "progs/invisibl.mdl");
	self.netname = "Ring of Shadows";
	self.items = IT_INVISIBILITY;
	setsize (self, '-16 -16 -24', '16 16 32');
	self.aflag = 300;
	self.desire = goal_artifact_invisibility;
	StartItem ();
};

void() lose_artifact_invisibility =
{
	self.items = self.items & IT_NOT_INVISIBILITY;
	self.invisible_finished = 0;
	self.invisible_time = 0;

#ifdef QUAKE
	if (self.flags & FL_PLAYER)
	{
		if (game_skinfix)
		{
			self.aiment.modelindex = 0;
			self.modelindex = modelindex_player;
			msg_entity = self;
			WriteByte(MSG_ONE, SVC_SETVIEWPORT);
			WriteEntity(MSG_ONE, self);
		}
		else
			self.modelindex = modelindex_player;
	}
	else
	{
		self.modelindex = 0;
		self.aiment.modelindex = modelindex_player;
	}
#endif // QUAKE

#ifdef QUAKEWORLD
	self.modelindex = modelindex_player;
#endif // QUAKEWORLD
};

/*QUAKED item_artifact_super_damage (0 .5 .8) (-16 -16 -24) (16 16 32)
The next attack from the player will do 4x damage
*/

void() goal_artifact_super_damage =
{
	goal_desire = 200 + self.total_damage;
};

void() item_artifact_super_damage =
{
	if (game_disable_powerups)
		self.flags = self.flags | FL_REMOVE;

	self.touch = powerup_touch;
	precache_model ("progs/quaddama.mdl");
	precache_sound ("items/damage.wav");
	precache_sound ("items/damage2.wav");
	precache_sound ("items/damage3.wav");
	self.noise = "items/damage.wav";
	setmodel (self, "progs/quaddama.mdl");
	if (quad_factor == 4)
		self.netname = "Quad Damage";
	else
		self.netname = "OctaPower";	

#ifdef QUAKEWORLD
	self.effects = self.effects | EF_BLUE;
#endif // QUAKEWORLD
	self.items = IT_QUAD;
	setsize (self, '-16 -16 -24', '16 16 32');
	self.aflag = 60;
	self.desire = goal_artifact_super_damage;
	StartItem ();
};

void() lose_artifact_super_damage =
{
	self.items = self.items & IT_NOT_QUAD;
	self.super_damage_finished = 0;
	self.super_time = 0;
	if (!self.invincible_finished)
	if (!(self.player_flag & ITEM_ENEMY_FLAG))
	{
	#ifdef QUAKE
		self.effects = self.aiment.effects = self.effects & NOT_EF_DIMLIGHT;
	#endif // QUAKE

	#ifdef QUAKEWORLD
		self.effects = self.effects & NOT_EF_DIMLIGHT;
	#endif // QUAKEWORLD
	}
#ifdef QUAKEWORLD
	self.effects = self.effects & NOT_EF_BLUE;
#endif // QUAKEWORLD
};

/*
===============================================================================

PLAYER BACKPACKS

===============================================================================
*/

void() RuneRespawn;

/*
============
LocateDynamicItem

============
*/
void() LocateDynamicItem =
{
	if (time >= self.frogbot_nextthink)
	{
		if (self.player_flag)
			RuneRespawn();	// rune
		else
			remove();	// backpack
	}
	else
	{
		self.touch_marker = LocateMarker(self.absmin + self.view_ofs);
		if (self.touch_marker.T & UNREACHABLE)
			self.touch_marker = world;

		self.Z_ = self.touch_marker.Z_;

		if (self.velocity != '0 0 0')
		{
			self.nextthink = time + 1;
		}
		else
		{
			self.nextthink = self.frogbot_nextthink;
			if (self.player_flag)
				self.think = RuneRespawn;	// rune
			else
				self.think = SUB_Remove;	// backpack
			if (!self.touch_marker)
				self.classname = "";	// can't locate so don't put in goal list
		}
	}
};

/*
============
G_is_connected

============
*/
float() G_is_connected =
{
	return TRUE;
};

/*
============
InitDynamicItem

============
*/
void(entity item) InitDynamicItem =
{
	item.touch_marker = LocateMarker(self.origin);
	if (item.touch_marker.T & UNREACHABLE)
		item.touch_marker = world;

	item.Z_ = item.touch_marker.Z_;

	item.nextthink = time + 1;
	item.think = LocateDynamicItem;
};

void() goal_health_backpack =
{
	if (self.invincible_time)
		goal_desire = 0;
	else
		goal_desire = 20;
};

void() BackpackTouch =
{
	local float acount;

	if (other.client_)
	{

	#ifdef MANUAL
		if (manual_mode)
			return;
	#endif // MANUAL

		if (other.takedamage)
		{
			msg_entity = other;
			msg_level = PRINT_LOW;

			if (deathmatch == 4)
			{
				if (other.invincible_time)
					return;

				sprint ("You get 10 additional health\n");

				other.health = other.health + 10;
				msg_entity = other;
				if ((other.health > 250) && (other.health < 300))
					sound (CHAN_ITEM, "items/protect3.wav", 1, ATTN_NORM);
				else
					sound (CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);
				bf();
				remove();

				if (other.health > 299)
				{               
					if (other.invincible_time != 1)
					{                       
						other.invincible_time = 1;
						other.invincible_finished = time + 30;
						other.super_time = 1;
						other.super_damage_finished = time + 30;
						other.items = other.items | IT_INVULNERABILITY_QUAD;
						other.ammo_cells = 0;		
						msg_entity = other;
						sound (CHAN_VOICE, "boss1/sight1.wav", 1, ATTN_NORM);
						bf();
						msg_level = PRINT_HIGH;             
						bprint_netname (other);
						bprint (" attains bonus powers!!!\n");
					}
				}
			}
			else
			{
				sprint ("You get ");

			// change weapons
				other.ammo_shells = other.ammo_shells + self.ammo_shells;
				other.ammo_nails = other.ammo_nails + self.ammo_nails;
				other.ammo_rockets = other.ammo_rockets + self.ammo_rockets;
				other.ammo_cells = other.ammo_cells + self.ammo_cells;
				bound_ammo ();

				if (self.items)
				{
					if (!(other.items & self.items))
					{
						acount = 1;
						sprint ("the ");
						sprint (self.netname);
						other.items = other.items | self.items;
					}

					Deathmatch_Weapon (self.items);
				}

				if (self.ammo_shells)
				{
					if (acount)
						sprint(", ");
					acount = 1;
					sprint_ftos (self.ammo_shells);
					sprint (" shells");
				}
				if (self.ammo_nails)
				{
					if (acount)
						sprint(", ");
					acount = 1;
					sprint_ftos (self.ammo_nails);
					sprint (" nails");
				}
				if (self.ammo_rockets)
				{
					if (acount)
						sprint(", ");
					acount = 1;
					sprint_ftos (self.ammo_rockets);
					sprint (" rockets");
				}
				if (self.ammo_cells)
				{
					if (acount)
						sprint(", ");
					acount = 1;
					sprint_ftos (self.ammo_cells);
					sprint (" cells");
				}

				sprint ("\n");
	
			// backpack touch sound
				sound (CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);

				bf();

				other.state = other.state | UPDATE_WEAPONS;

				UpdateGoalEntity();
				other.old_linked_marker = world;
				other.linked_marker = LocateMarker(other.origin);
				other.linked_marker_time = time + 5;

				remove();

				self = other;
				W_SetCurrentAmmo ();
			}
		}
	}
};

/*
===============
DropBackpack

===============
*/
void() DropBackpack =
{
	if (pre_game)
		return;

	item = spawn();
	item.origin = self.origin - '0 0 24';
	item.goal_respawn_time = time;

	items_ = self.weapon;

//ZOID--axe and hook don't go into backpack
	if (self.weapon != IT_HOOK || self.weapon != IT_AXE)
		item.items = items_;
	
	item.ammo_shells = self.ammo_shells;
	item.ammo_nails = self.ammo_nails;
	item.ammo_rockets = self.ammo_rockets;
	item.ammo_cells = self.ammo_cells;

	if (deathmatch != 4)
	{
		item.classname = "dynamic_item";

		if (items_ == IT_SUPER_SHOTGUN)
		{
			item.netname = "Double-barrelled Shotgun";
			item.desire = goal_supershotgun1;
		}
		else if (items_ == IT_NAILGUN)
		{
			item.netname = "Nailgun";
			item.desire = goal_nailgun1;
		}
		else if (items_ == IT_SUPER_NAILGUN)
		{
			item.netname = "Super Nailgun";
			item.desire = goal_supernailgun1;
		}
		else if (items_ == IT_GRENADE_LAUNCHER)
		{
			item.netname = "Grenade Launcher";
			item.desire = goal_grenadelauncher1;
		}
		else if (items_ == IT_ROCKET_LAUNCHER)
		{
			item.netname = "Rocket Launcher";
			item.desire = goal_rocketlauncher1;
		}
		else if (items_ == IT_LIGHTNING)
		{
			item.netname = "Thunderbolt";
			item.desire = goal_lightning1;
		}
		else
		{
			if (item.ammo_cells > (item.ammo_rockets * 5))
				item.desire = goal_cells;
			else if (item.ammo_rockets)
				item.desire = goal_rockets;
			else if (item.ammo_nails >= 50)
				item.desire = goal_spikes;
			else
				item.classname = "";
		}
	}
	else
	{
		item.classname = "dynamic_item";
		item.desire = goal_health_backpack;
	}

	item.velocity_z = 300;
	item.velocity_x = -100 + (random() * 200);
	item.velocity_y = -100 + (random() * 200);

	item.flags = FL_ITEM;
	item.solid = SOLID_TRIGGER;
	item.movetype = MOVETYPE_TOSS;
	setmodel (item, "progs/backpack.mdl");
	setsize (item, '-16 -16 0', '16 16 56');
	item.view_ofs = '31 31 25';
	item.touch = BackpackTouch;

	if (item.classname == "dynamic_item")
	{
		item.frogbot_nextthink = time + 120;	// remove after 2 minutes
		InitDynamicItem(item);
	}
	else
	{
		item.nextthink = time + 120;	// remove after 2 minutes
		item.think = SUB_Remove;
	}
};

// CTF ->

/*----------------------------------------------------------------------
  The Rune Game modes

  Rune 1 - Earth Magic
	  resistance
  Rune 2 - Black Magic
	  strength
  Rune 3 - Hell Magic
	  haste
  Rune 4 - Elder Magic
	  regeneration

 ----------------------------------------------------------------------*/

void() goal_rune =
{
	if (self.player_flag & ITEM_RUNE_MASK)
		goal_desire = 0;
	else
		goal_desire = 200;
};

void() SelectRuneSpawnPoint =
{
	runespawn = find(runespawn, classname, "info_player_deathmatch");
	if (!runespawn)
		runespawn = find (runespawn, classname, "info_player_deathmatch");
	self = runespawn;
};

void() RuneTouch =
{
	if (other.client_)
	{
	#ifdef MANUAL
		if (manual_mode)
			return;
	#endif // MANUAL

		if (other.player_flag & ITEM_RUNE_MASK)
			return; // one per customer
		if (other.takedamage)
		{
			other.player_flag = other.player_flag | self.player_flag;

			msg_entity = other;
			msg_level = PRINT_LOW;

			sprint("You got the ");
			sprint(self.netname);
			sprint(" rune\n");

			if (other.player_flag & ITEM_RUNE1_FLAG)
				other.total_damage = other.total_damage * 2;	// early update
			else if (other.player_flag & ITEM_RUNE2_FLAG)
				other.firepower = other.firepower * 2;	// early update

			// backpack touch sound
			msg_entity = other;
			sound (CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);
			bf();

			UpdateGoalEntity();
			other.old_linked_marker = world;
			other.linked_marker = LocateMarker(other.origin);
			other.linked_marker_time = time + 5;

			remove();
		}
	}
};

void (float flag) Do_DropRune;

void() RuneRespawn =
{
	rune_self = self;

	// choose random starting points
	SelectRuneSpawnPoint();
	Do_DropRune(rune_self.player_flag);

	self = rune_self;
	remove();
};

void (float flag) Do_DropRune = 
{
	item = spawn();
	item.origin = self.origin - '0 0 24';
	item.goal_respawn_time = time;

	item.player_flag = flag;

	item.velocity_z = 400;
	item.velocity_x = -500 + (random() * 1000);
	item.velocity_y = -500 + (random() * 1000);
	
	item.flags = FL_ITEM;
	item.solid = SOLID_TRIGGER;
	item.movetype = MOVETYPE_TOSS;
	if (flag & ITEM_RUNE1_FLAG)
	{
		setmodel (item, "progs/end1.mdl");
		item.netname = "Òåóéóôáîãå";
	}
	else if (flag & ITEM_RUNE2_FLAG)
	{
		setmodel (item, "progs/end2.mdl");
		item.netname = "Óôòåîçôè";
	}
	else if (flag & ITEM_RUNE3_FLAG)
	{
		setmodel (item, "progs/end3.mdl");
		item.netname = "Èáóôå";
	}
	else if (flag & ITEM_RUNE4_FLAG)
	{
		setmodel (item, "progs/end4.mdl");
		item.netname = "Òåçåîåòáôéïî";
	}
	setsize (item, '-16 -16 0', '16 16 56');

	if (pre_game)
	{
		self = item;
		first_item = AddToList(first_item);
		self.think = RuneRespawn;
	}
	else
	{
		item.desire = goal_rune;
		item.touch = RuneTouch;
		item.classname = "dynamic_item";
		item.frogbot_nextthink = time + 120; /* if no one touches it in two minutes,
			respawn it somewhere else, so inaccessible ones will come 'back' */
		InitDynamicItem(item);
	}
};

/*
===============
Droprune
self is player
===============
*/
void() DropRune =
{
	if (self.player_flag & ITEM_RUNE1_FLAG)
		Do_DropRune(ITEM_RUNE1_FLAG);
	if (self.player_flag & ITEM_RUNE2_FLAG)
		Do_DropRune(ITEM_RUNE2_FLAG);
	if (self.player_flag & ITEM_RUNE3_FLAG)
		Do_DropRune(ITEM_RUNE3_FLAG);
	if (self.player_flag & ITEM_RUNE4_FLAG)
		Do_DropRune(ITEM_RUNE4_FLAG);
	self.player_flag = self.player_flag - (self.player_flag & ITEM_RUNE_MASK);
};

/*
================
SpawnRunes
spawn all the runes
self is the entity that was created for us, we remove it
================
*/
void() SpawnRunes =
{
	if (game_enable_runes)
	{
		if (pre_game)
			return;
		game_enable_runes = FALSE;

		// choose random starting points
		rnd = random() * 10;
		while (rnd > 0)
		{
			SelectRuneSpawnPoint();
			rnd = rnd - 1;
		}

		SelectRuneSpawnPoint();
		Do_DropRune(ITEM_RUNE1_FLAG);
		SelectRuneSpawnPoint();
		Do_DropRune(ITEM_RUNE2_FLAG);
		SelectRuneSpawnPoint();
		Do_DropRune(ITEM_RUNE3_FLAG);
		SelectRuneSpawnPoint();
		Do_DropRune(ITEM_RUNE4_FLAG);
	}
};
// CTF <-
