Jump to content
Sign in to follow this  
lockjaw-65-

Spawned vehicle will not fire at enemy?

Recommended Posts

I have a trigger that spawns a ZSU-23 and a script that creates the crew. All works the ZSU-23 will move around and aim at enemy aircraft etc but it just wont fire at them? I have been trying to solve this for days but no effect.

This is the code that creates the ZSU-23.

_spawn = [getmarkerpos "air1", "ZSU_TK_EP1", "aa1",180] execVM "mission1b.sqf";

And this is the code for crew etc (mission1b.sqf)

_spawn_zone = _this select 0;
_veh_type = _this select 1;
_name = _this select 2;
_dir = _this select 3;// new

_group = createGroup east;
_veh = createVehicle [_veh_type, _spawn_zone, [], 0, "NONE"];
_driver = _veh emptyPositions "driver";
_gunner = _veh emptyPositions "gunner";
_commander = _veh emptyPositions "commander";
_cargo = (_veh emptyPositions "cargo") - 1;
if (_driver > 0) then {"TK_INS_Soldier_AR_EP1" createUnit [_spawn_zone, _group, "this moveinDriver _veh;this assignAsDriver _veh;this setskill [""general"",1];"];};
if (_gunner > 0) then {"TK_INS_Soldier_AR_EP1" createUnit [_spawn_zone, _group, "this moveinGunner _veh;this assignAsGunner _veh;this setskill [""general"",1];"];};
if (_commander > 0) then {"TK_INS_Soldier_AR_EP1" createUnit [_spawn_zone, _group, "this moveinCommander _veh;this assignAsCommander _veh;this setskill [""general"",1];"];};
for "_i" from 0 to _cargo do
{
"TK_INS_Soldier_AR_EP1" createUnit [_spawn_zone, _group, "this moveinCargo _veh;this assignAsCargo _veh;"];
};
_veh setdir _dir;// new
_veh SetVehicleVarName _name;
call compile format["%1 = _veh", _name];
_patrol = [_group, getmarkerpos "air1", 10] call bis_fnc_taskPatrol;

Edited by LockJaw-65-
forgot line

Share this post


Link to post
Share on other sites

Hello LockJaw,

have you tried yet to assign the ZSU a waypoint with "fire at will" ? If they still do not fire, maybe they can not see the aircraft ? Put a player role beside the ZSU and observe from first person perspective, if the aircraft can be seen and attacked from where the ZSU is. In addition you cound demand them directly to target and fire using commands like doTarget and doFire with explicit reference to that aircraft object.

Greetings

Share this post


Link to post
Share on other sites

Thanks for response, not sure how to assaign a waypoint and there are so many spawned vehicles in my mission. They can see the aircraft because you can see the guns following them. All the aircraft are randomly spawned so it would also be difficult to reference each one.

Share this post


Link to post
Share on other sites

Do you have any units of that side placed on the map not spawned? if you don't they will not fire at the enemy.

usual practice it to place one with probability of presence set to zero

Share this post


Link to post
Share on other sites

yes I have same side units on map from start. Its strange because as I said you can see the turret following the aircraft but its as if they dont have ammo?

Also I have infantry squads spawn at the same time with AA and they target and attack fine?

Edited by LockJaw-65-

Share this post


Link to post
Share on other sites

I'd say your crew does not board the vehicle because _veh does not exist in the unit init context.

Instead, use _unit = createUnit .... and _unit moveInDriver _veh after executing the createUnit command.

But you say the turret is following the aircraft which would undermine my above statement...

Otherwise perhaps check http://community.bistudio.com/wiki/setFriend

Share this post


Link to post
Share on other sites

The crew boards ok because the vehicle drives around with the turret moving around and tracking any aircraft!! I know this is an odd one and I have not had this problem before. I have tried spawning another vehicle and that does exactly the same???

Share this post


Link to post
Share on other sites

i had this exact problem - spawned vehicles - added gunners etc -all moved the said support weapons around at enemy- but would not fire.

spent ages messing with code, only to find the problem was due to adding the first aid modules - not sure if you have that in your mission. Just something to rule out.

Share this post


Link to post
Share on other sites

Don't add/spawn an AI commander and your ZSU should start firing again.

I might be wrong but I think there's also a CIT ticket for it.

Xeno

Share this post


Link to post
Share on other sites

Does it have ammo?

Another note: Since you're using bis functions anyway, why don't you use BIS_fnc_spawnVehicle?

Share this post


Link to post
Share on other sites

Another note: Since you're using bis functions anyway, why don't you use BIS_fnc_spawnVehicle?

This is a code snippet from my modified BIS_fnc_spawnVehicle/spawnCrew functions:

// Workaround for an ArmA problem
// don't spawn a commander in ZSUs, otherwise they don't fire at targets
// introduced in one of the betas before 1.59
if (_vehicle isKindOf "ZSU_Base") then {
   if (count _thisTurret > 1) then {
       _exitIt = true;
   };
};
if (_exitIt) exitWith {};

:p

Xeno

Share this post


Link to post
Share on other sites

I just tried the code in the first post and it works perfectly.

Share this post


Link to post
Share on other sites
I just tried the code in the first post and it works perfectly.

Thats strange because I have tried over and over but still the same. I was thinking it is conflicting with other scripts as suggested earlier but I have removed the commander position as suggested by Xeno and it works fine now... Cheers Xeno :)

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  

×