Author Topic: All Visibility Script  (Read 1005 times)

0 Members and 1 Guest are viewing this topic.

Offline ZachHox

  • Members
  • *
All Visibility Script
« on: 01 Feb 2010, 12:31:58 »
Hi guys.

I was hoping someone could help me making a All Visibility script. Which will reveal all units and players on the map. And marks the infantry with a little dot.
I figured to use a trigger, like an "WholeWorld" trigger covering the entire map and than have it reveal or track kinda all units.
I would use than 4 triggers for 4 sides, or however many are used in the mission.

That is the first part which on its own would be enough. But for the second part I would like have it track units and assign them with custom markers, dots, diamond, APC, armored vehicles, planes, choppers and tanks.

And something CPU friendly because it is to be used for a large range and variety of missions like evolution, warfare and custom missions.

« Last Edit: 04 Feb 2010, 12:27:37 by ZachHox »

Offline Wolfrug

  • Addons Depot
  • Administrator
  • *****
  • Official OFPEC Old Timer
Re: All Visibility Script
« Reply #1 on: 04 Feb 2010, 12:36:59 »
This is not a simple script I'm afraid. I think you should try to open up an Evolution mission or somesuch and see how their scripts work, rather than doing one from zero. Especially if it's to be MP-compatible (which I know very little about).

Anyway, attached is a script I've used to track units, called:

groupName execvm "trackUnits.sqf"

With a bit of editing it could work with something like what you suggested, i.e. a "whole world" trigger. Original script also has stuff you don't want, so if we remove that...for instance like this:

(called (list WholeWorld) execvm "trackUnits.sqf")

Code: [Select]
// Simple script that tracks all units of a group on the map, showing their locations with a little marker. Also allows for several different modes: i.e., green for healthy, yellow for wounded, red for incapacitated, black for dead. By Wolfrug @ OFPEC for HWM mission pack.

_grp = _this;

//How often does the script update?
_waitTime = 0.5;

//What markers are used for the soldiers?
_sMarkerType = "Select";

//What size are the markers?
_sMarkerSize = [0.4, 0.4];

//Marker color array - 0 = healthy, 1 = wounded, 2 = incapacitated, 3 = dead
_sMarkerColors = ["ColorGreen", "ColorYellow", "ColorRed", "ColorBlack"];

//Show unit numbers next to their markers?
_sShowNumbers = false;

//Create markers for each group member and put them into an array
_AllMarkersAndUnits = [];
_mrk = createMarkerLocal [(str(_grp find _x) + "RUG_TrackUnits"), getpos _x];
_mrk setMarkerTypeLocal _sMarkerType;
_mrk setMarkerSizeLocal _sMarkerSize;
_mrk setMarkerColorLocal (_sMarkerColors select 0);
if (_sShowNumbers) then {_mrk setMarkerTextLocal (str(units _grp find _x))};
_AllMarkersAndUnits = _AllMarkersAndUnits + [_mrk, _x];
} forEach _grp;

//hint format ["%1", _AllMarkersAndUnits];
// Start looping script
while {{alive _x} count _grp > 0} do
_i = 0;
// Actual updating of markers
while {count _AllMarkersAndUnits > _i} do
_curMrk = _AllMarkersAndUnits select _i;
_curUnit = _AllMarkersAndUnits select (_i + 1);
_curMrk setMarkerPosLocal [getpos _curUnit select 0, getpos _curunit select 1];
if (!alive _curUnit) then {_curMrk setMarkerColorLocal (_sMarkerColors select 3)};
//hint format ["%1, %2, %3", _curMrk, _curUnit, getMarkerColor _curMrk];
_i = _i + 2;
sleep _waitTime;

Original code attached (although I only changed a few things).

Not MP compatible, and not CPU-friendly.

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"