mirror of
https://github.com/ciribob/DCS-CSAR.git
synced 2025-10-29 16:56:07 +00:00
Release 1.8
Changed destruction to use explosion as its guaranteed to work. Aircraft is now destroyed after takeoff.
This commit is contained in:
parent
8c29b99ffc
commit
1f0b1ea355
56
CSAR.lua
56
CSAR.lua
@ -1,6 +1,6 @@
|
|||||||
-- CSAR Script for DCS Ciribob - 2015
|
-- CSAR Script for DCS Ciribob - 2015
|
||||||
-- Version 1.7 - 09/10/2015
|
-- Version 1.8 - 21/10/2015
|
||||||
-- DCS 1.7 Compatible - Needs Mist 4.0.55 or higher!
|
-- DCS 1.5 Compatible - Needs Mist 4.0.55 or higher!
|
||||||
|
|
||||||
csar = {}
|
csar = {}
|
||||||
|
|
||||||
@ -19,6 +19,8 @@ csar.disableIfNoEjection = false -- if true disables aircraft even if the pilot
|
|||||||
csar.disableAircraftTimeout = true -- Allow aircraft to be used after 20 minutes if the pilot isnt rescued
|
csar.disableAircraftTimeout = true -- Allow aircraft to be used after 20 minutes if the pilot isnt rescued
|
||||||
csar.disableTimeoutTime = 20 -- Time in minutes for TIMEOUT
|
csar.disableTimeoutTime = 20 -- Time in minutes for TIMEOUT
|
||||||
|
|
||||||
|
csar.destructionHeight = 150 -- height in meters an aircraft will be destroyed at if the aircraft is disabled
|
||||||
|
|
||||||
csar.disableCSARAircraft = false -- if set to TRUE then if a CSAR heli crashes or is shot down, it'll have to be rescued by another CSAR Heli!
|
csar.disableCSARAircraft = false -- if set to TRUE then if a CSAR heli crashes or is shot down, it'll have to be rescued by another CSAR Heli!
|
||||||
|
|
||||||
csar.enableForAI = false -- set to false to disable AI units from being rescued.
|
csar.enableForAI = false -- set to false to disable AI units from being rescued.
|
||||||
@ -138,6 +140,10 @@ function csar.eventHandler:onEvent(_event)
|
|||||||
return -- error!
|
return -- error!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if csar.currentlyDisabled[_unit:getName()] ~= nil then
|
||||||
|
return --already ejected once!
|
||||||
|
end
|
||||||
|
|
||||||
trigger.action.outTextForCoalition(_unit:getCoalition(), "MAYDAY MAYDAY! " .._unit:getTypeName() .. " shot down. No Chute!", 10)
|
trigger.action.outTextForCoalition(_unit:getCoalition(), "MAYDAY MAYDAY! " .._unit:getTypeName() .. " shot down. No Chute!", 10)
|
||||||
|
|
||||||
--mark plane as broken and unflyable
|
--mark plane as broken and unflyable
|
||||||
@ -249,39 +255,61 @@ function csar.checkDisabledAircraftStatus(_name)
|
|||||||
|
|
||||||
if csar.disableAircraftTimeout then
|
if csar.disableAircraftTimeout then
|
||||||
|
|
||||||
local _text = string.format("This aircraft cannot be flow as the pilot was killed in a crash. Reinforcements in %.2dM,%.2dS", (_time/60), _time%60)
|
local _text = string.format("This aircraft cannot be flow as the pilot was killed in a crash. Reinforcements in %.2dM,%.2dS\n\nIt will be destroyed on takeoff!", (_time/60), _time%60)
|
||||||
|
|
||||||
--display message,
|
--display message,
|
||||||
csar.displayMessageToSAR(_unit,_text, 10)
|
csar.displayMessageToSAR(_unit,_text, 10,true)
|
||||||
else
|
else
|
||||||
--display message,
|
--display message,
|
||||||
csar.displayMessageToSAR(_unit, "This aircraft cannot be flown again as the pilot was killed in a crash", 10)
|
csar.displayMessageToSAR(_unit, "This aircraft cannot be flown again as the pilot was killed in a crash\n\nIt will be destroyed on takeoff!", 10,true)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if csar.disableAircraftTimeout then
|
if csar.disableAircraftTimeout then
|
||||||
--display message,
|
--display message,
|
||||||
csar.displayMessageToSAR(_unit, _details.desc .. " needs to be rescued or reinforcements arrive before this aircraft can be flown again! Reinforcements in "..string.format("%.2dM,%.2d",(_time/60), _time%60), 10)
|
csar.displayMessageToSAR(_unit, _details.desc .. " needs to be rescued or reinforcements arrive before this aircraft can be flown again! Reinforcements in "..string.format("%.2dM,%.2d",(_time/60), _time%60).."\n\nIt will be destroyed on takeoff!", 10,true)
|
||||||
else
|
else
|
||||||
--display message,
|
--display message,
|
||||||
csar.displayMessageToSAR(_unit, _details.desc .. " needs to be rescued before this aircraft can be flown again! ", 10)
|
csar.displayMessageToSAR(_unit, _details.desc .. " needs to be rescued before this aircraft can be flown again!\n\nIt will be destroyed on takeoff!", 10,true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--destroy in 10 seconds
|
if csar.destroyUnit(_unit) then
|
||||||
timer.scheduleFunction(csar.destroyUnit, {_name, _unit:getPlayerName()}, timer.getTime() + 10)
|
return --plane destroyed
|
||||||
|
else
|
||||||
|
--check again in 10 seconds
|
||||||
|
timer.scheduleFunction(csar.checkDisabledAircraftStatus, _name, timer.getTime() + 10)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function csar.destroyUnit(_args)
|
function csar.destroyUnit(_unit)
|
||||||
local _unit = Unit.getByName(_args[1])
|
|
||||||
|
|
||||||
--destroy if the SAME player is still in the aircraft
|
--destroy if the SAME player is still in the aircraft
|
||||||
-- if a new player got in it'll be destroyed in a bit anyways
|
-- if a new player got in it'll be destroyed in a bit anyways
|
||||||
if _unit ~= nil and _unit:getPlayerName() == _args[2] then
|
if _unit ~= nil and _unit:getPlayerName() ~= nil then
|
||||||
_unit:destroy()
|
|
||||||
|
if csar.heightDiff(_unit) > csar.destructionHeight then
|
||||||
|
|
||||||
|
csar.displayMessageToSAR(_unit, "Aircraft Destroyed as the pilot needs to be rescued!", 10,true)
|
||||||
|
--if we're off the ground then explode
|
||||||
|
trigger.action.explosion(_unit:getPoint(),100);
|
||||||
|
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
--_unit:destroy() destroy doesnt work for playes who arent the host in multiplayer
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
function csar.heightDiff(_unit)
|
||||||
|
|
||||||
|
local _point = _unit:getPoint()
|
||||||
|
|
||||||
|
return _point.y - land.getHeight({ x = _point.x, y = _point.z })
|
||||||
end
|
end
|
||||||
|
|
||||||
csar.addBeaconToGroup = function(_woundedGroupName, _freq)
|
csar.addBeaconToGroup = function(_woundedGroupName, _freq)
|
||||||
@ -1304,4 +1332,4 @@ timer.scheduleFunction(csar.addMedevacMenuItem, nil, timer.getTime() + 5)
|
|||||||
|
|
||||||
world.addEventHandler(csar.eventHandler)
|
world.addEventHandler(csar.eventHandler)
|
||||||
|
|
||||||
env.info("Medevac event handler added")
|
env.info("CSAR event handler added")
|
||||||
BIN
csar-test.miz
BIN
csar-test.miz
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user