Home   Help Search Login Register  

Author Topic: Chopper to land when it sees smoke  (Read 1269 times)

0 Members and 1 Guest are viewing this topic.

Offline Wildebeest

  • Contributing Member
  • **
  • The time the wildebeest ruled the Earth.
Chopper to land when it sees smoke
« on: 20 Sep 2005, 10:45:22 »
Hi!

I'm making a mission in which I want a chopper to land when it sees red smoke that the player has thrown. But I don't know how to do it.

So, how to detect whether you have thrown a smokeshell? Something whith the nearestObject commad or what?

Thanks!  :)
Weeee...

Offline Blanco

  • Former Staff
  • ****
Re:Chopper to land when it sees smoke
« Reply #1 on: 20 Sep 2005, 11:19:50 »
There was a script named "Activesmoke"  made by Sterling Silvered, but I can't find back...I take a look


Here you go
« Last Edit: 20 Sep 2005, 11:26:23 by Blanco »
Search or search or search before you ask.

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Chopper to land when it sees smoke
« Reply #2 on: 20 Sep 2005, 16:39:40 »
add a fired eventhandler to the unit which checks to see what weapon it fired.
Some additional scripting can then ascertain where the unit was when he fired it, eg near the extratction zone etc

Having the fired event create a publicvariable that either a trigger is waiting on, or the helo waypoint etc will then allow the helo to do its bit
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Kyle Sarnik

  • Guest
Re:Chopper to land when it sees smoke
« Reply #3 on: 20 Sep 2005, 21:07:28 »
Aha, this is my specialty, I pretty much perfected chopper landing at smoke:

(Gutted from my support scripts)

EvacHelo\init.sqs
Code: [Select]
_helo = _this

BD_SPEvacHelo = true; Publicvariable "BD_SPEvacHelo"

_space = _helo call BD_SPFcargo_slots
_pos = (getpos _helo)
? _pos select 2 > 20 : goto "Standby"

#Base
_base = "HeliH" createvehicle [_pos select 0,_pos select 1,0]
_base setpos [_pos select 0,_pos select 1,0]

