#using scripts\codescripts\struct; #using scripts\shared\array_shared; #using scripts\shared\callbacks_shared; #using scripts\shared\clientfield_shared; #using scripts\shared\flagsys_shared; #using scripts\shared\hud_util_shared; #using scripts\shared\system_shared; #using scripts\shared\util_shared; #using scripts\shared\abilities\_ability_util; #precache( "string", "MP_CANNOT_LOCKON_TO_TARGET" ); #namespace multilockap_guidance; //#define MAX_SIMULTANEOUS_LOCKONS 5 this number corresponds to a code define function autoexec __init__sytem__() { system::register("multilockap_guidance",&__init__,undefined,undefined); } function __init__() { callback::on_spawned( &on_player_spawned ); SetDvar( "scr_max_simLocks",3 ); } function on_player_spawned() { self endon( "disconnect" ); self ClearAPTarget(); thread APToggleLoop(); self thread APFiredNotify(); } function ClearAPTarget( weapon, whom ) { if (!IsDefined(self.multiLockList)) { self.multiLockList=[]; } if (IsDefined(whom)) { for(i=0;i=GetDvarInt( "scr_max_simLocks" ) || self.multiLockList.size>=self GetWeaponAmmoClip(weapon)) { continue; } bestTarget = self GetBestTarget(weapon); if ( !IsDefined(bestTarget) && self.multiLockList.size==0 ) { self DestroyLockOnCanceledMessage(); continue; } //append to the lock list if we have the space if (IsDefined(bestTarget) && self.multiLockList.sizeb.dot) return 1; return 0; } function InsideAPReticleNoLock( target ) { radius = self getLockOnRadius(); return target_isincircle( target, self, 65, radius ); } function InsideAPReticleLocked( target ) { radius = (self getLockOnLossRadius()); return target_isincircle( target, self, 65, radius ); } function IsStillValidTarget( weapon, ent ) { if ( ! isdefined( ent ) ) return false; if ( ! InsideAPReticleLocked( ent ) ) return false; if ( !IsAlive( ent ) ) return false; if (!LockSightTest(ent)) return false; return true; } function SeekerSound( alias, looping, id ) { self notify( "stop_sound"+id); self endon ( "stop_sound"+id ); self endon( "disconnect" ); self endon ( "death" ); if (IsDefined(alias)) { self PlayRumbleOnEntity( "stinger_lock_rumble" ); time = SoundGetPlaybackTime(alias)*0.001; do { self playLocalSound( alias ); wait(time); } while (looping); self StopRumble( "stinger_lock_rumble" ); } } function LockSightTest( target ) { eyePos = self GetEye(); if ( !isdefined( target ) ) //targets can disapear during targeting. return false; if ( !IsAlive( target ) ) return false; pos = target GetShootAtPos(); if (IsDefined(pos)) { passed = BulletTracePassed( eyePos, pos, false, target, undefined, true, true ); if ( passed ) return true; } pos = target GetCentroid(); if (IsDefined(pos)) { passed = BulletTracePassed( eyePos, pos, false, target, undefined, true, true ); if ( passed ) return true; } pos=target.origin; passed = BulletTracePassed( eyePos, pos, false, target, undefined, true, true ); if ( passed ) return true; return false; }