Jump to content
Sign in to follow this  
deadactionman

Map and Shift+Left Click

Recommended Posts

Hello,

I was hoping to write a script that would allow the occupants of a vehicle to set a marker/WP on the map, (using the Shift+Left Click) and have it set a Waypoint on the map for the pilot/driver as well.

What I've found is that when you Shift+Left click on the map, although it appears as an on-screen WP-type-thing, it's not actually a waypoint. I tested this with a loop that counts the number of WPs for a given unit and when you place a Shift+Left click "thing", it doesn't change the WP count... in short, it's not a WP.

To test, place a unit with no waypoints and put this in the init...

null = [] spawn {while {alive player} do {hint format["Waypoint Count=%1",(count waypoints (group player))];sleep 1;};}

Shift+Left click and a marker appears (green for me) but the WP count doesn't move.

Then go back to the editor and give the unit a few waypoints and try again. The above loop is counting the WPs, but again, the Shift+Left Click thing doesn't alter the count.

Is there anyway to set a Shift+Left click marker/WP thing from a script? It's not a WP and it's not a marker, so what else is there?

Any help would be appreciated.

Cheers,

DAM

Share this post


Link to post
Share on other sites

ADuke823 made something really similar to your request - he created a minimap for the pilot and copilot of a helicopter and made it possible to add waypoints whenever the (co-)pilot clicked at any point in the map.

That could be a little bit overpowered for your "simple" request, and if it is, here's the basic routine to achieve that:

  • Use onMapSingleClick to react whenever someone (with the correct privileges) clicks into the map
  • Check if shift was pressed while clicking (see above link for more information)
  • Use addWaypoint to, uhm, add a new waypoint :D

Share this post


Link to post
Share on other sites

Thanks XxAnimusxX.

I've got the code to do it, but the problem is when you Shift+Left Click you're not actually placing a WP, it's something else. This code is work in progress, but you can see what I'm trying to do.

I'm calling DAM_GPS_coPilot with

onMapSingleClick "[_pos, _shift, _alt] call DAM_GPS_coPilot;";

DAM_GPS_coPilot = {
private ["_vehicle", "_inVehicle", "_pilot", "_isPilot","_pos", "_shift", "_alt", "_wp", "_mesage", "_nearestLocation", "_nearestLocationName", "_group"];
_pos = _this select 0;
_shift = _this select 1;
_alt = _this select 2;

_nearestLocation = (nearestLocations [_pos,["NameCityCapital","NameCity","NameVillage"],5000]) select 0;
_nearestLocationName = text _nearestLocation;

_coPilot = player;	// Whoever is calling the script
_vehicle = vehicle _coPilot;         // What vehicle?
_inVehicle = typeOf _vehicle == "Air";   // Is it an air unit?
_pilot = driver _vehicle;                // Get the pilot
_isPilot = _coPilot == _pilot;        // Is the coPilot the driver?
_group = group _pilot;

if (_shift && _alt && _inVehicle && !_isPilot) then {

	// Delete existing waypoint(s)
	// deleteWaypoint [_group, all]; // dunno if this works
	while {(count (waypoints _group)) > 0} do
	{
		deleteWaypoint ((waypoints _group) select 0);
	};

	_wp = _group addWaypoint [[_pos select 0, _pos select 1], 0]; // add a waypoint
	_wp setWaypointType "MOVE";
	_message = format["A new waypoint has been set near %1 by %2", _nearestLocationName, _coPilot];
	{
		//[nil_or_caller, nil_or_target_object,"loc", script_to_execute, par0, par1...] call RE;
		[nil, _x, rTITLETEXT, _message, "PLAIN DOWN", 0] call RE;
	} forEach crew _vehicle;
};
};

Still playing around with the RE bit, but this was supposed to run in veteran mode so WPs wouldn't show anyway. The above creates Waypoints, but what's really confusing me is that the Shift+Left Click thing doesn't appear to be an actual Waypoint.

Share this post


Link to post
Share on other sites

No it isn't as you already noticed, it's something built into the game which doesn't count towards waypoints or markers.

I assume its an image ctrl which gets placed in the map and activates some script to keep track of the distance to that point.

Btw:

typeOf _vehicle == "Air"

will return false, use isKindOf instead.

Share this post


Link to post
Share on other sites

Looks like I'll have to do something else instead then. Maybe a text overlay/resource with distance and bearing to target? Not as good as an on screen marker but it'll have to do... for now.

I always seem to use typeOf and isKindOf in the wrong place... thanks for noticing :)

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  

×