Forum Jump :

Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 59
In-game name: Kobayashi Maru

 
#195109 Posted at 2016-11-10 02:50        
     
Ach Teufel!
There are plenty of engine's behaviors and I don't know why a simple doTarget doFire is for heavy calibers only. You're right. So,I tested a bunch of codes and commands, and here is my 2 cent solution, until anybody can do smarter.

the target (cible) must be at 20m min distance of the AI firing.
In the AI init field (as far as firings start at the beginning of the mission, to the end):
0 = this spawn {  
  while {alive _this} do {  
    _this doTarget cible; 
    sleep 2; 
    if (_this ammo (currentWeapon _this) == 0) then {_this addMagazine currentMagazine _this};
    if ((_this weaponDirection (currentWeapon _this) vectorCos ((position cible) vectorDiff (eyepos _this))) > 0.999 min (0.975 + (0.00024 *(_this distance cible)))) then {
      _this forceWeaponFire [currentWeapon _this,"single"]
    } else {
      _this lookAt cible
    }; 
    sleep 3; 
  }  
}

So, to make it short, a doTarget is OK at start, then, I don't know why, the unit "swings" around the position of the target. The only command re-locking the AI on its target is lookAt. All others fail!.
forceWeaponFire is not sensible (no objective) but you can hit the target waiting for the good direction of the weapon (no problem here with lookAt). I check this good direction with vectorCos. But if you don't want to spill bullets too much at farther distance than 20 m, you must adjust the coef. (2nd part of inequality). It's very sensible between too sharp for firing and bullets spilled. But, as is, I think it does the job up to 100-150 m.
Just select the weapon you want, before running it.
Feel free to improve this code, in any way.

This post was edited by Pierre MGI (2016-11-10 18:00, ago)

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS