Jump to content

Recommended Posts

Hello, I'm doing a mission where there is an empty UAV (that new badass helicopter :D) and in case it's needed, I have a script that creates a crew, set a combat mode and the skill of the helo, but I can't get the uav the follow me... It's a transport helicopter mission so it's here to "defend" me.

The actual script:

_drone = d1;

createVehicleCrew _drone;
_drone setCombatMode "RED";
_drone setskill 1;
while {alive _drone} do {
        _drone move getpos player;
        // _wp = group _drone addWaypoint [position h1, 0];
        // _wp setWaypointType "LOITER";
        // _wp setWaypointLoiterType "CIRCLE_L";
        // _wp setWaypointLoiterRadius 100;
        sleep 2;
};

The _wp variable it's something I've tried that didn't worked neither...

Share this post


Link to post
Share on other sites

Yeah, but after some tries, the only thing it does is fly around the initial position (that's with the loiter waypoint) or follows me for some seconds and then start spinning in a 10 meter radius like a dog after its tail xD

Share this post


Link to post
Share on other sites

okay.

I think you should do it with waypoints but what you are doin is creating a new waypoint on every loop run. You should use setWaypointPosition instead

  • Like 1

Share this post


Link to post
Share on other sites
_drone = d1;


createVehicleCrew _drone;
sleep 1;   // crew creation may take some time


if (!isEngineOn _drone) then {_drone engineOn true};

_drone_grp = group driver _drone;


_drone_grp setCombatMode "RED";
_drone_grp setBehaviour "COMBAT";
_drone_grp setskill 1;


_wp = _drone_grp addWaypoint [player, 0];
_wp setWaypointType "LOITER";
_wp setWaypointLoiterType "CIRCLE_L";
_wp setWaypointLoiterRadius 100;

while {alive _drone} do
{
 if (currentWaypoint _drone_grp != _wp select 1) then {_drone_grp setCurrentWaypoint _wp;};
 _wp setWaypointPosition [position player, 0];
 sleep 2;
};

deleteWaypoint _wp;
{_drone deleteVehicleCrew _x} forEach crew _drone;
deleteGroup _drone_grp;

 

  • Like 2

Share this post


Link to post
Share on other sites

I've tried a little, and seemed to work, here your script with some modifications.

_drone = d1;
_h = h1;

_drone engineON true;
createVehicleCrew _drone;
sleep 1;

_drone_grp = group driver _drone;

_drone setCombatMode "RED";
_drone setBehaviour "COMBAT";
_drone setskill 1;
_drone flyInHeight 100;
//Throw me error Expected object instead of group, had to change it to simply _drone.

_wp = group _drone addWaypoint [position _h, 0];
_wp setWaypointType "LOITER";
_wp setWaypointLoiterType "CIRCLE_L";
_wp setWaypointLoiterRadius 100;

waitUntil {!isTouchingGround _h};
hint "Falcon started following you";

while {alive _drone} do {
		 if (currentWaypoint _drone_grp != _wp select 1) then {_drone_grp setCurrentWaypoint _wp;};
 _wp setWaypointPosition [position player, 0];
 sleep 2;
 };


deleteWaypoint _wp;
{_drone deleteVehicleCrew _x} forEach crew _drone;
deleteGroup _drone_grp;
	

Thanks a lot, will test more when coming back later.

Share this post


Link to post
Share on other sites

Hello again it's working well but I have more problems... I tried doing more modifications to continue but I found a problem that I cannot solve, but it seems so easy but I cannot figure this out.

in the while loop, I have two conditions one is the _onDuty boolean and the other is the alive condition, I tried 

while {_onDuty AND alive _drone}  do {};

and also

while {_onDuty == true AND alive _drone} do {};

When the boolean changes to false, nothing happens but when I destroy the drone, the script continues. What am I doing wrong?

Share this post


Link to post
Share on other sites

Try it with

alive driver _drone

Or better

damage _drone < 1

 

 

 

Share this post


Link to post
Share on other sites

Sorry I think I didn't explained exactly the problem.

In this while loop if one of the two conditions are not met the loop is skipped and the script continues, well at the start of the script the _onDuty Boolean is set to true and I have a trigger created inside the script with a radio "Alpha" activation. When I activate this trigger, nothing really happens, like if both conditions of the loop are still true when usually after setting "_onDuty = false" the loop should be skipped...

Share this post


Link to post
Share on other sites

_onDuty is local to the script and local to the trigger.
Use
onDuty
Instead

  • Like 1

Share this post


Link to post
Share on other sites

I did not read that the trigegr is in the same script. I was on the move with my mobile...

 

I think you should post the entire script to get help.
 

Share this post


Link to post
Share on other sites
_drone = d1;
_h = h1;
_lp = dronelp;
_onDuty = true;

_drone engineOn true;
createVehicleCrew _drone;
sleep 1;
 
_drone_grp = group driver _drone;
_drone setCombatMode "RED";
_drone setBehaviour "COMBAT";
_drone setskill 1;
_drone flyInHeight 100;

_wp = group _drone addWaypoint [position player, 0];
_wp setWaypointType "LOITER";
_wp setWaypointLoiterType "CIRCLE_L";
_wp setWaypointLoiterRadius 100;

waitUntil {!isTouchingGround _h};
[west, "HQ"] sideChat "Be advised, Falcon started following you.";

_t = createTrigger ["EmptyDetector", getPos player, true];
_t setTriggerArea [0, 0, 0, false];
_t setTriggerActivation ["ALPHA", "PRESENT", false];
_t setTriggerStatements ["this","_onDuty = false; hint 'Trigger Activated';",""];
_t setTriggerText "Dissmis Falcon.";

while {_onDuty AND alive _drone} do {
	if (currentWaypoint _drone_grp != _wp select 1) then {_drone_grp setCurrentWaypoint _wp;};
	_wp setWaypointPosition [position player, 0];
	sleep 2;
};

[west, "HQ"] sideChat "Be advised, Falcon is RTB.";
if (!alive _drone) then
	{
		deleteWaypoint _wp;
		{_drone deleteVehicleCrew _x} forEach crew _drone;
		deleteGroup _drone_grp;
	} else  //RTB
	{};

The hint in the trigger is to check if the trigger is actually being activated, when I press the radio message it successfully hints the message so I don't know why it's not working.

Share this post


Link to post
Share on other sites

try what I said above plz. I think the trigger needs a global variable.

 

use onDuty instead of _onDuty

 

_drone = d1;
_h = h1;
_lp = dronelp;
onDuty = true;

_drone engineOn true;
createVehicleCrew _drone;
sleep 1;
 
_drone_grp = group driver _drone;
_drone setCombatMode "RED";
_drone setBehaviour "COMBAT";
_drone setskill 1;
_drone flyInHeight 100;

_wp = group _drone addWaypoint [position player, 0];
_wp setWaypointType "LOITER";
_wp setWaypointLoiterType "CIRCLE_L";
_wp setWaypointLoiterRadius 100;

waitUntil {!isTouchingGround _h};
[west, "HQ"] sideChat "Be advised, Falcon started following you.";

_t = createTrigger ["EmptyDetector", getPos player, true];
_t setTriggerArea [0, 0, 0, false];
_t setTriggerActivation ["ALPHA", "PRESENT", false];
_t setTriggerStatements ["this","onDuty = false; hint 'Trigger Activated';",""];
_t setTriggerText "Dissmis Falcon.";

while {onDuty AND alive _drone} do {
	if (currentWaypoint _drone_grp != _wp select 1) then {_drone_grp setCurrentWaypoint _wp;};
	_wp setWaypointPosition [position player, 0];
	sleep 2;
};

[west, "HQ"] sideChat "Be advised, Falcon is RTB.";
if (!alive _drone) then
	{
		deleteWaypoint _wp;
		{_drone deleteVehicleCrew _x} forEach crew _drone;
		deleteGroup _drone_grp;
	} else  //RTB
	{};

 

and dont forget to delete the things you have created like the trigger :-)

  • Like 1

