Home   Help Search Login Register  

Author Topic: OnMapClick again  (Read 2285 times)

0 Members and 1 Guest are viewing this topic.

Dog - RM

  • Guest
OnMapClick again
« on: 12 Nov 2004, 08:09:48 »
I think that I have the public variable thing sorted out. But when the client uses the mapclick to move the chopper to a point on map the chopper will not land. It just hovers over the clicked area.

I attached the 3 files that the chopper extract script uses.

I will put the code up so it makes it easier.

heliMove.sqs

Code: [Select]
_pos = _this select 0

a = 0
b = 0
clicked = false

onMapSingleClick {a = (_pos select 0); b = (_pos select 1); clicked = true; publicVariable "a"; publicVariable "b"; publicVariable "clicked"}
{"publicVariable _x" forEach [a,b,clicked]}

@clicked

onMapSingleClick {}
_pos = [a,b]


2 setRadioMsg "HELO1 Return to base"

"blackhawk" setMarkerType "marker"
"blackhawk" setMarkerPos _pos
hMove setPos [(_pos select 0),(_pos select 1),0]

[_pos] exec "coords.sqs"
heliPilot doMove _pos
@ (unitReady heliPilot) && ((getPos heli select 2) > 10)
~2
heli land "get in"
@ (unitReady heliPilot) && ((getPos heli select 2) < 1)
heliPilot sideChat "Command this is HELO1 be advised we are on the Ground ......."

exit

heliBase.sqs

Code: [Select]
_pos = _this select 0

a = 0
b = 0
clicked = false

onMapSingleClick {a = (_pos select 0); b = (_pos select 1); clicked = true; publicVariable "a"; publicVariable "b"; publicVariable "clicked"}
{"publicVariable _x" forEach [a,b,clicked]}

@clicked

onMapSingleClick {}
_pos = [a,b]


2 setRadioMsg "null"

"blackhawk" setMarkerType "empty"

heliPilot sideChat "Command This is HELO1 returning to Base ....."
heliPilot doMove (getPos hBase)
@ (unitReady heliPilot) && ((getPos heli select 2) > 10)
~2
heli land "land"
@ (unitReady heliPilot) && ((getPos heli select 2) < 1)
heliPilot sideChat "Command this is HELO1 ..... we are on the ground and ready for new orders "

exit

coords.sqs

Code: [Select]
_pos = _this select 0

_xpos = _pos select 0
_ypos = _pos select 1

