sin-2015/sniperrifle.cpp
1999-04-22 00:00:00 +00:00

115 lines
No EOL
2.1 KiB
C++

// 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:
// Sniper rifle
//
#include "g_local.h"
#include "bullet.h"
#include "sniperrifle.h"
#include "player.h"
CLASS_DECLARATION( BulletWeapon, SniperRifle, "weapon_sniperrifle" );
Event EV_SniperRifle_Ready( "sniperrifle_ready" );
ResponseDef SniperRifle::Responses[] =
{
{ &EV_Weapon_SecondaryUse, ( Response )SniperRifle::SecondaryUse },
{ &EV_SniperRifle_Ready, ( Response )SniperRifle::DoneRaising },
{ &EV_Weapon_DoneRaising, ( Response )SniperRifle::Open },
{ &EV_Weapon_Shoot, ( Response )SniperRifle::Shoot },
{ NULL, NULL }
};
SniperRifle::SniperRifle()
{
SetModels( "sniperrifle.def", "view_srifle.def" );
SetAmmo( "BulletSniper", 1, 5 );
modelIndex( "sniper_ammo.def" );
SetRank( 100, 0 );
SetType( WEAPON_2HANDED_HI );
}
void SniperRifle::Shoot
(
Event *ev
)
{
assert( owner );
if ( !owner )
{
return;
}
if ( deathmatch->value )
FireBullets( 1, vec_zero, 105, 135, DAMAGE_BULLET|DAMAGE_NO_ARMOR, MOD_SNIPER, false );
else
FireBullets( 1, vec_zero, 105, 135, DAMAGE_BULLET, MOD_SNIPER, false );
NextAttack( 1.5 );
}
void SniperRifle::DoneRaising
(
Event *ev
)
{
BulletWeapon::DoneRaising( ev );
}
void SniperRifle::Open
(
Event *ev
)
{
RandomAnimate( "open", EV_SniperRifle_Ready );
}
void SniperRifle::SecondaryUse
(
Event *ev
)
{
Entity *ent;
Event *event;
event = new Event(EV_Player_ToggleZoomMode);
ent = ev->GetEntity(1);
ent->ProcessEvent(event);
}
void SniperRifle::DoneLowering
(
Event *ev
)
{
Event *event;
assert( owner );
if ( !owner )
{
return;
}
event = new Event( EV_Player_ZoomOut );
owner->ProcessEvent( event );
Weapon::DoneLowering( ev );
}
qboolean SniperRifle::AutoChange
(
void
)
{
return false;
}