Helicopter Resource
by Tim Heldna · 11/27/2005 (10:51 pm) · 185 comments
Download Code File
Helicopter Resource
Updated March 8th 2006
This resource will implement a new vehicle class named 'helivehicle'. As the name suggests it is a helicopter resource and does not try to emulate the physics of a real helicopter, rather just the basic flight movements.
The new heliVehicle class is derived from the flyingVehicle class, therefore all functions / effects that are available to a flying vehicle are available to a heliVehicle.
The helicopter seats two people and takes damage. Light smoke will trail from the helicopter when it is partly damaged, heavier smoke when close to being destroyed and it will explode and delete when destroyed.
The helicopter has three weapons mounted to it. Two miniguns which fire on left mouse button and one grenade launcher which fires with right mouse button. Weapons do damage, apply an impulse effect, leave decals, use projectile spread, and both have all particle fx and sounds included.
Collision has been improved a great deal, I have not yet managed to fly through terrain or any other object.
The zip file below contains all head code, scripts, models, textures, particles, sounds etc that you'll need. Disregard all other links to zips on this page. The sounds contained within ARE NOT free for commercial use.
Installation:
Download the zip file here(7.11mb)
Head Code
From the zip file copy the following 4 files into your engine/game/vehicles directory
- vehicle.cc
- vehicle.h
- heliVehicle.cc
- heliVehicle.h
Add them to your project, recompile and you're done.
Scripts & other stuff
I forget some stuff for player.cs in the zip file. Please make sure you do step 3 below if you are just copying/pasting.
The zip file contains all the scripts that you need so you can just copy & paste into a fresh 1.4 version of Torque. If you want to merge, this is what you'll have to do...
1) Open server/scripts/game.cs and add this with the rest of them
2) Open server/scripts/commands.cs and add this to end of file
3) All changes for this step occur in server/scripts/player.cs
a) Within the Armor::onMount(%this,%obj,%vehicle,%node) function just after the first opening brace '{' add this line
4) Open client/scripts/default.bind.cs and add this under function jump(%val)
5) Open client/scripts/client.cs and add this to end of file
6) Open client/init.cs and add this with the rest of them
7) Add the following files from the zip file to your server/scripts directory
- heli.cs
- vehicle.cs
- chaingun.cs
- rocket_launcher.cs
8) Add the following files from the zip file to your client/scripts directory
- heliDriverMap.cs
- heliPassengerMap.cs
9) Add the following three folders from the zip file to your data/shapes directory
- iroquis
- chaingun
- rocket_launcher
10) Go into client/scripts and delete the config.cs file, otherwise your new helicopter bindings won't take effect.
Run the game, use the mission editor to drop a helicopter into your world, fly away and send Kork into orbit. Try not to manipulate or move the helicopter around too much in editor mode, especially if you're in it.
Default Controls:
w - move forward
s - move backward
a - hover up
d - hover down
m - mount / dismount helicopter
q - change seats
left mouse button - fire miniguns
right mouse button - fire rocket launcher
Known Problems:
- Doesn't like to compile in .net compilers. Your helicopter has a constant force of gravity which means you may get stuck in the terrain. Compile in vc6 if you can and you won't have any problems.
This resource is a work in progress, it's not yet up to my standards and will be improved on over time.
Here's a video of the helicopter in action
Video(12mb)
Credit and thanks to Mike Stoddart for his excellent Vehicle Resource
All comments, feedback, suggestions for improvement are welcome.
Helicopter Resource
Updated March 8th 2006
This resource will implement a new vehicle class named 'helivehicle'. As the name suggests it is a helicopter resource and does not try to emulate the physics of a real helicopter, rather just the basic flight movements.
The new heliVehicle class is derived from the flyingVehicle class, therefore all functions / effects that are available to a flying vehicle are available to a heliVehicle.
The helicopter seats two people and takes damage. Light smoke will trail from the helicopter when it is partly damaged, heavier smoke when close to being destroyed and it will explode and delete when destroyed.
The helicopter has three weapons mounted to it. Two miniguns which fire on left mouse button and one grenade launcher which fires with right mouse button. Weapons do damage, apply an impulse effect, leave decals, use projectile spread, and both have all particle fx and sounds included.
Collision has been improved a great deal, I have not yet managed to fly through terrain or any other object.
The zip file below contains all head code, scripts, models, textures, particles, sounds etc that you'll need. Disregard all other links to zips on this page. The sounds contained within ARE NOT free for commercial use.
Installation:
Download the zip file here(7.11mb)
Head Code
From the zip file copy the following 4 files into your engine/game/vehicles directory
- vehicle.cc
- vehicle.h
- heliVehicle.cc
- heliVehicle.h
Add them to your project, recompile and you're done.
Scripts & other stuff
I forget some stuff for player.cs in the zip file. Please make sure you do step 3 below if you are just copying/pasting.
The zip file contains all the scripts that you need so you can just copy & paste into a fresh 1.4 version of Torque. If you want to merge, this is what you'll have to do...
1) Open server/scripts/game.cs and add this with the rest of them
// Heli Resource Code Start //
exec("./heli.cs");
exec("./vehicle.cs");
exec("./chaingun.cs");
exec("./rocket_launcher.cs");
// Heli Resource Code End //2) Open server/scripts/commands.cs and add this to end of file
// Heli Resource Code Start //
function serverCmdMountVehicle(%client)
{
//Determine how far should the picking ray extend into the world?
%selectRange = 3;
// Only search for vehicles
%searchMasks = $TypeMasks::vehicleObjectType;
%pos = %client.player.getEyePoint();
// Start with the shape's eye vector...
%eye = %client.player.getEyeVector();
%eye = vectorNormalize(%eye);
%vec = vectorScale(%eye, %selectRange);
%end = vectorAdd(%vec, %pos);
%scanTarg = ContainerRayCast (%pos, %end, %searchMasks);
// a target in range was found so select it
if (%scanTarg)
{
%targetObject = firstWord(%scanTarg);
echo("Found a vehicle: " @ %targetObject);
onMountVehicle(%targetObject.getDataBlock(),
%client.player,
%targetObject);
}
else
{
echo("No object found");
}
}
function serverCmdDismountVehicle(%client)
{
doPlayerDismount(%client, %client.player, %true);
}
function serverCmdFindNextFreeSeat(%client)
{
echo("serverCmdFindNextFreeSeat " @ %client.nameBase);
// Is the vehicle moving? If so, prevent the player from switching seats
if (isVehicleMoving(%client.player.mvehicle) == true)
return;
%newSeat = findNextFreeSeat(%client,
%client.player.mvehicle,
%client.player.mvehicle.getDataBlock());
if (%newSeat != -1)
{
echo("Found new seat " @ %newSeat);
setActiveSeat(%client.player,
%client.player.mvehicle,
%client.player.mvehicle.getDataBlock(),
%newSeat);
}
else
{
echo("No next free seat");
}
}
// Heli Resource Code End //3) All changes for this step occur in server/scripts/player.cs
a) Within the Armor::onMount(%this,%obj,%vehicle,%node) function just after the first opening brace '{' add this line
onPlayerMount(%this,%obj,%vehicle,%node);b) Within the Armor::onUnmount( %this, %obj, %vehicle, %node ) function after the first opening brace '{' add this line
onPlayerUnmount(%this, %obj, %vehicle, %node);c) Within the Armor::doDismount(%this, %obj, %forced) function after the first opening brace '{' add this line
doPlayerDismount(%this, %obj, %forced);
4) Open client/scripts/default.bind.cs and add this under function jump(%val)
// Heli Resource Code Start //
function mouseJet(%val)
{
$mvTriggerCount3++;
}
function mouseJetdn(%val)
{
$mvTriggerCount4++;
}
moveMap.bindCmd(keyboard, "m", "commandToServer('MountVehicle');", "");
// Heli Resource Code End //5) Open client/scripts/client.cs and add this to end of file
// Heli Resource Code Start //
//----------------------------------------------------------------------------
// Vehicle commands
//----------------------------------------------------------------------------
function clientCmdPopActionMap()
{
echo("Popping Player action map " );
movemap.pop();
}
function clientCmdPushActionMap()
{
echo("Pushing Player action map " );
movemap.push();
}
//----------------------------------------------------------------------------
function clientCmdPopActionMapHelicopterDriver()
{
echo("Popping Helicopter Driver action map " );
heliDriverMap.pop();
}
function clientCmdPopActionMapHelicopterPassenger()//%vehicleType
{
echo("Popping Helicopter Passenger action map " );
heliPassengerMap.pop();
}
//----------------------------------------------------------------------------
function clientCmdPushActionMapHelicopterDriver()
{
echo("Pushing Helicopter Driver action map " );
heliDriverMap.push();
}
function clientCmdPushActionMapHelicopterPassenger()
{
echo("Pushing Helicopter Passenger action map " );
heliPassengerMap.push();
}
// Heli Resource Code End //6) Open client/init.cs and add this with the rest of them
// Heli Resource Code Start //
exec("./scripts/heliDriverMap.cs");
exec("./scripts/heliPassengerMap.cs");
// Heli Resource Code End //7) Add the following files from the zip file to your server/scripts directory
- heli.cs
- vehicle.cs
- chaingun.cs
- rocket_launcher.cs
8) Add the following files from the zip file to your client/scripts directory
- heliDriverMap.cs
- heliPassengerMap.cs
9) Add the following three folders from the zip file to your data/shapes directory
- iroquis
- chaingun
- rocket_launcher
10) Go into client/scripts and delete the config.cs file, otherwise your new helicopter bindings won't take effect.
Run the game, use the mission editor to drop a helicopter into your world, fly away and send Kork into orbit. Try not to manipulate or move the helicopter around too much in editor mode, especially if you're in it.
Default Controls:
w - move forward
s - move backward
a - hover up
d - hover down
m - mount / dismount helicopter
q - change seats
left mouse button - fire miniguns
right mouse button - fire rocket launcher
Known Problems:
- Doesn't like to compile in .net compilers. Your helicopter has a constant force of gravity which means you may get stuck in the terrain. Compile in vc6 if you can and you won't have any problems.
This resource is a work in progress, it's not yet up to my standards and will be improved on over time.
Here's a video of the helicopter in action
Video(12mb)
Credit and thanks to Mike Stoddart for his excellent Vehicle Resource
All comments, feedback, suggestions for improvement are welcome.
About the author
Recent Blogs
• BCS Street props• Character Pack - Vince
• Recent Artwork
• Progress of our Weapon Pack
• Digital Speedometer
#2
One problem: There is no file =) (Did I miss something??)
11/27/2005 (11:24 pm)
Thank you so very much for this resource! I had almost given up on having a helicopter vehicle. =)One problem: There is no file =) (Did I miss something??)
#3
11/27/2005 (11:45 pm)
What Midhir said... Zip?
#4
Thanks for sharing your work Tim!
11/28/2005 (12:10 am)
I been watching your work for a while now and I am glad that is finnaly released as free resource....please upload zip file again. Thanks!Thanks for sharing your work Tim!
#5
11/28/2005 (1:55 am)
Sweet. Don't forget to port the resource to TDN.
#6
11/28/2005 (4:16 am)
Just so you know i am experience difficulties uploading the zip file. I will try again in a day or two but thank you to Denis Linardic for hosting the file in the meantime.
#7
11/28/2005 (12:44 pm)
Awesome, thank you guys! And thanks Denis
#8
11/28/2005 (1:26 pm)
Works straight out on 1.4 also except for one thing, I can mount the helicopter but the controls for the helicopter simply don't work. Any ideas?
#9
Good luck :p
Nice resource btw!
11/28/2005 (3:57 pm)
Quote:
-Collision issues. The helicopter will most likely get stuck if crashed into any type of terrain, diff object, dts object. You may be stuck indefinately or the game may crash as a result. This has nothing to do with the 'helivehicle code' and everything to do with Torque's collision code. Hopefully someone can come up with a fix.
Good luck :p
Nice resource btw!
#10
11/28/2005 (4:50 pm)
Thanks for giving this away even though you didn't have to. Good luck with your engine choice.
#11
11/28/2005 (5:11 pm)
Thankyou for releasing this resource. I have been waiting for a Helicopter Resource for along time.
#12
Having never used 1.4 i'm at a loss. Sounds like the helidrivermap.cs either isn't being iniated or isn't being pushed upon mounting the helicopter. Check to see if it's being loaded (just look to see if a dso was created for it) and after mounting the helicopter check the console and tell me what it says. It should say something like...
Lastly make sure client.cs and commands.cs are iniated and loading without error. From memory these 2 scripts take care of the vehicle maps.
11/28/2005 (8:00 pm)
Quote:Works straight out on 1.4 also except for one thing, I can mount the helicopter but the controls for the helicopter simply don't work. Any ideas?
Having never used 1.4 i'm at a loss. Sounds like the helidrivermap.cs either isn't being iniated or isn't being pushed upon mounting the helicopter. Check to see if it's being loaded (just look to see if a dso was created for it) and after mounting the helicopter check the console and tell me what it says. It should say something like...
Mapping string: MountVehicle to index: 5 Found a vehicle: 1441 This vehicle has 2 mount points. Mounting vehicle in seat 0 Mapping string: PopActionMap to index: 14 Popping Player action map Mapping string: PushActionMapHelicopterDriver to index: 15 Pushing Helicopter Driver action map
Lastly make sure client.cs and commands.cs are iniated and loading without error. From memory these 2 scripts take care of the vehicle maps.
#13
But i say thanks alot anyway !!
11/29/2005 (11:21 am)
Nice resource if i only could download it :)But i say thanks alot anyway !!
#14
With WinMerge it took minutes.
I'm inspired to re-do my vehicle mounting system. :)
Nice work.
Ari
*Edit: Oh, I'm using a heavily modified TGE 1.3 + TLK 1.3.5 via dedicated multiplayer and this resource worked pretty damn good.
11/29/2005 (1:41 pm)
There are a couple of minor bugs (collision is definately an issue) but with some wrenching I got this into my engine.With WinMerge it took minutes.
I'm inspired to re-do my vehicle mounting system. :)
Nice work.
Ari
*Edit: Oh, I'm using a heavily modified TGE 1.3 + TLK 1.3.5 via dedicated multiplayer and this resource worked pretty damn good.
#15
You can download this resource here:
[url]Link No longer working[/url]
11/30/2005 (12:25 am)
@Billy L You can download this resource here:
[url]Link No longer working[/url]
#16
11/30/2005 (2:24 am)
Tim, all that seemed fine apart from the console log you mentioned saying Keyboard device unaquired after mounting the helicopter, is that normal?
#17
Glad you got it working. The code is pretty messy i must admit, there's a lot of stuff that doesn't need to be there i'm just too pressed for time to fix it.
Originally i hadn't planned on doing anything else with this resource but i have a feeling i might change my mind...
The vehicle mounting system we have was necessary for us cos we had a large range of vehicles which we wanted to have very unique maps (key bindings) for and didn't want to make any sacrafices. You'll notice that there's still traces of our jeep in the code in places and in time i will clean all this up and re-release.
@ Ian "Xest" Winter
Yes, it's normal. It's just the engine letting you know when it's receiving / finished receiving input (i think). Anyhow, i've downloaded 1.4 and will have a tinker around and get it working. As mentioned above i will clean up the code as well and re-release. The helivehicle head code can actually be dropped in without changing vehicle.cc and flyingvehicle.cc but i was rushed to get this out and didn't bother making the necessary changes.
AS FAR AS THE ZIP FILE GOES I GIVE UP, I'VE UPLOADED IT TOO MANY TIMES TO MENTION :(
PLEASE USE PROVIDED LINK A FEW POSTS UP.
11/30/2005 (2:54 am)
@ AriGlad you got it working. The code is pretty messy i must admit, there's a lot of stuff that doesn't need to be there i'm just too pressed for time to fix it.
Originally i hadn't planned on doing anything else with this resource but i have a feeling i might change my mind...
The vehicle mounting system we have was necessary for us cos we had a large range of vehicles which we wanted to have very unique maps (key bindings) for and didn't want to make any sacrafices. You'll notice that there's still traces of our jeep in the code in places and in time i will clean all this up and re-release.
@ Ian "Xest" Winter
Yes, it's normal. It's just the engine letting you know when it's receiving / finished receiving input (i think). Anyhow, i've downloaded 1.4 and will have a tinker around and get it working. As mentioned above i will clean up the code as well and re-release. The helivehicle head code can actually be dropped in without changing vehicle.cc and flyingvehicle.cc but i was rushed to get this out and didn't bother making the necessary changes.
AS FAR AS THE ZIP FILE GOES I GIVE UP, I'VE UPLOADED IT TOO MANY TIMES TO MENTION :(
PLEASE USE PROVIDED LINK A FEW POSTS UP.
#18
[Edit] works now, don't know what it was, maybe my provider.
11/30/2005 (6:57 am)
Tim, thanks a bunch for sharing this! I cannot get the download link a few posts above to work - am I the only one experiencing this? Can someone send this to me?[Edit] works now, don't know what it was, maybe my provider.
#19
11/30/2005 (7:07 am)
Works fine for me, tested it just then.
#20
Just a note on collision.
I patched in the New Vehicles resource that has vehicle spawners.
I proceeded to crash the little bi-plane at high speed into the ground and interiors over and over and over.
NO real problems or going through the terrain/interiors like the helicopter or or most of my other vehicles.
Occasionally it got stuck in the ground a little but it almost felt like a feature.
We probably just need to create better collision meshes or switch to bounding box?
I think it's an art problem, so there is hope.
That little plane handled collision better than the tank or anything else I've seen.
Check it out.
And thank you for leaving the extra code in, it gave me a few ideas. :)
Ari
11/30/2005 (8:08 am)
@TimJust a note on collision.
I patched in the New Vehicles resource that has vehicle spawners.
I proceeded to crash the little bi-plane at high speed into the ground and interiors over and over and over.
NO real problems or going through the terrain/interiors like the helicopter or or most of my other vehicles.
Occasionally it got stuck in the ground a little but it almost felt like a feature.
We probably just need to create better collision meshes or switch to bounding box?
I think it's an art problem, so there is hope.
That little plane handled collision better than the tank or anything else I've seen.
Check it out.
And thank you for leaving the extra code in, it gave me a few ideas. :)
Ari

Torque Owner Ian Roach
Thanks for releasing this as a resource