Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Release Attack Players with Stinger
#1
Hello

Another release of something I did long time ago, save this as _stinger.gsc, if the other player is very far the stinger will follow him, Superman. This gsc file goes in maps\mp folder. You can do same with javelin just by copying code.

Code:
InitStingerUsage()
{
    self.stingerStage = undefined;
    self.stingerTarget = undefined;
    self.stingerLockStartTime = undefined;
    self.stingerLostSightlineTime = undefined;
    
    self thread ResetStingerLockingOnDeath();
    level.stingerTargets = [];
}


ResetStingerLocking()
{
    if ( !IsDefined( self.stingerUseEntered ) )
        return;
    self.stingerUseEntered = undefined;

    self notify( "stop_javelin_locking_feedback" );
    self notify( "stop_javelin_locked_feedback" );

    self WeaponLockFree();
    InitStingerUsage();
}


ResetStingerLockingOnDeath()
{
    self endon( "disconnect" );

    self notify ( "ResetStingerLockingOnDeath" );
    self endon ( "ResetStingerLockingOnDeath" );

    for ( ;; )
    {
        self waittill( "death" );
        self ResetStingerLocking();
    }
}


StillValidStingerLock( ent )
{
    assert( IsDefined( self ) );

    if ( !IsDefined( ent ) )
        return false;
    if ( !(self WorldPointInReticle_Circle( ent.origin, 65, 85 )) )
        return false;

    if ( self.stingerTarget == level.ac130.planeModel && !isDefined( level.ac130player ) )
        return false;

    return true;
}


LoopStingerLockingFeedback()
{
    self endon( "stop_javelin_locking_feedback" );

    for ( ;; )
    {
        if ( isDefined( level.chopper ) && isDefined( level.chopper.gunner ) && isDefined( self.stingerTarget ) && self.stingerTarget == level.chopper.gunner )
            level.chopper.gunner playLocalSound( "missile_locking" );

        if ( isDefined( level.ac130player ) && isDefined( self.stingerTarget ) && self.stingerTarget == level.ac130.planeModel )
            level.ac130player playLocalSound( "missile_locking" );
        
        self playLocalSound( "stinger_locking" );
        self PlayRumbleOnEntity( "ac130_25mm_fire" );

        wait 0.6;
    }
}


LoopStingerLockedFeedback()
{
    self endon( "stop_javelin_locked_feedback" );

    for ( ;; )
    {
        if ( isDefined( level.chopper ) && isDefined( level.chopper.gunner ) && isDefined( self.stingerTarget ) && self.stingerTarget == level.chopper.gunner )
            level.chopper.gunner playLocalSound( "missile_locking" );

        if ( isDefined( level.ac130player ) && isDefined( self.stingerTarget ) && self.stingerTarget == level.ac130.planeModel )
            level.ac130player playLocalSound( "missile_locking" );

        self playLocalSound( "stinger_locked" );
        self PlayRumbleOnEntity( "ac130_25mm_fire" );

        wait 0.25;
    }
}


/#
DrawStar( point )
{
    Line( point + (10,0,0), point - (10,0,0) );
    Line( point + (0,10,0), point - (0,10,0) );
    Line( point + (0,0,10), point - (0,0,10) );
}
#/


LockSightTest( target )
{
    eyePos = self GetEye();
    
    if ( !isDefined( target ) ) //targets can disapear during targeting.
        return false;
    
    passed = BulletTracePassed( eyePos, target.origin, false, target );
    if ( passed )
        return true;

    front = target GetPointInBounds( 1, 0, 0 );
    passed = BulletTracePassed( eyePos, front, false, target );
    if ( passed )
        return true;

    back = target GetPointInBounds( -1, 0, 0 );
    passed = BulletTracePassed( eyePos, back, false, target );
    if ( passed )
        return true;

    return false;
}


StingerDebugDraw( target )
{
/#
    if ( GetDVar( "missileDebugDraw" ) != "1" )
        return;
    if ( !IsDefined( target ) )
        return;

    org = target.origin;
    DrawStar( org );
    org = target GetPointInBounds( 1, 0, 0 );
    DrawStar( org );
    org = target GetPointInBounds( -1, 0, 0 );
    DrawStar( org );
#/
}


