#include	"world.h"

#include	"ai.h"
#include	"ai_utils.h"

#include	"ai_move.h"
#include	"ai_weapons.h"
#include	"ai_task.h"
#include	"ai_frames.h"

#include	"skat.h"
#include	"nodelist.h"

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

DllExport	void	monster_venomvermin (userEntity_t *self);

///////////////////////////////////////////////////////////////////////////////////
//	defines
///////////////////////////////////////////////////////////////////////////////////

#define	RAT_GRABDIST	72

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

static	int	vermin_count	= 0;

///////////////////////////////////////////////////////////////////////////////////
// vermin specific funcitons
///////////////////////////////////////////////////////////////////////////////////

void	vermin_ranged_attack (userEntity_t *self);
void	vermin_ranged_double_attack (userEntity_t *self);
void	vermin_melee_attack (userEntity_t *self);
void	vermin_jump_attack (userEntity_t *self);
void	vermin_start_jump_attack (userEntity_t *self);
void	vermin_poison_attack (userEntity_t *self);
void	vermin_begin_poison_attack (userEntity_t *self);

////////////////////////////////
//	vermin_init_frametable
//
////////////////////////////////

void	vermin_init_frametable (userEntity_t *self)
{
	playerHook_t	*hook = (playerHook_t *) self->userHook;
	
	/////////////////////////////////////////////////////////////////
	//	atak sequences
	/////////////////////////////////////////////////////////////////
	
	//	straight fire on all fours
	ai_set_sequence_data (self, hook->frames->atak [0], 0, "monsters/vermin/verminattack1.wav", -1, NULL, 0, -1, 0, -1, FRAME_ONCE);
	//	bite
	ai_set_sequence_data (self, hook->frames->atak [1], 6, NULL, -1, NULL, 0, -1, 0, -1, FRAME_ONCE);
	//	shooting from hind legs
	ai_set_sequence_data (self, hook->frames->atak [2], 0, "monsters/vermin/verminattack2.wav", -1, NULL, 0, -1, 0, -1, FRAME_ONCE);
	//	attack in the air
	ai_set_sequence_data (self, hook->frames->atak [3], 8, "monsters/vermin/verminattack2.wav", -1, NULL, 0, -1, 0, -1, FRAME_ONCE);

	/////////////////////////////////////////////////////////////////
	//	tranz sequences
	/////////////////////////////////////////////////////////////////

	//	sit up for rocket attack
	ai_set_sequence_data (self, hook->frames->trans [0], -1, NULL, -1, NULL, 0, -1, 0, -1, FRAME_ONCE);
	//	landing from fly or atakd
	ai_set_sequence_data (self, hook->frames->trans [1], -1, NULL, -1, NULL, 0, -1, 0, -1, FRAME_ONCE);
	//	pushing off from atakd
	ai_set_sequence_data (self, hook->frames->trans [2], 9, NULL, 14, NULL, 0, -1, 0, -1, FRAME_ONCE);
	//	gun coming out of mouth from stand
	ai_set_sequence_data (self, hook->frames->trans [3], -1, NULL, -1, NULL, 0, -1, 0, -1, FRAME_ONCE);
	//	jumping from ground to flya, start of jumping attack
	ai_set_sequence_data (self, hook->frames->trans [4], 14, NULL, -1, NULL, 0, -1, 0, -1, FRAME_ONCE);

	//	"flying" during attack -- FRAME_LOOP
	ai_set_sequence_data (self, hook->frames->fly [0], -1, NULL, -1, NULL, 0, -1, 0, -1, FRAME_ONCE);

	//	slash and land -- FRAME_ONCE

	//	slash and push off -- FRAME_ONCE
}

////////////////////////////////
//	vermin_set_attack_seq
//
////////////////////////////////

