Home   Help Search Login Register  

Author Topic: Air Support & onMapSingleClick  (Read 1850 times)

0 Members and 1 Guest are viewing this topic.

Offline SPhoenix

  • Members
  • *
  • Team BAC
    • BAC Clan Site
Air Support & onMapSingleClick
« on: 20 Jan 2008, 15:11:04 »
Hi everybody!
I'm currently making a PvP mission in which a side has the opportunity to launch a Napalm air strike, using a script I found on ArmAholic.
To that purpose I made a script where the leader has to click twice on the map to define the direction of the strike.
Here's the script:
Code: [Select]
hintC "Cliquez sur la carte deux fois pour definir la frappe aerienne";
onMapSingleClick " ""airstrike1"" setMarkerPos _pos; onMapSingleClick "" ""airstrike2""  setMarkerPos _pos; onMapSingleClick "" "";Defini = true; true""; true;";
hint "Frappe aerienne en cours.";
waitUntil {Defini == true};
_dir = acos ( ((getMarkerPos "airstrike2" select 0) - (getMarkerPos "airstrike1" select 0))/sqrt( ((getMarkerPos "airstrike2" select 1)-(getMarkerPos "airstrike1" select 1))^2 + ((getMarkerPos "airstrike2" select 0) - (getMarkerPos "airstrike1" select 0))^2));
Plane setPos [(getMarkerPos "airstrike1" select 0) - 1000*(sin _dir),(getMarkerPos "airstrike1" select 1) - 1000*(cos _dir),200];
Plane setDir _dir
Plane move getMarkerPos "airstrike1";
Plane setVelocity [100*(sin _dir),100*(cos _dir),100]
Plane flyInHeight 200

Bidon1 = "Barrel1" createVehicle getMarkerPos "airstrike1";
Bidon2 = "Barrel2" createVehicle [(getMarkerPos "airstrike1" select 0) + 2*(sin _dir),(getMarkerPos "airstrike1" select 1) + 2*(cos _dir),0];
Bidon3 = "Barrel3" createVehicle [(getMarkerPos "airstrike1" select 0) + 4*(sin _dir),(getMarkerPos "airstrike1" select 1) + 4*(cos _dir),0];
Bidon4 = "Barrel4" createVehicle [(getMarkerPos "airstrike1" select 0) + 6*(sin _dir),(getMarkerPos "airstrike1" select 1) + 6*(cos _dir),0];

waitUntil {(Plane distance Bidon1) < 100};
~10

Bidon1 setPos [(getPos Bidon1 select 0),(getPos Bidon1 select 1),(getPos Bidon1 select 2) +14200]; nil = [Bidon1] execVM "Napalm\Napalm.sqf";
Bidon2 setPos [(getPos Bidon2 select 0),(getPos Bidon2 select 1),(getPos Bidon2 select 2) +14200]; nil = [Bidon2] execVM "Napalm\Napalm.sqf";
Bidon3 setPos [(getPos Bidon3 select 0),(getPos Bidon3 select 1),(getPos Bidon3 select 2) +14200]; nil = [Bidon3] execVM "Napalm\Napalm.sqf";
Bidon4 setPos [(getPos Bidon4 select 0),(getPos Bidon4 select 1),(getPos Bidon4 select 2) +14200]; nil = [Bidon4] execVM "Napalm\Napalm.sqf";

However the part with the onMapSingleClick won't work.
It wouldn't accept it.
Any ideas?

Code: [Select]
onMapSingleClick " ""airstrike1"" setMarkerPos _pos; onMapSingleClick "" ""airstrike2""  setMarkerPos _pos; onMapSingleClick "" "";Defini = true; true""; true;";

Thanks in advance.
SPhoenix

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Air Support & onMapSingleClick
« Reply #1 on: 20 Jan 2008, 15:26:24 »
_pos is local, you should not use locals in external code, onMapSingleClick will not be able to resolve its value.

Offline SPhoenix

  • Members
  • *
  • Team BAC
    • BAC Clan Site
Re: Air Support & onMapSingleClick
« Reply #2 on: 20 Jan 2008, 15:39:29 »
So, I should be using setMarkerPosLocal?

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Air Support & onMapSingleClick
« Reply #3 on: 20 Jan 2008, 17:38:56 »
LOL, sorry, I messed up the reply, _pos is correct there.

This should work:
Code: [Select]
Defini = false;
onMapSingleClick " 'airstrike1' setMarkerPos _pos; onMapSingleClick ' ""airstrike2""  setMarkerPos _pos; onMapSingleClick
"""";Defini = true; true'; true;"; 

Offline Nixer6

  • Members
  • *
Re: Air Support & onMapSingleClick
« Reply #4 on: 19 Feb 2008, 20:38:07 »
What won't work is

Plane move getMarkerPos "airstrike1";

and that is the whole of the problem of using OnMapSingleclick to move AI units in MP. I am experimenting with creating waypoints for the unit at marker positions.
Why do I have to be a Rocket Scientist to make a good mission?