#WaitForMission
?! (alive _helo) || !(canmove _helo) || (count crew _helo < 1) : goto "OutOfAction"
~3
_missions = BD_SPEvacHeloMissions
? count _missions <= 0 : goto "WaitForMission"
_mission = _missions select 0
_caller = _mission select 0
~0.5
? (count BD_SPEvacHeloList) == 1 : goto "StartMission"
_distances = [BD_SPEvacHeloList,{_X distance _caller}] call BD_SPFcommand_foreach
~0.5
_lowest = _distances call BD_SPFlowest_number
~0.5
_closestnumber = [_distances,_lowest] call BD_SPFarray_number
~0.5
_closest = BD_SPEvacHeloList select _closestnumber
~0.5
? _closest != _helo : goto "WaitForMission"
#StartMission
?! (alive _helo) || !(canmove _helo) || (count crew _helo < 1) : goto "OutOfAction"
_LZ = _mission select 1
_units = _mission select 2
_ID = _mission select 3
? (count _units) > (_space - (_helo call BD_SPFcargo_taken)) : goto "Unavailable"
_mission call BD_SPFremove_EvacHelo_mission
BD_SPEvacHeloList = BD_SPEvacHeloList - [_helo]
_helo setbehaviour "CARELESS"
_helo setcombatmode "BLUE"
_helo setspeedmode "FULL"
_helo flyinheight 85
~1.5
_helo sidechat format ["Roger %1, this is %2 inbound for imediate extraction at grid %3. Over.",driver _helo,_caller,(getpos _LZ) call BD_SPFgrid_pos]
#MoveToMission
?! (alive _helo) || !(canmove _helo) || (count crew _helo < 1) : goto "OutOfAction"
? _ID call BD_SPFabort_mission == 1 : goto "Aborted"
_helo domove (getpos _LZ)
~3
? _helo distance _LZ > 200 : goto "MoveToMission"
dostop _helo
_helo flyinheight 35
_helo setspeedmode "LIMITED"
_helo setcombatmode "YELLOW"
#RandomCircleLZ
?! (alive _helo) || !(canmove _helo) || (count crew _helo < 1) : goto "OutOfAction"
_coef = 1
? random(2) > 1 : _coef = -1
_xpos = (getpos _LZ select 0) + ((200+random(50)) * _coef)
_coef = 1
? random(2) > 1 : _coef = -1
_ypos = (getpos _LZ select 1) + ((200+random(50)) * _coef)
_t = 0
_helo setspeedmode "LIMITED"
#CircleLZ
?! (alive _helo) || !(canmove _helo) || (count crew _helo < 1) : goto "OutOfAction"
_helo domove [_xpos,_ypos]
? _ID call BD_SPFabort_mission == 1 : goto "Aborted"
~5
_t = _t + 1
? _t >= 3 : goto "RandomCircleLZ"
_smoke = _ID call BD_SPFfind_smoke
? format ["%1",_smoke] == "NoSmoke" : goto "CircleLZ"
#SpotSmoke
?! (alive _helo) || !(canmove _helo) || (count crew _helo < 1) : goto "OutOfAction"
_LZ setpos (getpos (_smoke select 1))
_helo domove (getpos _LZ)
_helo sidechat format ["Roger that I see your %1, LZ is %2, inbound for landing.",(_smoke select 3),(_smoke select 2)]
_status = format ["Land%1",(_smoke select 2)]
goto _status
#LandClear
?! (alive _helo) || !(canmove _helo) || (count crew _helo < 1) : goto "OutOfAction"
~15
_helo land "Get In"
@ (getpos _helo select 2) < 7
goto "Landed"
#LandHot
?! (alive _helo) || !(canmove _helo) || (count crew _helo < 1) : goto "OutOfAction"
hint format ["%1 - %2",_helo distance _LZ,abs (speed _helo)]
_helo domove (getpos _LZ)
~4
? ((_helo distance _LZ > 50) && (abs (speed _helo) > 8)) : goto "LandHot"
;_helo flyinheight 0
_helo land "Get In"
@ (getpos _helo select 2) < 7
hint format ["%1",(getpos _helo select 2)]
~3
;_helo land "LAND"
#Landed
?! (alive _helo) || !(canmove _helo) || (count crew _helo < 1) : goto "OutOfAction"
;_helo flyinheight 0
;~1
;_helo engineon true
{[_X] join objnull} foreach (_units - [player])
_units allowgetin true
{_X assignascargo _helo} foreach _units
_units ordergetin true
#CheckUnits
?! (alive _helo) || !(canmove _helo) || (count crew _helo < 1) : goto "OutOfAction"
~3
? [_units,_helo] call BD_SPFunits_in_vehicle != 1 : goto "CheckUnits"
#TakeOff
?! (alive _helo) || !(canmove _helo) || (count crew _helo < 1) : goto "OutOfAction"
_helo flyinheight 85
_helo setcombatmode "BLUE"
_helo setspeedmode "FULL"
_aborted = false
#RTB
?! (alive _helo) || !(canmove _helo) || (count crew _helo < 1) : goto "OutOfAction"
_helo domove (getpos _base)
~3
? _helo distance _base > 150 : goto "RTB"
~0.5
_helo land "LAND"
{unassignvehicle _X} foreach (crew _helo - (units group driver _helo))
@ (getpos _helo select 2) < 7
BD_SPEvacHeloList = BD_SPEvacHeloList + [_helo]
~5
? _aborted : goto "WaitForMission"
(_units - [player]) join _caller
goto "WaitForMission"

#Aborted
?! (alive _helo) || !(canmove _helo) || (count crew _helo < 1) : goto "OutOfAction"
BD_SPHeloEvacCalled = false
~0.5
_helo sidechat format ["Roger %1, aborting extraction, %2 returning to base.",_caller,_helo]
_aborted = true
goto "RTB"

#OutOfAction
? _helo in BD_SPEvacHeloList : BD_SPEvacHeloList = BD_SPEvacHeloList - [_helo]; publicvariable "BD_SPEvacHeloList"
BD_SPHeloEvacCalled = false
exit

#Unavailable
hint "Current Evac Helicopter is unavailable, try again later."
BD_SPHeloEvacCalled = false
exit

