lethal
Dec 18 2006, 11:53
Over the last few days i have been trying to make myself a believable airstrike via scripts.
two scripts so far (nothing too complex http://forums.bistudio.com/oldsmileys/wink_o.gif ):
demo.sqs
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Targets = _This Select 0;
_Plane = _This Select 1;
_TargetCount = Count _Targets;
_x = 0;
#loop;
if (_x >= _targetcount) then goto "end";
_curTarget = _Targets select _x;
_Trigger = createTrigger ["EmptyDetector", position _curTarget];
_Trigger setTriggerArea [400,400,0,false];
_Trigger setTriggerActivation ["VEHICLE","PRESENT",true];
_Trigger triggerAttachVehicle [_Plane];
_Statement = Format['[%1,%2] exec "launch.sqs"',_curTarget,_plane];
_Trigger setTriggerStatements ["this",_Statement,""];
_x = _x + 1;
goto "loop";
#end;[/QUOTE]
launch.sqs
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Target = _this select 0;;
_Launcher = _this select 1;
_TargetPos = GetPosASL _Target;
_LauncherPos = GetPosASL _Launcher;
_LauncherPos set [2,((_TargetPos Select 2)+300)];
_VectorToTarget = [(_TargetPos Select 0)-(_LauncherPos Select 0),(_TargetPos Select 1)-(_LauncherPos Select 1),(_TargetPos Select 2)-(_LauncherPos Select 2)];
_Bomb = "Bo_GBU12_LGB" createvehicle [0,0,0];
_VelocityX = (_VectorToTarget Select 0)/3.8;
_VelocityY = (_VectorToTarget Select 1)/3.8;
_VelocityZ = (_VectorToTarget Select 2)/3.8;
_Bomb setPosASL _LauncherPos;
_Bomb setVectorDir [_VelocityX,_VelocityY,_VelocityZ];
_Bomb setVelocity [_VelocityX,_VelocityY,_VelocityZ];[/QUOTE]
I am calling demo.sqs with
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[[Impact1,Impact2,Impact3],Harrier1] exec "demo.sqs"[/QUOTE]
Impact1-3 are gamelogics i set up for simulating a ripple of 3 bombs.
Harrier1 is the AV8B overflying the area. Here's it's init field:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this FlyInHeight 400;[/QUOTE];
Now for the questions:
1) is there a formula i can use for determining the correct velocity vector for the bombs? i've been estimating the values which results in them being correct only at one specific launch-height and -distance.
2) i've recently added the second script 'demo.sqs' to enable multiple targets in one single pass. at first only one bomb was fired - after a bit of tinkering i thought i fixed the problem but for some reason there aren't any bombs dropped now and i don't know what the problem is.
ps: i'm pretty tired so it's quite possible that i simply don't see the obvious http://forums.bistudio.com/oldsmileys/wink_o.gif
two scripts so far (nothing too complex http://forums.bistudio.com/oldsmileys/wink_o.gif ):
demo.sqs
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Targets = _This Select 0;
_Plane = _This Select 1;
_TargetCount = Count _Targets;
_x = 0;
#loop;
if (_x >= _targetcount) then goto "end";
_curTarget = _Targets select _x;
_Trigger = createTrigger ["EmptyDetector", position _curTarget];
_Trigger setTriggerArea [400,400,0,false];
_Trigger setTriggerActivation ["VEHICLE","PRESENT",true];
_Trigger triggerAttachVehicle [_Plane];
_Statement = Format['[%1,%2] exec "launch.sqs"',_curTarget,_plane];
_Trigger setTriggerStatements ["this",_Statement,""];
_x = _x + 1;
goto "loop";
#end;[/QUOTE]
launch.sqs
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Target = _this select 0;;
_Launcher = _this select 1;
_TargetPos = GetPosASL _Target;
_LauncherPos = GetPosASL _Launcher;
_LauncherPos set [2,((_TargetPos Select 2)+300)];
_VectorToTarget = [(_TargetPos Select 0)-(_LauncherPos Select 0),(_TargetPos Select 1)-(_LauncherPos Select 1),(_TargetPos Select 2)-(_LauncherPos Select 2)];
_Bomb = "Bo_GBU12_LGB" createvehicle [0,0,0];
_VelocityX = (_VectorToTarget Select 0)/3.8;
_VelocityY = (_VectorToTarget Select 1)/3.8;
_VelocityZ = (_VectorToTarget Select 2)/3.8;
_Bomb setPosASL _LauncherPos;
_Bomb setVectorDir [_VelocityX,_VelocityY,_VelocityZ];
_Bomb setVelocity [_VelocityX,_VelocityY,_VelocityZ];[/QUOTE]
I am calling demo.sqs with
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[[Impact1,Impact2,Impact3],Harrier1] exec "demo.sqs"[/QUOTE]
Impact1-3 are gamelogics i set up for simulating a ripple of 3 bombs.
Harrier1 is the AV8B overflying the area. Here's it's init field:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this FlyInHeight 400;[/QUOTE];
Now for the questions:
1) is there a formula i can use for determining the correct velocity vector for the bombs? i've been estimating the values which results in them being correct only at one specific launch-height and -distance.
2) i've recently added the second script 'demo.sqs' to enable multiple targets in one single pass. at first only one bomb was fired - after a bit of tinkering i thought i fixed the problem but for some reason there aren't any bombs dropped now and i don't know what the problem is.
ps: i'm pretty tired so it's quite possible that i simply don't see the obvious http://forums.bistudio.com/oldsmileys/wink_o.gif