Jump to content

Recommended Posts

I've been working on a script the last few days with the aim of spawning an enemy blackfish, having it fly to the nearest player, loiter, and start killing everything in sight. I'm making this for a CTI mission where the players are able to respawn, therefore, I want this thing to be an absolute terror for ground forces until it's destroyed. I've tried several things to make this happen.

I've tried: 

1) Setting the camouflage coefficient of every unit in the mission to "1",

2) Revealing all units to the pilot/group leader,

3) Setting the groups' skills to 1

4) Separating pilot and crew, where the pilot is set to careless and the crew is set to "Terminator" (a separate issue with this occurred where the gunners/crew group would reset its behavior to "hold fire/defend" even though they were set in the script to combat mode "RED". Unable to resolve that issue, I've abandoned separating the groups. Further, even when set back to RED, it isn't any more effective than having them all in one group. The pilot maintains the proper holding pattern either way.

5) Creating a Seek And Destroy waypoint for the gunner/crew group after separating them from the pilot. 

6) Trying to add a "human sensor" to the radar, which is apparently a thing in Arma.                 https://community.bistudio.com/wiki/Arma_3_Sensors

7) Finally I tried setting unit state to "Aware" to see if they would enter "COMBAT" on their own when spotting an enemy, but they will not unless an enemy vehicle is present, and after the vehicle is destroyed, they usually lose all interest in Infantry. This leads me to believe that they, for the most part, just can't see the infantry on the ground, despite my attempts to make them see. Tanoa is the map I'm using for my mission so the buildings/trees/ground clutter is probably hiding most of the targets from the gunners. 

 

Here's the script so far in a mostly working configuration where the plane will spawn, fly to the nearest player, and loiter indefinitely, possibly taking occasional shots at very exposed infantry and vehicles.

 

__________________________________________________________________________________________________________________________________________________

// Spawn a Blackfish to loiter around player and kill any enemies.


_plane = createVehicle [(["B_T_VTOL_01_armed_F"] call BIS_fnc_selectRandom), [11567.8,3199.6,0], [], 0, "FLY"];                              This spawns the blackfish itself with the variable name _plane


_plane addEventHandler ["Fired",{               
    (_this select 0) setVehicleAmmo 1                                                                                    This allows it to have infinite ammo
}];

_pilotguy = [[0,0,0], WEST, ["B_Fighter_Pilot_F","B_Fighter_Pilot_F","B_Fighter_Pilot_F","B_Fighter_Pilot_F"],[],[],[],[],[],232] call BIS_fnc_spawnGroup;
((units _pilotguy) select 0) moveInDriver _plane;
((units _pilotguy) select 1) moveInAny _plane;
((units _pilotguy) select 2) moveInAny _plane;
((units _pilotguy) select 3) moveInAny _plane;
((units _pilotguy) select 0) setSkill ["spotDistance", 1];
((units _pilotguy) select 0) setSkill ["spotTime", 1];                                                                                      This chunk spawns the crew, forces it into the vehicle, and sets their skills and combat mode. group variable name is _pilotguy
((units _pilotguy) select 0) setSkill ["commanding", 1];
((units _pilotguy) select 0) setSkill ["aimingShake", 1];
((units _pilotguy) select 0) setSkill ["aimingSpeed", 1];
_pilotguy setCombatMode "RED";
_pilotguy setBehaviour "COMBAT";

 

private _markerPos = getPos leader _pilotguy;
private _playerList = allPlayers apply {[_markerPos distanceSqr _x, _x]};                        This bit sets up the "nearest player" part
_playerList sort true;
private _closestPlayer = (_playerList select 0) param [1, objNull];

 

_wpcas = _pilotguy addWaypoint [getPos _closestPlayer, 50];
_wpcas setWaypointType "LOITER";
_wpcas setWaypointLoiterRadius 900;
_wpcas setWaypointLoiterType "CIRCLE_L";
_wpcas setWaypointBehaviour "COMBAT";                                                       This sets up the waypoint with various specifications, possibly redundant to set the combat mode here as well
_wpcas setWaypointCombatMode "RED";
_plane flyInHeight 300;
_plane forceSpeed 60;
_pilotguy allowFleeing 0;
{(driver _plane) reveal [_x,4]} forEach allPlayers;                                 revealing all players might be redundant with revealing all units
{(driver _plane) reveal [_x, 4]}foreach allUnits;

 