EvacHelo\radio_callmission.sqs (called by addaction)
Code: [Select]
_unit = _this select 1
_obj = _this select 0
_ID = _this select 2

? _unit != player : exit

_holder = BD_SPRadioActions select 0
_array = BD_SPRadioActions - [_holder]
{_holder removeaction _X} foreach _array
BD_SPRadioActions = [_holder]

? cadetmode : hint "Select the units you want to extract (F1-F12 keys) and click on the map to select a pick up point.\nThe map click will expire in 30 seconds."
?! cadetmode : hint "Select units and click on map to select an LZ."

BD_SPMapClicker = _this select 0
BD_SPMapClick = []
_mapclick = 0
_n = 0
onMapSingleClick {[BD_SPMapClicker,_pos,_units,_shift,_alt] exec "Player\MapClick.sqs"}
#WaitForMapClick
~1
_n = _n + 1
_mapclick = BD_SPMapClicker call BD_SPFmap_click
? _n > 30 : goto "Expired"
? format ["%1",_mapclick] == "[]" : goto "WaitForMapClick"

?! ((secondaryweapon _holder) in BD_SPRadioWeapons) : hint "Cannot transmit message without a radio!"; exit

BD_SPHeloEvacCalled = true
[] exec "Player\radio_actions.sqs"
_pos = _mapclick select 1
_units = _mapclick select 2
? format ["%1",_units] == "scalar bool array string 0xfcffffef" : _units = []
_pad = "HeliHEmpty" createvehicle _pos
_pad setpos _pos
_randID = format ["%1",(random(20)-random(20))]
BD_SPRandomIDList = BD_SPRandomIDList + [_randID]
_mission = [_unit,_pad,_units + [_unit],_randID]
BD_SPEvacHeloMissions = BD_SPEvacHeloMissions + [[_unit,_pad,_units + [_unit],_randID]]
publicvariable "BD_SPEvacHeloMissions"
_unit sidechat format ["This is %1 requesting an imediate helicopter extraction at grid %2. I repeat, this is %1, I need an imediate helicopter extraction at %2. Over",_unit,_pos call BD_SPFgrid_pos]
? Daytime > 19 || Daytime < 5 : goto "Night"
_newsmokeR = "WeaponHolder" createvehicle (getpos _unit)
_newsmokeR setpos [(getpos _unit select 0)-0.05,getpos _unit select 1,0]
_newsmokeR addmagazinecargo ["BD_M18Red",1]
_newsmokeG = "WeaponHolder" createvehicle (getpos _unit)
_newsmokeG setpos [(getpos _unit select 0)+0.05,getpos _unit select 1,0]
_newsmokeG addmagazinecargo ["BD_M18Green",1]
_newsmokeR setdir 90
_newsmokeG setdir 90
BD_SPCurrentIDEvacHelo = _randID
FiredEHIndex = _unit addeventhandler ["fired",{[_this select 0,_this select 4,BD_SPCurrentIDEvacHelo] exec "Player\SmokeEH.sqs"}]
? cadetmode : hint "Use colored smoke grenades to mark an LZ when the chopper arrives (Red = Hot LZ; Green = Clear LZ)."
?! cadetmode : hint "Use colored smoke to mark an LZ."
exit

#Night
_newsmokeR = "WeaponHolder" createvehicle (getpos _unit)
_newsmokeR setpos [(getpos _unit select 0)-0.05,getpos _unit select 1,0]
_newsmokeR addmagazinecargo ["BD_StrobeIR",1]
_newsmokeG = "WeaponHolder" createvehicle (getpos _unit)
_newsmokeG setpos [(getpos _unit select 0)+0.05,getpos _unit select 1,0]
_newsmokeG addmagazinecargo ["BD_Strobe",1]
_newsmokeR setdir 55
_newsmokeG setdir 55
BD_SPCurrentIDEvacHelo = _randID
FiredEHIndex = _unit addeventhandler ["fired",{[_this select 0,_this select 4,BD_SPCurrentIDEvacHelo] exec "Player\SmokeEH.sqs"}]
? cadetmode : hint "Use strobes to mark an LZ when the chopper arrives (IR Strobe = Hot LZ; Blue Strobe = Clear LZ)."
?! cadetmode : hint "Use strobes to mark an LZ."
exit