SoftSightTest()
{
    LOST_SIGHT_LIMIT = 500;

    if ( self LockSightTest( self.stingerTarget ) )
    {
        self.stingerLostSightlineTime = 0;
        return true;
    }

    if ( self.stingerLostSightlineTime == 0 )
        self.stingerLostSightlineTime = getTime();

    timePassed = GetTime() - self.stingerLostSightlineTime;
    //PrintLn( "Losing sight of target [", timePassed, "]..." );

    if ( timePassed >= LOST_SIGHT_LIMIT )
    {
        //PrintLn( "Lost sight of target." );
        ResetStingerLocking();
        return false;
    }
    
    return true;
}

GetTargetList()
{
    targets = [];

    if ( level.teamBased )
    {
        if ( IsDefined( level.chopper ) && ( level.chopper.team != self.team || level.chopper.owner == self ) )
            targets[targets.size] = level.chopper;

        if ( isDefined( level.ac130player ) && level.ac130player.team != self.team )
            targets[targets.size] = level.ac130.planemodel;
        
        if ( isDefined( level.harriers) )
        {
            foreach( harrier in level.harriers )
            {
                if ( isDefined( harrier ) && ( harrier.team != self.team || ( isDefined( harrier.owner ) && harrier.owner == self ) ) )
                    targets[targets.size] = harrier;
            }
        }

        if ( isDefined( level.players) )
        {
            foreach( player in level.players )
            {
                if ( isDefined( player ) && ( player.team != self.team ) )
                    targets[targets.size] = player;
            }
        }
    
        if ( level.UAVModels[level.otherTeam[self.team]].size )
        {
            foreach ( UAV in level.UAVModels[level.otherTeam[self.team]] )
                targets[targets.size] = UAV;
        }

        if ( isDefined( level.littleBird ) )
        {
            foreach ( bird in level.littleBird )
            {
                if ( !isDefined( bird ) )
                    continue;
                
                if ( self.team != bird.owner.team || self == bird.owner )
                targets[targets.size] = bird;
            }
        }

    }
    else
    {
        if ( IsDefined( level.chopper ) && ( level.chopper.owner != self ) ) ///check for teams
            targets[targets.size] = level.chopper;

        if ( isDefined( level.ac130player ) )
            targets[targets.size] = level.ac130.planemodel;
        
        if ( isDefined( level.harriers) )
        {
            foreach( harrier in level.harriers )
            {
                if ( isDefined( harrier ) )
                    targets[targets.size] = harrier;
            }
        }

        if ( level.UAVModels.size )
        {
            foreach ( ownerGuid, UAV in level.UAVModels )
            {
                if ( isDefined( UAV.owner ) && UAV.owner == self )
                    continue;
                    
                targets[targets.size] = UAV;
            }
        }
    }
    
    return targets;
}


