Jump to content
Sign in to follow this  
RonnieJ

Problem with detection - 1 unit only

Recommended Posts

Hey guys... im having some problems with detection.

I want an enemy to do a speciel action when he detects one of the players in-game but im not sure how to do this...

I know you can create a detection trigger to look for a speciel unit... but not how to make a single unit look for 10 speciel players s1- s10...

I guess its some on going loop looking fo s1-s10 inlist? or something... really not sure how to do it hehe :P

Share this post


Link to post
Share on other sites

s1 in thisList

P.S. remember to set Activation to Anybody or a specific side!

Edited by JW Custom

Share this post


Link to post
Share on other sites

If the players are in the same group, you can group the trigger to one of the units, which will add extra options in the trigger's settings.

Share this post


Link to post
Share on other sites

Ye but its only one enemy unit that I want to take action when he and he alone detects one of the 10 players... so im not sure thats what I need...

Its because I want the single enemy unit to mark us with a laser and call in an enemy aircraft... that bit is sorted but im not sure how I can make only that unit detect only s1-s10 :S

Share this post


Link to post
Share on other sites
Ye but its only one enemy unit that I want to take action when he and he alone detects one of the 10 players... so im not sure thats what I need...

Its because I want the single enemy unit to mark us with a laser and call in an enemy aircraft... that bit is sorted but im not sure how I can make only that unit detect only s1-s10 :S

Like i said:

s1 in thisList

P.S. remember to set Activation to Anybody or a specific side!

That will make trigger go off if the unit named s1 is inside the trigger area.

s1 in thisList and s2 in thisList

will make trigger go off if the units s1 and s2 is inside the trigger area.

s1 in thisList || s2 in thisList

will make trigger go off if unit s1 or s2 is inside trigger area.

Share this post


Link to post
Share on other sites

JW Custom> that will force the trigger to go off if any of the 100 OPFOR detects any if the s1-s10 units in the trigger but that is not what im asking for! :) I want only 1 of the 100 OPFOR to do something when he and he alone detects s1-s10

Share this post


Link to post
Share on other sites

_unitArray = [s1, s2, s3, s4, s5, s6, s7, s8, s9, s10];
if ({enemyUnit knowsAbout _x > 3} count _unitArray > 0) then {
   hint "player spotted by enemyUnit";
} else {
   hint "enemyUnit hasn't spotted a player yet";
};

That more along the lines of what you're after?

Share this post


Link to post
Share on other sites

Check the Awarness script in my signature, its pretty similar. A trigger is a loop at 0.5 seconds, if you do your own loop you can set it more specific.

Share this post


Link to post
Share on other sites

bhaz> thats perfect! Just what I needed.... thumbs up - thx m8

Share this post


Link to post
Share on other sites

bhaz> if I want an array of enemys as well... how would I do that? if possible...

So I can use this nice code on a couple of guys insted of copy paste for each unit

Share this post


Link to post
Share on other sites
bhaz> if I want an array of enemys as well... how would I do that? if possible...

If it's not important to know who spotted them, then something like this would work:

_unitArray = [s1, s2, s3, s4, s5, s6, s7, s8, s9, s10];
_enemyArray = [enemy1, enemy2, enemy3, enemy4];
_i = 0;
_spotted = 0;

for "_i" from 0 to ((count _enemyArray) - 1) do {
   _spotted = _spotted + ({(_enemyArray select _i) knowsAbout _x > 3} count _unitArray);
};

if (_spotted > 0) then {
   hint "units were spotted";
} else {
   hint "no units were spotted";
};

If you need to know who spotted the player/s:

_unitArray = [s1, s2, s3, s4, s5, s6, s7, s8, s9, s10];
_enemyArray = [enemy1, enemy2, enemy3, enemy4];
for "_i" from 0 to ((count _enemyArray) - 1) do {
   if ({(_enemyArray select _i) knowsAbout _x > 3} count _unitArray > 0) then {
       hint format ["player has been spotted by %1", _enemyArray select _i];
   };
};

Problem is with this one, if a player has been spotted by all enemies, the script will trigger itself once for each enemy.

edit: I haven't actually tested either of these, might go do it now.

edit2: working as intended :) You can also change the number "3" something else to change sensitivity of the script. knowsAbout ranges from 0, being completely unknown to 4, "i'm looking at you".

edit3: You could also use the first script and add the enemies that spotted players to an array:

_unitArray = [p1];
_enemyArray = [e1, e2, e3, e4];
_spottedBy = [];
_i = 0;

for "_i" from 0 to ((count _enemyArray) - 1) do {
   if ({(_enemyArray select _i) knowsAbout _x > 3} count _unitArray > 0) then {
       _spottedBy = _spottedBy + [(_enemyArray select _i)];
   };
};

if (count _spottedBy > 0) then {
   hint format ["Player/s were spotted by: %1", _spottedBy];
} else {
   hint "No players were spotted";
};

For example, if players were spotted by e2 and e4, the hint would display as "Player/s were spotted by: [e2, e4]".

Edited by bhaz
extras

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
Sign in to follow this  

×