_letters = ["Aa","Ab","Ac","Ad","Ae","Af","Ag","Ah","Ai","Aj","Ba","Bb","Bc","Bd","Be","Bf","Bg","Bh","Bi","Bj","Ca","Cb",
"Cc","Cd","Ce","Cf","Cg","Ch","Ci","Cj","Da","Db","Dc","Dd","De","Df","Dg","Dh","Di","Dj","Ea","Eb","Ec","Ed","Ee","Ef","Eg","Eh",
"Ei","Ej","Fa","Fb","Fc","Fd","Fe","Ff","Fg","Fh","Fi","Fj","Ga","Gb","Gc","Gd","Ge","Gf","Gg","Gh","Gi","Gj","Ha","Hb","Hc","Hd","He","
Hf","Hg","Hh","Hi","Hj","Ia","Ib","Ic","Id","Ie","If","Ig","Ih","Ii","Ij","Ja","Jb","Jc","Jd","Je","Jf","Jg","Jh","Ji","Jj"]

_numbers = ["99","98","97","96","95","94","93","92","91","90","89","88","87","86","85","84","83","82","81","80","79","78","77","76","75",
"74","73","72","71","70","69","68","67","66","65","64","63","62","61","60","59","58","57","56","55","54","53","52","51","50","49","48",
"47","46","45","44","43","42","41","40","39","38","37","36","35","34","33","32","31","30","29","28","27","26","25","24","23","22","21","
20","19","18","17","16","15","14","13","12","11","10","09","08","07","06","05","04","03","02","01","00"]

? (_xpos < 0) or (_xpos > 12800) : _xcoor = "??"; goto "Ycoor"

_xcoor = _letters select ((_xpos-64)/128)

#Ycoor

? (_ypos < 0) or (_ypos > 12800) : _ycoor = "??"; goto "ShowXYcoor"

_ycoor = _numbers select ((_ypos-64)/128)

#ShowXYcoor

heliPilot sideChat format ["Command this is HELO1 we are en-route to grid reference %1%2", _xcoor, _ycoor]

exit

« Last Edit: 28 Nov 2004, 11:57:51 by Dog - RM »

Dog - RM

  • Guest
Re:OnMapClick again
« Reply #1 on: 18 Nov 2004, 18:17:50 »
Ok the response has been non-existent so I will attact the original scripts WITH THE README (hope the init.sqs is not the prob) made by
 the "master" Skumball. This is by far the best heli transport scipt i have found. Your guy (AI) will fly in no matter what the situation is on
ground (eg heavy fire) which is why I am so desparate to get it going for MP.

Offline Flaber

  • Members
  • *
    • Escuadron 13th TigerSharks
Re:OnMapClick again
« Reply #2 on: 19 Nov 2004, 13:38:38 »
Hi, try using
heli land "get out" instead of "get in"
I've tryed a lot and I think that "get in" command doesn't works fine in mp missions (at least with dedicated servers)
I  have an scritp for dinamic heli transport and works perfectly in multiplayer mission: here do you have the part of the script that i use to land the chopper without stoping the engines.

hope this helps you
comments are in spanish, but aren't important to understand the code.

Code: [Select]
; El piloto se desplaza a la zona de despliegue.
_piloto move _pos
_helicoptero FlyInHeight 25
~10
_piloto SetSpeedMode "normal"
~1
@ (_piloto distance _destino) <= 500
_piloto SetSpeedMode "limited"
_piloto sideChat "Aproximandonos a la zona de despliegue"
@ (unitReady _piloto)
~10
_helicoptero land "get out"
_helicoptero FlyInHeight 0
~1
@ (unitReady _piloto) && ((getPos _helicoptero select 2) < 1)
_piloto sideChat "Preparado"

If you want I can give you the full script I've made, but it's not translated into english.. sorry
Flaber

Dog - RM

  • Guest
Re:OnMapClick again
« Reply #3 on: 28 Nov 2004, 11:56:30 »
not quite what I was after, but thanks for the idea. We need the pilot to stay in the chopper and get out of there as soon as he recieves the
command to RTB. AI boarding and getting out of vehicles are notoriously dumb :(

Dog - RM

  • Guest
Re:OnMapClick again
« Reply #4 on: 19 Dec 2004, 17:34:52 »
We have tried everything and cannot get this to work in MP. By the way we are pretty dumb at scripting etc but slowly (very slowly) improving. It is just that the heli hovers when a non server player calls it. Anyone know what the heck we doing wrong???
« Last Edit: 19 Dec 2004, 17:35:39 by Dog - RM »

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re:OnMapClick again
« Reply #5 on: 29 Dec 2004, 01:22:14 »
Have you tried:

heli flyinheight 0

instead of or in addition to your command:

heli land "land"

Flaber's snippet used this technique, and I've seen Snypir use this in his "Quick Landings" scripts.

Also, if you suspect the AI doesn't want to land due to knowledge of enemy units, then try setting the heli to be in CARELESS mode.
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline Gnat

  • Addons Depot
  • Former Staff
  • ****
  • I Bite!
    • Gnats
Re:OnMapClick again
« Reply #6 on: 07 Jan 2005, 11:19:17 »
Just a couple of thoughts;
- Have you tried placing an invisible "H" at the spot ?
- Have you done an AssignAsCargo for each of the ppl that are meant to board ?

Dog - RM

  • Guest
Re:OnMapClick again
« Reply #7 on: 11 Jan 2005, 16:33:06 »
Just a couple of thoughts;
- Have you tried placing an invisible "H" at the spot ?
- Have you done an AssignAsCargo for each of the ppl that are meant to board ?


thought of that, but we use a lot of random stuff so do not know where we will be when call in chopper. The good thing about this is not having to worry about waypoints etc. There is no set destination or embark point. It is up to the commander in the mission at the time when we bail. Which is why th singlemap click is so cool. Luckily we have got it to work with some APC's.

Prob is they take a fair time to get to location especially if we have moved a fair way off. The only prob we have with this is that the chopper hovers. But will definately give the flyinheight 0 (or maybe 4) a go. usually something simple like that.
« Last Edit: 23 Jan 2005, 15:02:51 by Dog - RM »

polvy

  • Guest
Re:OnMapClick again
« Reply #8 on: 11 Jan 2005, 23:52:53 »
I tried this about a year ago. No luck. I did everything you've done so far. I think this one is a gonner unfortunatly.

Seabiscuit

  • Guest
Re:OnMapClick again
« Reply #9 on: 26 Jan 2005, 20:53:03 »
Dog-RM

I think that what Gnat was getting at was that you should create an invisible H, name it in the editor, then use a setPos to move it where you want the helo to land (i.e. the mapClick position).
Helos have a mind of their own when it comes to landing so if you don't give them an H they find a spot of their own.
On Gnat's second point, helos also dont like to land when they don't have cargo assigned to them.
Add another input parameter to your script and pass it the group name you want to un/mount from the helo then do an assignAsCargo  or unassignVehicle  at the appropriate time.
Another alternative is to use a rappel script, such as snYpers to just rope your guys in and forget about landing altogether.
Also check out that script to find out how to make your pilot 'oblivious' to enemy presence and make the gunner autonomous....its a great script...

Hope you don't mind but I'm going to 'borrow' some of your code here for a supressive fire script I've got rolling around in my head.

Good luck
SB...

Dingmatt

  • Guest
Re:OnMapClick again
« Reply #10 on: 05 Feb 2005, 19:44:34 »
Add this as your landing code it will force the heli to land, remember to add a heli flyinheight for it to take off again.

#Homeloop
_helihx = getpos heli select 0
_helihy = getpos heli select 1
_diffhx  = ((getpos pos select 0) - (getpos heli select 0))
_diffhy  = ((getpos pos select 1) - (getpos heli select 1))
_halfhx = _diffhx / 2
_halfhy = _diffhy / 2
_midhx = _halfhx + _helihx
_midhy = _halfhy + _helihy
heli move[_midhx,_midhy]
? (heli distance pos <300): goto "Position"
~1
goto "Homeloop"
#position

heli domove [getpos pos select 0,getpos pos select 1]
heli flyinheight 20
? (heli distance pos <30): goto "landposition"
~.01
goto "position"
#Landposition
heli domove [getpos pos select 0,getpos pos select 1]
heli flyinheight 5
? (heli distance pos <10): goto "landloop"
~.05
goto "landposition"

#Landloop
heli flyinheight 0
_heliy = getpos heli select 2
?(_heliy<=0): goto "exit2"
~.01
goto "landloop"
#exit2
~4