Home   Help Search Login Register  

Author Topic: Anti-Air ammo with time-range fuse  (Read 7839 times)

0 Members and 1 Guest are viewing this topic.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: distance from player to target with sqf?
« Reply #15 on: 14 Feb 2009, 18:58:16 »
i need measuring if angle of weapon is +/- at 10° from angle of target?

Yes, and you might consider also the vertical deviation, so that the target is in the cone of your weapon.

Offline Centerbe

  • Members
  • *
Re: distance from player to target with sqf?
« Reply #16 on: 14 Feb 2009, 19:24:24 »
ohhh now work...
i had divide it for 790.... values showed are plausibles

now i will check the correct target pointings:

I can use weaponDirection command,

_weaponDir = "NDD_Fletcher" weaponDirection "5inch"   // is a vector?
_targetDir = getPosASL _x                                       
_difference = _weaponDir - _targetDir
 if (-50 < _difference < 50) then
         {
                                                                         // target aquisition
          };
« Last Edit: 14 Feb 2009, 20:38:00 by Centerbe »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: distance from player to target with sqf?
« Reply #17 on: 14 Feb 2009, 20:46:47 »
weaponDirection returns a direction vector where, for example, [0,1,0] means north and level [x,y,z].
But your getPosASL is a position. And definitively you cannot get angles, or angle differences substracting a 3D position from a direction vector.

Offline Centerbe

  • Members
  • *
Re: distance from player to target with sqf?
« Reply #18 on: 14 Feb 2009, 20:56:14 »
ok, i can get the weapon direction angle with "getDir" but how get the angle of target relative to the weapon position in rad?

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: distance from player to target with sqf?
« Reply #19 on: 14 Feb 2009, 21:02:11 »
Possibly you could use the command rad.


Planck
I know a little about a lot, and a lot about a little.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: distance from player to target with sqf?
« Reply #20 on: 14 Feb 2009, 21:21:50 »
Why do you want to use rads? All trigonometry functions in ArmA work well with degrees.
And no, you cannot get the weapon direction with getDir, getDir will return the vehicle direction.

Code: [Select]
// Angle to target (between ship and target), between -180 and 180 degrees.
_atarget = ((getPos _target select 0)-(getPos _ship select 0)) atan2 ((getPos _target select 1)-(getPos _ship select 1));
_wvdir = _ship weaponDirection "5inch"; // If 5inch is any weapon ...

// Angle of the weapon, between -180 and 180 degrees.
_aweapon = (_wvdir select 0) atan2 (_wvdir select 1);

Offline Centerbe

  • Members
  • *
Re: distance from player to target with sqf?
« Reply #21 on: 14 Feb 2009, 22:05:29 »
ah, getDir give a direction in degrees not in rad....
so i get 2 Arrays in degree of target and weapon,

_difference = (( _atarget select 0) - (_aweapon  select 0)) atan2 (( _atarget select 1) - (_aweapon  select 1));

 if (( -10 < (_difference select 0) < 10 ) atan2 ( -10 < (_difference select 1) < 10)) then
{
                  // // target aquisition
};



Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: distance from player to target with sqf?
« Reply #22 on: 14 Feb 2009, 22:07:02 »
No, in my example, _atarget is the angle in degrees between the ship and the target, and _aweapon is the angle in degrees of the weapon. None of them is any array, just plain angles.

Offline Centerbe

  • Members
  • *
Re: distance from player to target with sqf?
« Reply #23 on: 14 Feb 2009, 22:34:04 »
i will try the code....

Code: [Select]
  private["_ship", "_trigger", "_planes", "_msg", "_dist", "_target", "_atarget", "_wvdir", "_aweapon", "_diff"];
   _ship = _this select 0;
   _maxrange = 5000;
   _trigger = createTrigger ["EmptyDetector", getPos _ship];
   _trigger setTriggerActivation ["ANY", "PRESENT", false];
   _trigger setTriggerArea [_maxrange, _maxrange, 0, false];
   _trigger setTriggerType "NONE";
   _trigger setTriggerStatements ["this", "", ""];
   _trigger setTriggerTimeout [0, 0, 0, false ];
   Sleep 1;
   while {true} do
   {
      _trigger setPos getPos _ship;
      _planes = [];
      _target = [];
     
      {
         if (_x isKindOf "Air") then
         {
            if ((isEngineOn _x) && (side _x == east)) then
            {
               _planes = _planes + [_x];
               _target = _target + [_x];
            };
         };
      } forEach list _trigger;
                   
        if (count _planes > 0) then
            {
    // Angle to target (between ship and target), between -180 and 180 degrees.
          _atarget = ((getPos _target select 0)-(getPos _ship select 0)) atan2 ((getPos _target select 1)-(getPos _ship select 1));
          _wvdir = _ship weaponDirection "5inch"; // If 5inch is any weapon ...
          // Angle of the weapon, between -180 and 180 degrees.
          _aweapon = (_wvdir select 0) atan2 (_wvdir select 1);
    _diff = (_atarget select 0)-(_aweapon  select 0) atan2 (_atarget select 1) - (_aweapon select 1);
          _msg = "";
         {
             _dist = _x distance _ship;
             _times = _dist / 790;
             _msg = _msg + format["Target:%1 - Range: %2\n", _x, _times];
         } forEach _planes;
         hint format ["%1",_msg];          // show the distances and targets values
      };
      Sleep 0.5;
   };
    [\code]
