//-----------------------------------------------------------------------------
//
//  $Logfile:: /game/explosion.h                                              $
// $Revision:: 2                                                              $
//   $Author:: Burgermac                                                      $
//     $Date:: 12/27/00 6:51 PM                                               $
//
// 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:
// Standard explosion object that is spawned by other entites and not map designers.
// Explosion is used by many of the weapons for the blast effect, but is also used
// by the Exploder and MultiExploder triggers.  These triggers create one or more
// explosions each time they are activated.
//

#ifndef __EXPLOSION_H__
#define __EXPLOSION_H__

#include "g_local.h"
#include "entity.h"
#include "trigger.h"

class Exploder : public Trigger
{
private:
	int damage;
	float attenuation;
	float volume;

	virtual void MakeExplosion( Event* ev );

public:
	CLASS_PROTOTYPE( Exploder );

	Exploder();
	virtual void      Archive( Archiver& arc );
	virtual void      Unarchive( Archiver& arc );
};

inline void Exploder::Archive( Archiver& arc )
{
	Trigger::Archive( arc );

	arc.WriteInteger( damage );
	arc.WriteFloat( attenuation );
	arc.WriteFloat( volume );
}

inline void Exploder::Unarchive( Archiver& arc )
{
	Trigger::Unarchive( arc );

	damage = arc.ReadInteger();
	attenuation = arc.ReadFloat();
	volume = arc.ReadFloat();
}


class MultiExploder : public Trigger
{
private:
	float explodewait;
	float explode_time;
	float duration;
	int damage;
	float attenuation;
	float volume;
	float randomness;

	virtual void MakeExplosion( Event* ev );

public:
	CLASS_PROTOTYPE( MultiExploder );

	MultiExploder();
	virtual void Archive( Archiver& arc );
	virtual void Unarchive( Archiver& arc );
};

inline void MultiExploder::Archive( Archiver& arc )
{
	Trigger::Archive( arc );

	arc.WriteFloat( explodewait );
	arc.WriteFloat( explode_time );
	arc.WriteFloat( duration );
	arc.WriteInteger( damage );
	arc.WriteFloat( attenuation );
	arc.WriteFloat( volume );
	arc.WriteFloat( randomness );
}

inline void MultiExploder::Unarchive( Archiver& arc )
{
	Trigger::Unarchive( arc );

	explodewait = arc.ReadFloat();
	explode_time = arc.ReadFloat();
	duration = arc.ReadFloat();
	damage = arc.ReadInteger();
	attenuation = arc.ReadFloat();
	volume = arc.ReadFloat();
	randomness = arc.ReadFloat();
}

void CreateExplosion( Vector pos, float damage = 120, float scale = 1.0f, qboolean bigexplosion = true, Entity* inflictor = NULL, Entity* attacker = NULL, Entity* ignore = NULL, int meansofdeath = MOD_ROCKETSPLASH, float volume = 1.0f, float attenuation = ATTN_NORM, float r = 1.0f, float g = 0.2f, float b = 0.0f, float light_radius = 240, float life = 1, float decay = 0.95 );

void RadiusDamage( Entity* inflictorent, Entity* attackerent, int damage, Entity* ignoreent, int mod );

void FlashPlayers( Vector org, float r, float g, float b, float a, float rad );

#endif /* explosion.h */
