-- Script for Hot LZ Mi-24P-1 landing time and distance from center. local Helo_Name = Group.getByName('Hot LZ Mi-24P-1') local Helo_Group_ID = Group.getID(Helo_Name) local Goal_Time = trigger.misc.getUserFlag("41") local Flag_Time = trigger.misc.getUserFlag("51") local Delta_Time = 0 local LZ_Distance = 5280 -- Set this to equal the distance from the initation trigger zone to the hot LZ local End_Msg_String = " seconds to land within 100 ft. of the center of the hot LZ. " -- Speed Conversion Factors local fps_mph = 0.68181818181818 -- feet per second to miles per hour local fps_kph = 1.0972799122176 -- feet per second to kilometers per hour local fps_knots = 0.59248385248241 -- feet per second to knots (knots is a speed. -- Avg Speed Calculations for Goal local GAvg_mph = math.ceil((LZ_Distance/Goal_Time)*fps_mph) local GAvg_kph = math.ceil((LZ_Distance/Goal_Time)*fps_kph) local GAvg_kn = math.ceil((LZ_Distance/Goal_Time)*fps_knots) -- Avg Speed Calculations for Attempt local Avg_mph = math.ceil((LZ_Distance/Flag_Time)*fps_mph) local Avg_kph = math.ceil((LZ_Distance/Flag_Time)*fps_kph) local Avg_kn = math.ceil((LZ_Distance/Flag_Time)*fps_knots) if (Flag_Time <= Goal_Time) then -- First determine if the Flag_Time is <= Gaol_Time, i.e., they met or geat the set gaol time.This is done as the messages are different and to avoid negative numbers. Delta_Time = Goal_Time - Flag_Time trigger.action.outSoundForCoalition(2 , "InEnvelope.wav" ) if 0 <= Delta_Time and Delta_Time < 3 then trigger.action.outTextForCoalition(2,'\n\nALL - Congradualations are due to Hot LZ Mi-24P-1.\n\nIt only took them ' .. Flag_Time .. End_Msg_String .. 'It was close but they beat the goal time of ' .. Goal_Time .. ' by ' .. Delta_Time .. ' seconds.', 10) elseif (3 <= Delta_Time and Delta_Time < 6) then trigger.action.outTextForCoalition(2,'\n\nALL - Congradualations are due to Hot LZ Mi-24P-1.\n\nIt only took them ' .. Flag_Time .. End_Msg_String .. ' They beat the goal time of ' .. Goal_Time .. ' by ' .. Delta_Time .. ' seconds. Pretty good.' , 10) else trigger.action.outTextForCoalition(2,'\n\nALL - Congradualations are due to Hot LZ Mi-24P-1.\n\nIt only took them ' .. Flag_Time .. End_Msg_String .. ' They blew the goal time of goal time of ' .. Goal_Time .. ' away! They beat it by ' .. Delta_Time .. " seconds. Wonder what their secret is?", 10) end -- Output the Goal time and Avg_Speed to the Coaltion trigger.action.outTextForCoalition(2, "\n\nThe results of Mi-24P-1's last atempt are: \n\n Mi-24P-1 Avg Speed Goal Avg Speed\n " .. Avg_kn .. ' kn ' .. GAvg_kn .. ' kn\n ' .. Avg_mph ..' mph ' .. GAvg_mph .. ' mph\n ' .. Avg_kph .. ' kpm ' .. GAvg_kph .. ' kmh', 15) else -- This branch is perfomred wehn it Flag_Time is > Gaol_Time. Delta_Time = Flag_Time - Goal_Time if 1 <= Delta_Time and Delta_Time < 6 then trigger.action.outTextForGroup(Helo_Group_ID, '\n\nIt took you ' .. Flag_Time .. End_Msg_String..' ALthough it was close, you missed the goal time of ' .. Goal_Time .. ' by ' .. Delta_Time .. ' seconds.', 10) elseif 6 <= Delta_Time and Delta_Time < 11 then trigger.action.outTextForGroup(Helo_Group_ID, '\n\nIt took you ' .. Flag_Time .. End_Msg_String..' A noble attempt, but you missed the goal time of ' .. Goal_Time .. ' by ' .. Delta_Time .. ' seconds. Not a bad attempt.', 10) elseif 11 <= Delta_Time and Delta_Time < 16 then trigger.action.outTextForGroup(Helo_Group_ID, '\n\nIt took you ' .. Flag_Time .. End_Msg_String..' You missed the goal time of ' .. Goal_Time .. ' by ' .. Delta_Time .. " seconds. Check to make sure you don't have a anchor dragging and try again", 10) else trigger.action.outTextForGroup(Helo_Group_ID,'\n\nIt took you ' .. Flag_Time .. End_Msg_String..' You missed the goal time of ' .. Goal_Time .. ' by ' .. Delta_Time .. ' seconds. Check to make your engines are on and try again.', 10) end -- Output the Goal time and Avg Speed to the client trigger.action.outTextForGroup(Helo_Group_ID, '\n\nThe results of your last atempt are: \n\n Your Avg Speed Goal Avg Speed\n ' .. Avg_kn .. ' kn ' .. GAvg_kn .. 'kn\n ' .. Avg_mph ..' mph ' .. GAvg_mph .. ' mph\n ' .. Avg_kph .. ' kpm ' .. GAvg_kph .. ' kmh', 15) end