void	vermin_set_attack_seq (userEntity_t *self)
{
	playerHook_t	*hook = (playerHook_t *) self->userHook;
	float			dist;
	int				i;
	Vector			temp;

	dist = qv_dist (self->s.origin, self->enemy->s.origin);

	/////////////////////////////////////////////////////
	//	if health is over 15, vermin will jump attack
	/////////////////////////////////////////////////////
	if (dist > 128)
	{
		//if (self->health > 15)
		{
			ai_init_sequence (self, hook->frames->trans [4], SEQUENCE_TRANS, 4);

			//	pick the melee weapon from inventory
			self->curWeapon = gstate->InventoryFindItem (self->inventory, "poison bite mild");

			vermin_start_jump_attack (self);

			return;
		}
	}
	else
	{
		///////////////////////////////////////////////////////////
		//	FIXME: implement
		//	vermin is hurt, so it will try to get away and then
		//	shoot a poison bubble
		///////////////////////////////////////////////////////////
		
		if (dist <= 128)
		{
			//	FIXME: change to jump straight up and bounce away
			ai_begin_transition (self, hook->frames->trans [0], SEQUENCE_TRANS, 0, vermin_begin_poison_attack);

			//	pick the melee weapon from inventory
			self->curWeapon = gstate->InventoryFindItem (self->inventory, "poison bubble");
		}
	}
}

/************************** jumping attack ****************************/

///////////////////////////
//	vermin_land
//
//	vermin is coming to a rest on the ground after a jump attack
///////////////////////////

void	vermin_land (userEntity_t *self)
{
	playerHook_t	*hook = (playerHook_t *) self->userHook;

	if (hook->frame_flags & FRAME_PLAYSOUND1)
	{
		hook->frame_flags = hook->frame_flags - FRAME_PLAYSOUND1;

		if (hook->sound1)
			gstate->sound (self, CHAN_AUTO, hook->sound1, ATTN_NORM, 128.0);
	}
	if (hook->frame_flags & FRAME_PLAYSOUND2)
	{
		hook->frame_flags = hook->frame_flags - FRAME_PLAYSOUND2;
	
		if (hook->sound2)
			gstate->sound (self, CHAN_AUTO, hook->sound2, ATTN_NORM, 128.0);
	}

	if (hook->frame_flags & FRAME_STATIC)
	{
		hook->frame_flags -= FRAME_STATIC;	

		hook->dflags -= (hook->dflags & DFL_FACENONE);

		if (self->enemy->deadflag != DEAD_NO)
		{
			//	pop off everything thru TASK_CHASE for this enemy
			ai_killed_enemy (self);

			return;
		}
		else // if (dist > hook->attack_dist || !com->Visible (self, self->enemy))
		{
			//	leaving, so pop off TASK_ATTACK
			task_pop (&hook->task_stack);

			ai_should_follow (self);

			return;
		}
	}

	ai_set_think (self, vermin_land, "vermin_land");
}

///////////////////////////
//	vermin_push_off
//
//	vermin is rebounding off of his enemy
//	velocity was already set in vermin_jump_attack
//
//	at end of sequence vermin model will be facing 180 degrees
//	from the facing of the vermin entity, so before going to
//	landing frames, we have to flip vermin model's facing 180 degrees
///////////////////////////

void	vermin_push_off (userEntity_t *self)
{
	playerHook_t	*hook = (playerHook_t *) self->userHook;
	Vector			ang;

	if (hook->frame_flags & FRAME_PLAYSOUND1)
	{
		hook->frame_flags = hook->frame_flags - FRAME_PLAYSOUND1;

		if (hook->sound1)
			gstate->sound (self, CHAN_AUTO, hook->sound1, ATTN_NORM, 128.0);

		if (self->flags & FL_HCHILD)
		{
			//	unstick rat from enemy
			gstate->hr_RemoveChild (self->enemy, self, false);
			com->ZeroVector (self->velocity);
		}

		//	push off
		ang = Vector (self->s.angles);
//		ang.y = com->AngleMod (ang.y + rnd () * 180 - 90);
		ang.AngleVectors (forward, right, up);

		self->s.angles [0] = 0;
		self->s.angles [1] = ang.y;
		self->s.angles [2] = 0;

		ang = forward * - hook->run_speed * 0.75;
		ang.z = hook->upward_vel * 1.25;
		self->gravity = 0.75;
		ang.set (self->velocity);
	}
	if (hook->frame_flags & FRAME_PLAYSOUND2)
	{
		hook->frame_flags = hook->frame_flags - FRAME_PLAYSOUND2;

		//	reset solid a few frames after jumping off so that
		//	we don't get stuck in the player's bounding 
		self->solid = SOLID_SLIDEBOX;
		self->movetype = MOVETYPE_STEP;
		self->owner = self;

		if (hook->sound2)
			gstate->sound (self, CHAN_AUTO, hook->sound2, ATTN_NORM, 128.0);
	}

	if (hook->frame_flags & FRAME_STATIC)
	{
		hook->frame_flags -= FRAME_STATIC;	

		//	landing sequence
		ai_init_sequence (self, hook->frames->trans [1], SEQUENCE_TRANS, 1);
		
		//	flip entity 180 degrees
		self->s.angles [1] = com->AngleMod (self->s.angles [1] + 180.0);

		vermin_land (self);

		return;
	}

	ai_set_think (self, vermin_push_off, "vermin_push_off");
}

