Post by Sa8Gecko on Apr 24, 2005 10:31:18 GMT -5
I'm writing this little guide to help those of you that have
problems adding MCAR to their vehicles.
- What's MCAR, first of all: MCAR is a collection of scripts and
functions that should help you in making car type vehicles fire
missiles. As default, you can't fire missiles from the 'Car' and 'Ship'
classes of vehicles. Only machine-gun bullets.
For ships and boats in general, I'd recommend you, at least
if you don't have particular requirements which would need
a scripted missile guidance code, to stick with an attachment
script, like the one used by Col. Klink, that is build the missile
launcher as a separate addon, as a tank or apc, and 'attach'
it to the vessel with a script like the one mentioned above.
You'll save yourself a lot of work in scripting.
Can you use this method also for cars? Yes, but it will look
crappy when the vehicle is not sitting on a flat, horizontal
piece of land.
- How MCAR works: two (or more) gamelogics are placed
in cargo spaces appositely created for them as the unit is
initialized. These two gamelogics are usually included in
the 'otochlaven' selection, so that they rotate with the
turret and elevate with the weapon. The weapon is still
configured as a machine-gun in config.cpp. When the weapon
is fired the bullet is removed and a missile (scripted) is
created in its place, in the position returned by one of the
two gamelogics (GLs) and in the direction returned by
both the GLs (a little like usti hlavne and konec hlavne).
- Do you really need GLs for your addon: well, maybe even
no. Not having them will save you further model editing to
place them in the right spots and the use of several scripts.
You can do without them if you mean to fire a rocket from
your car, or a grenade, or a shell: something that doesn't
need to be guided to the target. It all depends on what
you want your addon to do. For example, the jeep with the
recoilless gun released by Hater_Kint some month ago
still uses GLs, even if only a non-guided grenade is launched.
The GLs are used mostly when 'special effects' are generated,
that is the empty cartridge expelled about two seconds
after having fired the gun and the smoke effects. But
really if you don't mind about these eye-candy features
(that anyway are the addon essence), you can do without
GLs. How? Just pass to the scripts generating the grenade
the position the bullet is created and its velocity, directly
from the 'fired' EventHandler, like this:
Then you can create the grenade at the position returned
by PSY_pos, giving it the velocity PSY_vel. This could be
done directly in the fired EH, if you don't want to start
any script.
- So, when do you need GLs: you need them when the
projectile (a missile, most of the times) need to be guided
to some target. You just can't camCreate a missile and expect
it to hit some target. You need first to find a target for that
missile, and then to guide it to the target. Does it seem
complicate ? It is. But fortunately someone has already
figured out how to make it, and if you don't need some
particular and exotic way to destroy the target you should
find in the already written MCAR script something that should
suit you.
- Ok, you need GLs: how should you place them in the
vehicle? Most of the times you'll need only two GLs. The
GLs occupy cargo spaces, that must have been set in the
p3d model, in all resolution LODs. They must be included
of course, as explained above, in the otocHlaven and otocVez
selections of these resolution LODs. The most common
error is to set up these two spaces, proxy:Cargo.x, and
then forget to tell the OFP engine that there are two extra
cargo spaces, with the 'transportSoldier' command in
config.cpp. Here's an example: your car will transport the
driver, the gunner, three passengers and the two GLs used to
launch and guide the missile. This makes a total of FIVE
cargo slots (three passengers and two GLs), so the value
to give to transportsoldier in config.cpp is 5. This is very
important, as if you set the transportsoldier wrong, VERY
PROBABLY your unit won't work: and if it works it means
you have done another error.
The second most common error is to name the GLs wrong.
They must be the last cargo spaces to be occupied.
So if the vehicle has three passengers, you must name
these spaces proxy:Cargo.01,proxy:Cargo.02,proxy:Cargo.03 and the
gamelogics slot proxy:Cargo.04 and proxy:Cargo.05. This
takes us to the other common error: to name the cargo
spaces wrong. For example, the seat beside the driver
normally is named proxy:jeepCoDriver.01. Then you can't
name the first GL space proxy:Cargo.01: you must name
it proxy:Cargo.02, and the other GL space proxy:Cargo.03.
This way it will ensure the cargo spaces are occupied in the
correct order: first the passenger seat and then the two
GLs places. Another common error is to invert the place
of the two GLs spot. The one nearer to the turret must be
named first, then the other more distant must have a
successive number. This in general, for example the SA-8B
uses four GLs and they're named in a little different fashion:
but in this case the scripts know this and make all the things
work smoothly. Even in the standard MCAR code there's
a sort of check to sort out the GL more nearer to the turret,
but it works because the turret is made in a certain way.
Anyway, if you have placed the GLs the wrong order, you
can realized this because the unit will either explode,
hit by the same missile it's generated via script, or fire
the wrong way: in this case the error is the one just
described above, there can't be any other explanation.
problems adding MCAR to their vehicles.
- What's MCAR, first of all: MCAR is a collection of scripts and
functions that should help you in making car type vehicles fire
missiles. As default, you can't fire missiles from the 'Car' and 'Ship'
classes of vehicles. Only machine-gun bullets.
For ships and boats in general, I'd recommend you, at least
if you don't have particular requirements which would need
a scripted missile guidance code, to stick with an attachment
script, like the one used by Col. Klink, that is build the missile
launcher as a separate addon, as a tank or apc, and 'attach'
it to the vessel with a script like the one mentioned above.
You'll save yourself a lot of work in scripting.
Can you use this method also for cars? Yes, but it will look
crappy when the vehicle is not sitting on a flat, horizontal
piece of land.
- How MCAR works: two (or more) gamelogics are placed
in cargo spaces appositely created for them as the unit is
initialized. These two gamelogics are usually included in
the 'otochlaven' selection, so that they rotate with the
turret and elevate with the weapon. The weapon is still
configured as a machine-gun in config.cpp. When the weapon
is fired the bullet is removed and a missile (scripted) is
created in its place, in the position returned by one of the
two gamelogics (GLs) and in the direction returned by
both the GLs (a little like usti hlavne and konec hlavne).
- Do you really need GLs for your addon: well, maybe even
no. Not having them will save you further model editing to
place them in the right spots and the use of several scripts.
You can do without them if you mean to fire a rocket from
your car, or a grenade, or a shell: something that doesn't
need to be guided to the target. It all depends on what
you want your addon to do. For example, the jeep with the
recoilless gun released by Hater_Kint some month ago
still uses GLs, even if only a non-guided grenade is launched.
The GLs are used mostly when 'special effects' are generated,
that is the empty cartridge expelled about two seconds
after having fired the gun and the smoke effects. But
really if you don't mind about these eye-candy features
(that anyway are the addon essence), you can do without
GLs. How? Just pass to the scripts generating the grenade
the position the bullet is created and its velocity, directly
from the 'fired' EventHandler, like this:
fired="PSY_mis = (nearestObject [_this select 0, _this select 4]);PSY_vel =velocity PSY_Mis;PSY_pos = position PSY_Mis; deletevehicle PSY_Mis;[_this select 0, _this select 4,PSY_vel,PSY_pos] exec ""\psy_mcar_scripts\aa\PSY_MCAR_getAmmo4.sqs""";
Then you can create the grenade at the position returned
by PSY_pos, giving it the velocity PSY_vel. This could be
done directly in the fired EH, if you don't want to start
any script.
- So, when do you need GLs: you need them when the
projectile (a missile, most of the times) need to be guided
to some target. You just can't camCreate a missile and expect
it to hit some target. You need first to find a target for that
missile, and then to guide it to the target. Does it seem
complicate ? It is. But fortunately someone has already
figured out how to make it, and if you don't need some
particular and exotic way to destroy the target you should
find in the already written MCAR script something that should
suit you.
- Ok, you need GLs: how should you place them in the
vehicle? Most of the times you'll need only two GLs. The
GLs occupy cargo spaces, that must have been set in the
p3d model, in all resolution LODs. They must be included
of course, as explained above, in the otocHlaven and otocVez
selections of these resolution LODs. The most common
error is to set up these two spaces, proxy:Cargo.x, and
then forget to tell the OFP engine that there are two extra
cargo spaces, with the 'transportSoldier' command in
config.cpp. Here's an example: your car will transport the
driver, the gunner, three passengers and the two GLs used to
launch and guide the missile. This makes a total of FIVE
cargo slots (three passengers and two GLs), so the value
to give to transportsoldier in config.cpp is 5. This is very
important, as if you set the transportsoldier wrong, VERY
PROBABLY your unit won't work: and if it works it means
you have done another error.
The second most common error is to name the GLs wrong.
They must be the last cargo spaces to be occupied.
So if the vehicle has three passengers, you must name
these spaces proxy:Cargo.01,proxy:Cargo.02,proxy:Cargo.03 and the
gamelogics slot proxy:Cargo.04 and proxy:Cargo.05. This
takes us to the other common error: to name the cargo
spaces wrong. For example, the seat beside the driver
normally is named proxy:jeepCoDriver.01. Then you can't
name the first GL space proxy:Cargo.01: you must name
it proxy:Cargo.02, and the other GL space proxy:Cargo.03.
This way it will ensure the cargo spaces are occupied in the
correct order: first the passenger seat and then the two
GLs places. Another common error is to invert the place
of the two GLs spot. The one nearer to the turret must be
named first, then the other more distant must have a
successive number. This in general, for example the SA-8B
uses four GLs and they're named in a little different fashion:
but in this case the scripts know this and make all the things
work smoothly. Even in the standard MCAR code there's
a sort of check to sort out the GL more nearer to the turret,
but it works because the turret is made in a certain way.
Anyway, if you have placed the GLs the wrong order, you
can realized this because the unit will either explode,
hit by the same missile it's generated via script, or fire
the wrong way: in this case the error is the one just
described above, there can't be any other explanation.