Jump to content
Pictou

Force a BLUEFOR tank to shoot a BLUEFOR vehicle.

Recommended Posts

Hello everyone,

I started playing around with the editor and I'm trying to make a Slammer shoot a HMG hunter.

 

I used multiple commands, doFire, fireAtTarget, forceWeaponFire, all work while I'm asking a soldier to shoot another one, but for vehicles it seems that the behaviour is different.

 

How would you do it in a simple way? All I want is to pop two vehicles (slammer + HMG hunter), myself as a player and I want the slammer to shoot the hunter. I stopped trying as everytime I use a while loop, the game crashes.

 

I'm learning to use the editor with videos on youtube and with google, have you got a better way to learn?

 

Thank you.

Share this post


Link to post
Share on other sites

Yup I thought about that, but I would like to force the vehicle to fire, not just bait it. It matters to me that both vehicles are BLUEFOR or both OPFOR.

Share this post


Link to post
Share on other sites

hi,

 

use fire, it should work.

_unit = _this select 0;
_target = _this select 1;

_unit addRating 100000;
 
    while {(alive _target) && (canFire _unit)} do
    {
         _unit doTarget _target;
         waitUntil
         {
            _unit aimedAtTarget [_target] > 0;
            sleep 0.1
        };
         _unit fire (weapons (_unit) select 0);
        sleep 0.25;
    };

cya.

 

Nikiller.

Share this post


Link to post
Share on other sites

Helli Nikiller,

I think I'm using your script the wrong way.

 

Let me describe you what I did so you can point my mistakes.

 

I don't know where to put that script, so I decided to put it in the initialization of the slammer unit named "SLAM1".

The target named HMG1 is set in front of the slammer (SLAM1).

  • I discarded the two first lines as I have an error stating that I'm using global variables in a local statement.
  • I replaced _unit with SLAM1
  • I replaced _target with HMG1

When I do this, and I'm sure it's wrong but I don't know where because of my lack of knowledge, the game never starts and the game crashes (probably because of the while loop).

 

Could you tell me, step by step, what I should do or point me to a website where I could learn what to do with the piece of coding you shared here? Thank you, and sorry but I barely started.

Share this post


Link to post
Share on other sites

hi,

 

have a look here and here it is for ArmA 2 but it works the same in arma 3.

 

You have to copy and paste the script in notepad,

save it as sqf (not txt),

put it in your mission folder (in Documents/arma3/yourName/missions/youMissionFolder)

and execute it in your vehicle's init field with [sLAM1, HMG1] execVM "myScriptName.sqf"

 

cya.

 

Nikiller.

Share this post


Link to post
Share on other sites

Hello nikiller,

Thanks for your help, with the script the vehicle is targeting correctly but still do not fire.

 

Just a correction in case someone tries, code in the init field should be : nameOfVariable=[sLAM1, HMG1] execVM "myScriptName.sqf", otherwise an error Type script, expected nothing occurs.

 

Have you used the command fire before? does it work with vehicles?

Share this post


Link to post
Share on other sites

Remove the waitUntil, it seems aimedAtTarget is not working in this case.

_unit = _this select 0;
_target = _this select 1;

_unit addRating 100000;
 
	while {(alive _target) && (canFire _unit)} do
	{
		_unit doWatch _target;
		_unit fire (weapons (_unit) select 0);
		sleep 0.25;
	};

EDIT:

 

My bad aimedAtTarget works but instead of doTarget you must use doWatch.

 

Try this final version:

//By Nikiller
//31/12/2015
//v1.0
//Force a vehicle to fire on another vehicle
//0 = [unitName, targetName] execVM "scriptName.sqf"

_unit = _this select 0;
_target = _this select 1;
 
    while {(alive _target) && (canFire _unit)} do
    {
        _unit doWatch _target;
        if (_unit aimedAtTarget [_target] > 0) then
        {
	     _unit fire (weapons (_unit) select 0);
        };
        sleep 0.25;
    };

Share this post


Link to post
Share on other sites

Hello nikiller,

Thank you very much for your help, it works perfectly.

 

I would like to add 2 questions on top, really close to this one.

 

For example,

I would like a piece of coding that would make the hunter HMG shoot an infantry. I tried many ways but couldn't find one to work : doFire, fire, forceWeaponFire and finally fireAtTarget that only shot one bullet.

From what I noticed, the fire command allowed the Slam tank to shoot the hunter, and the hunter to shoot the Slam tank, however, the hunter cannot shoot another hunter with the command fire. It seems there is a hierarchy in these commands and I need to use the correct one for each situation, however I can't find any help on the internet as all the solutions proposed do not work for a reason I don't know.

 

The questions are simple :

  • How can I make the hunter shoot another hunter
  • How can I make the hunter shoot an infantry

Note aside, the fire command work with an AT infantry shooting the hunter, but not a rifleman shooting the hunter (probably because he has no AT capability).

 

Thank you again for your help. Happy new year!

Share this post


Link to post
Share on other sites

hi,

 

You will have to modify the script from a single target to an array of targets and then use a function to choose a target in array. The question is how you choose the target? Randomly? Nearest?

 

cya.

 

Nikiller.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×