//-----------------------------------------------------------------------------
//
//  $Logfile:: /game/thrall.h                                                 $
// $Revision:: 2                                                              $
//   $Author:: Burgermac                                                      $
//     $Date:: 12/27/00 7:20 PM                                               $
//
// Copyright (C) 1998 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:
// ThrallMaster
//

#ifndef __THRALLMASTER_H__
#define __THRALLMASTER_H__

#include "g_local.h"
#include "actor.h"
#include "specialfx.h"

class ThrallMaster : public Actor
{
protected:
	weaponmode_t weaponmode;
	str gunbone;

public:
	CLASS_PROTOTYPE( ThrallMaster );

	ThrallMaster();
	virtual Vector    GunPosition( void );
	virtual qboolean  CanShootFrom( Vector pos, Entity* ent, qboolean usecurrentangles );
	virtual void        Chatter( const char* sound, float chance = 10, float volume = 1.0f, int channel = CHAN_VOICE );
	virtual void        WeaponUse( Event* ev );
	virtual void        FirePulse( Event* ev );
	virtual void        FireRockets( Event* ev );
	virtual void        GibFest( Event* ev );
	virtual void      Archive( Archiver& arc );
	virtual void      Unarchive( Archiver& arc );
};

inline void ThrallMaster::Archive( Archiver& arc )
{
	Actor::Archive( arc );

	arc.WriteInteger( weaponmode );
	arc.WriteString( gunbone );
}


inline void ThrallMaster::Unarchive( Archiver& arc )
{
	Actor::Unarchive( arc );

	weaponmode = ( weaponmode_t )arc.ReadInteger();
	arc.ReadString( &gunbone );
}

class ThrallGun : public Weapon
{
public:
	CLASS_PROTOTYPE( ThrallGun );

	ThrallGun();
	virtual void        Shoot( Event* ev );
	virtual void      SecondaryUse( Event* ev );
};

class DrunkMissile : public Projectile
{
private:
	EntityPtr target;

public:
	CLASS_PROTOTYPE( DrunkMissile );

	float            AdjustAngle( float maxadjust, float currangle, float targetangle );
	void             Explode( Event* ev );
	float            ResolveMinimumDistance( Entity* potential_target, float currmin );
	void             HeatSeek( Event* ev );
	void             Prethink( void );
	void             Setup( Entity* owner, Vector pos, Vector dir );
	virtual void   Archive( Archiver& arc );
	virtual void   Unarchive( Archiver& arc );
};

inline void DrunkMissile::Archive( Archiver& arc )
{
	Projectile::Archive( arc );

	arc.WriteSafePointer( target );
}

inline void DrunkMissile::Unarchive( Archiver& arc )
{
	Projectile::Unarchive( arc );

	arc.ReadSafePointer( &target );
}

class ThrallPulse : public Projectile
{
public:
	CLASS_PROTOTYPE( ThrallPulse );

	void       Explode( Event* ev );
	void       Setup( Entity* owner, Vector pos, Vector dir );
};

class ThrallPulseDebris : public Projectile
{
private:
	float size;
	float spawntime;
	float nexttouch;

public:
	CLASS_PROTOTYPE( ThrallPulseDebris );

	void       Touch( Event* ev );
	void     Prethink( void );
	void       Setup( Entity* owner, Vector pos, float size );
	virtual void   Archive( Archiver& arc );
	virtual void   Unarchive( Archiver& arc );
};

inline void ThrallPulseDebris::Archive( Archiver& arc )
{
	Projectile::Archive( arc );

	arc.WriteFloat( size );
	arc.WriteFloat( spawntime );
	arc.WriteFloat( nexttouch );
}


inline void ThrallPulseDebris::Unarchive( Archiver& arc )
{
	Projectile::Unarchive( arc );

	size = arc.ReadFloat();
	spawntime = arc.ReadFloat();
	nexttouch = arc.ReadFloat();
}

#endif /* thrall.h */
