Jump to content
Sign in to follow this  
masterfulninja

Civilian search helicopter

Recommended Posts

Does anyone have any idea how to make a civilian helicopter start patrolling looking for members of a squad then lock onto them with the searchlight if they find them?

Share this post


Link to post
Share on other sites

the lights arent a problem, they work.

null=[] spawn { while {true} do {  player action ["lightOn", Cheli]; sleep 0.01};};  

I found this and the lights force on at all times so that's good to go. I also found code forcing civilians and independent to be enemies and tested it and it works too. So i need script that makes the heli actually fly and look for pre-designated units and then orient itself to face them in such a manner as to aim the light on them when it finds them. if possible also script that makes the helicopter reveal the squads location to Opfor

---------- Post added at 04:17 ---------- Previous post was at 03:48 ----------

i know this isnt right because im not very good at scripting but this is what i think im looking for, at least in the ballpark.

_search = _Cheli knowsAbout _Mainchar;

if (_search) then { _Cheli lookAt _Mainchar; _Cheli moveto _Mainchar; }

Share this post


Link to post
Share on other sites
the lights arent a problem, they work.

null=[] spawn { while {true} do {  player action ["lightOn", Cheli]; sleep 0.01};};  

I found this and the lights force on at all times so that's good to go. I also found code forcing civilians and independent to be enemies and tested it and it works too. So i need script that makes the heli actually fly and look for pre-designated units and then orient itself to face them in such a manner as to aim the light on them when it finds them. if possible also script that makes the helicopter reveal the squads location to Opfor

---------- Post added at 04:17 ---------- Previous post was at 03:48 ----------

i know this isnt right because im not very good at scripting but this is what i think im looking for, at least in the ballpark.

[color="#FF8040"][color="#1874CD"]_search[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#1874CD"]_Cheli[/color] [color="#191970"][b]knowsAbout[/b][/color] [color="#1874CD"]_mainChar[/color][color="#8B3E2F"][b];[/b][/color]

[color="#191970"][b]if[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#1874CD"]_search[/color] [color="#8B3E2F"][b]>[/b][/color][color="#8B3E2F"][b]=[/b][/color] [color="#FF0000"]3[/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]then[/b][/color]
[color="#8B3E2F"][b]{[/b][/color]
[color="#8B3E2F"][b]([/b][/color][color="#191970"][b]group[/b][/color] [color="#1874CD"]_Cheli[/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]move[/b][/color] [color="#191970"][b]getPos[/b][/color] [color="#1874CD"]_mainChar[/color][color="#8B3E2F"][b])[/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color][/color]

Made with KK's SQF to BBCode Converter

Something like this could work.

Share this post


Link to post
Share on other sites

I'm trying to set up a loop with the code you suggested and I'm having trouble getting my hints to fire off... I'm doing something wrong still. Searching fires but loop start never does...

hint "searching";
_search = _searcher knowsAbout _mainchar;
_looking = true;
null = [] spawn {
private ["_search", "_looking"];
hint "loop start";
while {true} do {
	_search = _searcher knowsAbout _mainchar;
	hint "Im looking";
		if (_search >= 0) then{
			(group _searcher) move getPos _mainchar); 
hint "found him";
			}; 
		sleep 0.1;
		};

};

Share this post


Link to post
Share on other sites

[color="#FF8040"][color="#191970"][b]private[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"_search"[/color][color="#8B3E2F"][b],[/b][/color] [color="#7A7A7A"]"_looking"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"_searcher"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"_mainChar"[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]

[color="#1874CD"]_searcher[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]_this[/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]0[/color][color="#8B3E2F"][b];[/b][/color]
[color="#1874CD"]_mainChar[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]_this[/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]1[/color][color="#8B3E2F"][b];[/b][/color]

[color="#1874CD"]_search[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#1874CD"]_searcher[/color] [color="#191970"][b]knowsAbout[/b][/color] [color="#1874CD"]_mainChar[/color][color="#8B3E2F"][b];[/b][/color]
[color="#1874CD"]_looking[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]true[/color][color="#8B3E2F"][b];[/b][/color]

[color="#191970"][b]hint[/b][/color] [color="#7A7A7A"]"loop start"[/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]while[/b][/color] [color="#8B3E2F"][b]{[/b][/color][color="#1874CD"]_looking[/color][color="#8B3E2F"][b]}[/b][/color] [color="#191970"][b]do[/b][/color] 
[color="#8B3E2F"][b]{[/b][/color]
[color="#1874CD"]_search[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#1874CD"]_searcher[/color] [color="#191970"][b]knowsAbout[/b][/color] [color="#1874CD"]_mainChar[/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]hint[/b][/color] [color="#7A7A7A"]"I'm looking"[/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]if[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#1874CD"]_search[/color] [color="#8B3E2F"][b]>[/b][/color][color="#8B3E2F"][b]=[/b][/color] [color="#FF0000"]0[/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]then[/b][/color]
[color="#8B3E2F"][b]{[/b][/color]
	[color="#8B3E2F"][b]([/b][/color][color="#191970"][b]group[/b][/color] [color="#1874CD"]_searcher[/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]move[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#191970"][b]getPos[/b][/color] [color="#1874CD"]_mainChar[/color][color="#8B3E2F"][b])[/b][/color][color="#8B3E2F"][b];[/b][/color] 
	[color="#191970"][b]hintSilent[/b][/color] [color="#7A7A7A"]"found him"[/color][color="#8B3E2F"][b];[/b][/color]
	[color="#1874CD"]_looking[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]false[/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color] 
[color="#191970"][b]sleep[/b][/color] [color="#FF0000"]1[/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color]

[/color]

Made with KK's SQF to BBCode Converter

[_searcher,_mainChar] execVM "search.sqf";

I think that spawn part is obsolete, but if someone knows better, please correct me.

Share this post


Link to post
Share on other sites

Thanks for the help, Im trying that now and im getting "im looking" to fire in the loop which is a step forward but even with the knowsAbout set anywhere above 0 and the heli flying directly over the guy at 50 meters still no firing of the final knowsAbout clause.

I know they see him because they set off the detected script that fires the search script to begin with.

EDIT:

Ok i got the basics to all fire, now i need some help with getting the behavior set right.

private ["_search", "_looking","_searcher","_mainchar","_wp"];

_searcher = _this select 0;

_mainchar = _this select 1;

_wp = getPos _mainchar;

_search = _searcher knowsAbout _mainchar;

_looking = true;

hint "loop start";

while {_looking} do

{

_search = _searcher knowsAbout _mainchar;

hint "I'm looking";

if (_search >= 0) then

{

hint "found him 1";

_searcher move getPos _mainchar;

_searcher doFollow _mainchar;

_searcher doWatch _mainchar;

_searcher doTarget _mainchar;

_searcher lookAt _mainchar;

deleteWaypoint [_searcher, 1];

_wp =_searcher addWaypoint [getPos _mainchar, 0];

hint "found him 1.5";

[_searcher, 1] setWaypointLoiterType "CIRCLE";

[_searcher, 1] setWaypointLoiterRadius 50;

hint "found him 2";

};

sleep 10;

};

After further debugging i found that the code only fires when knows about is set exactly on 0, > 0.01 doesnt fire when flying directly over the unit. I finally got the loop ironed out and help text that alternates between the beginning and end of the cycle so i know the code is cycling and i know they see the unit because they call him out. Somehow i guess im not linking to the script correctly?

This is what i have in the triggers activation box.

null = [searcher, mainchar] execVM "search.sqf";

names are all lower case no caps

Edited by masterfulninja

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  

×