Jump to content
zagor64bz

[SOLVED]How to add LOITER Way-points with OnMapSingleClick??

Recommended Posts

Ok..it's me, again.

 

I have this snippet which tells my AI heli driver to move to that location. It opens the map and all. All working ok.

IF ((Gunner (vehicle player)) == player) THEN {openMap true; 
onMapSingleClick " 
 openMap false; 
 Driver (vehicle player) move _pos; 
 (vehicle player) vehiclechat 'ROGER, en route to destination'; 
 onMapSingleClick '';"; 
};

What I've tried to do in the past couple of hours is to add waypoints to that. Specifically the "LOITER" ones.

I try with:

IF ((Gunner (vehicle player)) == player) THEN {openMap true; 
onMapSingleClick " 
 openMap false; 

Driver (vehicle player) move _pos;
Driver (vehicle player) setBehaviour "CARELESS";Driver (vehicle player) setCombatMode "BLUE";Driver(vehicle player) limitSpeed 220;
wp = Driver (vehicle player) addWaypoint [_pos, 0];
wp setWaypointType "LOITER";
wp setWaypointLoiterType "CIRCLE_L";
wp setWaypointLoiterRadius 1500;
(vehicle player) forceSpeed 60;
onMapSingleClick '';"; 
};

NO JOY!!!:headscratch:

Share this post


Link to post
Share on other sites

Do not use "" inside "". Also, onMapSingleClick also accepts code {} so I'd really recommend to use code instead.

Also addWaypoint accepts group not an object.

 

openMap true ;
onMapSingleClick {
	openMap false ;
	_grp = group player ;
	_grp setBehaviour "CARELESS" ;
	_grp setCombatMode "BLUE" ;
	vehicle playewr limitSpeed 220 ;
	vehicle playewr forceSpeed 60 ;
	_wp = _grp addWaypoint [_pos,0] ;
	_wp setWaypointType "LOITER" ;
	_wp setWaypointLoiterType "CIRCLE_L" ;
	_wp setWaypointLoiterRadius 1500 ;
	onMapSingleClick {} ;
} ;

 

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
3 hours ago, POLPOX said:

Do not use "" inside "". Also, onMapSingleClick also accepts code {} so I'd really recommend to use code instead.

Also addWaypoint accepts group not an object.

 


openMap true ;
onMapSingleClick {
	openMap false ;
	_grp = group player ;
	_grp setBehaviour "CARELESS" ;
	_grp setCombatMode "BLUE" ;
	vehicle playewr limitSpeed 220 ;
	vehicle playewr forceSpeed 60 ;
	_wp = _grp addWaypoint [_pos,0] ;
	_wp setWaypointType "LOITER" ;
	_wp setWaypointLoiterType "CIRCLE_L" ;
	_wp setWaypointLoiterRadius 1500 ;
	onMapSingleClick {} ;
} ;

 

ABSOLUTE JOY!!!!

Thank you POLPOX!!!

Share this post


Link to post
Share on other sites

Dont use onMapSingleClick, it will be overridden by any other use of it. Instead use the MEH version which is stackable( can be used multiple times without effecting other uses of it ).

Share this post


Link to post
Share on other sites
 
 
0
 Advanced issues found
 
1
4 minutes ago, Larrow said:

Dont use onMapSingleClick, it will be overridden by any other use of it. Instead use the MEH version which is stackable( can be used multiple times without effecting other uses of it ).

Ok.... thank you LARROW..but I'm a little confused.:headscratch:

 

If I got this correctly, you're telling me that if I have 2 onMapSingleClick snippets one will override the other?

Let's say 1 is for a move command, and the other is for the loiter ones.

If I use the move ones my AI group will execute the command, but if I use the loiter ones before they actually get where I send them, the move command will be overridden by the loiter ones?

 

Those are the only 2 "onMapSingleClick" use for this mission so that it will not be a problem if they cancel each other out.

Anyway, how would I use the EH you mention?

Share this post


Link to post
Share on other sites
Quote

but if i use the loiter ones before they actually get where I send them, the move command will be overridden by the loiter ones?

No if you issue a onMapSingleClick then another onMapSingleClick is used, the first will be overridden( will not exist, there can only ever be one onMapSingleClick set ).