///////////////////////////
//	vermin_jump_attack
//
///////////////////////////

void	vermin_jump_attack (userEntity_t *self)
{
	playerHook_t	*hook = (playerHook_t *) self->userHook;
	float			dist;
	Vector			ang;

	//ai_face_enemy (self);
	hook->dflags |= DFL_FACEENEMY;

	dist = qv_dist (self->s.origin, self->enemy->s.origin);

	if (hook->frame_flags & FRAME_PLAYSOUND1)
	{
		hook->frame_flags = hook->frame_flags - FRAME_PLAYSOUND1;

		ai_fire_curWeapon (self, Vector (self->s.origin), Vector (self->enemy->s.origin), 0, 0);
	}
	if (hook->frame_flags & FRAME_PLAYSOUND2)
	{
		hook->frame_flags = hook->frame_flags - FRAME_PLAYSOUND2;

		ai_fire_curWeapon (self, Vector (self->s.origin), Vector (self->enemy->s.origin), 0, 0);
	}

	if (dist < RAT_GRABDIST && !(self->flags & FL_HCHILD))
	{
		ang = Vector (self->velocity);
		ang.Normalize ();
		
		ang = Vector (self->s.origin) + ang * (dist - 32.0);
		gstate->SetOrigin2 (self, ang.vec ());

		gstate->hr_InitRelative (self->enemy, self, 0);
	}

	///////////////////////////////////////////////////////////////
	//	finished attack, so decide to push off or land
	///////////////////////////////////////////////////////////////

	if (hook->frame_flags & FRAME_STATIC)
	{
		hook->frame_flags -= FRAME_STATIC;	

		if (dist > RAT_GRABDIST)
		{
			//	enemy is too far away to push off of, so go to land
			ai_init_sequence (self, hook->frames->trans [1], SEQUENCE_TRANS, 1);

			if (self->flags & FL_HCHILD)
			{
				//	unstick rat from enemy
				gstate->hr_RemoveChild (self->enemy, self, false);
				com->ZeroVector (self->velocity);

				self->solid = SOLID_SLIDEBOX;
				self->movetype = MOVETYPE_STEP;
				self->owner = self;
			}

			vermin_land (self);
		}
		else
		{
			ai_init_sequence (self, hook->frames->trans [2], SEQUENCE_TRANS, 2);
			hook->frameInc = 2;

			vermin_push_off (self);

			//	don't turn to face goal
			hook->dflags |= DFL_FACENONE;
		}

		return;
	}

	ai_set_think (self, vermin_jump_attack, "vermin_jump_attack");
}

///////////////////////////////
//	vermin_jump_direction
//
///////////////////////////////

float	vermin_jump_direction (userEntity_t *self)
{
	float	dp;
	Vector	dir, move_dir;

	//	targets movement vector
	move_dir = Vector (self->enemy->velocity);
	move_dir.Normalize ();
	
	//	get vector to target
	dir = Vector (self->enemy->s.origin) - Vector (self->s.origin);
	dir.Normalize ();

	dp = dir ^ move_dir;

	return	dp;
}

///////////////////////////
//	vermin_start_jump_attack
//
//	vermin has jumped at target and is checking
//	to see if it will land on it
///////////////////////////

