// user interface file between katana and dlls
#include	"p_user.h"
#include	"hooks.h"
#include	"common.h"

///////////////////////////////////////////////////////////////////////////////
//	globals
///////////////////////////////////////////////////////////////////////////////

extern	serverState_t	*gstate;
extern	common_export_t	*com;

///////////////////////////////////////////////////////////////////////////////
//	exports
///////////////////////////////////////////////////////////////////////////////

DllExport	void	item_potion (userEntity_t *self);
DllExport	void	item_wooden_chest (userEntity_t *self);
DllExport	void	item_black_chest (userEntity_t *self);
DllExport	void	item_health_field (userEntity_t *self);
DllExport	void	item_health_kit_10 (userEntity_t *self);
DllExport	void	item_health_kit_20 (userEntity_t *self);
DllExport	void	item_plasteel_armor (userEntity_t *self);
DllExport	void	item_chromatic_armor (userEntity_t *self);
DllExport	void	item_silver_armor (userEntity_t *self);
DllExport	void	item_gold_armor (userEntity_t *self);
DllExport	void	item_chainmail_armor (userEntity_t *self);
DllExport	void	item_black_adamant_armor (userEntity_t *self);
DllExport	void	item_kevlar_armor (userEntity_t *self);
DllExport	void	item_ebonite_armor (userEntity_t *self);
DllExport	void	item_ebonite_armor (userEntity_t *self);
DllExport	void	item_wraithorb (userEntity_t *self);
DllExport	void	item_megashield (userEntity_t *self);
DllExport	void	item_goldensoul (userEntity_t *self);
DllExport	void	item_antidote (userEntity_t *self);
DllExport	void	item_power_boost (userEntity_t *self);
DllExport	void	item_attack_boost (userEntity_t *self);
DllExport	void	item_speed_boost (userEntity_t *self);
DllExport	void	item_acro_boost (userEntity_t *self);
DllExport	void	item_vita_boost (userEntity_t *self);
DllExport	void	item_jet_boots (userEntity_t *self);
DllExport	void	item_oxylung (userEntity_t *self);
DllExport	void	item_ice_boots (userEntity_t *self);
DllExport	void	item_envirosuit (userEntity_t *self);

////////////////////////////////////////
// item_potion
////////////////////////////////////////

void	item_health_touch (userEntity_t *self, userEntity_t *other, cplane_t *plane, csurface_t *surf)
{
	playerHook_t	*ohook = (playerHook_t *) other->userHook;

	if (!com->ValidTouch (self, other))
		return;

	if (other->health == ohook->max_health)
		return;

	com->Health (other, self->health, ohook->max_health);

	com->SetRespawn (self, 30, FALSE, 0.0);

	gstate->sound (self, CHAN_VOICE, "items/healthpickup.wav", 255, ATTN_NORM);

	if (other->flags & FL_CLIENT)
		gstate->sprint (other, "You picked up the %s.\n", self->netname);
}

///////////////////////////////////////////////////////////////////////////////
// 
///////////////////////////////////////////////////////////////////////////////

