Jump to content
Sign in to follow this  
scifer

Enemy detection sensor

Recommended Posts

How do I make a sensor, in script, which performs an action when the player detects enemies?

Share this post


Link to post
Share on other sites

Place trigger, set it to "detected by east/west/res" and syncronize it with the unit that is to be detected. In the trigger you can futher define whats happening after activation.

Share this post


Link to post
Share on other sites
syncronize it with the unit that is to be detected.

Thanks for answering me Beagle :)

For this purpose you do not syncronize triggers with units, you group it.

And I asked how to do it in script not in editor.

Share this post


Link to post
Share on other sites

This will get the objects of land, air, man and check if they are same side as _enemyside wich here is east, can be changed ofc.

And if player knowsabout them, means he has identified them as 100% enemy the code will execute for each of the enemys player knowsabout within this 500 meters., if you use a variable way in the <Do your actions here>, you can set a code or action to execute after the foreach line.

_enemySide = east;
_nearTargets = (getPos  player) nearObjects ["AllVehicles",500];
{
  if ( (player knowsabout _x) == 4 AND (side _x) == _enemySide ) then {
     <Do your actions here for each known enemys spotted by player>
  };
} foreach _nearTargets;

one action is done after any enemys is detected:

_enemySide = east;
_foundEnemys = false;
_nearTargets = (getPos  player) nearObjects ["AllVehicles",500];
{
  if ( (player knowsabout _x) == 4 AND (side _x) == _enemySide ) then {_foundEnemys=true};
} foreach _nearTargets;
if (_foundEnemys) then {
  <do your one action here if any enemys was detected by player>
};

Edited by Demonized
added variable way

Share this post


Link to post
Share on other sites

Thanks Demonized. This was a great help. But is it possible to set _enemySide dynamically?

---------- Post added at 05:27 PM ---------- Previous post was at 05:24 PM ----------

I just released my first script. I think it does things that are missing in arma 2. And I don't know any other script that does it. It's called Behaviour Jukebox. I'm trying to implement this sensor in behaviour.sqf Have a look. ;)

---------- Post added at 05:32 PM ---------- Previous post was at 05:27 PM ----------

Is it possible to set _enemySide dynamically?

If I used if or switch structures I couldn't determine if Independent side is enemy or friend :(

Share this post


Link to post
Share on other sites
Thanks Demonized. This was a great help. But is it possible to set _enemySide dynamically?

_enemySide = [east,resistance];
_foundEnemys = false;
_nearTargets = (getPos  player) nearObjects ["AllVehicles",500];
{
  if ( (player knowsabout _x) == 4 AND (side _x) in _enemySide ) then {_foundEnemys=true};
} foreach _nearTargets;
if (_foundEnemys) then {
  <do your one action here if any enemys was detected by player>
};  

best i could come up with, you need to add the different enemy sides into _enemysides in top of script, then it checks if its any of the entered sides, so here any opfor and resistance units will be threated as enemy.

Share this post


Link to post
Share on other sites

I think knowsAbout return value (0 - 4) meaning is very confusing and I couldn't find an explanation in BIS wiki :(

Could anybody clarify it to me?

---------- Post added at 10:42 PM ---------- Previous post was at 10:40 PM ----------

Is there any function that return some firepower coefficient?

Share this post


Link to post
Share on other sites

knowsabout 4 == 100% verified enemy at correct position, knowsabout below 1 is unknow, below 0.5 i think is unknown entity, (not sure if car or tank or man)

above 1 to 3.9 im not sure, but 4 is same as i "know" who, what and where the target is...

1-3.9 probably is some form of i know who, maybe i know what, maybe i know ca where...

Quick Search of Forums on knowsabout yielded not much more clarity.

But 4 is known enemy.

You can test various knowsabout levels by running a script on a radio trigger hinting knowsabout value of an enemy and yourself from different ranges, positions.

Edit: for dynamically side selectionof enemys i found this:

http://community.bistudio.com/wiki/getFriend

---------- Post added at 03:06 AM ---------- Previous post was at 03:02 AM ----------

this for firepower checks, threat based.

nearTargets

Edited by Demonized

Share this post


Link to post
Share on other sites

Using "nearTargets", it's returning a Subjective Cost like "-9.99999e+006" for friendlies. Do you know how to interpret it?

Share this post


Link to post
Share on other sites

no sorry, have not looked to much into it, but it seems complicated and unreliable from various tests, do some search of neartargets on forum using advanced search and search titles only and youll find a post with video tests and more info.

I stick with knowsabout atm.

Share this post


Link to post
Share on other sites
do search using advanced search and search titles only.

That is something I should know before. Thanks again.

Share this post


Link to post
Share on other sites

yeah, it gets messy when just using search and i understand people not bothering or ever finding anything by searching without knowing this.

Ofc you can search threads, but any big project probably have 1 or all the keywords you are looking for and it again gets messy.

Figured awhile ago that this was worthy of a place in my sig :)

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  

×