void	vermin_start_jump_attack (userEntity_t *self)
{
	playerHook_t	*hook = (playerHook_t *) self->userHook;
	Vector			temp, p_org;
	float			dist;
	
	//ai_face_enemy (self);
	hook->dflags |= DFL_FACEENEMY;

	dist = qv_dist (self->s.origin, self->enemy->s.origin);

	if (hook->frame_flags & FRAME_PLAYSOUND1 && hook->cur_seq_type == SEQUENCE_TRANS)
	{
		hook->frame_flags = hook->frame_flags - FRAME_PLAYSOUND1;

		//	give jumping velocity to vermin here
		ai_lead_target (self->enemy, Vector (self->s.origin), hook->run_speed * 1.5, p_org);
//		temp = Vector (0, self->s.angles [1] + 45 * vermin_jump_direction (self), 0);
//		temp.AngleVectors (forward, right, up);

		forward = p_org - Vector (self->s.origin);
		forward.Normalize ();

		temp = forward * hook->attack_speed * 1.5;
		temp.set (self->velocity);

		self->velocity [2] = hook->upward_vel;
		self->flags -= (self->flags & FL_ONGROUND);
		self->gravity = 1.0;

		if (hook->sound1)
			gstate->sound (self, CHAN_AUTO, hook->sound1, ATTN_NORM, 128.0);
	}
	if (hook->frame_flags & FRAME_PLAYSOUND2)
	{
		hook->frame_flags = hook->frame_flags - FRAME_PLAYSOUND2;

		if (hook->sound2)
			gstate->sound (self, CHAN_AUTO, hook->sound2, ATTN_NORM, 128.0);
	}

	///////////////////////////////////////////////////////////////
	//	if frame is static, we've reached the end of the initial
	//	jump attack sequence, so start playing the fly sequence
	//	unless we're close enough to attack... then start the attack
	//	sequence
	///////////////////////////////////////////////////////////////

	if (hook->frame_flags & FRAME_STATIC)
	{
		hook->frame_flags -= FRAME_STATIC;	

		if (dist <= 128.0)
		{
			//	enemy within attack range, so attack them
			ai_init_sequence (self, hook->frames->atak [3], SEQUENCE_ATAK, 3);
			hook->frameInc = 2;
			vermin_jump_attack (self);
		}
		else
		{
			ai_init_sequence (self, hook->frames->trans [1], SEQUENCE_TRANS, 1);

			vermin_land (self);
		}

		return;
	}

	ai_set_think (self, vermin_start_jump_attack, "vermin_start_jump_attack");
}

/************************* poison bubble attack ***********************/

////////////////////////////
//	vermin_poison_attack
//
////////////////////////////

void	vermin_poison_attack (userEntity_t *self)
{
	playerHook_t	*hook = (playerHook_t *) self->userHook;
	Vector			temp;
	float			dist;

	//ai_face_enemy (self);
	hook->dflags |= DFL_FACEENEMY;

	dist = qv_dist (self->s.origin, self->enemy->s.origin);

	if (hook->frame_flags & FRAME_PLAYSOUND1)
	{
		hook->frame_flags = hook->frame_flags - FRAME_PLAYSOUND1;

		ai_fire_curWeapon (self, Vector (self->s.origin) + Vector (self->view_ofs), Vector (self->enemy->s.origin) + Vector (self->enemy->view_ofs), 0, 0);
	}
	
	if (hook->frame_flags & FRAME_STATIC)
	{
		hook->frame_flags -= FRAME_STATIC;

		if (self->enemy->deadflag != DEAD_NO)
		{
			//	leaving, so pop off TASK_ATTACK
			task_pop (&hook->task_stack);

			ai_killed_enemy (self);

			return;
		}
		else
		{
			//	always advances a bit after firing
			//	leaving, so pop off TASK_ATTACK
			task_pop (&hook->task_stack);

			ai_should_follow (self);

			hook->attack_finished = gstate->time + 0.5;

			return;
		}
	}

	ai_set_think (self, vermin_ranged_attack, "vermin_poison_attack");
}

////////////////////////////
//	vermin_poison_attack
//
////////////////////////////

void	vermin_begin_poison_attack (userEntity_t *self)
{
	playerHook_t	*hook = (playerHook_t *) self->userHook;

	ai_init_sequence (self, hook->frames->atak [2], SEQUENCE_ATAK, 2);

	vermin_poison_attack (self);
}

/*************************** ranged attack ****************************/

///////////////////////////
//	vermin_ranged_attack
//
//	FIXME: shoot out a floating, growing
//	poison bubble
///////////////////////////

