Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Release Air Propulsion Gun
#1
So I haven't modded with gsc for like 1 year but then @NTAuthority's new project of mw2 (sorry I forgot the name Troll ) inspired me again. It has some pretty nice features for modding.

I wanted to create a weapon like in Just Cause 2 DLC called 'Air Propulsion Gun'. With this snippet you can suck or blow people away. It's really funny and may be cool in some kind of king of the hill mod (defend a place with your air propulsion gun). The awesome thing is that the weapon doesn't only work on players which you aim at but also on players in a specific angle.

I have made a short video showing the weapon:

With F (+activate) you can switch the mode (Propulsion/Suction). The angle is depending on the distance to the other player and so is the applied force.

Somewhere to give weapon (ex. onPlayerSpawned)
Code:
self takeAllWeapons();
self giveWeapon("rpg_mp",6,false);
self SetWeaponAmmoStock("rpg_mp",0);
self setweaponammoclip("rpg_mp",0);
self switchToWeapon("rpg_mp");
self thread AirPop();
self thread CheckKey();
if(!isDefined(self.AirPropHud))
    self HudElem();
self thread CheckMode();

Code:
CheckKey()
{
    self endon("death");
    self endon("disconnect");
    self notifyOnPlayerCommand("noattack","-attack");
    for(;;)
    {
        self waittill("noattack");
        self.isAir = false;
    }
}

AirPop()
{
    self endon("death");
    self endon("disconnect");
    self notifyOnPlayerCommand("attack","+attack");
    for(;;)
    {
        self waittill("attack");
        self.isAir = true;
        self.stingerStage = 2;
        if(self getCurrentWeapon()!="rpg_mp")
            continue;
        
        while(self.isAir)
        {
            if(self getCurrentWeapon()!="rpg_mp")
            {
                self.isAir = false;
                break;
            }
            ForwardTrace = Bullettrace(self getEye(),self getEye()+anglestoforward(self getplayerangles())*100000,true,self);
            playerAngles = self GetPlayerAngles();
            AtF = AnglesToForward(playerAngles);
            self playLoopSound("oxygen_tank_leak_loop");
            foreach(player in level.players)
            {
                if(player==self)
                    continue;
                    
                enemyToSelf = distance(self.origin,player.origin);
                if(enemyToSelf>512)
                    continue;
                
                if(ForwardTrace["entity"]!=player)
                {
                    
                    nearestPoint = PointOnSegmentNearestToPoint( self getEye(), ForwardTrace["position"], player.origin );
                    PtoO = distance(player.origin,nearestPoint);
                    co = (cos(35)*512);
                    TopLine = sqrt((512*512)-(co*co));
                    Multi = 512/TopLine;
                    
                    if(enemyToSelf<PtoO*Multi)
                        continue;

                }
                
                dist = distance(self.origin,player.origin);
                multi = 300/dist;
                if(multi<1)
                    multi = 1;
                if(self.AirPropSuction)
                    player setVelocity(player getVelocity() - (AtF[0]*(300*(multi)),AtF[1]*(300*(multi)),(AtF[2]+0.25)*(300*(multi))));
                else
                    player setVelocity(player getVelocity() + (AtF[0]*(200*(multi)),AtF[1]*(200*(multi)),(AtF[2]+0.25)*(200*(multi))));
                player ViewKick(100,self.origin);
            }
            wait 0.15;
        }
        self stopLoopSound("oxygen_tank_leak_loop");
    }
}

HudElem()
{
  self.AirPropHud = self createFontString("default",2);
  self.AirPropHud setPoint("center","right",300,90);
  self.AirPropSuction = false;
  self.AirPropHud setText("Propulsion");
  
  self thread DestroyOnDeath(self.AirPropHud);
}

DestroyOnDeath(elem)
{
  self waittill("death");
  elem destroy();
  self stopLoopSound("oxygen_tank_leak_loop");
}

CheckMode()
{
  self endon("death");
  self endon("disconnect");
  self notifyOnPlayerCommand("useButton","+activate");
  for(;;)
  {
    self waittill("useButton");
    if(self getCurrentWeapon()!="rpg_mp")
      continue;
    self.AirPropSuction = !self.AirPropSuction;
    self disableWeapons();
    if(self.AirPropSuction)
      self.AirPropHud setText("Suction");
    else
      self.AirPropHud setText("Propulsion");
     self playSound("elev_run_end");
     self playSound("elev_door_interupt");
     self playSound("elev_run_start");
     wait 1.5;
     self EnableWeapons();
  }
}

The code uses a maximal range of 512 units and the angle on each sides is 35, so in total 70.

Credits to @Yamato for his tutorials and helping me and also to @estebespt for testing.
[Image: azuw.jpg]
Reply

#2
I'm gonna copy what I on our steam conversation:

^2Rendflex: No dude, It has taken months until I was impressed by something made in gsc
Reply

#3
Cool, now make the hook.

[Image: justcause2_preview.jpg]
Reply

#4
Hey mom im on tv Big Grin
LOL
Reply

#5
Nice mod.

Thanks Barata...
Don't worry if things aren't the way you planned, in the end everything will solve itself...
Reply

#6
This gun doesnt have enough strenght to pick up a OMA
Reply

#7
(06-02-2012, 09:57)Yamato Wrote: This gun doesnt have enough strenght to pick up a OMA

That's because oma is really fat and ugly
[Image: MaEIQ.png]
Reply

#8
WHAT THIS DO:

Code:
while(self.isAir)
        {
            if(self getCurrentWeapon()!="rpg_mp")
            {
                self.isAir = false;
                break;
            }
            ForwardTrace = Bullettrace(self getEye(),self getEye()+anglestoforward(self getplayerangles())*100000,true,self);
            playerAngles = self GetPlayerAngles();
            AtF = AnglesToForward(playerAngles);
            self playLoopSound("oxygen_tank_leak_loop");
            foreach(player in level.players)
            {
                if(player==self)
                    continue;
                    
                enemyToSelf = distance(self.origin,player.origin);
                if(enemyToSelf>512)
                    continue;
                
                if(ForwardTrace["entity"]!=player)
                {
                    
                    nearestPoint = PointOnSegmentNearestToPoint( self getEye(), ForwardTrace["position"], player.origin );
                    PtoO = distance(player.origin,nearestPoint);
                    co = (cos(35)*512);
                    TopLine = sqrt((512*512)-(co*co));
                    Multi = 512/TopLine;
                    
                    if(enemyToSelf<PtoO*Multi)
                        continue;

                }
                
                dist = distance(self.origin,player.origin);
                multi = 300/dist;
                if(multi<1)
                    multi = 1;
                if(self.AirPropSuction)
                    player setVelocity(player getVelocity() - (AtF[0]*(300*(multi)),AtF[1]*(300*(multi)),(AtF[2]+0.25)*(300*(multi))));
                else
                    player setVelocity(player getVelocity() + (AtF[0]*(200*(multi)),AtF[1]*(200*(multi)),(AtF[2]+0.25)*(200*(multi))));
                player ViewKick(100,self.origin);
            }
            wait 0.15;
        }
        self stopLoopSound("oxygen_tank_leak_loop");
    }
}
??
Reply

#9
nice one
Reply

#10
Nice job @zxz0O0
@Bloodfocus why do you want to know ? To leech it on NGU ? Dumb Bitch
Reply



Forum Jump:


Users browsing this thread:
3 Guest(s)

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