Jump to content
Sign in to follow this  
Callaghan

OnMapClick CAS

Recommended Posts

Can anyone help me with the onmapclick command? the idea is to be able to provide a human player in MP with a move/seek and destroy waypoint when a player, in a different group, clicks on the map. The waypoint would need to be deleted after a time limit.

Secondly, for AI, I would like a script that tells a unit to get into "PlaneName", tells it to take off and engage at will and creates a LaserTarget (MAP addons i think) onmapclick location before creating a seek and destroy waypoint directly over the laser target. The waypoint should then be deleted after 5 mins and the plane commanded to autoland for rearm and repair, finally making it ready for the next CAS request.

Finally, a variation on this that causes the aircraft to take off but instead of attacking joins the players group for 5 mins before landing and rearming.

Any help/redirections with this would be greatly appreciated and will be used in missions for use on the {GOL} clan server, available to all of course.

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_type = _this select 0

_base = _this select 1

_times = _this select 2

;_times = 120

_west = ["AH1W","AH6","UH60MG", "A10", "AV8B", "AV8B2"]

_east = ["KA50","Mi17_MG","Su34","Su34B"]

?(_type in _west): _tpilot = "SoldierWPilot"; _side = west

?(_type in _east): _tpilot = "SoldierEPilot"; _side = east

?(side player != _side):exit

?(cas_busy):[_side, "airbase"] sidechat format ["%1, currently no CAS available.", name player];exit

cas_busy = true

[_side, "airbase"] sidechat format ["%1, broadcast position for CAS over.", name player]

onmapsingleclick"pos = _pos; onmapsingleclick''; goon = true; true; hint 'braodcast'"

@goon

_posi = pos

goon = false

_gridc = compile loadfile "gridcoord.sqf"

_tmp = "helihempty" createvehicle _posi

~1

_area = [_tmp] call _gridc

deletevehicle _tmp

[_side, "airbase"] sidechat format ["Understood %1, CAS supporting position %2.", name player, _area]

?(_type == "AH1W" || _type == "AH6" || _type == "KA50"):goto "heli"

?(_type == "A10" || _type == "AV8B" || _type == "AV8B2" || _type == "Su34" || _type == "Su34B"):goto "plane"

#heli

_pgroup = creategroup _side

_plane = _type createvehicle [getpos _base select 0, getpos _base select 1, 0]

[_plane, "track"] exec "follow.sqs"

_pilot = _pgroup createunit [_tpilot, getpos _plane, [], 0, "NONE"]

_pilot setskill 1

_pilot moveindriver _plane

?(_type == "AH1W" || _type == "Su34" || _type == "Su34B"):_gunner = _pgroup createunit [_tpilot, getpos _plane, [], 0, "NONE"]; _gunner moveingunner _plane

;_plane setpos [getpos _plane select 0, getpos _plane select 1, 100]

_wp = _pgroup addwaypoint [_posi,0]

_wp setwaypointtype "SAD"

_pgroup setcurrentwaypoint [_pgroup, 1]

~30

@unitready _plane

hint "unit ready"

_i = 0

#loopheli

~1

?(!alive _plane): _pilot sidechat format ["%1, %2, going down!", name player, name _pilot]; deletevehicle _pilot; goto "exit"

?(!canmove _plane): _pilot sidechat format ["%1, %2, going down!", name player, name _pilot]; deletevehicle _pilot; goto "exit"

?(!alive _pilot): _pilot sidechat format ["%1, %2, going down!", name player, name _pilot];{deletevehicle _x} foreach crew _plane; goto "exit"

?(!someammo _plane): _pilot sidechat format ["%1, %2, out of ammo!\nReturning to base. Over", name player, name _pilot];goto "helireturn"

?(fuel _plane <= 0.25): _pilot sidechat format ["%1, %2, out of fuel!\nReturning to base. Over", name player, name _pilot];goto "helireturn"

?(_times > 0): _i = _i + 1

hint format ["%1:%2", _i, _times]

?(_times > _i):goto "loopheli"

_pilot sidechat format ["%1, %2, Returning to base", name player, name _pilot]

#helireturn

~30

_plane move getpos _base

@unitready _plane

hint "delete"

goto "exit"

#plane

_pgroup = creategroup _side

_plane = _type createvehicle [getpos _base select 0, getpos _base select 1, 1000]

[_plane, "track"] exec "follow.sqs"

_vel = velocity _plane;

_dir = direction _plane;

_speed = 200; comment "Added speed";

_plane setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+ (cos _dir*_speed),(_vel select 2)];

_pilot = _pgroup createunit [_tpilot, getpos _plane, [], 0, "NONE"]

_pilot setskill 1

_pilot moveindriver _plane

?(_type == "AH1W" || _type == "Su34" || _type == "Su34B"):_gunner = _pgroup createunit [_tpilot, getpos _plane, [], 0, "NONE"]; _gunner moveingunner _plane

