Jump to content
Sign in to follow this  
fabrizio_t

Need list of "known" enemies for group leader

Recommended Posts

I am looking for a way to get a list of the known enemies for group leader without using a trigger on editor.

I think it should be possible ...

can anybody help me ?

Share this post


Link to post
Share on other sites
I am looking for a way to get a list of the known enemies for group leader without using a trigger on editor.

I think it should be possible ...

can anybody help me ?

You also can script triggers, check the biki (link in my sig).

Share this post


Link to post
Share on other sites

Thx Raedor,

if that's the only case i think i'd stick with normal triggers.

Anyway it would be interesting to have a function for that (returning only the list of known "targets" for each unit). To me looping  upon triggers lists and checking through "knowsabout" it'quite cumbersome and time consuming with many eneny units on the field.

Share this post


Link to post
Share on other sites

We had a discussion about an array which contains all active units on the field a few days ago already. Had been introduced with VBS and will be available in VBS2 again for sure.

Share this post


Link to post
Share on other sites

You can probably come close with nearestObjects. I haven't tested or even run the code below but I've used something similar in one of my scripts so know that the basic function works...

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

//assumes enemies are 'SoldierEB' but you can change this if necessary

getKnownEnemy = {

_ldr = _this select 0;

_threshold = 0.3; //I have no idea what the actual number should be

//

_enemy = nearestObjects [_ldr, ["SoldierEB"], 200];

{

if (_ldr knowsabout _x < _threshold) then {

_enemy=_enemy-[_x] ;

};

} foreach _enemy;

_enemy;

};

*edit* Oops - missing brace

*edit again* fixed array subtraction, corrected soldier type

Share this post


Link to post
Share on other sites

now this sounds interesting and pretty straightforward.

Can you elaborate about this code:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> if (_ldr knowsabout _x < _threshold) then {

_enemy=_enemy-_x ;

} .

hard to understand what "enemy=_enemy-_x" does mean.

Thx.

Share this post


Link to post
Share on other sites

huh.gif Huh ? What kinda syntax is that ?

//assumes west leader - easy to change if you want

getKnownEnemy = <span style='color:RED'>{</span>

_ldr = _this select 0;

_threshold = 0.3; //I have no idea what the actual number should be

_enemy = nearestObjects [_ldr, ["SoldierE"], 200];

{

if (_ldr knowsabout _x < _threshold) then {

_enemy=_enemy-_x ;

} foreach _enemy;

_enemy;

<span style='color:RED'>}</span>;

Share this post


Link to post
Share on other sites
now this sounds interesting and pretty straightforward.

Can you elaborate about this code:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> if (_ldr knowsabout _x < _threshold) then {

_enemy=_enemy-_x ;

}

.

hard to understand what "enemy=_enemy-_x" does mean.

Thx.

It removes the just checked enemy from the list of enemies if the leader 'doesnt know enough about him'.

Afterwards only the enemys the leader knows enough about are kept in the list,

Share this post


Link to post
Share on other sites

I fear OFP-Syntax is the only thing such an idea would work on biggrin_o.gifbiggrin_o.gif

Share this post


Link to post
Share on other sites
Quote[/b] ]Huh ? What kinda syntax is that ?

Not sure if you were serious or not but just in case smile_o.gif

It's sqf syntax. getKnownEnemy is a named function. You could use this function in the following way:-

1) Put the code in an sqf file (eg my_functions.sqf).

2) In your init code

execVM "my_functions.sqf"

3) When you want to use the function:-

_soldiers = [player] call getKnownEnemy ;

Share this post


Link to post
Share on other sites

Aww - ok .. It's that 'code-handle' which has been introduced with arma. that 'call' and parseFile-stuff. kay wink_o.gif

Share this post


Link to post
Share on other sites
Quote[/b] ]hard to understand what "enemy=_enemy-_x" does mean.

As ManDay says, it just removes 'unknown' soldiers from the enemy list. I should probably explain my comment about the 'threshold' as well. I haven't used 'knowsAbout' myself so don't really know what kinds of values it returns.

Biki suggests the value can take a wide range.

Share this post


Link to post
Share on other sites

Tried the script and had some issues with it, i've done my modifications though.

Two fixes i did were:

change "SoldierE" to "SoldierEB",

maybe it's just the unit i've chosen that didn't triggered the loop, but that did the trick;

change "enemy=_enemy-_x" to "enemy=_enemy-[_x]",

since it's an array subtraction.

So far it seems to work!

Share this post


Link to post
Share on other sites

Good smile_o.gif You probably noticed the missing brace as well then ! I've gone back and edited the code for correctness.

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  

×