StingerUsageLoop()
{
    self endon("death");
    self endon("disconnect");

    LOCK_LENGTH = 1000;

    InitStingerUsage();

    for( ;; )
    {
        wait 0.05;

        weapon = self getCurrentWeapon();
        
        if ( weapon != "stinger_mp" && weapon != "at4_mp" )
        {
            ResetStingerLocking();
            continue;
        }

        if ( self PlayerADS() < 0.95 )
        {
            ResetStingerLocking();
            continue;
        }

        self.stingerUseEntered = true;

        if ( !IsDefined( self.stingerStage ) )
            self.stingerStage = 0;

        StingerDebugDraw( self.stingerTarget );

        if ( self.stingerStage == 0 )  // searching for target
        {
            targets = GetTargetList();
            if ( targets.size == 0 )
                continue;

            targetsInReticle = [];
            foreach ( target in targets )
            {
                if ( !isDefined( target ) )
                    continue;
                
                insideReticle = self WorldPointInReticle_Circle( target.origin, 65, 75 );
                
                if ( insideReticle )
                    targetsInReticle[targetsInReticle.size] = target;
            }
            if ( targetsInReticle.size == 0 )
                continue;

            sortedTargets = SortByDistance( targetsInReticle, self.origin );
            if ( !( self LockSightTest( sortedTargets[0] ) ) )
                continue;

            //PrintLn( "Found a target to lock to..." );
            thread LoopStingerLockingFeedback();
            self.stingerTarget = sortedTargets[0];
            self.stingerLockStartTime = GetTime();
            self.stingerStage = 1;
            self.stingerLostSightlineTime = 0;
        }

        if ( self.stingerStage == 1 )  // locking on to a target
        {
            if ( !(self StillValidStingerLock( self.stingerTarget )) )
            {
                //PrintLn( "Failed to get lock." );
                ResetStingerLocking();
                continue;
            }

            passed = SoftSightTest();
            if ( !passed )
                continue;

            timePassed = getTime() - self.stingerLockStartTime;
            //PrintLn( "Locking [", timePassed, "]..." );
            if ( timePassed < LOCK_LENGTH )
                continue;

            self notify( "stop_javelin_locking_feedback" );
            thread LoopStingerLockedFeedback();

            //PrintLn( "Locked!");
            if ( self.stingerTarget.model == "vehicle_av8b_harrier_jet_mp"  || self.stingerTarget.model == "vehicle_little_bird_armed" )
                self WeaponLockFinalize( self.stingerTarget );
            else
                self WeaponLockFinalize( self.stingerTarget, (100,0,-32) );
            
            self.stingerStage = 2;        
        }

        if ( self.stingerStage == 2 )  // target locked
        {
            passed = SoftSightTest();
            if ( !passed )
                continue;

            if ( !(self StillValidStingerLock( self.stingerTarget )) )
            {
                //PrintLn( "Gave up lock." );
                ResetStingerLocking();
                continue;
            }
        }
    }
}
Reply

#2
Epic as always
(08-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply

#3
Quote: if ( isDefined( level.players) )
{
foreach( player in level.players )
{
if ( isDefined( player ) && ( player.team != self.team ) )
targets[targets.size] = player;
}
}
just that ?
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#4
(08-30-2011, 13:14)Se7en Wrote:
Quote: if ( isDefined( level.players) )
{
foreach( player in level.players )
{
if ( isDefined( player ) && ( player.team != self.team ) )
targets[targets.size] = player;
}
}
just that ?

Yes, add it to FFA too, I forgot that.
Reply

#5
Heck yeah. Homing javelin missile/stinger,thanks Yamato I <3 your mods.
Reply

#6
Thats a simpel but cool Script Yamato.

but heres my little idea you could add...

do it that you can Lock on players Bodys if you aim at them with stinger.
and set the minimal lock range so low as possible.

its unfair but who cares Smile
that would be cool! This Night i had a new Idea for a NEW Killstreak that rocks.
If i get it to run you will see it soon Big Grin

[Image: Riot_cop_point_blank.gif?]
Troll ------------------- GIRL vs JUGGERNAUT ------------------ Troll

Reply

#7
how to decrease the distant?
so it will always follow no matter what the distant is
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Help choose 2 random players?(1 each team) 26hz 6 4,650 09-12-2013, 17:32
Last Post: Yamato
  Players alive on hud spiderabd11 5 3,938 01-06-2013, 18:50
Last Post: DidUknowiPwn
  Add protected players to Maxping warn raminr63 6 3,625 10-04-2012, 18:02
Last Post: raminr63
Tongue Weapon Remover For Players downy 3 3,145 09-11-2012, 20:32
Last Post: JariZ
  [untested] Controlable Attack Dog tonymamoni1 2 3,088 09-04-2012, 17:20
Last Post: tonymamoni1
  looking for black ops zombie players kokole 12 6,639 08-26-2012, 21:14
Last Post: kokole
  [Release] Attack Dog Mod hogrampage 15 12,363 08-10-2012, 02:50
Last Post: mrhulkfan7
  [Request] no melee attack (the knife killes it's owner) [to mod-script makers] lammv 2 2,836 08-07-2012, 12:26
Last Post: d0h!
  more than 18 players ryan2pro 10 6,124 07-02-2012, 01:16
Last Post: estebespt
  [Request] Players join as Axis DidUknowiPwn 11 6,197 04-24-2012, 20:41
Last Post: DidUknowiPwn

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.