06-01-2012, 21:54
So I haven't modded with gsc for like 1 year but then @NTAuthority's new project of mw2 (sorry I forgot the name ) 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)
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 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.