Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Release Shoot any where with stinger
#1
Last time I requested a code about how to shoot stingers anywhere but now I have learned a little bit more about GSC modding (sort of) so I'm proud to release the code.

Code:
onPlayerSpawned()
{
    for(;;)
    {
        self waittill("spawned_player");
        self thread stinger();    
    }
}

stinger()
{
       self endon("death");

       self notifyOnPlayerCommand("stingershoot", "+attack");
       for(;;)
       {
            self waittill( "stingershoot" );
            if ( self getCurrentWeapon() == "stinger_mp" )
            {
            MagicBullet( "stinger_mp", self getTagOrigin("tag_eye"), self GetCursorPos(), self );
            self setWeaponAmmoClip("stinger_mp", 0);
            }
       }
}

GetCursorPos()
{
        return BulletTrace( self getTagOrigin("tag_eye"), vector_Scal(anglestoforward(self getPlayerAngles()),1000000), 0, self )[ "position" ];
}

vector_scal(vec, scale)
{
        return (vec[0] * scale, vec[1] * scale, vec[2] * scale);
}

How to use? Just shoot it like a normal gun,regardless of ADS

Have fun. Big Grin
Reply

#2
Nice idea.. Wink But thats not the Real stinger.. its a MagicBullet..

Code:
MagicBullet( "stinger_mp", self getTagOrigin("tag_eye"), self


Heres the Whole Stinger GSC

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 = 999;

    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 ( 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;
            }
        }
    }
}

Simple add Player to
LoopStingerLockingTarget lists..
and i think you could Aim Players


much Fun




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

Reply

#3
(08-19-2011, 15:25)BloKK187 Wrote: Nice idea.. Wink But thats not the Real stinger.. its a MagicBullet..

Code:
MagicBullet( "stinger_mp", self getTagOrigin("tag_eye"), self


Heres the Whole Stinger GSC

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 = 999;

    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 ( 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;
            }
        }
    }
}

Simple add Player to
LoopStingerLockingTarget lists..
and i think you could Aim Players


much Fun

No, in the target list by using foreach player in level.players. Btw, didnt I send you this code?
Reply

#4
Quote:No, in the target list by using foreach player in level.players. Btw, didnt I send you this code?

NO Yamato it was JAVELIN

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

Reply

#5
(08-20-2011, 15:38)BloKK187 Wrote:
Quote:No, in the target list by using foreach player in level.players. Btw, didnt I send you this code?

NO Yamato it was JAVELIN

I mean the magicbullet thing, to metro police
Reply

#6
[/quote]

I mean the magicbullet thing, to metro police
[/quote]

wow that was a fast reply ^^
[Image: Riot_cop_point_blank.gif?]
Troll ------------------- GIRL vs JUGGERNAUT ------------------ Troll

Reply

#7
(08-20-2011, 15:38)Yamato Wrote:
(08-20-2011, 15:38)BloKK187 Wrote:
Quote:No, in the target list by using foreach player in level.players. Btw, didnt I send you this code?

NO Yamato it was JAVELIN

I mean the magicbullet thing, to metro police

You gave me this:

Code:
MagicBullet("stinger_mp", self.origin, self.origin+(randomInt(1000),randomInt(1000),randomInt(1000)),self);

not the full code Sleepy
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Help Make ac130 shoot custom bullets Ra3shed 0 2,745 07-23-2013, 13:02
Last Post: Ra3shed
  Help Is there any way to force a player to shoot? pedjas 6 4,047 01-13-2013, 11:37
Last Post: Nekochan
  [Release] Attack Players with Stinger Yamato 6 4,795 12-30-2011, 18:00
Last Post: GscGunner
  Free stinger shooting Metro-Police#45 5 2,647 06-21-2011, 15:15
Last Post: Metro-Police#45
  [Request] Shoot semtex mixedgamer123 5 2,511 06-08-2011, 21:27
Last Post: koil
  [Release] Shoot Nukes d0h! 6 4,080 03-27-2011, 09:19
Last Post: Ivankec
  [Request] Weapons That Shoot NovaGas bastard016017 3 2,369 03-22-2011, 20:26
Last Post: Tomsen1410

Forum Jump:


Users browsing this thread:
1 Guest(s)

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