Jump to content
Sign in to follow this  
=242= CPT. Helios

onmapdoubleclick question

Recommended Posts

Hello and thank you for your time. I'm having difficulty in getting an AI character which has been assigned as driver and moved into a ship to move to a specific area on the map with the execution of a radio command running a .sqf script which has a onmapdoubleclick function. I have two questions for this.

The boat begins with a disabled move AI due to the fact that there are also gunners in the boat which have the annoying tendency of moving the boat around in order to engage enemies. This should not happen and the ship must be 100% stationary unless ordered around by a player.

1. How do I automatically show the map on the execution of this radio command?

2. What would I need to do to order this unit around?

I currently am using this setup.

titletext ["Click on the map to set the Ship's destination","plain down"];
onMapSingleClick "boatdriver enableai "move"; _boatdriver domove _pos; "destination" setmarkerpos _pos; onmapsingleclick ''; true;"

while {(ship1 distance destination) < 300} do
{
	boatdriver enableai "move";
	anfundaunted setspeedmode "full";
	boatdriver domove getpos destination;
	boatdriver dowatch getpos destination;
}
boatdriver disableai "move";
exit

a blufor officer named boatdriver is spawned in the corner of the map, assigned as driver and then moved into the driver seat of the ship titled ship1. He is finally given a disableai "move" command and cannot move until this moving script has executed it's enableai "move" command. Which allows the other units in the turret guns to complain all they want but cannot adjust the ship's position.

This script however, does not work. Would someone please help me solve this problem? Thanks.

Share this post


Link to post
Share on other sites

Hi helios. I'm not in a convenient position to give a complete response, but I thought it would be a shame to let this thread get buried without any replies.

1. How do I automatically show the map on the execution of this radio command?

The OpenMap command should get what you're looking for.

2. What would I need to do to order this unit around?

The following should work:

onDoubleClick {boatdriver move _pos}

This script however, does not work. Would someone please help me solve this problem? Thanks.

When debugging, the first step is to isolate the problem. Which part does not work? Can you get any onMapSingleClick or onDoubleClick commands to work? Can you get any units to move using these commands? Start with simple commands and then add each layer of complexity one by one.

An essential step in debugging is to use the -showScriptErrors startup parameter.

One possible error I noticed just from looking:

boatdriver enableai "move"; _boatdriver domove _pos

Here you seem to be treating "boatdriver" inconsistently as a local variable and a global variable. That will mess things up. I've done that mistake 2 million times.

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  

×