Post by Sa8Gecko on Oct 30, 2004 12:20:31 GMT -5
This guide will hopefully teach you the basic to understand
how to create your own AT missile and modify the parameters in
the script.
First, the O2 editing part is intentionally left out: if you don't
know how to model a missile, search for some tutorial on the net.
Config.cpp
You must define a bullet, that will be the actual ammo fired by
your vehicle, which has about the same hitting performances as
your intended missile: look at how's done in MCAR:
cfgAmmo:
You can just copy the code above in your config.cpp. Just change
the class name. As you can see it has no sound, no tracer, no
explosive, just enough hitting power to make the AI fire it at tanks.
Then you must define the 'real' missile (the one you want to
show up in game): this is how's done in MCAR:
minRange,midRange and so on are not significative, and can be omitted. Same
thing for irlock and laserlock. The important things are initTime and thrust
(and thrusTime, leave it at 20, even if the engine will not burn for more
than 10 seconds). Thrust must be very low, to evitate to spoil the missile
trajectory. And initTime should be around 0, so the missile engine will always
appear light.
If you need the missile to light the engine after a certain amount of time,
you should define another missile the same as your own, with the chosen
initTime, and instruct the scripts when to change it with the 'normal'
(engine always on) one. Fortunately this is far from difficult, even because
it's already provided for in the scripts. Take for example fired3.sqs:
The first line contains the type of missile that will be launched. You can
see it's named "..fake", for a reason: the tow missile arms its warhead
when it's about 70 meters from the shooting vehicle. So before reaching
this distance it will do little damage. We defined this missile has having
low hit power, and with the engine off, so that in the initial phase it
will simulate properly the real tow missile. When the missile has reached
more than 60 meters from the shooter, it gets substituted with the proper
one:
Seen ? not difficult. You just need to change the type names with your own.
cfgWeapons
You must define a weapon just for the bullet: the missiles won't need it.
above is how's done in MCAR. As you can see this weapon uses the
bullet defined above as ammo. Keep burst = 0 to fire a bullet a time.
The important thing here it's initspeed: set it at least high as above
(fifteen thousands meters/second) so that the AI won't put any lead
on the target.
Done, remember to add this weapon on the vehicle (cfgVehicle).
Also, the tow2a real and tow2b real can record kills (not 100%
accurate, but on low lag environment it works well).
How's done this ? Well, in cfgAmmo is defined another bullet,
having the same missile (the one you want to appear in game)
parameters as regard hitting power.
Then a weapon is defined that will fire that bullet. Don't worry,
it won't show up in game. The only thing left to do is to add
a magazine of this weapon (one magazine = only one single shot)
to the magazines of the vehicle. Don't add the weapon, so it won't
show up in game.
At the right time, when the missile is very near the target, the
scripts add this weapon to the unit, make it fire a shot, remove
the weapon and re-add a magazine. The player doesn't realize it
(at night it could see the light of the weapon firing, but won't
see anything else). The Fired event handler will take this bullet
and store it in a safe place. When the missile is very very near
the target, this bullet is substituted in place of the missile
and does (hopefully, it could miss) the kill, that will be registered
on the Stats sheet.
In this case, that is you want kills to be recorded, you must instruct
properly the fired EH not to delete this bullet; here's how's done
in MCAR:
(the 'else' part). You can see that only the bullet fired intentionally by
the player or AI, that represents the missile, is deleted. So modifing a
little this code and it's purpose you can make a BTR-90 with missiles and
30mm cannon.
scripts
You must obviously modify the scripts so that they contain the reference
to your own missile types. Do a search with Windows looking for MCAR
missile types in *.sqs and *.sqf files and replace the occurrences when
necessary.
Then you may wish to choose a particular guidance code: the scripts
have some, if you don't want to write your own.
- guidMis_2.sqs is a terrain following guidance code, that is the missile
will follow terrain contour (not very realistic), flying about 2 meters
above ground.
- guidMis_3.sqs is similar to the BIS standard one, but it's not lead
collision, is lead-pursuit. This is more realistic than the previous one.
The missile can be guided manually if or until a target is not found.
- guidMis_4.sqs is also terrain following, but the missile flies 20 m above
ground.
- gudMis_7.sqs is completely hand guided to the target. It will only lock
on target when this is less than 100 meters from the missile: this to help
the AI hitting the target. It is also the script that permits kills to be
registered. This also means that you can't target a vehicle 1000 meters
away and then go to hide, or move, as you have to keep (realistically) the
crossair on the target to hit it. This script is used by the real tow2a and
tow2b missiles.
In guidMis_2.sqs and guidMis_4.sqs missile speed is calculated in a very simple,
although unrealistic, way. The advantage of guidMis_4.sqs above guidMis_2.sqs
is that speed is calculated with time, that is the result will be equal on
all sytem tested, where in guidMis_2 would be not. But it's easy to move
this part of the code:
to guidMis2.sqs, putting '_misTime = _time' at script start.
GuidMis_3.sqs and guidMis_7.sqs use a realistic, although a little simplified,
speed curve. In towspeed.sqf is defined an array: the even members are the
initial speed, in a two second cycles, of the missile, the odd members the
accelerations in the same 2 seconds cycle (keep in mind that array indexes
start with 0). So, for example, if this array is written this way:
this means that from 0 to 2 sec the missile speed will raise from 70 to 280 with an
acceleration of 105 m/s^2, while from 2 to 4 sec it will descend from 280 to 230
with a de-celeration of 25 m/s^2, and so on.
You can use this speed curve or make your own if you have the proper one
for your missile.
Well, the basic should be covered: put your questions below,if you have any.
how to create your own AT missile and modify the parameters in
the script.
First, the O2 editing part is intentionally left out: if you don't
know how to model a missile, search for some tutorial on the net.
Config.cpp
You must define a bullet, that will be the actual ammo fired by
your vehicle, which has about the same hitting performances as
your intended missile: look at how's done in MCAR:
cfgAmmo:
class BulletSingle: Default {};
class Bullet7_6: BulletSingle {};
class Bullet12_7: Bullet7_6 {};
class psy_mcar_dummyTow: Bullet12_7
{
airLock=1;
hit=1500;
indirectHit=100;
indirectHitRange=.5;
minRange=100;
minRangeProbab=.7;
midRange=1500;
midRangeProbab=0.9;
maxRange=3500;
maxRangeProbab=0.8;
soundHit[]={"",0,1};
soundHitMan[]={"",0,1};
soundHitArmor[]={"",0,1};
soundHitBuilding[]={"",0,1};
soundFly[]={"",0.010000,2};
soundEngine[]={"",0.001000,1};
explosive=0;
initTime=-1.000000;
cost=1000;
tracerColor[]={0,0,0,0.001};
visibleFire=32
audibleFire=32
visibleFireTime=20
};
You can just copy the code above in your config.cpp. Just change
the class name. As you can see it has no sound, no tracer, no
explosive, just enough hitting power to make the AI fire it at tanks.
Then you must define the 'real' missile (the one you want to
show up in game): this is how's done in MCAR:
class psy_mcar_tow2a: AT3
{
hit=1000;
indirectHit=250;
indirectHitRange=2.500000;
minRange=50;
minRangeProbab=0.500000;
midRange=600;
midRangeProbab=0.950000;
maxRange=2500;
maxRangeProbab=0.500000;
maxSpeed=300;
cost=20000
model="\psy_mcar_ammo\tow2a\psy_mcar_tow2a";
airlock=0;
irLock=1;
laserLock=1;
manualControl=0;
maxControlRange=100000;
maneuvrability=20.000000;
initTime=0.050000;
thrustTime=20;
thrust=10;
soundFly[]={"\psy_mcar_sound\psy_mcar_rocketfly.wav",db12,2};
};
minRange,midRange and so on are not significative, and can be omitted. Same
thing for irlock and laserlock. The important things are initTime and thrust
(and thrusTime, leave it at 20, even if the engine will not burn for more
than 10 seconds). Thrust must be very low, to evitate to spoil the missile
trajectory. And initTime should be around 0, so the missile engine will always
appear light.
If you need the missile to light the engine after a certain amount of time,
you should define another missile the same as your own, with the chosen
initTime, and instruct the scripts when to change it with the 'normal'
(engine always on) one. Fortunately this is far from difficult, even because
it's already provided for in the scripts. Take for example fired3.sqs:
...
_misType = "psy_mcar_tow2aFake"
? typeOf _vS == "psy_mcar_hmmwv_tow2bReal": _misType = "psy_mcar_tow2bFake"
_MCOP = _this select 2
[_MCOP,_ammovel] call PSY_MCAR_smokerAT
_realmissile = [_shooter,_MCOP,_velmod,_misType] call PSY_MCAR_launchAT
The first line contains the type of missile that will be launched. You can
see it's named "..fake", for a reason: the tow missile arms its warhead
when it's about 70 meters from the shooting vehicle. So before reaching
this distance it will do little damage. We defined this missile has having
low hit power, and with the engine off, so that in the initial phase it
will simulate properly the real tow missile. When the missile has reached
more than 60 meters from the shooter, it gets substituted with the proper
one:
...
?(_realmissile distance _shooter) <60: goto "loop"
_misType = "psy_mcar_tow2a"
? typeOf _vS == "psy_mcar_hmmwv_tow2bReal": _misType = "psy_mcar_tow2b"
_realmissile = [_realmissile,_misType] call PSY_MCAR_subs
...
Seen ? not difficult. You just need to change the type names with your own.
cfgWeapons
You must define a weapon just for the bullet: the missiles won't need it.
class MGun: Default {};
class MachineGun7_6: MGun {};
class MachineGun12_7: MachineGun7_6 {};
class psy_mcar_tow2aLauncher: MachineGun12_7
{
ammo="psy_mcar_dummyTow";
displayName="TOW 2A";
magazine="TOW 2A BLII";
displayNameMagazine="TOW 2A";
shortNameMagazine="TOW 2A";
count=7;
soundContinuous=0;
dispersion=0.00;
maxLeadSpeed=1250;
ffCount=1;
autoFire=1;
multiplier=1;
burst=0;
aiRateOfFire=37.5;
aiRateOfFireDistance=3750;
autoReload=1;
canlock =2;
initSpeed=15000;
flash="gunfire";
flashSize=1.000000;
magazines[]={"psy_mcar_tow2aLauncher","psy_mcar_tow2bLauncher"};
sound[]={"\psy_mcar_sound\psy_mcar_towshot.wav",db7,1};
reloadSound[]={"\psy_mcar_sound\psy_mcar_towreload.wav",db-75,0};
PSY_MCAR_RAN_RELOAD_SHOT_TOW;
};
above is how's done in MCAR. As you can see this weapon uses the
bullet defined above as ammo. Keep burst = 0 to fire a bullet a time.
The important thing here it's initspeed: set it at least high as above
(fifteen thousands meters/second) so that the AI won't put any lead
on the target.
Done, remember to add this weapon on the vehicle (cfgVehicle).
Also, the tow2a real and tow2b real can record kills (not 100%
accurate, but on low lag environment it works well).
How's done this ? Well, in cfgAmmo is defined another bullet,
having the same missile (the one you want to appear in game)
parameters as regard hitting power.
Then a weapon is defined that will fire that bullet. Don't worry,
it won't show up in game. The only thing left to do is to add
a magazine of this weapon (one magazine = only one single shot)
to the magazines of the vehicle. Don't add the weapon, so it won't
show up in game.
At the right time, when the missile is very near the target, the
scripts add this weapon to the unit, make it fire a shot, remove
the weapon and re-add a magazine. The player doesn't realize it
(at night it could see the light of the weapon firing, but won't
see anything else). The Fired event handler will take this bullet
and store it in a safe place. When the missile is very very near
the target, this bullet is substituted in place of the missile
and does (hopefully, it could miss) the kill, that will be registered
on the Stats sheet.
In this case, that is you want kills to be recorded, you must instruct
properly the fired EH not to delete this bullet; here's how's done
in MCAR:
...
fired = "if ((_this select 4) == ""psy_mcar_dummyTow"") then {deleteVehicle (nearestObject [_this select 0, _this select 4]);[_this select 0, _this select 4] exec ""\psy_mcar_scripts\at\PSY_MCAR_getAmmo_3.sqs""}else{[_this select 0, _this select 4,4000] call PSY_MCAR_realbullet;};";
...
(the 'else' part). You can see that only the bullet fired intentionally by
the player or AI, that represents the missile, is deleted. So modifing a
little this code and it's purpose you can make a BTR-90 with missiles and
30mm cannon.
scripts
You must obviously modify the scripts so that they contain the reference
to your own missile types. Do a search with Windows looking for MCAR
missile types in *.sqs and *.sqf files and replace the occurrences when
necessary.
Then you may wish to choose a particular guidance code: the scripts
have some, if you don't want to write your own.
- guidMis_2.sqs is a terrain following guidance code, that is the missile
will follow terrain contour (not very realistic), flying about 2 meters
above ground.
- guidMis_3.sqs is similar to the BIS standard one, but it's not lead
collision, is lead-pursuit. This is more realistic than the previous one.
The missile can be guided manually if or until a target is not found.
- guidMis_4.sqs is also terrain following, but the missile flies 20 m above
ground.
- gudMis_7.sqs is completely hand guided to the target. It will only lock
on target when this is less than 100 meters from the missile: this to help
the AI hitting the target. It is also the script that permits kills to be
registered. This also means that you can't target a vehicle 1000 meters
away and then go to hide, or move, as you have to keep (realistically) the
crossair on the target to hit it. This script is used by the real tow2a and
tow2b missiles.
In guidMis_2.sqs and guidMis_4.sqs missile speed is calculated in a very simple,
although unrealistic, way. The advantage of guidMis_4.sqs above guidMis_2.sqs
is that speed is calculated with time, that is the result will be equal on
all sytem tested, where in guidMis_2 would be not. But it's easy to move
this part of the code:
...
_speed = 50 + (60* (_time - _misTime))
? _speed > 200: _speed = 200
...
to guidMis2.sqs, putting '_misTime = _time' at script start.
GuidMis_3.sqs and guidMis_7.sqs use a realistic, although a little simplified,
speed curve. In towspeed.sqf is defined an array: the even members are the
initial speed, in a two second cycles, of the missile, the odd members the
accelerations in the same 2 seconds cycle (keep in mind that array indexes
start with 0). So, for example, if this array is written this way:
_velArray = [70,105,280,-25,230,-12.5,205,-12.5,180,-7.5,165,-7.5,150,-5,140,-5,130,-5,120,-5,112,-4,104,-4];
this means that from 0 to 2 sec the missile speed will raise from 70 to 280 with an
acceleration of 105 m/s^2, while from 2 to 4 sec it will descend from 280 to 230
with a de-celeration of 25 m/s^2, and so on.
You can use this speed curve or make your own if you have the proper one
for your missile.
Well, the basic should be covered: put your questions below,if you have any.