//-----------------------------------------------------------------------------
//
//  $Logfile:: /game/testweapon.cpp                                           $
// $Revision:: 2                                                              $
//   $Author:: Burgermac                                                      $
//     $Date:: 12/27/00 7:41 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:
// Weapon for testing view models
//

#include "g_local.h"
#include "testweapon.h"

cvar_t* gun_model_cvar;
cvar_t* gun_wmodel;

CLASS_DECLARATION( Weapon, TestWeapon, NULL );

ResponseDef TestWeapon::Responses[] =
{
	{ &EV_Weapon_Shoot, ( Response )& TestWeapon::Shoot },
	{ &EV_Weapon_DoneFiring, ( Response )& TestWeapon::Done },
	{ NULL, NULL }
};

TestWeapon::TestWeapon()
{
	char* wmodel;
	char* model;

	gun_model_cvar = gi.cvar( "w_model", "magnum.def", 0 );
	gun_wmodel = gi.cvar( "ww_model", "magnum_w.def", 0 );

	model = gun_model_cvar->string;
	wmodel = gun_wmodel->string;

	SetModels( wmodel, model );
	SetAmmo( "Bullet357", 0, 0 );
	SetRank( 0, 0 );

	flags |= FL_PRETHINK;
}

void TestWeapon::Prethink( void )
{
	char* wmodel;
	char* model;

	if( Q_stricmp( gun_model_cvar->string, viewmodel.c_str() ) ||
			Q_stricmp( gun_wmodel->string, worldmodel.c_str() ) )
	{
		model = gun_model_cvar->string;
		wmodel = gun_wmodel->string;

		SetModels( wmodel, model );
	}
}

void TestWeapon::Shoot( Event* ev )
{
	assert( owner );
	if( !owner )
	{
		return;
	}

	// Long attack since the animation will control it
	NextAttack( 1 );
}

void TestWeapon::Done( Event* ev )
{
	NextAttack( 0 );
	Weapon::DoneFiring( ev );
}
