Home   Help Search Login Register  

Author Topic: display enemy units on map  (Read 1992 times)

0 Members and 1 Guest are viewing this topic.

Offline domomo

  • Members
  • *
display enemy units on map
« on: 07 Sep 2007, 19:54:13 »
although units will appear on the map when they are in view, i'd like to make a script so that either specific units appear on the map, or even better, to make all units within a certain distance from the player to appear on the map, thank you

surdus

Offline Cheetah

  • Former Staff
  • ****
Re: display enemy units on map
« Reply #1 on: 07 Sep 2007, 19:59:55 »
Not sure if this is a request (if so, correct board: recruitment lounge). But you could do the following:

Make a trigger (whatever size you need) and keep it follow the player. A global variable should be used to store all of the units inside the radius of the trigger (command: list).

Then make a script which should run as soon as you want enemy units to be present on the map. In the script add markers to new units that weren't in the list previously and update the markers for units already in the list (update every 3 seconds for example). Should do the trick. Don't forget to delete markers of units which aren't on the list.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline domomo

  • Members
  • *
Re: display enemy units on map
« Reply #2 on: 07 Sep 2007, 20:11:39 »
so all the units would have to be defined? i couldnt make the trigger detect an entire side?

Offline Cheetah

  • Former Staff
  • ****
Re: display enemy units on map
« Reply #3 on: 07 Sep 2007, 20:43:31 »
No, you don't have to name all of the units. You'll have to switch the trigger activation to present "OPFOR" (of blufor), repeatly and a timeout of a few seconds. Name the trigger "detectMarkerUnits".

In the condition: true
On activation: markerUnits = list detectMarkerUnits;

This should save the list of people inside the trigger (activating the trigger by being present..) in the variable markerUnits.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline domomo

  • Members
  • *
Re: display enemy units on map
« Reply #4 on: 07 Sep 2007, 21:17:55 »
and then make a marker appear on the global variable 'markerunits'?

Offline Cheetah

  • Former Staff
  • ****
Re: display enemy units on map
« Reply #5 on: 07 Sep 2007, 21:19:50 »
Quote
Then make a script which should run as soon as you want enemy units to be present on the map. In the script add markers to new units that weren't in the list previously and update the markers for units already in the list (update every 3 seconds for example). Should do the trick. Don't forget to delete markers of units which aren't on the list.

With this, you should be able to do it. It is a script which should be run from the beginning of the mission. Creating markers with createMarker, moving them with setMarkerPos and deleting them when required with deleteMarker.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline domomo

  • Members
  • *
Re: display enemy units on map
« Reply #6 on: 07 Sep 2007, 21:29:34 »
thank you

Offline domomo

  • Members
  • *
Re: display enemy units on map
« Reply #7 on: 09 Sep 2007, 02:57:03 »
i've been trying to make this script work now, but all i can get is a single unit to appear on the map.  so far i've got a trigger that follows the player, a global variable keeping tabs and a marker generator, but i cants get more than 1 marker on the map, heres what i have so far:

Code: [Select]
VSP_radarArray = []

#radar
radarTrig1 setPos [getPos player select 0, (getPos player select 1) + 0]
VSP_radarArray = list radarTrig1

_markerNo = random 10
{marker = createMarker [format ["marker_%1",_markerNo], _x]}foreach VSP_radarArray

{marker = createMarker [_markerNo, _x]}foreach VSP_radarArray
_markerNo setMarkerType "dot"

~1

{deletemarker _markerNo}foreach VSP_radarArray

goto "radar"

i know i need some loops inside the loop, but can someone help me fill in the gaps?

surdus
« Last Edit: 09 Sep 2007, 12:52:39 by domomo »

Offline Cheetah

  • Former Staff
  • ****
Re: display enemy units on map
« Reply #8 on: 09 Sep 2007, 10:07:14 »
To start with, replace the goto "loop" at the bottom with, goto "radar".

Might come with further improvements later on.

EDIT: together with domomo (= Surdus Priest) I tried to make the script. However, we ran into a problem. The trigger list (with all the units inside) seems to be updated only once resulting in a lot of errors about stuff not excisting.

See attachment. Ideas?
« Last Edit: 09 Sep 2007, 14:33:32 by Cheetah »
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: display enemy units on map
« Reply #9 on: 12 Sep 2007, 09:55:28 »
Didn't take a look at your script, but here's something that works for me.
It's in sqf because I don't deal in sqs anymore ;)

Code: [Select]
//init the few varibs
_radarArray = [];
_markerArray = [];
_mark = "";

//main loop, active until the player dies
while {alive _this}
 do {
        //keep the trigger at player's position
myRadarTrig setPos (position (vehicle player));
        //get the content of the trigger (player excluded)
_radarArray = (list myRadarTrig)-[vehicle player];

        //if markers present delete them (a very crappy way of making the markers disappear when the detected units are out of trigger range)
if (count _markerArray > 0) then {{deleteMarkerLocal _x} forEach _markerArray};

        //create markers
for [{_i=0},{_i<(count _radarArray)},{_i=_i+1}]
do {
_dname = call {format ["myRadarMarker_%1",_i]};
_mark = createMarkerLocal [_dname,(position (_radarArray select _i))];
_mark setMarkerTypeLocal "Dot";

if (!(_mark in _markerArray)) then {_markerArray = _markerArray + [_mark]};
    };
        //wait a while... and refresh
sleep 3;
    };

//radar.sqf
//by h-

In the missions you need:
- A trigger of desired radius, set off by desired side, activated once.
- Name the trigger, in the script is called myRadarTrig but you can use whatever name you want, just remember to use the correct name in the script

Execute the script from the player's init field either with
Code: [Select]
void=this execVM "radar.sqf"or
Code: [Select]
call {this execVM "radar.sqf"}
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: display enemy units on map
« Reply #10 on: 16 Sep 2007, 16:25:25 »
h-, its perfect, thank you very much :D
Campaigns are hard, I'll stick with scripting for now!