59 lines
No EOL
1.5 KiB
Text
59 lines
No EOL
1.5 KiB
Text
/***********************************************************************
|
|
|
|
weapon_sniperrifle.script
|
|
|
|
***********************************************************************/
|
|
|
|
object weapon_sniperrifle : weapon_clip {
|
|
void preinit();
|
|
void DoFire();
|
|
void PlayFireAnim();
|
|
void ChamberSoundThread();
|
|
|
|
void OnNetworkTracer( vector start, vector end, float strength );
|
|
}
|
|
|
|
void weapon_sniperrifle::preinit() {
|
|
hasScope = true;
|
|
hasScopeZoom = true;
|
|
hasIronSights = false;
|
|
|
|
fireRateSingle = getFloatKeyWithDefault( "fire_rate", 0.2f );
|
|
|
|
if ( sys.getLocalPlayer() == myPlayer ) {
|
|
sys.setGUIFloat( GUI_GLOBALS_HANDLE, "weapons.distance", -2 );
|
|
thread RangeUpdateThread( myPlayer, 16384 );
|
|
}
|
|
}
|
|
|
|
void weapon_sniperrifle::DoFire() {
|
|
if ( !mainFireDown ) {
|
|
FireSingle();
|
|
if ( !sys.isClient() ) {
|
|
vector start = getBulletTracerStart();
|
|
vector end = getBulletTracerEnd();
|
|
sendTracerMessage( start, end, 1.0f );
|
|
}
|
|
|
|
waitUntil( animDone( ANIMCHANNEL_ALL, 4 ) );
|
|
}
|
|
}
|
|
|
|
void weapon_sniperrifle::OnNetworkTracer( vector start, vector end, float strength ) {
|
|
if ( sys.getLocalPlayer() != myPlayer ) {
|
|
doProjectileTracer( 0, start, end );
|
|
}
|
|
}
|
|
|
|
void weapon_sniperrifle::PlayFireAnim() {
|
|
if ( myPlayer.IsSniperScopeUp() ) {
|
|
thread ChamberSoundThread();
|
|
}
|
|
|
|
playAnim( ANIMCHANNEL_ALL, "fire" );
|
|
}
|
|
|
|
void weapon_sniperrifle::ChamberSoundThread() {
|
|
sys.wait( 0.5f );
|
|
startSound( "snd_chamber", SND_WEAPON_RELOAD );
|
|
} |