« Last Edit: 15 Feb 2009, 09:16:05 by Centerbe »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: distance from player to target with sqf?
« Reply #24 on: 14 Feb 2009, 23:55:19 »
This is becoming chaotic and erratic. Please, check the commands and the data types you are using into that script as well as the loops inside as in its current shape it is a nonsense.

BTW, is "5inch" any valid weapon?
Do you have any _target variable initialized?
Why do you check the weapon direction and angle of target inside the first loop instead of the loop where you have the potential planes?
What kind of condition or set or whatever is this??  :blink: :blink: :blink:
Code: [Select]
Set (configFile >> "CfgAmmo" >> "AA" >> "explosionTime") == _times;
Take your time and analyze your script as you didnt do an error but a lot of them.


Offline Centerbe

  • Members
  • *
Re: distance from player to target with sqf?
« Reply #25 on: 15 Feb 2009, 00:19:40 »
i will check all... im sorry
"5inch" is a valid weapon in the cfgWeapons
i have deleted the "Set (configFile >> "CfgAmmo" >> "AA" >> "explosionTime") == _times;" string....

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Anti-Air ammo with time-range fuse
« Reply #26 on: 15 Feb 2009, 10:11:59 »
With the new topic it is a bit clearer what you are trying to do but:
- Is this intended for players firing the guns manually?
- If yes, are the targets going to be formations of very slow flying bombers?

Because if you try to fire with this idea against an incoming 800km/h Su34, when you detect it, lets say at 3Km you may calculate the range, the muzzle velocity of the shell and conclude that you need to have a 1.5 seconds timed fuse based only on range to target and muzzle vel. But in 1.5 seconds the Su34 is 333m closer to your ship. So, in fact, your shell will explode too late even if the shell was fired considering an interception course.

Offline Centerbe

  • Members
  • *
Re: Anti-Air ammo with time-range fuse
« Reply #27 on: 15 Feb 2009, 12:33:02 »
Hi mandoble,

Yes players can fire manually.

The addon is a WW2 Fletcher Destroyer with; 5 turrets with 5inch cannon (also anti air, with radar range shells time), 4 turrets with double 40mm bofors cannons (primary anti air), and 8 turrets with 20mm anti air machine guns.

The enemy planes will be the same planes of ww2 with relative low velocity and agility....
in numerous test, i have used the germans BF109 as enemy targets.
I had do many test, and in all of this the gunners AI can anyway (low, around 5-10%) hit planes without any explosive ammo, simple with direct hit of shells.

I have do other tests with explosive shells with a explosionTime ammo set up.... they hit planes perfectly an realistic look smoke explosion on air, explosion was at determinate range and relative times (example 0.5-2 sec).

Now this anti-air shell work fine with a simple determinate explosiontime valor, if this srcipt will work i think i will rename this as "Mando Anti-Air Explosive Shells".

A script question; why have you make a new _target variable and you havent use the previous _x variable for targets? I have modifield script, deleted bad strings, put targets discriminations is into the second loop and initialized _target as _x. But i have the same an error on _difference string.
« Last Edit: 15 Feb 2009, 13:10:36 by Centerbe »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Anti-Air ammo with time-range fuse
« Reply #28 on: 15 Feb 2009, 12:40:03 »
Might be this can be of some help for you.

Offline Centerbe

  • Members
  • *
Re: Anti-Air ammo with time-range fuse
« Reply #29 on: 15 Feb 2009, 12:58:14 »
I had just see your gun script, but it shoot at planes with defined dispersion of shells....!?

I dont want increase the direct target hit probably of this weapons.

In this case weapons dont hit the planes increasing the hit target probability, but more WW2 realistic with a explosion of shells at given range.... also if targets arent hitted directly but simple in proximity. The AI gunners will aiming normally the targets as well they can. Shells are explosives (it give a realistic explosion on air in any case), and explodes at a given range (time in script).

This idea born from the constatation that much real WW2 ammo, use a time fuse shells (see a WW2 movie)... and in some case, time of fuse was setting up by the radar rangefinder in general, by ship radar in this case.

This is different also from proximity range explosion fuse, because proximity fuse explode only if they will be near the targets.... but for ww2 realistic shells they must explodes anyway.

For your questions; the fact is i neednt a precise time-range valutation of all targets, because in real it wasnt much precise, but works fine the same. The probably of shoot down a target is the sum of a direct hit explosion and an indirect explosion at a given range.
« Last Edit: 15 Feb 2009, 13:27:21 by Centerbe »