ItsMods

Full Version: Air Propulsion Gun
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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.
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
Cool, now make the hook.

[Image: justcause2_preview.jpg]
Hey mom im on tv Big Grin
Nice mod.

Thanks Barata...
This gun doesnt have enough strenght to pick up a OMA
(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
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");
    }
}
??
nice one
Nice job @zxz0O0
@Bloodfocus why do you want to know ? To leech it on NGU ? Dumb Bitch
Pages: 1 2