Creating your first ARMED Airplane by Brsseb
Preparing for the lesson
Finally got back to writing tuts again and here is one I have wanted to make for months: its your first tutorial about equipping a vehicle with lots of firepower. We are talking about a machinegun, heat seeking missiles and maybe an unguided rocket or 80 ;).
Ok, people. I will tell you how to arm a vehicle in this tut, and for that we need a vehicle. Move to next page.
We need a vehicle for this tutorial, and I have picked the plane from tutorial 6. Its basically the same model from the end of the tut, with all the planeish features (flaps, rotors, etc) working nicely. All its missing is some firepower and that's what we`ll take care of now. Note that this tutorial will be useful for not just planes, but helicopters and most other vehicles in the game. Also, if you combine parts of this tutorial with tutorial 3 (the sniper rifle), you can do stuff like Rocket launchers for soldiers and the likes.
Our final plane from tutorial 6 in flight
But lets get the model. Its the same, except I have changed the folder and p3d file name from “firstplane” to “armedplane” so we don't interfere with the old firstplane pbo if you want both of them in the game at the same time. And of course, i have updated the texture paths in the p3d file and the lines in the configfile to suit the new name.
Also, i have deleted the View Pilot and View Cargo LOD. We need to add stuff to the original LOD, “0.00”, and the changes also needs to be reflected in both View LODs, so i just deleted them and are gonna make new ones at the very end to save us from doing 3x more work.
For simple reason i didn't change the passenger proxy to the gunner, so the pilot will be in charge of the guns all the time. Much more fun, i think ;).
Now move on to the first job.
First up is the common machinegun that most warplanes have. We will make some sort of gunbarrel pointing out of the plane near the nose (to make this tut simple, I'm not gonna make an accurate machinegun model in this tut) pointing strait forward. The sad limit here is that an airplane cant have a gunturret like you can have on a helicopter (like hte UH60) or my gunboat from lesson 5. You cant like a tailgunner like on a german ww2 Stuka plane or something like that. Guns on airplanes can only fire strait forward in a fixed position.
NB: This lack of turret on planes has been a limit for very long time. But after patch 1.90, there was some features added that indicated that this could now be done. But since its very new info and still onthe experimental level for the time being, im gonna assume that movable turrets on planes are not possible.
Argh, too much text and info to remember there. Lets go, go go go!:
The gun i made. Simple box with a cylinder structure sticking out of it. All textured with the “black” texture.
Ok, the totally ultra-high-detailed (a little bit of irony there) machinegun model is in place. But as for all guns, we need a muzzleflash. You should be able to do this one in your sleep if you have don't tut 3. Its simple, just 3 flat structures (two planes, one circle), all double sided (hit F6 twice when creating the faces) with a muzzleflash texture on it. But to save you people who avoided the daunting-looking tutorial 3, i have made the muzzleflash for you. Its in a seperate file in the project folder and we need it on the plane. Good time to learn what the “merge” function does, eh?
Hmm, nothing really new yet, is it? Not if you have done lesson 3 or lesson 5. But it will come along eventually. Now lets head for Memory LOD.
Tada, the machinegun is ready! WHAT you might say? Bhaw, humburg, what about all the other stuff we made on earlier gun models, all the crazy stuff about “osaVeze”, “Konec Hlavne”, and all that crazy czech gibberish? Well, remember the thing about us not being able to do movable turrets on planes? Yep, with a fixed gun position all the selection stuff before is not needed. We need just a muzzleflash in model lod and a single vertex in mem to indicate where we want the bullet to start from. It will always go in the plane direction.
The only usable selection we have left might be the nabojnicestart&end (indicate where the empty cartridges are shot out from), but I don't want out plane to shoot them out of the body and maybe risk getting one in the propeller or something like that.
Our plane with the new machinegun and flash
Ok the gun is done. Except it needs a proper configfile to work. As usual, I do configfile editing at the very end so you must wait to the end of tut before compiling and testing your machinegun plane. Sorry. Move on then:
Ok, lets make our first rockets for the plane. We want two pods under each wing carrying a decent load of rockets on them, like many choppers in ofp do. Now the trick with unguided rockets in pods is you make a pod-like structure that you place under each wing, then you define some selection names in Memory LOD to indicate where these pods are and when you fire, a rocket model (from a separate p3d file) is inserted where these points are and flies in the heading of the aircraft. We will make our own pod model and use a rocket model already in OFP. We wont do custom rockets for these pods, we`ll make our own rockets in the last part of the tutorial. For now, we must settle with some pod modeling and I`ll show you how to use OFP rockets for these pods in the configfile later.
So, first we need a pod for the rockets to fire from. We need two pods, but we`ll make one and copy it. As always in my tuts, this is done with minimal modeling detail to speed things up a bit.
Now lets head for memory LOD:
Ok, thats the basic setup. The only thing stopping us from firing rockets now is the configfile setup. In the configfile, we can select type of rockets to fire from the pods. Later, then.
Ok, now we got a machinegun for closeup dog fighting and some unguided rockets to destroy ground objects with. But somethings missing…
Ok, we got our machinegun for closeup dog fighting and unguided rockets for those ground kills, but there is one thing missing! yep, proper AntiAircrart defense! And that's why we`re gonna make some guided AA rockets, using your very own self-made rocket type!
This one will not be inside a pod, but we will have the actual rocket hanging under the wings, ready to launch at your command. To do that we must create our rocket in a separate p3d file and insert it as a proxy in the plane p3d file. Just like we do with soldiers, then. Very easy, really, its the configfile setup that's a pit painful here.
Now select all structures and apply the texture to them. Check the result out in bulldozer. If you are happy with it (move some vertices and retexture if you aren't) , create the remaining 6 wings by copying and rotating the two first onces. In the end it should look like this:
Maybe not the most perfect paint job ever, but it looks nice for a tutorial-quality model, eh?
Ok, rockets only need two lods, “0.00” lod (the one we have made) and Geometry LOD. We do it very simple for Geo LOD:
Finally, lets scale the rocket to a bit more real dimensions. If your model is very similar to mine, you have a like 10 meter rocket on your hands here ;); so a bit big for an airplane then. Lets scale it down to about 1 meter, shall we? Scale down the whole model Points→Transform 3d→Scale. I used 0.1 in all fields and ticked off the Apply to all Lods-field so that Geometry LOD would be scaled too. Now my rocket is about a metre, which is a decent size for our tutorial.
Ok, the rocket model is now done. Save it as “Sidewinder.p3d” in the armedplane directory. Now lets get it onto our airplane!
Now we head back to our plane model and prepare to insert the rocket proxys. We`ll have 3 rockets on each wing, 6 in total.
Ok, the rockets are in place where we want them and all I looking good, eh? Actually, there is only a few things left before we once again say hello to mister Configfile himself:
Now we wont be able to view them in Bulldozer anymore, but thats ok. We are done positioning them and now the game engine will get them working properly. Dont ask, its how its done ;).
Ok, set to go then. One thing i must tell you when trying to create your own rockets: You can only have ONE TYPE OF CUSTOM ROCKET PROXYS on your model at a time! I mean, you cant make some stingers and some hellfires and set them up like we did for our Sidewinder, it wont work. Its an engine limitation, sorry. If you must have lots or rocket types on your aircraft, only one can have rockets fitted the way we have now and all the other must go in pods (like we did for our unguided missiles).
Ok, now the main plane model is done and…..(sudden thunder)..hey, whats that? Who's there, at the door? (story continue on the next page…)
…OH DEAR LORD! Is it Death? Satan? George Bush??. NO, its FAR worse!! Its the evil and scary configfile!! Nooooooooooooo! The dreaded file that with its alien C++ nature eats n00bs as if they were Pringels!
O my God, its nothing like I have ever seen before! We have done weapons, cars, planes and the likes. And it has kept getting bigger and meaner each time. But now we want an airplane, WITH a machinegun, and not one, but TWO different rocket types, one of them OUR OWN CUSTOM ROCKET!. We`re really asking for trouble here, and the Mighty one seems pretty pissed off at the moment. Jeezees, we are talking about several pages here! Maybe as height as…(scary drumroll) TWO or THREE! pages of text! Noooooooo…..
OK, lets cut the crap, shall we ;). As you can see, im getting bored writing this tut now so thank god we are nearly done! As always, I have done the configfile and we`ll walk trough it together with me highlighting some important issues. I'm not doing a tutorial on configfiles, for that you need to get a C++ Programming tut. Lets go!
At the top is the usual stuff, just some standard declarations, the CfgPatches class where we introduce our planemodel. Note that we don't list the weapons we have since we aren't gonna use them in other PBOs (aka not export the weapons for use on other vehicles). Then its CfgModels, where we define out airplane class and the custom proxy weapon we are gonna use. Note that when we have our own custom made rocket, we must mention it in this class. And, whenever we have proxys, its crucial that the rocket class name match the actual rocket filename! (class sidewinder, sidewinder.p3d).
Next class up is CfgAmmo. In this class all the ammo we are gonna use is defined (remember rocket is an ammo). Note that since we are gonna use OFP bullets for our machinegun and OFP rockets for the unguided rockets, we don't need to define them in anyway. They are defined elsewhere in the game and we can just put them on our plane without much writing. Our sidewinder is defined in this class.
The CfgWeapons class naturally is the place to define the weapons we have on board our plane. First up is the machinegun, which is a pretty standard gun using “Bullet30”, which is a standard OFP-defined explosive bullet. Count indicate we have 500 rounds and autofire=true that we can hold down the fire button and bump out bullets automatically. Reloadtime 0.08 means that it is 8/100 second between each bullet being fired.
Here is the rest of the CfgWeapons class and here the sidewinder launcher is defined. Now, we could have put the the AA rocket in a tube, but we want them naked on the wings. But we still need to define a launcher, and in this case the launcher is using the same model as the ammo, “sidewinder.p3d”. And by doing it this way, the engine removes a rocket model (a launcher) from the wing (if the “count=x” is equal to the number of rocket proxys on the plane, in this case 6).
There is also the class for the unguided missile launcher. It don't have a model, its just gonna fire its rockets out from the two points we defined in Memory LOD. The rockets being fired is the standard rockets fired from the OFP ZuniLauncher, hence the class we are inheriting from (a bit of C++ there, n00bz, sorry). The count=80 gives us 80 rockets to play with.
Then its the CfgVehicle class, which you have seen all over the tutorials so far so I wont go in detail here. Just note the two arrays Weapons and Magazines containing the weapon names we have defined earlier.
And last but not least, the all-important CfgNonAIVehicles that we need for all addons that have weapon and ammo classes in them. Notice we have the class names here with a added “Proxy” before each name. Here you mention the weapons used in the addon. Note that the unguided rocket launcher is missing, I forgot it but it worked anyway, so i guess its just weapons that you have defined a custom ammo class to, aka just the MG and the AA rocket in this case. The important thing is the Proxyclass for the sidewinder, where we tell that the sidewinder.p3d file is inserted as a proxy. Very important this one!
So boring stuff all this, but at the same time so important! But I hope that this configfile will help you in your future projects. If you have questions, ask me or any other cpp-knowing fellow. But for now, lets compile and test!!
We are nearly there now, just need to compile it and off we go. So open PBOTool, select Compress, select the folder armedplane, name it “armedplane.pbo” and save it in the Addons-folder in OFP dir.
Check out the model ingame (Under West→My Armed plane) and make sure everything works as planned. Any trouble, look back at the tutorial and see if you missed out on something. You can also download the final PBO, open it and compare it to your project.
The the final PBO file Brsseb_lesson7_done.rar.
Well, there you go. The long-awaited rocket tutorial. Hopefully you have learned something and can start adding weapons to your vehicles. Remember there is still much to learn and the OFP engine is often messing with you, so be careful, take it nice and slowly, do only one change at a time. Never expect a model to work the first time, usually it takes a good few change-recompile-restart OFP before everything works. And most important DON'T GIVE UP!
As always, firstname.lastname@example.org for bug reports, questions, or simply good old “hate you/love you man” messages.
This tutorial was written by Brsseb in ofp.gamepark.cz/_hosted/brsseb/, it was posted here with his permissions, thank you Brsseb!