while {alive _pilotguy} do {
{(_x) foreach allUnits setUnitTrait ["camouflageCoef", 1]};            the goal of this line is to have the units' coefficient revert to normal after the blackfish is destroyed
sleep 10;

_________________________________________________________________________________________________________________________________________________

 

Thanks in advance for any help.

Share this post


Link to post
Share on other sites

Yes, the Blackfish will not engage ground units.

 

A possible workaround could be to spawn an invisible object on the ground unit's position, and have the Blackfish engage the object.  It's not a perfect solution, but may be good enough for your purpose. 

Share this post


Link to post
Share on other sites
5 hours ago, stburr91 said:

Yes, the Blackfish will not engage ground units.

 

A possible workaround could be to spawn an invisible object on the ground unit's position, and have the Blackfish engage the object.  It's not a perfect solution, but may be good enough for your purpose. 

 

I mean it will, just pretty sporadically,  In today's testing, I found that lowering the altitude and loiter radius by 100 helped a bit.

  • Like 1

Share this post


Link to post
Share on other sites

Update: I've managed a workaround where I spawn an invincible UAV above the nearest player to spot infantry for the Blackfish. It seems to work reasonably well. Although I'd like to have the UAV disappear/die when the Blackfish is destroyed

Script as it is now:

 

// Spawn a Blackfish to loiter around player and kill any enemies.


_plane = createVehicle [(["B_T_VTOL_01_armed_F"] call BIS_fnc_selectRandom), [12098.7,-19.4438,200], [], 100, "FLY"];


_plane addEventHandler ["Fired",{
    (_this select 0) setVehicleAmmo 1
}];

_pilotguy = [[0,0,0], WEST, ["B_Fighter_Pilot_F","B_Fighter_Pilot_F","B_Fighter_Pilot_F","B_Fighter_Pilot_F"],[],[],[],[],[],232] call BIS_fnc_spawnGroup;
((units _pilotguy) select 0) moveInDriver _plane;
((units _pilotguy) select 1) moveInAny _plane;
((units _pilotguy) select 2) moveInAny _plane;
((units _pilotguy) select 3) moveInAny _plane;
_plane setskill 1;
_pilotguy setCombatMode "RED";
_pilotguy setBehaviour "COMBAT";


private _markerPos = getPos leader _pilotguy;
private _playerList = allPlayers apply {[_markerPos distanceSqr _x, _x]};
_playerList sort true;
private _closestPlayer = (_playerList select 0) param [1, objNull];


_wpcas = _pilotguy addWaypoint [getPos _closestPlayer, 50];
_wpcas setWaypointType "LOITER";
_wpcas setWaypointLoiterRadius 700;
_wpcas setWaypointLoiterType "CIRCLE_L";
_wpcas setWaypointBehaviour "COMBAT";
_wpcas setWaypointCombatMode "RED";
_plane flyInHeight 200;
_plane forceSpeed 60;
_plane setVehicleRadar 2;
_pilotguy allowFleeing 0;

 

_uav = createVehicle ["B_UAV_01_F", position player, [],0,"fly"];
_droneguy = [[0,0,0], WEST, ["B_Fighter_Pilot_F","B_Fighter_Pilot_F"],[],[],[],[],[],232] call BIS_fnc_spawnGroup;         //spawns a darter drone to spot infantry
((units _droneguy) select 0) moveInAny _uav;
((units _droneguy) select 1) moveInAny _uav;
[_droneguy] join _pilotguy;
_uav allowdamage false;

 

{(driver _plane) reveal [_x,4]} forEach allPlayers;
{(driver _plane) reveal [_x, 4]}foreach allUnits;


while {alive _pilotguy} do {
{(_x) foreach allUnits setUnitTrait ["camouflageCoef", 1]};
sleep 10;

Share this post


Link to post
Share on other sites

For destroying the UAV surely something as simple as this would work:

 

if (!alive _pilotguy) { //or _plane
	_uav allowdamage true; //re-enables damage
	_uav setDamage [1, false]; //Sets it's damage to fully destroyed with no effects played
}

 

  • Like 1

Share this post


Link to post
Share on other sites

If you're using CBA you can add a "Killed" event handler to the blackfish and pass the drone to destroy in the additional arguments. Since in vanilla there is no engine solution to pass additional arguments to an event handler code, something like this would work too:
 

[_plane, _drone] spawn {
	params ["_plane", "_drone"];
	waitUntil {
		sleep 3;
		!alive _plane
	};

	deleteVehicle _drone;
};

EDIT: Regarding your original intent to have the Blackfish shoot stuff, have you tried periodically revealing targets to the gunners? Another, more "rigid" idea would be to (create a game logic at the pos of a desired target and) use fireAtTarget.

Share this post


Link to post
Share on other sites
22 hours ago, runy888 said:

If you're using CBA you can add a "Killed" event handler to the blackfish and pass the drone to destroy in the additional arguments. Since in vanilla there is no engine solution to pass additional arguments to an event handler code, something like this would work too:
 


[_plane, _drone] spawn {
	params ["_plane", "_drone"];
	waitUntil {
		sleep 3;
		!alive _plane
	};

	deleteVehicle _drone;
};

EDIT: Regarding your original intent to have the Blackfish shoot stuff, have you tried periodically revealing targets to the gunners? Another, more "rigid" idea would be to (create a game logic at the pos of a desired target and) use fireAtTarget.

Unfortunately the code didn't work. The drone lives on.

 

I have actually changed the code to reveal units repeatedly. Haven't done anything with game logic as I don't understand it at all, and what I have now works well.

  • Like 1

Share this post


Link to post
Share on other sites
23 hours ago, JulesMK2 said:

For destroying the UAV surely something as simple as this would work:

 


if (!alive _pilotguy) { //or _plane
	_uav allowdamage true; //re-enables damage
	_uav setDamage [1, false]; //Sets it's damage to fully destroyed with no effects played
}

 

unfortunately this code didn't work either. Maybe it has something to do with ace or something.

Share this post


Link to post
Share on other sites
3 hours ago, He'sCalledTheStig said:

unfortunately this code didn't work either. Maybe it has something to do with ace or something.

 

3 hours ago, He'sCalledTheStig said:

Unfortunately the code didn't work. The drone lives on.

 

I have actually changed the code to reveal units repeatedly. Haven't done anything with game logic as I don't understand it at all, and what I have now works well.

Actually I was putting your codes at the end of the script and for whatever reason the script just disregarded them. They work now that I've placed them before "while alive". 
Thanks guys.

  • Like 1

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

×