Author Topic: Vehicle Weapons (Warplane)  (Read 1093 times)

Working on one of my vehicles and I'm using the warplane.cs as a base for it but not sure how to do what I need doing. First off here's what I've done so far, Script link. All I've done is removed and changed some of the settings and emitters that I don't want. What I really need help with is the weapons part, I need to remove the rocket that fires downwards and add a second weapon to mount2. Both weapons need to shoot at the same time when fired.

Any help would be great :D, Also do I need to make a new weapon script for the 2 mounted weapons?
« Last Edit: March 24, 2008, 03:11:40 PM by Packer »

I'll take a look and get back to you shortly.

Edit: getting rid of the rocket:
remove this portion of code(line 1056 to 1081)
Code: [Select]
function TieFightervehicle::onTrigger(%this, %obj, %triggerNum, %val)
{
if(%triggerNum == 2 && %val && !iseventpending(%obj.rocketreload)){
%obj.client = %obj.getcontrollingclient();
%pos = %obj.getposition();
%client = %obj.client;
%pos = vectoradd(%pos,"0 0 -0.8");
%pos = vectoradd(%pos,%obj.getforwardvector());
%vel = "0 0 -22.5";
%planevz = getword(%obj.getvelocity(),2);
if(%planevz < 0){
%vel = VectorAdd(%vel,"0 0 " @ %planevz);
}
%p = new Projectile()
{
dataBlock = rocketlauncherprojectile;
initialVelocity = %vel;
initialPosition = %pos;
client = %obj.client;
sourceObject = %obj.client.player;
sourceClient = %obj.client;
};
MissionCleanup.add(%p);
%obj.rocketreload = schedule(1000,0,"");
}
}

to add another gun:(line 1088)
Code: [Select]
function TieFightervehicle::onadd(%this,%obj)
{
parent::onadd(%this,%obj);
%obj.mountimage(warmgunImage,2);
%obj.mountimage(warmgunImage,2);//change the 2 to the other point
}

to make the other gun fire as well:(line 1039)
Code: [Select]
function Armor::onTrigger(%this, %obj, %triggerNum, %val)
{
%pmount = %obj.getObjectMount();
if(isobject(%pmount)){
if(%pmount.getdatablock().getname() $= "TieFightervehicle" && %triggerNum == 0){
%pmount.setimagetrigger(2,1);
%pmount.setimagetrigger(2,1);//change the 2 to the other mount point that you listed in adding the other gun
%pmount.client = %obj.client;
cancel(%obj.fightsch);
cancel(%obj.fightsch2);
%obj.fightsch = schedule(10,0,"Untrigger",%pmount,2);
%obj.fightsch2 = schedule(10,0,"Untrigger",%pmount,2);//change the 2 to the other weapons mount point
}
}
parent::onTrigger(%this, %obj, %triggerNum, %val);
}
};



That should be it, remember to go through and do what my comments in the code say.(mostly changing the mount point number in some of the functions to whatever one is the place you want the other gun.)
« Last Edit: March 24, 2008, 06:00:20 PM by rkynick »



Hmm tried but couldn't get the 2nd gun to spawn. The rocket got removed though :D
It'd be easier if you could just upload your edit, also gun 1 is in mount1 and gun 2 is in mount2.

You completely skipped the last step, but the other gun should spawn anyways. Not exactly sure what would be stopping it.

Ok I went over it and tried 1 and 3 and they both didn't work what so ever. Hmm... console says nothing other then emitter problems as normal.