void	vermin_ranged_attack (userEntity_t *self)
{
	playerHook_t	*hook = (playerHook_t *) self->userHook;
	Vector			temp;
	float			dist;

	//ai_face_enemy (self);
	hook->dflags |= DFL_FACEENEMY;

	dist = qv_dist (self->s.origin, self->enemy->s.origin);

	if (hook->frame_flags & FRAME_PLAYSOUND1)
	{
		hook->frame_flags = hook->frame_flags - FRAME_PLAYSOUND1;

		ai_fire_curWeapon (self, Vector (self->s.origin) + Vector (self->view_ofs), Vector (self->enemy->s.origin) + Vector (self->enemy->view_ofs), 0, 0);
	}
	
	if (hook->frame_flags & FRAME_STATIC)
	{
		hook->frame_flags -= FRAME_STATIC;

		if (self->enemy->deadflag != DEAD_NO)
		{
			//	leaving, so pop off TASK_ATTACK
			task_pop (&hook->task_stack);

			ai_killed_enemy (self);

			return;
		}
		else
		{
			//	always advances a bit after firing
			//	leaving, so pop off TASK_ATTACK
			task_pop (&hook->task_stack);

			ai_should_follow (self);

			hook->attack_finished = gstate->time + 0.5;

			return;
		}
	}

	ai_set_think (self, vermin_ranged_attack, "vermin_ranged_attack");
}

///////////////////////////
//	vermin_ranged_double_attack
//
///////////////////////////

void	vermin_ranged_double_attack (userEntity_t *self)
{
	playerHook_t	*hook = (playerHook_t *) self->userHook;
	Vector			temp;
	float			dist;

	//ai_face_enemy (self);
	hook->dflags |= DFL_FACEENEMY;

	dist = qv_dist (self->s.origin, self->enemy->s.origin);

	if (hook->frame_flags & FRAME_PLAYSOUND1)
	{
		hook->frame_flags = hook->frame_flags - FRAME_PLAYSOUND1;

		ai_fire_curWeapon (self, Vector (self->s.origin) + Vector (self->view_ofs), Vector (self->enemy->s.origin) + Vector (self->enemy->view_ofs), 0, 0);
	}
	
	if (hook->frame_flags & FRAME_STATIC)
	{
		hook->frame_flags -= FRAME_STATIC;

		if (self->enemy->deadflag != DEAD_NO)
		{
			//	leaving, so pop off TASK_ATTACK
			task_pop (&hook->task_stack);

			ai_killed_enemy (self);

			return;
		}
		else if (dist > hook->attack_dist + 64.0 || !com->Visible (self, self->enemy))
		{
			//	leaving, so pop off TASK_ATTACK
			task_pop (&hook->task_stack);

			ai_should_follow (self);

			return;
		}
		else
		{
			//	always advances a bit after firing

			//	leaving, so pop off TASK_ATTACK
			task_pop (&hook->task_stack);

			ai_should_follow (self);

			hook->attack_finished = gstate->time + 1.0;

			return;
		}
	}

	ai_set_think (self, vermin_ranged_double_attack, "vermin_ranged_double_attack");
}

///////////////////////////
//	vermin_melee_attack
//
///////////////////////////

void	vermin_melee_attack (userEntity_t *self)
{
	playerHook_t	*hook = (playerHook_t *) self->userHook;
	Vector			temp;
	float			dist;

	//ai_face_enemy (self);
	hook->dflags |= DFL_FACEENEMY;

	dist = qv_dist (self->s.origin, self->enemy->s.origin);

	if (hook->frame_flags & FRAME_PLAYSOUND1)
	{
		hook->frame_flags = hook->frame_flags - FRAME_PLAYSOUND1;
				
		if (hook->sound1)
			gstate->sound (self, CHAN_AUTO, hook->sound1, 128, ATTN_NORM);
	}
	
	if (hook->frame_flags & FRAME_PLAYSOUND2)
	{
		hook->frame_flags = hook->frame_flags - FRAME_PLAYSOUND2;

		if (hook->sound2)
			gstate->sound (self, CHAN_AUTO, hook->sound2, 128, ATTN_NORM);
	}
	
	if (hook->frame_flags & FRAME_LAST)
	{
		hook->frame_flags -= FRAME_LAST;

		if (self->enemy->deadflag != DEAD_NO)
		{
			//	leaving, so pop off TASK_ATTACK
			task_pop (&hook->task_stack);

			hook->begin_wander (self);

			return;
		}
		else if (dist > hook->attack_dist || !com->Visible (self, self->enemy))
		{
			//	leaving, so pop off TASK_ATTACK
			task_pop (&hook->task_stack);

			ai_should_follow (self);

			return;
		}
		else
		{
			vermin_set_attack_seq (self);

			return;
		}
	}

	ai_set_think (self, vermin_melee_attack, "vermin_melee_attack");
}

////////////////////////////
//	vermin_begin_attack
//
////////////////////////////

