#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "weapons.h"
#include "nodes.h"
#include "soundent.h"
#include "decals.h"
#include "effects.h"
#include "aura.h"
#include "classes.h"
#include "magicattack.h"
#include "explodingattack.h"
#include "player.h"
#include "gamerules.h"
#include "magicattack.h"
#include "explodingattack.h"
#include "beamattack.h"

//extern int gmsgPointEntTrail;
extern int gmsgEntEntTrail;
extern int gmsgKillTrail;
extern int gmsgRemoveEffect;

void CBeamAttack::AddEntEntTrail(int startent, int attachment, int starta,int startb, int flarea, int flareb, int beam,int size,int detail, Vector vecOrigin)
{	MESSAGE_BEGIN( MSG_ALL, gmsgEntEntTrail, NULL );
		WRITE_LONG( startent );						//start entity
		WRITE_LONG( entindex() );					//end entity
		WRITE_BYTE( attachment );					//start attachment
		WRITE_SHORT( starta );						//start sprites
		WRITE_SHORT( startb );								
		WRITE_SHORT( flarea );						//flare sprites
		WRITE_SHORT( flareb );						
		WRITE_SHORT( beam );						//beam sprite
		WRITE_BYTE( size * 0.1);					//size in .1's
		WRITE_BYTE(detail);
		WRITE_COORD(vecOrigin.x);
		WRITE_COORD(vecOrigin.y);
		WRITE_COORD(vecOrigin.z);
	MESSAGE_END();
}

void CBeamAttack::Remove(void)
{	
	MESSAGE_BEGIN( MSG_ALL, gmsgKillTrail, NULL );
		WRITE_LONG (entindex());		//entity to remove trail from
	MESSAGE_END();

	//remove all fx on this beam
	MESSAGE_BEGIN( MSG_ALL, gmsgRemoveEffect, NULL );
		WRITE_BYTE(0);//all fx
		WRITE_SHORT(entindex());				
	MESSAGE_END();

	STOP_SOUND( ENT(pev), CHAN_WEAPON, "weapons/beamhead.wav" );
	CMagicAttack::Remove();
}
