Jump to content
Sign in to follow this  
smokedribs

How to make 2+ weapons on 1 vehicle

Recommended Posts

Here is the script i use to create a vehicle with extra weapon stations.  I created a atgm stryker using this script.

First I created the stryker with a machine gun as its weapon since its a wheeled vehicle.  Next I created a seperate atgm vehicle with a gunner in it.  

In the code of the atgm vehicle I put the following line in the init field to call the script, which was named skippy.sqs.  Stryker1 refers to the carrier vehicles name, so name that whatever you name your vehicle you want to attach the weapon to.

[ stryker1, this, [ 0, -2.1, 2.1, 0 ]] exec "skippy.sqs"

Play with the numbers to position the weapon exactly where you want it on your vehicle.  With these numbers I put my atgm on the correct spot of the stryker.

Since this is a seperate vehicle now the stryker can have 2 gunners, and the missle fires missles, no more silly explosive bullets on wheeled vehicles.  This script will work with any vehicle.  So you can mount a machine gun on a truck for example and position it correctly.

When the main vehicle drives around the attached vehicle (weapon) will stay positioned and drive with the main vehicle, its pretty cool.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

;// Carry a unit on another unit, maintaining relative offset and azimuth

;// [ carrier, cargo, [ offset.x, offset.y, offset.z, azimuth ]]

;// Carrier that carries cargo [object]

_carrier = _this select 0

;// Cargo carried by carrier [object]

_cargo   = _this select 1

;// Cargo's offset (from carrier's origin) and azimuth [4-vector]

_co      = _this select 2

;// Init

_co_x = _co select 0

_co_y = _co select 1

_co_z = _co select 2

_co_a = _co select 3

endCargoSession = false

#loop

;// Get carrier's position and azimuth

_pos = getPos _carrier

_dir = getDir _carrier

;// Rotate cargo's position around carrier's z-axis

_sind = sin _dir

_cosd = cos _dir

_cargo setPos [( _pos select 0 ) + _cosd * _co_x + _sind * _co_y, ( _pos select 1 ) + _cosd * _co_y - _sind * _co_x, ( _pos select 2 ) + _co_z ]

;// Set cargo's azimuth relative to carrier's

_cargo setDir ( _dir + _co_a )

~.01

? (!endCargoSession) : goto "loop"

@endCargoSession

exit

Here is a picture of my atgm stryker with the missle object.  The ATGM isnt textured yet but you can see a sample of what you can do with this script.

...smokedribsatgmstryker.jpg

Share this post


Link to post
Share on other sites

Oh yeah,

Is there a way to put a script somewhere besides your mission folder, where the game will always see it regardless of it being in your mission folder. I dont want to copy this script to every mission that uses it.

Thanks!

Share this post


Link to post
Share on other sites

How does it handle with bumps and going uphill etc? smile_o.gif

Share this post


Link to post
Share on other sites

Its not perfect on hills since the attached weapon tries to maintain its relative angle to the terrain its driving over. Ill try to fix it so it works a bit better.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×