Jump to content
Cheitan

Hard time with waypoints

Recommended Posts

Hey there !

 

I'm having troubles to make waypoints spawned by scripts to work. For test purposes, what I want to do is to order a small squad to board a vehicle. When I try placing waypoints in the editor, all is working as expected : at mission start, the squad head to the vehicle and board it. I can even chain waypoints, for example by ordering them to go here and there once they are in the vehicle.

 

But with a script... Nothing is working anymore.

 

Here is the small code I wrote for test purposes, aiming to do the same simple thing as above :

_gp = group leader (nearestObject [player, "KICC_HOMME_EQUIPAGE"]);
_wp = _gp addWaypoint [nearestObject [player, "KICC_GORGON"], 0];
_wp setWaypointType "GETIN";

The classnames are from a custom faction, no problem with that. Player is here my character, located at a few metters of both the squad and the vehicle. When I start the mission, nothing happens : the squad stay in place.

 

I've decided to try these things because I'm having a hard time doing a sort of "general alert" script, making all drivers to run to their vehicles and to board it. Of course, they don't care. I use a code close to what I've posted here. And I also use a similar code to order some other groups to wander around ("dismiss" waypoint). "GETIN" waypoints are not working at all, whereas "DISMISS" waypoints are fully working.

 

Any idea ?

 

EDIT :

Some progress about this. It seems that nearestObject is a bit old and not capable of detecting units, only not living things. My crew member were not found by the command. So here is the new version of the code :

_gp = group ((player nearEntities ["KICC_HOMME_EQUIPAGE", 50]) select 0);
systemChat str _gp;
_wp = _gp addWaypoint [nearestObject [player, "KICC_GORGON"], 0];
_wp setWaypointType "GETIN";

What happens here is that the group is well displayed in the systemChat, and we can see that the squad is moving to the vehicle. But they stop once they are close to it, and never enter it. Is there any problem with the way I set up the "GETIN" waypoint ?

Edited by Cheitan
More info

Share this post


Link to post
Share on other sites

Hi...

 

I believe you need to synch the "GETIN" with a "LOAD" on the vehicle...

 

Ex: I am loading Infantry Squads into Helicopters:

 

	// LOOP - foreach (CHALK) //
	{
		// chalk - return group name from string //
		_chkGrp = missionNamespace getVariable [_x, objNull];
			
		// chalk (GETIN)- create waypoint //
		_wpChk = [_arrXn,_arrYn,_arrZ];
		_wpChkLd = _chkGrp addWaypoint [_wpChk,0];
		_wpChkLd setWaypointType "GETIN";
		_wpChkLd setWaypointBehaviour "CARELESS";
		_wpChkArr pushBack _wpChkLd;
		_arrXn = _arrXn + 5;
		_arrYn = _arrYn + 5;
		
	} foreach _chkArr;
	
	// slick/chalk (SYNC) - load waypoints //
	_wpSlkLd synchronizeWaypoint _wpChkArr;

 

Regards,
Scott

  • Like 1

Share this post


Link to post
Share on other sites

Hi scott,

 

Thanks for your answer. I took a quick look on the LOAD waypoint, it seems to implies that the group must "possess" a vehicle, which is in my case a bit hard to do, as vehicles and units are spawned dynamically.

 

But I think that I finally got it work. When you are placing waypoints through Eden, it automatically attach the waypoint to the vehicle you are clicking on. But with script, placing the waypoint on the precise position of the vehicle is not sufficient. The IA head to the position but don't know what vehicle to board (even if there is only one). So we have two solutions :

 

1) Use the "GETIN NEAREST" waypoint. IA will board the nearest vehicle with enough free space. I have tried that, fully working. But in my case, there is a risk that the IA board in another vehicle because of the mystery of pathfinding. So I used solution 2 :

2) Use the "GETIN" waypoint combined with the waypointAttachVehicle command. This command have to be called before the waypoint is reached, so in order to be sure that everything is okay, I use it as soon as the waypoint is created, even before setting the type. Here is the code I used :

_gp = group ((player nearEntities ["KICC_HOMME_EQUIPAGE", 50]) select 0);
_veh = nearestObject [player, "KICC_GORGON"];
_wp = _gp addWaypoint [_veh, 0];
_wp waypointAttachVehicle _veh;
_wp setWaypointType "GETIN";
_wp = _gp addWaypoint [getMarkerPos "marker_0", 0];
_wp setWaypointType "SENTRY";

With this method, all seems to work as expected, but I'm gonna keep on investigating with more complex situations. At least here, the group go to the vehicle, board it, then use the vehicle to go to the marker and stay here, watching for ennemies. Maybe you can use this to simplify your code by using only one waypoint instead of two ?

Share this post


Link to post
Share on other sites

Hi...

 

Glad you have it sorted - yeah - I'm still at the point where I need to solve each problem as it comes up with scripting... I'll keep you info in mind if I come across a similar need - thanks as well...

 

Regards,
Scott

Share this post


Link to post
Share on other sites

Can I use this thread to find a similar but simpler solution?

I want a "repair" to pull up to an area, stop for say 30 seconds, wait for 3 ai to jump in, then bugger off.

Can I use a script in the "on activation" to do this?,...and what might that script be?

Thanks

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

×