Jump to content
Sign in to follow this  
VonNexus

Issues onMapSingleClick and locations.

Recommended Posts

In the last two days I've been trying to write a simple supply drop script. It uses the onMapSingleClick to create a marker in the place where the platoon commander (called alphaleader) wants the ammos to be dropped. The marker works as a destination for a MV22 Osprey's (called mv_22) wayipoint.The script is called via a Radio Alpha trigger. This is what I've done so far:

alphaleader sidechat "Open your map and mark the drop zone for the supplies by clicking one time where you'd like for the ammos to be dropped";
_mk = createMarker ["drop_zone_mk",position player]; 
_mk setMarkerColor "colorBlue";
_mk setMarkerShape "icon";
_mk setMarkerSize [1,1];
_mk setMarkerDir random -10 +random 20;
_mk setmarkerText "Supply Drop Zone";
_mk setMarkerType "empty";
mapclick = false;
onMapSingleClick """drop_zone_mk"" setMarkerPos _pos; clickpos = _pos; mapclick = true; onMapSingleClick """";true;";



waituntil {mapclick};
_pos = clickpos;
alphaleader sidechat "Drop zone marked!";
mv_22 enableSimulation true;
mv_22 hideObject false;
_wp=osprey addWaypoint [getMarkerPos "drop_zone_mk",0];
_wp setWaypointType "MOVE";
_wp setWaypointSpeed "LIMITED";
_wp setWaypointBehaviour "CARELESS";



if (mapclick) then 
{ _mk setMarkerType "Flag1";

};



if (mv_22 in _pos) then 
{ ammos = "USSpecialWeaponsBox" createVehicle (position mv_22); 
 chute = "parachute_US_EP1" createVehicle  (position mv_22);
  ammos attachTo [chute, [0,0,0], "paraEnd"];
  ammos setpos [getpos mv_22 select 0, getpos mv_22 select 1, 34];
   chute setpos [getpos mv_22 select 0, getpos mv_22 select 1, 34];

};           




exit;

This script has no problem but the last part. The piece of code simply doesn't get triggered. However, _pos should be the name of the location created with the map click. Maybe I deleted the location with the commands

onMapSingleClick """";true;";

?

I've not been able to figure out what's wrong.

Share this post


Link to post
Share on other sites

Have you tried moving the remove onclick functionality to below the waituntil, it should work there.

alphaleader sidechat "Open your map and mark the drop zone for the supplies by clicking one time where you'd like for the ammos to be dropped";
_mk = createMarker ["drop_zone_mk",position player]; 
_mk setMarkerColor "colorBlue";
_mk setMarkerShape "icon";
_mk setMarkerSize [1,1];
_mk setMarkerDir random -10 +random 20;
_mk setmarkerText "Supply Drop Zone";
_mk setMarkerType "empty";
mapclick = false;
onMapSingleClick """drop_zone_mk"" setMarkerPos _pos; clickpos = _pos; mapclick = true; true;";



waituntil {mapclick};
onMapSingleClick "";

alphaleader sidechat "Drop zone marked!";
mv_22 enableSimulation true;
mv_22 hideObject false;
_wp=osprey addWaypoint [getMarkerPos "drop_zone_mk",0];
_wp setWaypointType "MOVE";
_wp setWaypointSpeed "LIMITED";
_wp setWaypointBehaviour "CARELESS";



if (mapclick) then 
{ _mk setMarkerType "Flag1";

};

Not tested, but is how I have it setup when users update their steerpoint in my PINS mod.

Also is this line required at all after the waituntil?

_pos = clickpos;

Hope this helps

Blake

Share this post


Link to post
Share on other sites
Have you tried moving the remove onclick functionality to below the waituntil, it should work there.