void	vermin_begin_attack (userEntity_t *self)
{
	playerHook_t	*hook = (playerHook_t *) self->userHook;
	float			dist;

	com->ZeroVector (self->velocity);

	hook->th_state = TH_ATTACK;
	hook->attack_finished = gstate->time + 1.0;

	vermin_set_attack_seq (self);
}

//////////////////////////
//	monster_vermin
//
//	creates the superfly entity and sets him up to smack down
//	everything that gets in his way.
//////////////////////////

void	monster_venomvermin (userEntity_t *self)
{
	playerHook_t		*hook;
	int					i;
	float				f;
	Vector				v;

	hook = ai_init_monster (self, TYPE_VERMIN);

	self->className = "monster_venomvermin";
	self->netname = "VenomVermin XP5";

	gstate->Precache_Sound ("monsters/vermin/verminattack1.wav");
	gstate->Precache_Sound ("monsters/vermin/verminattack2.wav");
/*
	gstate->Precache_Sound ("monsters/vermin/vermindeath1.wav");
	gstate->Precache_Sound ("monsters/vermin/vermindeath2.wav");
	gstate->Precache_Sound ("monsters/vermin/verminpain1.wav");
	gstate->Precache_Sound ("monsters/vermin/verminpain2.wav");
	gstate->Precache_Sound ("monsters/vermin/verminsight1.wav");
	gstate->Precache_Sound ("monsters/vermin/verminsight2.wav");
	gstate->Precache_Sound ("monsters/vermin/verminwander1.wav");
	gstate->Precache_Sound ("monsters/vermin/verminwander2.wav");
*/
	gstate->Precache_Model ("models/vermin.mdl");
	gstate->Precache_Model ("models/bubble.mdl");

	gstate->SetModel (self, "models/vermin.mdl");
	gstate->SetSize (self, -16.0, -16.0, -24.0, 16.0, 16.0, 0.0);

	////////////////////////////////////////////////////////////////
	// set up animation stuff
	////////////////////////////////////////////////////////////////

	ai_get_sequences (self);

	vermin_init_frametable (self);

	///////////////////////////////////////////////////////////
	// set up pointers to this creature's ai functions
	///////////////////////////////////////////////////////////

	hook->begin_attack = vermin_begin_attack;

	hook->run_speed = 160;
	hook->walk_speed = 60;
	hook->attack_speed = 320;
	hook->attack_dist = 180;
	hook->upward_vel = 250;

	self->health = 60;
	hook->max_health = 60;
	hook->pain_chance = 10;
	hook->dflags |= DFL_JUMPATTACK;
	hook->jump_chance = 100;
	self->mass = 2.0;

	self->think = ai_get_spawn_node;
	self->nextthink = gstate->time + 0.2;

	self->translucent = 0;

	//////////////////////////////////////////////
	//	set up monster's inventory and weapons
	//////////////////////////////////////////////
	
	self->inventory = gstate->InventoryNew ();
/*
	self->curWeapon = ai_weapon_create ("poison bubble", poison_bubble, NULL);
	i = 2; 	ai_weapon_command (self->curWeapon, "base_damage", &i);
	i = 2;	ai_weapon_command (self->curWeapon, "rnd_damage", &i);
	f = 0.0; ai_weapon_command (self->curWeapon, "spread_x", &f);
	f = 0.0; ai_weapon_command (self->curWeapon, "spread_z", &f);
	f = 450.0;	ai_weapon_command (self->curWeapon, "speed", &f);
	v = Vector (0, 16, 16);	ai_weapon_command (self->curWeapon, "ofs", &v);
	gstate->InventoryAddItem (self->inventory, self->curWeapon);

	self->curWeapon = ai_weapon_create ("poison bite mild", poison_bite_mild, NULL);
	i = 5;
	ai_weapon_command (self->curWeapon, "base_damage", &i);
	ai_weapon_command (self->curWeapon, "rnd_damage", &i);
	gstate->InventoryAddItem (self->inventory, self->curWeapon);
*/

	self->curWeapon = ai_init_weapon (self, 2, 2, 0, 0, 450.0, hook->attack_dist, Vector (0, 16, 16), "poison bubble", poison_bubble, WEAPON_PROJECTILE);
	gstate->InventoryAddItem (self->inventory, self->curWeapon);

	self->curWeapon = ai_init_weapon (self, 5, 5, 0, 0, 0, hook->attack_dist, Vector (0, 0, 0), "poison bite mild", poison_bite_mild, WEAPON_TRACE);
	gstate->InventoryAddItem (self->inventory, self->curWeapon);

}

