KronicBuzzKill 10 Posted September 24, 2013 Hey guys just wondering if someone could help out with this issue or is having similar.... The problems will follow as well as the script... 1. The chopper detects the smoke only. 2. When the chopper lands at base and all units disembark chopper explodes. //this addEventHandler ["fired",{_this execvm "detect_smoke.sqf"}] _shooter = _this Select 0; _ammotype = _this Select 4; //hint format["%1",_ammotype]; sleep 2; switch (_ammotype) do { case "SmokeShellGreen": { Hint "Green Smoke Detected"; _wp0 = group chopper addWaypoint [ getpos player, 50]; _wp0 setWaypointType "MOVE"; _wp0 setWaypointStatements ["true", "chopper land 'land'"]; waituntil {{_x in chopper}count units blue == {alive _x} count units blue}; _wp1 = group chopper addWaypoint [getpos base, 50]; _wp1 setWaypointType "MOVE"; _wp2 = group chopper addWaypoint [getpos base, 50]; _wp2 setWaypointType "TR UNLOAD"; _wp2 setWaypointStatements ["true", "chopper land 'land';chopper setdamage 1"]; waituntil {{_x in chopper}count units blue == {alive _x} count units blue}; }; case "1Rnd_SmokeGreen_Grenade_shell": { Hint "Green SmokeShell Detected"; }; case "FlareGreen_F": { Hint "Green Flare Detected"; }; case "3Rnd_SmokeGreen_Grenade_shell": { Hint "Green SmokeShell Detected"; }; case "UGL_FlareGreen_F": { Hint "Green Flare Detected"; }; case "3Rnd_UGL_FlareGreen_F": { Hint "Green Flare Detected"; }; }; Thanks guys :) Share this post Link to post Share on other sites
kylania 568 Posted September 24, 2013 This is what I've used for a similar situation. This brings reinforcements to you, but you can just leave them off and hop on the helo instead. :) // SMOKEHELI by kylania with fixes from Larrow // Options. SMOKEHELI_spawnMarker = "heliBase"; // STRING - marker name of where to start and delete the helicopter. SMOKEHELI_helicopterType = "B_Heli_Light_01_F"; // STRING - class name of the helicopter to use. SMOKEHELI_groupType = (configFile >> "CfgGroups" >> "West" >> "BLU_F" >> "Infantry" >> "BUS_ReconPatrol"); // CONFIG - CfgGroups entry of preset group // SMOKEHELI_groupType = ["B_Soldier_F","B_Soldier_F","B_Soldier_F"]; // ARRAY - List of classnames to spawn for reinforcements. Option instead of above. SMOKEHELI_SmokeColor = "SmokeShellGreen"; // STRING - classname of the smoke grenade to look for. SMOKEHELI_feedback = true; // BOOL - Yell smoke out like a boss? if (isNil "SMOKEHELI_Active") then {SMOKEHELI_Active = false;}; // Function to check for smoke being thrown. SMOKEHELI_fnc_addSmokeCheck = { // Add eventHandler for tossing smoke from Demonized _idx = player addEventHandler ["Fired", { if (((_this select 5) != SMOKEHELI_SmokeColor) || SMOKEHELI_Active) exitWith {}; // Not green so ignore it. // Green! Lets see where it lands. _null = (_this select 6) spawn { // Get current location of the smoke shell _posg = getPos _this; sleep 0.5; // As it rolls keep updating the location. If it keeps rolling or jitters it's last pos when it disappears will be _posg. while {(_posg distance (getPos _this)) > 0} do { _posg = getPos _this; sleep 0.5; }; // We've come to a stop and know where to fly so lets do it! [[_posg, player], "SMOKEHELI_fnc_spawnReinforcements", false] spawn BIS_fnc_MP; if (SMOKEHELI_feedback) then { player sideChat "Smoke out!"; playSound3D ["A3\dubbing_radio_f\data\Male02\RadioProtocolENG\Stealth\200_CombatShouts\ThrowingSmokeE_2.ogg", player]; // so lulz :) }; }; }]; }; // Function to spawn helicopter and reinforcements and deploy them. SMOKEHELI_fnc_spawnReinforcements = { private["_reinforcements", "_heli"]; SMOKEHELI_Active = true; publicVariable "SMOKEHELI_Active"; _landPos = _this select 0; _unit = _this select 1; _spawnPos = getMarkerPos SMOKEHELI_spawnMarker; //make sure helipad is at 0 elevation _landPos set [2, 0]; // Spawn invis helipad at the smoke to land on. _helipad = createVehicle ["Land_HeliPadEmpty_F", _landPos, [], 0, "NONE"]; // Spawn helicopter and crew. _helisv = [_spawnPos, [_spawnPos, _landPos] call BIS_fnc_dirTo , SMOKEHELI_helicopterType, west] call BIS_fnc_spawnVehicle; _heli = _helisv select 0; _heliCrew = _helisv select 1; _heliGroup = _helisv select 2; // Spawn reinforcements and get them in the helicopter. _reinforcements = [_spawnPos, blufor, SMOKEHELI_groupType] call BIS_fnc_spawnGroup; {_x assignAsCargo _heli; _x moveInCargo _heli;} forEach units _reinforcements; // Waypoint to the location for heli _wp1 = _heliGroup addWaypoint [_landPos, 0]; _wp1 setWaypointSpeed "FULL"; _wp1 setWaypointType "TR UNLOAD"; _wp1 setWaypointStatements ["true", "(vehicle this) LAND 'GET OUT';"]; // Wait till we're out. waitUntil{sleep 1; {_x in _heli} count units _reinforcements == 0}; // Release heli from being landed and clean up. _heli flyInHeight 50; // Join the units to the player's group. units _reinforcements joinSilent _unit; //Waypoint back to base and delete _dir = [_landPos, _spawnpos] call BIS_fnc_dirTo; _delPos = [_spawnPos, 500, _dir] call BIS_fnc_relPos; _wp2 = _heliGroup addWaypoint [_delPos, 0]; _wp2 setWaypointSpeed "FULL"; _wp2 setWaypointType "MOVE"; _wp2 setWaypointStatements ["true", "{deleteVehicle _x} forEach crew (vehicle this) + [vehicle this]; SMOKEHELI_Active = false; publicVariable 'SMOKEHELI_Active';"]; deleteVehicle _helipad; }; // Add eventhandler to player. player call SMOKEHELI_fnc_addSmokeCheck; Share this post Link to post Share on other sites
thestuntman 10 Posted December 9, 2013 What would be the easiest way to modify this so that the chopper moves to a spot on the map (selected using onMapClick. I have no problem with this part) and once it arrives at this spot, THEN it starts waiting for the smoke grenade before landing? ---------- Post added at 09:05 ---------- Previous post was at 07:49 ---------- Super messy but it seems to work. Any improvements would be appreciated // SMOKEHELI by kylania with fixes from Larrow // Options. SMOKEHELI_spawnMarker = "heliBase"; // STRING - marker name of where to start and delete the helicopter. SMOKEHELI_helicopterType = "B_Heli_Light_01_F"; // STRING - class name of the helicopter to use. SMOKEHELI_groupType = (configFile >> "CfgGroups" >> "West" >> "BLU_F" >> "Infantry" >> "BUS_ReconPatrol"); // CONFIG - CfgGroups entry of preset group // SMOKEHELI_groupType = ["B_Soldier_F","B_Soldier_F","B_Soldier_F"]; // ARRAY - List of classnames to spawn for reinforcements. Option instead of above. SMOKEHELI_SmokeColor = "SmokeShellGreen"; // STRING - classname of the smoke grenade to look for. SMOKEHELI_feedback = true; // BOOL - Yell smoke out like a boss? SMOKEHELI_hovering = false; hoverpos = []; if (isNil "SMOKEHELI_Active") then {SMOKEHELI_Active = false;}; // Function to check for smoke being thrown. SMOKEHELI_fnc_addSmokeCheck = { _spawnPos = getMarkerPos SMOKEHELI_spawnMarker; waituntil {visibleMap}; MapClicked = false; hint "click point on map"; sleep 0.2; onMapSingleClick "hoverpos = _pos; onMapSingleClick ' '; MapClicked = true; true;"; hoverpos = [hoverpos,random 360,[50,100],false,2] execvm "SHK_pos.sqf"; //hoverpos = [(hoverpos select 0)-(100*sin(random 359)),(hoverpos select 1)-(100*cos(random 359)),(hoverpos select 2)]; waituntil {MapClicked}; hint format ["Point Marked: %1",hoverpos]; sleep 1; MapClicked = false; //reset the variable for if you want to do it again // Spawn helicopter and crew. _helisv = [_spawnPos, [_spawnPos, hoverpos] call BIS_fnc_dirTo , SMOKEHELI_helicopterType, west] call BIS_fnc_spawnVehicle; _heli = _helisv select 0; _heliCrew = _helisv select 1; _heliGroup = _helisv select 2; SMOKEHELI_name = _heli; // Spawn reinforcements and get them in the helicopter. // *****Commented out for reinforcements***** //_reinforcements = [_spawnPos, blufor, SMOKEHELI_groupType] call BIS_fnc_spawnGroup; //{_x assignAsCargo _heli; _x moveInCargo _heli;} forEach units _reinforcements; SMOKEHELI_name flyInHeight 50; // Waypoint to the location for heli _wp1 = _heliGroup addWaypoint [hoverpos, 0]; _wp1 setWaypointSpeed "FULL"; // *****Commented out for reinforcements***** //_wp1 setWaypointType "TR UNLOAD"; _wp1 setWaypointType "MOVE"; _wp1 setWaypointStatements ["true", "SMOKEHELI_hovering=true;"]; waituntil{SMOKEHELI_hovering}; _heli sideChat "Evac chopper awaiting confirmation of LZ. Mark it with Green Smoke and we'll bring her down"; // Add eventHandler for tossing smoke from Demonized _idx = player addEventHandler ["Fired", { if (((_this select 5) != SMOKEHELI_SmokeColor) || SMOKEHELI_Active) exitWith {}; // Not green so ignore it. // Green! Lets see where it lands. _null = (_this select 6) spawn { // Get current location of the smoke shell _posg = getPos _this; sleep 0.5; // As it rolls keep updating the location. If it keeps rolling or jitters it's last pos when it disappears will be _posg. while {(_posg distance (getPos _this)) > 0} do { _posg = getPos _this; sleep 0.5; }; // We've come to a stop and know where to fly so lets do it! [[_posg], "SMOKEHELI_fnc_spawnReinforcements", false] spawn BIS_fnc_MP; if (SMOKEHELI_feedback) then { SMOKEHELI_name sideChat "Smoke seen. Landing now"; }; }; }]; }; // Function to spawn helicopter and reinforcements and deploy them. SMOKEHELI_fnc_spawnReinforcements = { private["_reinforcements", "_heli"]; SMOKEHELI_Active = true; publicVariable "SMOKEHELI_Active"; _landPos = _this select 0; _heligroup = group SMOKEHELI_name; _basePos = getMarkerPos SMOKEHELI_spawnMarker; hint format ["Heli: %1", SMOKEHELI_name]; sleep 2; hint format ["Group: %1", _heligroup]; //make sure helipad is at 0 elevation _landPos set [2, 0]; // Spawn invis helipad at the smoke to land on. _helipad = createVehicle ["Land_HeliPadEmpty_F", _landPos, [], 0, "NONE"]; // Waypoint to the location for heli _wp1 = _heliGroup addWaypoint [_landPos, 0]; _wp1 setWaypointSpeed "FULL"; // *****Commented out for reinforcements***** //_wp1 setWaypointType "TR UNLOAD"; _wp1 setWaypointType "MOVE"; _wp1 setWaypointStatements ["true", "(vehicle this) LAND 'GET IN';"]; // Wait till we're out. waitUntil{sleep 1; {_x in SMOKEHELI_name} count units group player == count units group player}; SMOKEHELI_hovering = false; // Release heli from being landed and clean up. SMOKEHELI_name flyInHeight 50; // Join the units to the player's group. // *****Commented out for reinforcements***** //units _reinforcements joinSilent _unit; //Waypoint back to base and delete _dir = [_landPos, _basePos] call BIS_fnc_dirTo; _delPos = [_basePos, 500, _dir] call BIS_fnc_relPos; _wp2 = _heliGroup addWaypoint [_delPos, 0]; _wp2 setWaypointSpeed "FULL"; _wp2 setWaypointType "MOVE"; // *****Commented out for reinforcements***** //_wp2 setWaypointStatements ["true", "{deleteVehicle _x} forEach crew (vehicle this) + [vehicle this]; SMOKEHELI_Active = false; publicVariable 'SMOKEHELI_Active';"]; _wp2 setWaypointStatements ["true", "(vehicle this) LAND 'LAND';SMOKEHELI_Active = false; publicVariable 'SMOKEHELI_Active';"]; deleteVehicle _helipad; }; // Add eventhandler to player. player call SMOKEHELI_fnc_addSmokeCheck; Share this post Link to post Share on other sites