You may not be doing this yourself but if any other scripts/addons use it yours maybe overridden. Always safer to use MEH version.

 

Quote

Anyway, how would I use the EH you mention?

openMap true ;
addMissionEventHandler [ "MapSingleClick", {
	params[ "_units", "_pos", "_alt", "_shift" ];
	
	openMap false ;
	_grp = group player ;
	_grp setBehaviour "CARELESS" ;
	_grp setCombatMode "BLUE" ;
	vehicle player limitSpeed 220 ;
	vehicle player forceSpeed 60 ;
	_wp = _grp addWaypoint [_pos,0] ;
	_wp setWaypointType "LOITER" ;
	_wp setWaypointLoiterType "CIRCLE_L" ;
	_wp setWaypointLoiterRadius 1500 ;
	
	removeMissionEventHandler[ "MapSingleClick", _thisEventHandler ];
}];

 

  • Like 2

Share this post


Link to post
Share on other sites
30 minutes ago, Larrow said:

No if you issue a onMapSingleClick then another onMapSingleClick is used, the first will be overridden( will not exist, there can only ever be one onMapSingleClick set ).

You may not be doing this yourself but if any other scripts/addons use it yours maybe overridden. Always safer to use MEH version.

 


openMap true ;
addMissionEventHandler [ "MapSingleClick", {
	params[ "_units", "_pos", "_alt", "_shift" ];
	
	openMap false ;
	_grp = group player ;
	_grp setBehaviour "CARELESS" ;
	_grp setCombatMode "BLUE" ;
	vehicle player limitSpeed 220 ;
	vehicle player forceSpeed 60 ;
	_wp = _grp addWaypoint [_pos,0] ;
	_wp setWaypointType "LOITER" ;
	_wp setWaypointLoiterType "CIRCLE_L" ;
	_wp setWaypointLoiterRadius 1500 ;
	
	removeMissionEventHandler[ "MapSingleClick", _thisEventHandler ];
}];

 

That also works, thank you. 

Now..I realize that before adding a waypoint, I have to delete the previous one, right?

As suggested HERE, I tried this

openMap true ;  
addMissionEventHandler [ "MapSingleClick", {  
 params[ "_units", "_pos", "_alt", "_shift" ];  
   
 openMap false ; 
 _grp = group player ; 
 while {(count (waypoints _grp)) > 0} do 
 { 
  deleteWaypoint ((waypoints _grp) select 0); 
 };///as suggested
 _grp setBehaviour "CARELESS" ;  
 _grp setCombatMode "BLUE" ;  
 vehicle player limitSpeed 220 ;  
 vehicle player forceSpeed 60 ; 
 vehicle player flyInHeightASL [500, 500, 500];///added this for a smooth circling of loiter waypoint 
 _wp = _grp addWaypoint [_pos,0] ;  
 _wp setWaypointType "LOITER" ;  
 _wp setWaypointLoiterType "CIRCLE_L" ;  
 _wp setWaypointLoiterRadius 1500 ;  
   
 removeMissionEventHandler[ "MapSingleClick", _thisEventHandler ];  
}];

Works as intended now.

  • Like 2

Share this post


Link to post
Share on other sites
24 minutes ago, zagor64bz said:

Now..I realize that before adding a waypoint, I have to delete the previous one, right?

No, just set the groups current waypoint as the one you added.

_wp = _grp addWaypoint [_pos,0] ;  
_wp setWaypointType "LOITER" ;  
_wp setWaypointLoiterType "CIRCLE_L" ;  
_wp setWaypointLoiterRadius 1500 ;

_grp setCurrentWaypoint _wp;

 

  • Thanks 1

Share this post


Link to post
Share on other sites
5 minutes ago, Larrow said:

No, just set the groups current waypoint as the one you added.


_wp = _grp addWaypoint [_pos,0] ;  
_wp setWaypointType "LOITER" ;  
_wp setWaypointLoiterType "CIRCLE_L" ;  
_wp setWaypointLoiterRadius 1500 ;

_grp setCurrentWaypoint _wp;

 

I see....it works , thanks!

  • Like 1

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

×