Jump to content
Sign in to follow this  
Tand3rsson

How to use knowsabout for a group?

Recommended Posts

Hi!

Quick (I hope) question: How do I use knowsAbout for a unit spotting a member of a certain group?

like:

_unitOne knowsAbout _x > 2 forEach units _opforgroup

Ofcourse that one dosent work, but I was hoping it would help someone understand my question.

I am trying to use it as a if-statement, like:

{
if (_unitOne knowsAbout _x > 2) then 
{
something happens
};
} forEach units _opforgroup;

Thanks! :)

Share this post


Link to post
Share on other sites

I don't see any reason it won't work.

As it reads

IF unitone knows anything more than 2 about any member of opforgroup then do something.

I don't see a problem.

Share this post


Link to post
Share on other sites

This works....

waituntil {{_unitOne knowsAbout _x >2} foreach units _opforgroup};
hint "I know about them";

Share this post


Link to post
Share on other sites

I just tested it and it does work, it didn't work at first as I called it from a units init box. Calling it from a trigger worked.

Share this post


Link to post
Share on other sites

I am trying to get the code to execute from a script like this:

init:

null = [unit1, unit2] execVM "Iseeu.sqf";

Iseeu.sqf

_guard = _this select 0;
_opforman = _this select 1;

_opforgrp = group _opforman;

{
if (_guard knowsAbout _x > 2) then 
{
hint "KNOWSABOUT";
_guard addMagazine "15Rnd_9x19_M9";
_guard addWeapon "M9";
_guard addMagazine "15Rnd_9x19_M9";

};
} forEach units _opforgroup;

And I am getting zero response from unit1 :S

Share this post


Link to post
Share on other sites

Try placing the call code in a trigger, It's probably running before the units have spawned.

or change it to this.

null= [] spawn {sleep 1; null = [unit1, unit2] execVM "Iseeu.sqf";}

Share this post


Link to post
Share on other sites

Yep, that's why i was asking. You definitely need to execute it in a trigger, or use twirly's code.

What you have been doing up until now just execute the code once at the initialization, when nobody knows anything about anybody.

Share this post


Link to post
Share on other sites

Nope, still nothing :S I have tried many different approches (the one with delay, the trigger and such). I have checked, and doubble checked that everything is namned correct and such. If I change the whole squadthing to only check for unit2 (_opforman) then it suddenly works, so it has to be something with the group :S

Share this post


Link to post
Share on other sites

I think it's the way your using group.

place this in the group leaders init

opforgrp = group this;

call with

null = [unit1, opforgrp] execVM "Iseeu.sqf";

_guard = _this select 0;
_opforGRP = _this select 1;

//_opforgrp = group _opforman;
///hint "ok";

{	
if (_guard knowsAbout _x > 2) then 
{
hint "KNOWSABOUT";
_guard addMagazine "15Rnd_9x19_M9";
_guard addWeapon "M9";
_guard addMagazine "15Rnd_9x19_M9";

};
} forEach units _opforgrp;

Share this post


Link to post
Share on other sites

Ah yes! F2k Sel, that worked!

However, I have discovered a new problem, which I should have predicted. How do I loop this so that it constantly checks if knowsAbout > 2 untill it is so?

What I am experiencing now is that guard only reacts if he knowsAbout that squad in the opening seconds of the game, which is not what I wish to have.

Would it be possible to make the script go back to the if, and once fullfilled, exit the script?

Share this post


Link to post
Share on other sites

Using the Twirly idea would be easiest.

_guard = _this select 0;
_opforGRP = _this select 1;

waituntil {{_guard knowsAbout _x > 2} foreach units _opforgrp};

hint "KNOWSABOUT";
_guard addMagazine "15Rnd_9x19_M9";
_guard addWeapon "M9";
_guard addMagazine "15Rnd_9x19_M9";

Share this post


Link to post
Share on other sites

I have found that with waituntil (in the many scripts i tried it before) it just jumps past the argument. Tried this also when Twirly wrote it with my script, and it just ran through the script even though the knowsAbout was not fullfilled. A work around I have used previously might work for me here.

waitUntil {_heliTp distance _invisH < 80};
nul= [] execVm "land.sqf";

Thats how I solved it previously in another script, cause otherwise it would just go on. This is an issue which I have heard other people mention to. Right this second I am unable to test it, but I will as soon as possible. :)

And also would like to take the time to thanks everyone who takes the time to help here on the forums!

EDIT: Tested now, and it seems to work :S Which is great, but I do not understand what I have done wrong previously with the waituntil since I deleted it :S Thanks again F2k Sel! And everyone else!

Edited by Tand3rsson
TESTED

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  

×