alphaleader sidechat "Open your map and mark the drop zone for the supplies by clicking one time where you'd like for the ammos to be dropped";
_mk = createMarker ["drop_zone_mk",position player]; 
_mk setMarkerColor "colorBlue";
_mk setMarkerShape "icon";
_mk setMarkerSize [1,1];
_mk setMarkerDir random -10 +random 20;
_mk setmarkerText "Supply Drop Zone";
_mk setMarkerType "empty";
mapclick = false;
onMapSingleClick """drop_zone_mk"" setMarkerPos _pos; clickpos = _pos; mapclick = true; true;";



waituntil {mapclick};
onMapSingleClick "";

alphaleader sidechat "Drop zone marked!";
mv_22 enableSimulation true;
mv_22 hideObject false;
_wp=osprey addWaypoint [getMarkerPos "drop_zone_mk",0];
_wp setWaypointType "MOVE";
_wp setWaypointSpeed "LIMITED";
_wp setWaypointBehaviour "CARELESS";



if (mapclick) then 
{ _mk setMarkerType "Flag1";

};

Not tested, but is how I have it setup when users update their steerpoint in my PINS mod.

Also is this line required at all after the waituntil?

_pos = clickpos;

Hope this helps

Blake

Thanks for the reply.

I changed my code to yours, and yes, the clickpos thing apparently it's not needed. However, nothing changed. The marker stuff and waypoint works perfectly, but still getting issues with the _pos statement.

Share this post


Link to post
Share on other sites

Ok from my first read I assumed it was just to do with the on click aspect.

There were a few things

addwaypoint references a group, not the unit.

the if statement will only check for a result once not multiple times waiting until the condition is true. You need some sort of loop for that eg waituntil.

I'm not sure of how close in has to be when referencing a location, but I think you would need something to check for a bigger range. Also the location isn't a position, but a location object.

You used mv_22, then you use osprey where osprey doesn't look to be defined.

Added a couple of extra checks, when trying to get it working. Plus smoke as I was curoius as to how it would look.

Try this:

alphaleader sidechat "Open your map and mark the drop zone for the supplies by clicking one time where you'd like for the ammos to be dropped";
_mk = createMarker ["drop_zone_mk",position player]; 
_mk setMarkerColor "colorBlue";
_mk setMarkerShape "icon";
_mk setMarkerSize [1,1];
_mk setMarkerDir random -10 +random 20;
_mk setmarkerText "Supply Drop Zone";
_mk setMarkerType "empty";
mapclick = false;
onMapSingleClick """drop_zone_mk"" setMarkerPos _pos; clickpos = _pos; mapclick = true; onMapSingleClick """";true;";

waituntil {mapclick};

alphaleader sidechat "Drop zone marked!";
mv_22 enableSimulation true;
mv_22 hideObject false;
sleep 0.5;
_start_pos = getpos mv_22;
deleteWaypoint [group mv_22,1];
_wp=(group mv_22) addWaypoint [getMarkerPos "drop_zone_mk",0];
_wp setWaypointType "MOVE";
_wp setWaypointBehaviour "CARELESS";

mv_22 flyinheight 200;

_mk setMarkerType "Flag1";

waituntil  {! alive mv_22 or (mv_22 distance clickpos) < 700} ;
if (alive mv_22) then
{
sleep (3 + (random 3));
hint "drop drop drop";
_ammos = "USSpecialWeaponsBox" createVehicle (mv_22 modeltoworld [0,-10,0]); 
_smoke = "SmokeShellyellow" createVehicle (mv_22 modeltoworld [0,-10,0]);
 	_chute = "parachute_US_EP1" createVehicle  (mv_22 modeltoworld [0,-10,0]);
  	_ammos attachTo [_chute, [0,0,0], "paraEnd"];
_smoke attachTo [_chute, [0,0,0], "paraEnd"];
  	_chute setpos (mv_22 modeltoworld [0,-10,0]);

deleteWaypoint [group mv_22,1];
sleep 3;

_wp=(group mv_22) addWaypoint [_start_pos,0];
_wp setWaypointType "MOVE";
_wp setWaypointSpeed "NORMAL";
_wp setWaypointBehaviour "CARELESS";

	waituntil  {! alive mv_22 or (mv_22 distance _start_pos) < 500} ;
 	mv_22 enableSimulation false;
mv_22 hideObject true;      
};

Edited by blakeace

Share this post


Link to post
Share on other sites
Ok from my first read I assumed it was just to do with the on click aspect.

There were a few things

addwaypoint references a group, not the unit.

the if statement will only check for a result once not multiple times waiting until the condition is true. You need some sort of loop for that eg waituntil.

I'm not sure of how close in has to be when referencing a location, but I think you would need something to check for a bigger range. Also the location isn't a position, but a location object.

You used mv_22, then you use osprey where osprey doesn't look to be defined.

Added a couple of extra checks, when trying to get it working. Plus smoke as I was curoius as to how it would look.

Try this:

alphaleader sidechat "Open your map and mark the drop zone for the supplies by clicking one time where you'd like for the ammos to be dropped";
_mk = createMarker ["drop_zone_mk",position player]; 
_mk setMarkerColor "colorBlue";
_mk setMarkerShape "icon";
_mk setMarkerSize [1,1];
_mk setMarkerDir random -10 +random 20;
_mk setmarkerText "Supply Drop Zone";
_mk setMarkerType "empty";
mapclick = false;
onMapSingleClick """drop_zone_mk"" setMarkerPos _pos; clickpos = _pos; mapclick = true; onMapSingleClick """";true;";

waituntil {mapclick};

alphaleader sidechat "Drop zone marked!";
mv_22 enableSimulation true;
mv_22 hideObject false;
sleep 0.5;
_start_pos = getpos mv_22;
deleteWaypoint [group mv_22,1];
_wp=(group mv_22) addWaypoint [getMarkerPos "drop_zone_mk",0];
_wp setWaypointType "MOVE";
_wp setWaypointBehaviour "CARELESS";

mv_22 flyinheight 200;

_mk setMarkerType "Flag1";

waituntil  {! alive mv_22 or (mv_22 distance clickpos) < 700} ;
if (alive mv_22) then
{
sleep (3 + (random 3));
hint "drop drop drop";
_ammos = "USSpecialWeaponsBox" createVehicle (mv_22 modeltoworld [0,-10,0]); 
_smoke = "SmokeShellyellow" createVehicle (mv_22 modeltoworld [0,-10,0]);
 	_chute = "parachute_US_EP1" createVehicle  (mv_22 modeltoworld [0,-10,0]);
  	_ammos attachTo [_chute, [0,0,0], "paraEnd"];
_smoke attachTo [_chute, [0,0,0], "paraEnd"];
  	_chute setpos (mv_22 modeltoworld [0,-10,0]);

deleteWaypoint [group mv_22,1];
sleep 3;

_wp=(group mv_22) addWaypoint [_start_pos,0];
_wp setWaypointType "MOVE";
_wp setWaypointSpeed "NORMAL";
_wp setWaypointBehaviour "CARELESS";

	waituntil  {! alive mv_22 or (mv_22 distance _start_pos) < 500} ;
 	mv_22 enableSimulation false;
mv_22 hideObject true;      
};

I'll try with this one then. However, Osprey is just the groupname of the Mv22.

EDIT: OK your code does perfectly the trick. However when the crate lands it goes underground. I tought that paraEnd in the attachTo command would have avoided that, but apparently it hasn't.

Edited by VonNexus

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  

×