Forum Jump :

Author Message


Posts: 31
Rank:


Level: Member

Country: be
Location: Flanders
Occupation: student
Age:
In-game name:

 
#1 Posted at 2016-08-29 20:12        
     
So I'm making a shooting range and I wanted some ambient ai shooting popup targets. So I set up an ai on my short range shooting rage, did some scripting and got him to shoot 2 targets with the following commands:

with -ai1 being the ai that's shooting
-target1 and 2 being the popup targets (at about 100m away)
-and he is using the spar 16
This script makes him shoot one and then the other 2 times with different times between the shots.

Then I went to my medium/long range firing range and tried the same thing. Here is the code I used:
with -sniper being the ei that's shooting
-sntg1 and 2 being the popuptargets (about 350-400m away)
-he's using the MAR-10 .338

And here is the problem, the sniper won't fire at the targets that are 350-400m away, he does targets them but doesn't shoot. (He is look from right to left without shooting).

Does anyone know what I should do to make the sniper shoot?

(forgot to mention, I'm not making this in vanilla arma, I'm using CBA, ACE (and 3den enhanced)

This post was edited by gg1gamer (2016-08-30 10:24, 1056 days ago)

If you're going through hell,
keep going! -W. Churchill

Author Message


Posts: 1589
Rank:


Level: Member

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

 
#2 Posted at 2016-08-30 19:17        
     
Try
sniper reveal [sntg1,4];
before doTarget
and increase sleep.

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

Advertisement


Author Message


Posts: 31
Rank:


Level: Member

Country: be
Location: Flanders
Occupation: student
Age:
In-game name:

 
#3 Posted at 2016-08-31 12:29        
     
# Pierre MGI : Try
sniper reveal [sntg1,4];
before doTarget
and increase sleep.

I added that and increased the sleep to 4, but unfortunately it didn't work.

And I found out that it isn't the range that prevents the ai from firing. I placed another ambient unit that is supposed to shoot a pistol at a target 25m away and he doesn't do that either.
(this is the code I used:)
I messed around a bit with other commands (like doFire, and others) but those didn't work either.

And just a little question: is there a script to make the ai have infinite ammo? I don't seem to find it.

If you're going through hell,
keep going! -W. Churchill

Author Message


Posts: 1589
Rank:


Level: Member

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

 
#4 Posted at 2016-09-01 04:47        
     
Infinite shoot at popup target.
Name the popup taget (example: cible)
In init field of the sniper, or thru a trigger (then name the sniper also):

0 = this spawn {
  while {alive _this} do {
  _this removeMagazines (currentMagazine _this);
  _this setAmmo [primaryWeapon _this, 1];
  sleep 3;
  _this doTarget cible;
  _this doFire cible;
  sleep 7
  }
}

These is always one bullet added before the shoot;
the sleep works because there is no more bullet in loaded magazine. If you let 7 bullets, dofire doesn't cope with sleep and the cadence depends on the gun hard coded parameter only.

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

Author Message


Posts: 31
Rank:


Level: Member

Country: be
Location: Flanders
Occupation: student
Age:
In-game name:

 
#5 Posted at 2016-09-01 07:56        
     
# Pierre MGI :
0 = this spawn {
  while {alive _this} do {
  _this removeMagazines (currentMagazine _this);
  _this setAmmo [primaryWeapon _this, 1];
  sleep 3;
  _this doTarget cible;
  _this doFire cible;
  sleep 7
  }
}

Unfortunately none of the ai shoot at anything with this code. They do only have 1 mag in their gun, so that part works :)

If you're going through hell,
keep going! -W. Churchill

Author Message


Posts: 1589
Rank:


Level: Member

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

 
#6 Posted at 2016-09-01 08:53        
     
I tested that in Tanoa airfield with a pop-up target (400 m), a sniper and the player looking at the sequence.
So, don't say that doesn't work! It does. Or you have an addon or a script interfering with this small code.
Verify also, the sniper is in sight of the target. And for your info, setammo to 1 is not for one remaining mag but for one remaining bullet in the current mag. Otherwise, the sniper shoot every 3 seconds approx. Enjoy!

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

Author Message


Posts: 31
Rank:


Level: Member

Country: be
Location: Flanders
Occupation: student
Age:
In-game name:

 
#7 Posted at 2016-09-01 10:54        
     
Great then i'm gonne have to test if it's ace, cba, virtual vehicle spawner or the bullet tracking script (Hypnomatics) that's causing my trouble. My money is on the bullet tracking.

Added 9 minutes later:

Damn, I guessed wrong, it was ACE3 that was causing all the trouble.

Thanks for all the help

This post was edited by gg1gamer (2016-09-01 11:04, 1054 days ago)

If you're going through hell,
keep going! -W. Churchill

Author Message


Posts: 1589
Rank:


Level: Member

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

 
#8 Posted at 2016-09-02 02:28        
     
little improvement. Sleep is now the duration after the target raises.

0 = this spawn {
  while {alive _this} do {
  waitUntil {cible animationPhase "Terc" == 0};
  _time = diag_tickTime;
  sleep 3;
  _this removeMagazines (currentMagazine _this);
  _this setAmmo [primaryWeapon _this, 1];
  _this doTarget cible;
  _this doFire cible;
  waitUntil {cible animationPhase "Terc" == 1 or diag_tickTime > _time + 10};
  }
}

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

Author Message

dtzr  



Posts: 2
Rank:


Level: Member

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

 
#9 Posted at 2016-11-09 17:21        
     
# Pierre MGI : Infinite shoot at popup target.
Name the popup taget (example: cible)
In init field of the sniper, or thru a trigger (then name the sniper also):

0 = this spawn {
  while {alive _this} do {
  _this removeMagazines (currentMagazine _this);
  _this setAmmo [primaryWeapon _this, 1];
  sleep 3;
  _this doTarget cible;
  _this doFire cible;
  sleep 7
  }
}

These is always one bullet added before the shoot;
the sleep works because there is no more bullet in loaded magazine. If you let 7 bullets, dofire doesn't cope with sleep and the cadence depends on the gun hard coded parameter only.


Hi Pierre, thanks for the code.
It works great, except it only seems to work with most weapons 7.62 or above.
Any idea why that could be?
Is there a way to make it work with pistols and smaller rifle calibers?

Sorry if this is a noob question.

I'm using the quoted version of the code because I'm using simple targets.

Thanks.


Author Message


Posts: 1589
Rank:


Level: Member

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

 
#10 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, 984 days ago)

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

Author Message

dtzr  



Posts: 2
Rank:


Level: Member

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

 
#11 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.