Jump to content
Sign in to follow this  
tinter

Getting tanks to fire cannon at infantry

Recommended Posts

As it says in the title, it would be nice to know if there's some way to get tanks to fire main gun at infantry, even if it's just a looping script. As of now I haven't even been able to find a script that makes them fire their main gun at all, with or without a target.

Share this post


Link to post
Share on other sites

the fire command allows you to force an AI to fire a specific weapon and blah blah blah

--Edit

forceWeaponFire seems to be a better option

Edited by Lala14

Share this post


Link to post
Share on other sites

How do you get the classname of a main gun from a modded tank?

Share this post


Link to post
Share on other sites

Use the config viewer in the editor. You can also retrieve weapons dynamically via script if you know the config structure.

Share this post


Link to post
Share on other sites
As it says in the title, it would be nice to know if there's some way to get tanks to fire main gun at infantry, even if it's just a looping script. As of now I haven't even been able to find a script that makes them fire their main gun at all, with or without a target.

Have you tried attaching an enemy car to the target unit then do a deleteCollection?

Share this post


Link to post
Share on other sites

isnt deleteCollection just hideObject?

anyway there was posted there on the foreWeaponFire page about dynamically getting the weapon by ffur2007slx2_5

_weapon = (weapons _veh) select 3;
_mode = (getarray (configfile >> "cfgweapons" >> _weapon >> "modes")) select 0;
if (_mode == "this") then {_mode = _weapon;};
(driver _veh) forceWeaponFire [_weapon, _mode];
//Force a CAS fire a rocket.

we could modify this with the "modded" tank value by doing

_veh = _this select 0; //or we could do a if (vehicle player != player) then { _veh = vehicle player;
_weapon = (weapons _veh) select 0; //select Cannon
_mode = (getarray (configfile >> "cfgweapons" >> _weapon >> "modes")) select 0;
if (_mode == "this") then {_mode = _weapon;};
(gunner _veh) forceWeaponFire [_weapon, _mode];
//Force cannon to fire which for tanks is usually the first weapon which would be 0.

Edited by Lala14

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
Sign in to follow this  

×