void	item_potion (userEntity_t *self)
{
	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_FLY;
	gstate->Precache_Model ("models/healthpotion.mdl");
	gstate->SetModel (self, "models/healthpotion.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->netname = "health potion";
	self->health = 10;
	self->touch = item_health_touch;
	com->SetVector (self->avelocity, 0.0, 180, 0.0);

	gstate->Precache_Sound ("items/healthpickup.wav");
}

///////////////////////////////////////////////////////////////////////////////
// item_wooden_chest
///////////////////////////////////////////////////////////////////////////////

void	item_wooden_chest_open (userEntity_t *self, userEntity_t *other)
{
}

///////////////////////////////////////////////////////////////////////////////
// 
///////////////////////////////////////////////////////////////////////////////

void	item_wooden_chest_use (userEntity_t *self, userEntity_t *other, userEntity_t *activator)
{
	gstate->sound (self, CHAN_AUTO, "items/woodenchestopen.wav", 255, ATTN_NORM);
	gstate->bprint ("The chest is locked, suck it down.\n");
}

///////////////////////////////////////////////////////////////////////////////
// 
///////////////////////////////////////////////////////////////////////////////

void	item_wooden_chest (userEntity_t *self)
{
	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_NONE;
	gstate->Precache_Model ("models/woodchest.mdl");
	gstate->SetModel (self, "models/woodchest.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->use = item_wooden_chest_use;

	gstate->Precache_Sound ("items/woodenchestopen1.wav");
}

////////////////////////////////////////
// item_black_chest
////////////////////////////////////////

void	item_black_chest (userEntity_t *self)
{
	self = gstate->SpawnEntity ();
	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_NONE;
	gstate->Precache_Model ("models/artifact.mdl");
	gstate->SetModel (self, "models/artifact.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	gstate->Precache_Sound ("items/healthpickup.wav");
}

////////////////////////////////////////
// item_health_field
////////////////////////////////////////

void	item_health_field (userEntity_t *self)
{
	float			r;

	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_NONE;
	gstate->Precache_Model ("models/canister.mdl");
	gstate->SetModel (self, "models/canister.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	r = rnd () * 10.0F;
	if (r < 5)
		self->health = 10;
	else if (r < 9)
		self->health = 25;
	else 
		self->health = 40;

	self->netname = "health field cannister";
	self->touch = item_health_touch;

	gstate->Precache_Sound ("items/healthpickup.wav");
}

////////////////////////////////////////
// item_health_kit_10
////////////////////////////////////////

void	item_health_kit_10 (userEntity_t *self)
{
	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_NONE;
	gstate->SetModel (self, "models/artifact.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->netname = "health kit";
	self->health = 10;
	self->touch = item_health_touch;

	gstate->Precache_Sound ("items/healthpickup.wav");
}

////////////////////////////////////////
// item_health_kit_20
////////////////////////////////////////

void	item_health_kit_20 (userEntity_t *self)
{
	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_NONE;
	gstate->SetModel (self, "models/artifact.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->netname = "health kit";
	self->health = 20;
	self->touch = item_health_touch;

	gstate->Precache_Sound ("items/healthpickup.wav");
}

////////////////////////////////////////
// item_plasteel_armor
////////////////////////////////////////

void	item_armor_touch (userEntity_t *self, userEntity_t *other, cplane_t *plane, csurface_t *surf)
{
	playerHook_t	*ohook = (playerHook_t *) other->userHook;
	
	if (!com->ValidTouch (self, other))
		return;

	// check to see if current armor is worse than this armor
	if (self->health * self->frags <= other->armor_val * other->armor_abs)
	{
		gstate->Con_Printf ("armor no good.  Me go now\n");
		return;
	}

	other->armor_val = self->health;
	other->armor_abs = self->frags;

	ohook->items = ohook->items - (ohook->items & (IT_PLASTEEL | IT_CHROMATIC | IT_SILVER | 
				  IT_GOLD | IT_CHAINMAIL | IT_BLACK_ADAMANT | IT_KEVLAR | IT_EBONITE));
	
	ohook->items = ohook->items | self->spawnflags;

	com->SetRespawn (self, 30, FALSE, 0.0);

/*	
	// send new armor value down to client
	gstate->WriteByte (other, MSG_ONE, SVC_ARMORVAL);
	gstate->WriteByte (other, MSG_ONE, (int)ohook->armor_val);
*/
	if (other->flags & FL_CLIENT)
		gstate->sprint (other, "You picked up the %s.\n", self->netname);
}

void	item_plasteel_armor (userEntity_t *self)
{
	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_FLY;
	gstate->Precache_Model ("models/plasteel.mdl");
	gstate->SetModel (self, "models/plasteel.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->health = 100;
	self->frags = 0.33;
	self->takedamage = DAMAGE_NO;
	self->flags = FL_ITEM;
	self->spawnflags = IT_PLASTEEL;
	self->netname = "plasteel armor";
	self->className = "armor_plasteel";
	self->touch = item_armor_touch;

	self->avelocity [1] = 180.0;

	gstate->Precache_Sound ("items/itempickup1.wav");
}

////////////////////////////////////////
// item_chromatic_armor
////////////////////////////////////////

void	item_chromatic_armor (userEntity_t *self)
{
	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_FLY;
	gstate->SetModel (self, "models\\armor.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->health = 200;
	self->frags = 0.5;
	self->takedamage = DAMAGE_NO;
	self->spawnflags = IT_CHROMATIC;
	self->flags = FL_ITEM;
	self->netname = "chromatic armor";
	self->className = "armor_chromatic";
	self->touch = item_armor_touch;

	self->avelocity [1] = 180.0;

	gstate->Precache_Sound ("items/itempickup1.wav");
}

////////////////////////////////////////
// item_silver_armor
////////////////////////////////////////

void	item_silver_armor (userEntity_t *self)
{
	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_FLY;
	gstate->SetModel (self, "models/armor.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->health = 200;
	self->frags = 0.5;
	self->takedamage = DAMAGE_NO;
	self->spawnflags = IT_SILVER;
	self->flags = FL_ITEM;
	self->netname = "silver armor";
	self->className = "armor_silver";
	self->touch = item_armor_touch;

	self->avelocity [1] = 180.0;

	gstate->Precache_Sound ("items/itempickup1.wav");
}

////////////////////////////////////////
// item_gold_armor
////////////////////////////////////////

void	item_gold_armor (userEntity_t *self)
{
	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_FLY;
	gstate->SetModel (self, "models/armor.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->health = 200;
	self->frags = 0.75;
	self->takedamage = DAMAGE_NO;
	self->spawnflags = IT_GOLD;
	self->flags = FL_ITEM;
	self->netname = "gold armor";
	self->className = "armor_gold";
	self->touch = item_armor_touch;

	self->avelocity [1] = 180.0;

	gstate->Precache_Sound ("items/itempickup1.wav");
}

////////////////////////////////////////
// item_chainmail_armor
////////////////////////////////////////

void	item_chainmail_armor (userEntity_t *self)
{
	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_FLY;
	gstate->Precache_Model ("models/chainmail.mdl");
	gstate->SetModel (self, "models/chainmail.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->health = 125;
	self->frags = 0.33;
	self->takedamage = DAMAGE_NO;
	self->spawnflags = IT_CHAINMAIL;
	self->flags = FL_ITEM;
	self->netname = "chainmail armor";
	self->className = "armor_chainmail";
	self->touch = item_armor_touch;

	self->avelocity [1] = 180.0;

	gstate->Precache_Sound ("items/itempickup1.wav");
}

////////////////////////////////////////
// item_black_adamant_armor
////////////////////////////////////////

void	item_black_adamant_armor (userEntity_t *self)
{
	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_FLY;
	gstate->SetModel (self, "models/armor.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->health = 250;
	self->frags = 0.5;
	self->takedamage = DAMAGE_NO;
	self->spawnflags = IT_BLACK_ADAMANT;
	self->flags = FL_ITEM;
	self->netname = "black adamant armor";
	self->className = "armor_black_adamant";
	self->touch = item_armor_touch;

	self->avelocity [1] = 180.0;

	gstate->Precache_Sound ("items/itempickup1.wav");
}

////////////////////////////////////////
// item_kevlar_armor
////////////////////////////////////////

void	item_kevlar_armor (userEntity_t *self)
{
	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_FLY;
	gstate->SetModel (self, "models/armor.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->health = 100;
	self->frags = 0.4;
	self->takedamage = DAMAGE_NO;
	self->spawnflags = IT_KEVLAR;
	self->flags = FL_ITEM;
	self->netname = "kevlar armor";
	self->className = "armor_kevlar";
	self->touch = item_armor_touch;

	self->avelocity [1] = 180.0;

	gstate->Precache_Sound ("items/itempickup1.wav");
}

////////////////////////////////////////
// item_ebonite_armor
////////////////////////////////////////

void	item_ebonite_armor (userEntity_t *self)
{
	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_FLY;
	gstate->SetModel (self, "models/armor.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->health = 200;
	self->frags = 0.6;
	self->takedamage = DAMAGE_NO;
	self->spawnflags = IT_EBONITE;
	self->flags = FL_ITEM;
	self->netname = "ebonite armor";
	self->className = "armor_ebonite";
	self->touch = item_armor_touch;

	self->avelocity [1] = 180.0;

	//self->translucent = 2;
	gstate->Precache_Sound ("items/itempickup1.wav");
}

////////////////////////////////////////
// item_wraithorb
////////////////////////////////////////

void	item_wraithorb_touch (userEntity_t *self, userEntity_t *other, cplane_t *plane, csurface_t *surf)
{
	playerHook_t	*ohook = (playerHook_t *) other->userHook;

	if (!com->ValidTouch (self, other))
		return;

	ohook->wraithorb_time = gstate->time + 30.0;
	ohook->items = ohook->items | IT_WRAITHORB;
	ohook->exp_flags = ohook->exp_flags | EXP_WRAITHORB;

	other->translucent = 4;

	gstate->sound (self, CHAN_VOICE, "artifacts/wraithorb/wraithorbpickup.wav", 255, ATTN_NORM);

	com->AmbientVolume (self, Vector (self->s.origin), 0.0);
	com->SetRespawn (self, 300.0, TRUE, 255);
	
	com->ClientPrint (other, "You have the Wraith Orb.\n");
}

void	item_wraithorb (userEntity_t *self)
{
	float			fade = 1.5;
	int				i;

	i = 0;
	while (self->epair [i].key != NULL)
	{
		if (!stricmp (self->epair [i].key, "fade"))
			fade = atof (self->epair [i].value);

		i++;
	}

	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_FLY;
	gstate->Precache_Model ("models/wraithorb.mdl");
	gstate->SetModel (self, "models/wraithorb.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->spawnflags = IT_WRAITHORB;
	self->flags = FL_ITEM;
	self->netname = "wraith orb";
	self->className = "item_artifact_wraithorb";

	self->touch = item_wraithorb_touch;

	gstate->Precache_Sound ("suck1.wav");

	self->avelocity [1] = 180;

	gstate->Precache_Sound ("artifacts/wraithorb/wraithorbfade.wav");
	gstate->Precache_Sound ("artifacts/wraithorb/wraithorbpickup.wav");
	gstate->Precache_Sound ("artifacts/wraithorb/wraithorbwait.wav");

	gstate->AmbientSound (self->s.origin, "artifacts/wraithorb/wraithorbwait.wav", 255, ATTN_STATIC, fade);
}

////////////////////////////////////////
// item_megashield
////////////////////////////////////////

void	item_megashield_touch (userEntity_t *self, userEntity_t *other, cplane_t *plane, csurface_t *surf)
{
	playerHook_t	*ohook = (playerHook_t *) other->userHook;

	if (!com->ValidTouch (self, other))
		return;

	ohook->megashield_time = gstate->time + 30.0;
	ohook->items = ohook->items | IT_MEGASHIELD;
	ohook->exp_flags = ohook->exp_flags | EXP_MEGASHIELD;

	gstate->sound (self, CHAN_VOICE, "artifacts/megashield/megapick.wav", 255, ATTN_NORM);

	com->AmbientVolume (self, Vector (self->s.origin), 0.0);
	com->SetRespawn (self, 300.0, TRUE, 255);
	
	com->ClientPrint (other, "You have the megashield.\n");
}

void	item_megashield (userEntity_t *self)
{
	float			fade = 1.5;
	int				i;

	i = 0;
	while (self->epair [i].key != NULL)
	{
		if (!stricmp (self->epair [i].key, "fade"))
			fade = atof (self->epair [i].value);

		i++;
	}

	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_FLY;
	gstate->Precache_Model ("models/megashield.mdl");
	gstate->SetModel (self, "models/megashield.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->spawnflags = IT_MEGASHIELD;
	self->flags = FL_ITEM;
	self->netname = "megashield";
	self->className = "item_artifact_megashield";
	self->touch = item_megashield_touch;

	self->avelocity [1] = 180;

	gstate->Precache_Sound ("artifacts/megashield/megawait.wav");
	gstate->Precache_Sound ("artifacts/megashield/megapick.wav");
	gstate->Precache_Sound ("artifacts/megashield/megafade.wav");
	gstate->Precache_Sound ("artifacts/megashield/megahit.wav");
	gstate->AmbientSound (self->s.origin, "artifacts/megashield/megawait.wav", 255, ATTN_STATIC, fade);
}

////////////////////////////////////////
// item_goldensoul
////////////////////////////////////////

void	item_goldensoul_touch (userEntity_t *self, userEntity_t *other, cplane_t *plane, csurface_t *surf)
{
	playerHook_t	*ohook = (playerHook_t *) other->userHook;

	if (!com->ValidTouch (self, other))
		return;

	if (other->health == ohook->max_health * 2.0)
		return;

	com->Health (other, self->health, ohook->max_health * 2.0);

	gstate->sound (self, CHAN_VOICE, "artifacts/goldensoul/goldensoulpickup.wav", 255, ATTN_NORM);

	com->AmbientVolume (self, Vector (self->s.origin), 0.0);
	com->SetRespawn (self, 300.0, TRUE, 255);

	com->ClientPrint (other, "You picked up the packet of souls.\n");
}

void	item_goldensoul (userEntity_t *self)
{
	float			fade = 1.5;
	int				i;

	i = 0;
	while (self->epair [i].key != NULL)
	{
		if (!stricmp (self->epair [i].key, "fade"))
			fade = atof (self->epair [i].value);

		i++;
	}

	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_FLY;

	gstate->Precache_Model ("models/goldsoul.mdl");
	gstate->SetModel (self, "models/goldsoul.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->avelocity [1] = 180;

	self->health = 100;
	self->spawnflags = IT_GOLDENSOUL;
	self->flags = FL_ITEM;
	self->netname = "goldensoul";
	self->className = "item_artifact_goldensoul";
	self->touch = item_goldensoul_touch;

	gstate->Precache_Sound ("artifacts/goldensoul/goldensoulpickup.wav");
	gstate->Precache_Sound ("artifacts/goldensoul/goldensoulwait.wav");
	gstate->AmbientSound (self->s.origin, "artifacts/goldensoul/goldensoulwait.wav", 255, ATTN_STATIC, fade);
}

////////////////////////////////////////
// item_antidote
////////////////////////////////////////

void	item_antidote_touch (userEntity_t *self, userEntity_t *other, cplane_t *plane, csurface_t *surf)
{
	playerHook_t	*ohook = (playerHook_t *) other->userHook;

	if (!com->ValidTouch (self, other))
		return;

	if (other->health == ohook->max_health * 2.0)
		return;

	com->Health (other, self->health, ohook->max_health * 2.0);

	gstate->sound (self, CHAN_VOICE, "artifacts/antidote/antidoteuse.wav", 255, ATTN_NORM);

	com->AmbientVolume (self, Vector (self->s.origin), 0.0);
	com->SetRespawn (self, 300.0, TRUE, 1.0);

	com->ClientPrint (other, "You picked up the antidote, suck it down.\n");
}

void	item_antidote (userEntity_t *self)
{
	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_FLY;
	gstate->Precache_Model ("models/antidote.mdl");
	gstate->SetModel (self, "models/antidote.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->spawnflags = IT_ANTIDOTE;
	self->flags = FL_ITEM;
	self->netname = "antidote";
	self->className = "item_antidote";

	self->avelocity [1] = 180.0;

	gstate->Precache_Sound ("artifacts/antidote/antidoteuse.wav");
}

///////////////////////////////////////////
// item_boost_touch
///////////////////////////////////////////

void	item_boost_touch (userEntity_t *self, userEntity_t *other, cplane_t *plane, csurface_t *surf)
{
	playerHook_t	*ohook = (playerHook_t *) other->userHook;

	if (!com->ValidTouch (self, other))
		return;

	if (!self->className)
		return;

	if (!stricmp (self->className, "item_power_boost"))
	{
		if (ohook->items & IT_POWERBOOST)
			return;

		ohook->power_boost += 3;
		ohook->items = ohook->items | IT_POWERBOOST;
		ohook->exp_flags = ohook->exp_flags | EXP_POWERBOOST;

		ohook->power_boost_time = gstate->time + 30.0;
	}
	else if (!stricmp (self->className, "item_attack_boost"))
	{
		if (ohook->items & IT_ATTACKBOOST)
			return;

		ohook->attack_boost += 3;
		ohook->items = ohook->items | IT_ATTACKBOOST;
		ohook->exp_flags = ohook->exp_flags | EXP_ATTACKBOOST;

		ohook->attack_boost_time = gstate->time + 30.0;
	}
	else if (!stricmp (self->className, "item_speed_boost"))
	{
		if (ohook->items & IT_SPEEDBOOST)
			return;

		ohook->speed_boost += 3;
		ohook->items = ohook->items | IT_SPEEDBOOST;
		ohook->exp_flags = ohook->exp_flags | EXP_SPEEDBOOST;

		ohook->speed_boost_time = gstate->time + 30.0;
	}
	else if (!stricmp (self->className, "item_acro_boost"))
	{
		if (ohook->items & IT_ACROBOOST)
			return;

		ohook->acro_boost += 3;
		ohook->items = ohook->items | IT_ACROBOOST;
		ohook->exp_flags = ohook->exp_flags | EXP_ACROBOOST;

		ohook->acro_boost_time = gstate->time + 30.0;
	}
	else if (!stricmp (self->className, "item_vita_boost"))
	{
		if (ohook->items & IT_VITABOOST)
			return;

		ohook->vita_boost += 3;
		ohook->items = ohook->items | IT_VITABOOST;
		ohook->exp_flags = ohook->exp_flags | EXP_VITABOOST;
	
		ohook->vita_boost_time = gstate->time + 30.0;
	}

	gstate->sound (self, CHAN_AUTO, "items/itempickup1.wav", 255.0, ATTN_NORM);

	com->SetRespawn (self, 30.0, FALSE, 0.0);

	com->CalcBoosts (other);

	if (other->flags & FL_CLIENT)
	{
		gstate->sprint (other, "You picked up a ");
		gstate->sprint (other, self->netname);
		gstate->sprint (other, "\n");
	}
}

////////////////////////////////////////
// item_power_boost
////////////////////////////////////////

void	item_power_boost (userEntity_t *self)
{
	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_FLY;
	gstate->Precache_Model ("models/boost_p.mdl");
	gstate->SetModel (self, "models/boost_p.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->spawnflags = IT_POWERBOOST;
	self->flags = FL_ITEM;
	self->netname = "power boost";
	self->className = "item_power_boost";

	self->touch = item_boost_touch;

	com->SetVector (self->avelocity, 0, 180, 0);

	gstate->Precache_Sound ("items/itempickup1.wav");
}

////////////////////////////////////////
// item_attack_boost
////////////////////////////////////////

void	item_attack_boost (userEntity_t *self)
{
	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_FLY;
	gstate->Precache_Model ("models/boost_at.mdl");
	gstate->SetModel (self, "models/boost_at.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->spawnflags = IT_ATTACKBOOST;
	self->flags = FL_ITEM;
	self->netname = "attack boost";
	self->className = "item_attack_boost";

	self->touch = item_boost_touch;

	com->SetVector (self->avelocity, 0, 180, 0);
	gstate->Precache_Sound ("items/itempickup1.wav");
}

////////////////////////////////////////
// item_speed_boost
////////////////////////////////////////

void	item_speed_boost (userEntity_t *self)
{
	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_FLY;
	gstate->Precache_Model ("models/boost_sp.mdl");
	gstate->SetModel (self, "models/boost_sp.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->spawnflags = IT_SPEEDBOOST;
	self->flags = FL_ITEM;
	self->netname = "speed boost";
	self->className = "item_speed_boost";

	self->touch = item_boost_touch;

	com->SetVector (self->avelocity, 0, 180, 0);
	gstate->Precache_Sound ("items/itempickup1.wav");
}

////////////////////////////////////////
// item_acro_boost
////////////////////////////////////////

void	item_acro_boost (userEntity_t *self)
{
	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_FLY;
	gstate->Precache_Model ("models/boost_ac.mdl");
	gstate->SetModel (self, "models/boost_ac.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->spawnflags = IT_ACROBOOST;
	self->flags = FL_ITEM;
	self->netname = "acrobatic boost";
	self->className = "item_acro_boost";

	self->touch = item_boost_touch;

	com->SetVector (self->avelocity, 0, 180, 0);
	gstate->Precache_Sound ("items/itempickup1.wav");
}

////////////////////////////////////////
// item_vita_boost
////////////////////////////////////////

void	item_vita_boost (userEntity_t *self)
{
	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_FLY;
	gstate->Precache_Model ("models/boost_v.mdl");
	gstate->SetModel (self, "models/boost_v.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->spawnflags = IT_VITABOOST;
	self->flags = FL_ITEM;
	self->netname = "vitality boost";
	self->className = "item_vita_boost";

	self->touch = item_boost_touch;

	com->SetVector (self->avelocity, 0, 180, 0);
	gstate->Precache_Sound ("items/itempickup1.wav");
}

////////////////////////////////////////
// item_jet_boots
////////////////////////////////////////

void	item_jet_boots (userEntity_t *self)
{
	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_FLY;
	gstate->Precache_Model ("models/jetboots.mdl");
	gstate->SetModel (self, "models/jetboots.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->avelocity [1] = 180;

	self->spawnflags = IT_JET_BOOTS;
	self->flags = FL_ITEM;
	self->netname = "jet boots";
	self->className = "item_jet_boots";
	gstate->Precache_Sound ("items/itempickup1.wav");
}

////////////////////////////////////////
// item_oxy_lung
////////////////////////////////////////

void	item_oxylung_touch (userEntity_t *self, userEntity_t *other, cplane_t *plane, csurface_t *surf)
{
	playerHook_t	*ohook = (playerHook_t *) other->userHook;

	if(!com->ValidTouch (self, other))
		return;

	ohook->oxylung_time = gstate->time + 60.0;
	ohook->items = ohook->items | IT_OXYLUNG;
	ohook->exp_flags = ohook->exp_flags | EXP_OXYLUNG;

	com->SetRespawn (self, 30.0, FALSE, 0.0);

	com->ClientPrint (other, "You picked up the oxylung.\n");

	gstate->sound (self, CHAN_VOICE, "artifacts/oxylung/oxylungpickup.wav", 255.0, ATTN_NORM);
}

void	item_oxylung (userEntity_t *self)
{
	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_FLY;
	gstate->Precache_Model ("models/oxylung.mdl");
	gstate->SetModel (self, "models/oxylung.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->spawnflags = IT_OXYLUNG;
	self->flags = FL_ITEM;
	self->netname = "oxylung";
	self->className = "item_oxylung";
	self->touch = item_oxylung_touch;

	self->avelocity [1] = 180;

	gstate->Precache_Sound ("artifacts/oxylung/oxylungpickup.wav");
	gstate->Precache_Sound ("artifacts/oxylung/oxylungfade.wav");
}

////////////////////////////////////////
// item_ice_boots
////////////////////////////////////////

void	item_ice_boots_touch (userEntity_t *self, userEntity_t *other, cplane_t *plane, csurface_t *surf)
{
	playerHook_t	*ohook = (playerHook_t *) other->userHook;

	if (!com->ValidTouch (self, other))
		return;

	com->SetRespawn (self, 30, FALSE, 0.0);

	gstate->sound (self, CHAN_VOICE, "items/itempickup1.wav", 255, ATTN_NORM);

	if (other->flags & FL_CLIENT)
		gstate->sprint (other, "You picked up the %s.\n", self->netname);
}

void	item_ice_boots (userEntity_t *self)
{
	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_FLY;
	gstate->Precache_Model ("models/iceboots.mdl");
	gstate->SetModel (self, "models/iceboots.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->spawnflags = IT_ICE_BOOTS;
	self->flags = FL_ITEM;
	self->netname = "ice boots";
	self->className = "item_ice_boots";
	self->touch = item_ice_boots_touch;

	self->avelocity [1] = 180.0;

	gstate->Precache_Sound ("items/itempickup1.wav");
}

////////////////////////////////////////
// item_envirosuit
////////////////////////////////////////

void	item_envirosuit_touch (userEntity_t *self, userEntity_t *other, cplane_t *plane, csurface_t *surf)
{
	playerHook_t	*ohook = (playerHook_t *) other->userHook;

	if(!com->ValidTouch (self, other))
		return;

	ohook->envirosuit_time = gstate->time + 60.0;
	ohook->items = ohook->items | IT_ENVIROSUIT;
	ohook->exp_flags = ohook->exp_flags | EXP_ENVIROSUIT;

	com->SetRespawn (self, 120.0, FALSE, 0.0);

	com->ClientPrint (other, "You picked up an envirosuit.\n");

	gstate->sound (self, CHAN_ITEM, "artifacts/envirosuit/envirosuitpickup.wav", 255.0, ATTN_NORM);
}

void	item_envirosuit (userEntity_t *self)
{
	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_FLY;
	gstate->Precache_Model ("models/envirosuit.mdl");
	gstate->SetModel (self, "models/envirosuit.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->spawnflags = IT_ENVIROSUIT;
	self->flags = FL_ITEM;
	self->netname = "envirosuit";
	self->className = "item_envirosuit";
	self->touch = item_envirosuit_touch;

	self->avelocity [1] = 180;

	gstate->Precache_Sound ("artifacts/envirosuit/envirosuitpickup.wav");
	gstate->Precache_Sound ("artifacts/envirosuit/envirosuitfade.wav");
}

////////////////////////////////////////
// item_earwax
////////////////////////////////////////

void	item_earwax_touch (userEntity_t *self, userEntity_t *other, cplane_t *plane, csurface_t *surf)
{
	playerHook_t	*ohook = (playerHook_t *) other->userHook;

	if(!com->ValidTouch (self, other))
		return;

	ohook->envirosuit_time = gstate->time + 60.0;
	ohook->items = ohook->items | IT_ENVIROSUIT;
	ohook->exp_flags = ohook->exp_flags | EXP_ENVIROSUIT;

	com->SetRespawn (self, 120.0, FALSE, 0.0);

	com->ClientPrint (other, "You picked up some earwax.\n");

	gstate->sound (self, CHAN_AUTO, "items/itempickup1.wav", 255.0, ATTN_NORM);
}

void	item_earwax (userEntity_t *self)
{
	self->solid = SOLID_TRIGGER;
	self->movetype = MOVETYPE_FLY;
	gstate->Precache_Model ("models/earwax.mdl");
	gstate->SetModel (self, "models/earwax.mdl");
	gstate->SetSize (self, -16, -16, -24, 16, 16, 32);
	gstate->SetOrigin (self, self->s.origin [0], self->s.origin [1], self->s.origin [2]);

	self->spawnflags = IT_ENVIROSUIT;
	self->flags = FL_ITEM;
	self->netname = "earwax";
	self->className = "item_earwax";
	self->touch = item_envirosuit_touch;

	self->avelocity [1] = 180;

	gstate->Precache_Sound ("items/itempickup1.wav");
}