_plane setpos [getpos _plane select 0, getpos _plane select 1, 300]

_wp = _pgroup addwaypoint [_posi,0]

_wp setwaypointtype "SAD"

_pgroup setcurrentwaypoint [_pgroup, 1]

~30

@unitready _plane

hint "unit ready"

_i = 0

#loopplane

~1

?(!alive _plane): _pilot sidechat format ["%1, %2, going down!", name player, name _pilot]; deletevehicle _pilot; goto "exit"

?(!canmove _plane): _pilot sidechat format ["%1, %2, going down!", name player, name _pilot]; deletevehicle _pilot; goto "exit"

?(!alive _pilot): _pilot sidechat format ["%1, %2, going down!", name player, name _pilot];{deletevehicle _x} foreach crew _plane; goto "exit"

?(!someammo _plane): _pilot sidechat format ["%1, %2, out of ammo!\nReturning to base. Over", name player, name _pilot];goto "planereturn"

?(fuel _plane <= 0.25): _pilot sidechat format ["%1, %2, out of fuel!\nReturning to base. Over", name player, name _pilot];goto "planereturn"

?(_times > 0): _i = _i + 1

hint format ["%1:%2", _i, _times]

?(_times > _i):goto "loopplane"

_pilot sidechat format ["%1, %2, Returning to base", name player, name _pilot]

#planereturn

_plane move getpos _base

~30

@unitready _plane

hint "delete"

#exit

deletevehicle _plane

deletevehicle _pilot

~_time

cas_busy = false

exit

there is one example. not exactly what u want and not sure if it works in MP but you can change that i guess.

doesn't work with UH60MG yet i think. no gunners in there.

also its pretty dirty coding. did that some time in the early morning hours and just left it that way as it finally worked.

-Asuriel

Share this post


Link to post
Share on other sites

btw here is the gridcoord.sqf which is called inside the cas.sqs which i posted above.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">comment "Cheetah, 6th of January 2007 - contact: forum www.ofpec.com or cheetah99 [at] hotmail [dot] com";

comment "V1.00";

private ["_unit","_x","_upperArray","_lowerArray","_numberArray","_xLeft","_yLeft","_s1","_s2","_s3","_s4","_xCoordB","_xCoordS","_yCoordB","_yCoordS","_coord"];

_unit = _this select 0;

_xLeft = (getPos _unit) select 0;

_yLeft = (getPos _unit) select 1;

_upperArray = ["V","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P"];

_lowerArray = ["a","b","c","d","e","f","g","h","i","j"];

_numberArray = ["4","3","2","1","0","9","8","7","6","5","4","3","2","1","0","9","8","7","6"];

_numbersArray = ["1","0","9","8","7","6","5","4","3","2","1","0","9"];

_s1 = -10000;

_s2 = -8000;

_s3 = 0;

while { (_xLeft >= _s1) } do

{

if (abs(_xLeft) < _s2) then

{

if (_xLeft > 0) then

{

_xLeft = _xLeft - ((_s3-5) * 2000);

};

};

_s1 = _s1 + 2000;

_s2 = _s2 + 2000;

_s3 = _s3 + 1;

};

if (abs(_xLeft) >= 2000) then

{

_xLeft = _xLeft + (abs(_s3-5) * 2000);

_x = 1;

};

_s4 = (abs(_xLeft) / 200);

_s4 = (_s4 - (_s4 mod 1));

_xCoordB = (_upperArray select (_s3-1));

if(_x == 1) then { _s4 = 9-_s4; };

if(_xCoordB == "Z") then { _s4 = 9-_s4; };

_xCoordS = (_lowerArray select _s4);

_s1 = -9520;

_s2 = -7520;

_s3 = 0;

while { (_yLeft >= _s1) } do

{

if (_yLeft < _s2) then

{

if (_yLeft < 0) then

{

_yLeft = _yLeft + (_s3 * 2000);

_yLeft = _yLeft * -1;

}

else

{

_yLeft = _yLeft - ((_s3-5) * 2000);

};

};

_s1 = _s1 + 2000;

_s2 = _s2 + 2000;

_s3 = _s3 + 1;

};

_s4 = ((_yLeft-80) / 200);

_yCoordS = (_numbersArray select (_s4 - (_s4 mod 1)));

_yCoordB = (_numberArray select (_s3-1));

_coord = format ["%1%2%3%4",_xCoordB,_xCoordS,_yCoordB,_yCoordS];

_coord

Share this post


Link to post
Share on other sites
Quote[/b] ]

....;

_coord = format ["%1%2%3%4",_xCoordB,_xCoordS,_yCoordB,_yCoordS];

_coord

tounge2.gif

Quote[/b] ]

...;

format ["%1%2%3%4",_xCoordB,_xCoordS,_yCoordB,_yCoordS]

wink_o.gif

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  

×