#Expired
hint "30 seconds has expired with no map click.\nThe radio message was not sent."
?! ((secondaryweapon _unit) in BD_SPRadioWeapons) : exit
[] exec "Player\radio_actions.sqs"
exit

Player\SmokeEH (the script called by the eventhandler ^^)
Code: [Select]
_unit = _this select 0
_ammo = _this select 1
_ID = _this select 2

_smoke = nearestobject [_unit,_ammo]
?! (_ammo in ["BD_M18G","BD_M18R","BD_StrobeA"]) : exit
? _ammo == "BD_M18R" : _LZ = "Hot"; _smoketype = "BD_M18Red"; _type = "smoke"
? _ammo == "BD_M18G" : _LZ = "Clear"; _smoketype = "BD_M18Green"; _type = "smoke"
? _ammo == "BD_StrobeA" : _LZ = "Hot"; _smoketype = "BD_Strobe"; _type = "strobe"

_unit removeeventhandler ["fired",FiredEHIndex]

@ ((velocity _smoke select 0 <= 1) && (velocity _smoke select 0 >= -1)) && ((velocity _smoke select 1 <= 1) && (velocity _smoke select 1 >= -1))

_d1 = "EmptyDetector" createvehicle [(getpos _smoke select 0)-2,(getpos _smoke select 1)+2]
_d2 = "EmptyDetector" createvehicle [(getpos _smoke select 0)+2,(getpos _smoke select 1)+2]
_d3 = "EmptyDetector" createvehicle [(getpos _smoke select 0)+2,(getpos _smoke select 1)-2]
_d4 = "EmptyDetector" createvehicle [(getpos _smoke select 0)-2,(getpos _smoke select 1)-2]

? (_d1 distance _d2 > 4.25) || (_d3 distance _d4 > 4.25) : goto "UnEven"

deletevehicle _d1
deletevehicle _d2
deletevehicle _d3
deletevehicle _d4

_logic = "Logic" createvehicle (getpos _smoke)
_logic setpos (getpos _smoke)

hint format ["You have marked a %1 LZ.",_LZ]

BD_SPSmokeIDList = BD_SPSmokeIDList + [_ID]
BD_SPSmokeArray = BD_SPSmokeArray + [[_ID,_logic,_LZ,_type]]
exit

#UnEven
hint "Ground is too uneven for the helicopter to land.\nChoose a new LZ."
_newsmoke = "WeaponHolder" createvehicle (getpos _unit)
_newsmoke setpos [getpos _unit select 0,getpos _unit select 1,0]
_newsmoke addmagazinecargo [_smoketype,1]
_newsmoke setdir (getdir _unit)
FiredEHIndex = _unit addeventhandler ["fired",{[_this select 0,_this select 4,BD_SPCurrentIDEvacHelo] exec "Player\SmokeEH.sqs"}]
exit

Player\MapClick.sqs (this one's necessity is is questionable)
Code: [Select]
_mapclick = _this

BD_SPMapClick = _mapclick
exit

Player\radio_actions.sqs is a script that handles the added actions for all of the different support assets, you probably would't need it.

Anyways, what this does:
-Allows mission maker to manualy add evac missions
-Allows player request helicopter extraction
  -From action menu
  -Mapclick for the pickup point and units to board (inlcudes him)
-If any helicopters are available, the closest one to the players position will respond
-Helicopter will fly to the point marked and enter a holding pattern
-Player is given smoke grenades (1 red, 1 green)
-When player throws a smoke, it will detect if the ground is flat enough
-The color of the smoke indicates the LZ status: Red for hot, green for clear
-Helicopter comes in and lands at LZ (differently depending on the LZ status)
-Helicopter waits for all selected units and the player to board
-Helicopter takes off and returns to IT'S original position
-Extracted units disembark, helicopter shuts down and is now ready to recieve more missions

Since its gutted from my system, you WILL have to modifiy it rather heavily so it suites your system. Peace  8)

Edit: Whoops, here are the functions btw (attached). You can preload them at the mission start.

« Last Edit: 20 Sep 2005, 21:12:03 by Kyle Sarnik »