SPhoenix
Jun 29 2007, 21:50
Hi everyone!
With the help of 5133p39 I created this script.
It uses the function nearTargets (http://community.bistudio.com/wiki/nearTargets) to list all the enemies a unit knows about in a given range.
And then it creates a red dot on the map to mark its last known location.
Here is the code:
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private ["_i","_m","_oldI"];
_oldI = 0;
while {true} do {
Array01 = P01 nearTargets 100;
Array02 = P02 nearTargets 100;
Array03 = P03 nearTargets 200;
Array04 = P04 nearTargets 100;
Array05 = P05 nearTargets 200;
Array06 = P06 nearTargets 200;
Array07 = P07 nearTargets 100;
ArrayEnnemis = [Array01, Array02, Array03, Array04, Array05, Array06, Array07];
_i = 0;
{
{
CampEnnemi = _x select 2;
if (CampEnnemi == east) then {
_m = format ["mark%1", _i];
// create marker if _m not exists, otherwise only setpos the existing one
if ((getMarkerPos _m) select 0 == 0) then {
_m = createMarker [_m, _x select 0];
_m setMarkerShape "ICON";
_m setMarkerType "Dot";
_m setMarkerColor "ColorRed";
} else {
_m setMarkerPos (_x select 0);
};
_i = _i + 1;
};
} forEach _x;
} forEach ArrayEnnemis;
// delete markers of old, forgotten targets
while {_oldI >= _i} do {
_m = format ["mark%1", _oldI];
if ((getMarkerPos _m) select 0 != 0) then {
deleteMarker _m;
};
_oldI = _oldI - 1;
};
_oldI = _i;
sleep 30;
};[/QUOTE]
This script is called once for the whole mission and is used once for all the units you want (no need to multiply the utilisation of this script, just set up one trigger and you're good to go).
As is, this script is used with US units to report SLA units.
You can change it through the CampEnnemi variable, set it to be equal to west or guer.
You can always change, as well, the marker shape and color.
This way you will be able to use the script for both sides.
You can easily customize the range of the nearTargets function to suit your needs at the beginning of the script.
The P01, .. , P07 are variables attached to units.
If you want the script to report the enemies spotted by a whole group, you can just name one of the units in the group, like the group leader, and use the script on him.
Note the "sleep 30" at the end of the script: it is used to renew the markers every 30 seconds.
The markers are updated, and therefore you won't see the movement of the enemy as time passes.
Feel free to customize this script as much as you want - it's all yours!
Happy playing and happy editing to everyone http://forums.bistudio.com/oldsmileys/smile_o.gif
PLEASE NOTE: the script is in sqf syntax. You need to call it with execVM (http://community.bistudio.com/wiki/execVM).
Kindly
SPhoenix
With the help of 5133p39 I created this script.
It uses the function nearTargets (http://community.bistudio.com/wiki/nearTargets) to list all the enemies a unit knows about in a given range.
And then it creates a red dot on the map to mark its last known location.
Here is the code:
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private ["_i","_m","_oldI"];
_oldI = 0;
while {true} do {
Array01 = P01 nearTargets 100;
Array02 = P02 nearTargets 100;
Array03 = P03 nearTargets 200;
Array04 = P04 nearTargets 100;
Array05 = P05 nearTargets 200;
Array06 = P06 nearTargets 200;
Array07 = P07 nearTargets 100;
ArrayEnnemis = [Array01, Array02, Array03, Array04, Array05, Array06, Array07];
_i = 0;
{
{
CampEnnemi = _x select 2;
if (CampEnnemi == east) then {
_m = format ["mark%1", _i];
// create marker if _m not exists, otherwise only setpos the existing one
if ((getMarkerPos _m) select 0 == 0) then {
_m = createMarker [_m, _x select 0];
_m setMarkerShape "ICON";
_m setMarkerType "Dot";
_m setMarkerColor "ColorRed";
} else {
_m setMarkerPos (_x select 0);
};
_i = _i + 1;
};
} forEach _x;
} forEach ArrayEnnemis;
// delete markers of old, forgotten targets
while {_oldI >= _i} do {
_m = format ["mark%1", _oldI];
if ((getMarkerPos _m) select 0 != 0) then {
deleteMarker _m;
};
_oldI = _oldI - 1;
};
_oldI = _i;
sleep 30;
};[/QUOTE]
This script is called once for the whole mission and is used once for all the units you want (no need to multiply the utilisation of this script, just set up one trigger and you're good to go).
As is, this script is used with US units to report SLA units.
You can change it through the CampEnnemi variable, set it to be equal to west or guer.
You can always change, as well, the marker shape and color.
This way you will be able to use the script for both sides.
You can easily customize the range of the nearTargets function to suit your needs at the beginning of the script.
The P01, .. , P07 are variables attached to units.
If you want the script to report the enemies spotted by a whole group, you can just name one of the units in the group, like the group leader, and use the script on him.
Note the "sleep 30" at the end of the script: it is used to renew the markers every 30 seconds.
The markers are updated, and therefore you won't see the movement of the enemy as time passes.
Feel free to customize this script as much as you want - it's all yours!
Happy playing and happy editing to everyone http://forums.bistudio.com/oldsmileys/smile_o.gif
PLEASE NOTE: the script is in sqf syntax. You need to call it with execVM (http://community.bistudio.com/wiki/execVM).
Kindly
SPhoenix