1. Place OPFOR tank in front of the BLUFOR player in editor. I used BTR-K Kamysh
2. Name it "tank".
3. Run this code from debug console:
[] spawn {
tank setDir direction player;
tank setVehiclePosition [player modeltoworld [0,30,0], [], 0, "none"];
player reveal [tank, 4];
onEachFrame {
hintsilent format [
"Nearest enemy: %1\nCrew tank: %2",
player findNearestEnemy player,
count crew tank
];
};
sleep 5;
{
moveout _x;
_x setVehiclePosition [player modeltoworld [50,100,0], [], 0, "none"];
} foreach crew tank;
};
The hint will show you that "tank" is detected and is nearest enemy and the crew of the tank is 3
After 5 seconds the crew will be moved out to some 100m away from you and tank, but "tank", while
empty, is still nearest enemy and continues to be one for a long time.
4. Now clear mission and run this code to do exactly the same only with script:
[] spawn {
tank = "O_APC_Tracked_02_cannon_F" createVehicle [0,0,0];
createVehicleCrew tank;
tank setVehicleVarName "tank";
tank setDir direction player;
tank setVehiclePosition [player modeltoworld [0,30,0], [], 0, "none"];
player reveal [tank, 4];
onEachFrame {
hintsilent format [
"Nearest enemy: %1\nCrew tank: %2",
player findNearestEnemy player,
count crew tank
];
};
sleep 5;
{
moveout _x;
_x setVehiclePosition [player modeltoworld [50,100,0], [], 0, "none"];
} foreach crew tank;
};
As soon as crew disembarks, tank is removed from nearest enemy and after a while, if you point
to disembarked crew, one of the crew becomes nearest enemy.