Share this post


Link to post
Share on other sites

Thanks a lot now it works but if the trigger is in the script, why the Boolean has to be global?

Could you explain just a little bit the code in the while loop, I don't understand it at 100%, I know it's about selecting waypoints.

 

Yeah in this script I totally forgot to delete the trigger, thanks.

 

would the landAt command work with the Falcon?

Share this post


Link to post
Share on other sites

the while loop ensures that the position of the waypoint is changed periodically. this is what this line does:

 

_wp setWaypointPosition [position player, 0];

but I think you got that yourself.

 

the following line is to ensure that _wp is always the waypoint which the _drone pilot tries to complete:

if (currentWaypoint _drone_grp != _wp select 1) then {_drone_grp setCurrentWaypoint _wp;};

I never used loiter waypoints before and therefore idk if they can be completed.

What happens if a waypoint is completed? The next waypoint will be taken and the pilot would try to complete this one.

To suppress this behavior I check if _wp is the current waypoint and if it is not then set it as current waypoint.

 

this returns the index number of the current waypoint for the group _drone_grp:

currentWaypoint _drone_grp

 

_wp select 1

selects the 2nd element of the array _wp.

_wp is a waypoint object and every waypoint object has this array structure:

[group, waypoint index]

 

therefore the whole if statement just checks if the index number of the current waypoint is equal to the index number of our desired loiter waypoint.

 

But I dont know if this check is nesseccary and therefore you should try to comment it out and test if the script is working.

 

Why has onDuty to be global? this is a good question. My own explanation for this is that you create an object which "carries" the code. there are other commands which have the same behavior like event handlers, waypoint statements and so on. I dont have a better explanation.

 

I think landAt should work with a drone. but ... just try it.

  • Like 1

Share this post


Link to post
Share on other sites

Again, thanks a lot for all the explanation and your help, I'll try to mess around with that :D 

  • Like 1

Share this post


Link to post
Share on other sites

I have a new little problem, when I have an AI group with the order to board my Empty helicopter if now I get in that helicopter while they're still boarding, the team leader of that group won't get in the helicopter.

If I am in the pilot seat before the boarding order, only two out of four members of the group will board, and will not run (I have set them to speed "FULL").

If I board the pilot seat after the order is given, three members get in the chopper but the team leader doesn't but at least they are running.

Unique solution is to board the chopper after them, but that's not a suitable solution.

I'm assigned as driver of the helicopter, and each member of the group is assigned as cargo.

 

I'm sorry for asking so much question, I know that this kind of problems can be solved trying, trying and trying, but I don't have much time and maybe someone know the answer but I'll continue trying.

 

Thanks a lot for helping me.

Edited by erwin23p
New problem...

Share this post


Link to post
Share on other sites

After trying a lot, I still couldn't figure this out... I'll leave the script here, the code is still WIP so maybe there are a lot of errors but now I'm just focusing on solving this problem:

mission.sqf

 

SOLVED: I had another trigger in the editor that when I got in the helicopter, it would assign again all the group as cargo thus confusing the AI i suppose.

Edited by erwin23p
Solved

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

×