Script:Files:script/weapons/sniperrifle.script
From Mod Wiki
/*********************************************************************** 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() || sys.getLocalPlayer() == myPlayer ) { handle effectHandle = getLastTracer(); if ( effectHandle ) { if ( !sys.isClient() ) { // send an unreliable event so clients can show it vector start = getEffectOrigin( effectHandle ); vector end = getEffectEndOrigin( effectHandle ); 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 ); }