I just want to write a script to simulate HuntIR (it's a grenade for 203 with a camera and you can launch it from 203 and then you can see in a monitor what the camera see, so it's perfect for recon your area). I know HuntIR is the part of ACE mod, but I don't want download a 3 gigabyte mod for this tiny thing. And - first I thought - it's easy to simulate with a script.
The idea is if the player launch a white flare grenade from 203 my script detect it, and when the flare grenade in top of its ballistic line, the script create a camera where the grenade is and targeted to the ground. Easy.
But I missed something or what, because my camera is placed well where the grenade is, but it's targeting to North and not under the grenade.
This is my code:
_ammocount = player ammo "M203Muzzle"; //FlareWhite_M203, M203Muzzle, F_40mm_White
hintsilent format["flare ammo = %1",_ammocount];
if (isNil "_ammocount") exitWith {player sideChat "There is no ammo white flare"};
waitUntil {_ammocount > player ammo "M203Muzzle"};
hintsilent "shoot";
sleep 0.5;
_granat = nearestObject [player,"F_40mm_White"];
_magassag = (getPos _granat) select 2;
sleep 0.2;
//This loop has to be detect the top of the ballistic curve, but it exit a few before the real top
while {_magassag > (getPos _granat) select 2} do {
_magassag = (getPos _granat) select 2;
hintsilent format["alt=%1",_magassag];
sleep 0.1;
};
hintsilent "top";
_sattgt = "Logic" createVehicleLocal [getPos _granat select 0, getPos _granat select 1, -10];
_sattgt setDir 0;
_sattgt setpos [getPos _granat select 0, getPos _granat select 1, 0];
sleep 0.1;
_camera = "camera" camcreate getPos _granat;
_camera cameraeffect ["internal", "back"];
showCinemaBorder false;
//This command has to target under the grenade, but it failed and target to side (to North)
_camera camSetTarget [(getPos _granat) select 0, (getPos _granat) select 1, -10];
_camera camSetFOV 1;
_camera camCommit 0;
_debugx = (getPos _granat) select 0;
_debugy = (getPos _granat) select 1;
_zoominout = 1;
while {((getPos _granat) select 2 > 2)} do {
_camera camSetPos (getPos _granat);
//This command has to target under the grenade, but it failed and target to side (to North)
_camera camSetTarget [(getPos _granat) select 0, (getPos _granat) select 1, 0];
_camera camSetFOV _zoominout;
_camera camCommit 0;
hintsilent format["alt = %1",(getPos _granat) select 2];
waituntil{camCommitted _camera};
};
player cameraEffect ["terminate","back"];
camdestroy _camera;
deletevehicle _sattgt;
camUseNVG false;
(findDisplay 46) displayRemoveAllEventHandlers "KeyDown";
0 fadesound 1;
hintsilent format["here was the grenade x=%1, y=%2",_debugx,_debugy];
I'm absolutely sure the idea is correct, but I just missed a small mistake or typo... Please help me to find it.
And when it's done, I'll have an other problem: because the flare grenade will be too light and will block the view, so I have to be replace it with something. But first I need your help in targeting the camera correctly.