Forum Jump :

Author Message

dtzr  



Posts: 2
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#195201 Posted at 2016-11-17 19:33        
     
# Pierre MGI : 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.

Ah, I wasn't sure if I was just missing some secret. Didn't realise it was just wonky behaviour!

Thanks for the code, great work.