//-----------------------------------------------------------------------------
//
// $Logfile:: /GameSource/turret.h                   $
// $Revision:: 2  $
// $Author:: Burge $
// $Date:: 12/27/00 7:05  $
//
// Copyright (C) 1997 by Ritual Entertainment, Inc.
// All rights reserved.
//
// This source is may not be distributed and/or modified without
// expressly written permission by Ritual Entertainment, Inc.
//
// DESCRIPTION:
// Script controlled turret.
//

#ifndef __TURRET_H__
#define __TURRET_H__

#ifndef __SENTIENT_H__
#include "sentient.h"
#endif

#define TURRET_OUTOFRANGE       0
#define TURRET_WAKEUPRANGE      1
#define TURRET_FIRERANGE        2

class Turret : public Sentient
{
protected:
	int base;
	int enemy;
	float lastSightTime;
	qboolean active;
	qboolean attacking;
	qboolean turning;
	float neworientation;
	float turntime;
	float lagtime;
	float firetime;
	float patience;
	int wakeupdistance;
	int firingdistance;
	qboolean activated;
	str thread;
	str sight_target;

public:
	CLASS_PROTOTYPE( Turret );

	Turret();

	virtual qboolean CanSee( Entity* ent );
	virtual int Range( float dist );
	virtual float Distance( Entity* targ );
	virtual void Pain( Event* ev );
	virtual void Killed( Event* ev );
	virtual qboolean FindTarget( void );
	virtual float AdjustAngle( float maxadjust, float currangle, float targetangle );
	virtual void Seek( Event* ev );
	virtual void Fire( Event* ev );
	virtual void Turn( Event* ev );
	virtual void EndSeek( Event* ev );
	virtual void CheckVicinity( Event* ev );
	virtual void GoUp( Event* ev );
	virtual void GoDown( Event* ev );
	virtual void Down( Event* ev );
	virtual void AttackStart( Event* ev );
	virtual void AttackFinished( Event* ev );
	virtual void Activate( Event* ev );
	virtual void Deactivate( Event* ev );
	virtual void Lagtime( Event* ev );
	virtual void SetSightTime( Event* ev );
	virtual void Archive( Archiver& arc );
	virtual void Unarchive( Archiver& arc );
};

extern Event EV_Turret_GoUp;
extern Event EV_Turret_GoDown;
extern Event EV_Turret_Turn;
extern Event EV_Turret_Seek;
extern Event EV_Turret_Attack;

#endif /* turret.h */
