CTLD - added option to force opening of doors

This commit is contained in:
Applevangelist
2021-10-12 08:32:34 +02:00
parent 0388d47f23
commit 8b9143d3f1
+21 -4
View File
@@ -22,7 +22,7 @@
-- @module Ops.CTLD -- @module Ops.CTLD
-- @image OPS_CTLD.jpg -- @image OPS_CTLD.jpg
-- Date: Sep 2021 -- Date: Oct 2021
do do
------------------------------------------------------ ------------------------------------------------------
@@ -669,6 +669,7 @@ do
-- my_ctld.cratecountry = country.id.GERMANY -- ID of crates. Will default to country.id.RUSSIA for RED coalition setups. -- my_ctld.cratecountry = country.id.GERMANY -- ID of crates. Will default to country.id.RUSSIA for RED coalition setups.
-- my_ctld.allowcratepickupagain = true -- allow re-pickup crates that were dropped. -- my_ctld.allowcratepickupagain = true -- allow re-pickup crates that were dropped.
-- my_ctld.enableslingload = false -- allow cargos to be slingloaded - might not work for all cargo types -- my_ctld.enableslingload = false -- allow cargos to be slingloaded - might not work for all cargo types
-- my_ctld.pilotmustopendoors = false -- -- force opening of doors
-- --
-- ## 2.1 User functions -- ## 2.1 User functions
-- --
@@ -987,7 +988,7 @@ CTLD.UnitTypes = {
--- CTLD class version. --- CTLD class version.
-- @field #string version -- @field #string version
CTLD.version="0.2.3" CTLD.version="0.2.4"
--- Instantiate a new CTLD. --- Instantiate a new CTLD.
-- @param #CTLD self -- @param #CTLD self
@@ -1131,6 +1132,9 @@ function CTLD:New(Coalition, Prefixes, Alias)
-- country of crates spawned -- country of crates spawned
self.cratecountry = country.id.GERMANY self.cratecountry = country.id.GERMANY
-- for opening doors
self.pilotmustopendoors = false
if self.coalition == coalition.side.RED then if self.coalition == coalition.side.RED then
self.cratecountry = country.id.RUSSIA self.cratecountry = country.id.RUSSIA
end end
@@ -1436,6 +1440,7 @@ function CTLD:_LoadTroops(Group, Unit, Cargotype)
-- landed or hovering over load zone? -- landed or hovering over load zone?
local grounded = not self:IsUnitInAir(Unit) local grounded = not self:IsUnitInAir(Unit)
local hoverload = self:CanHoverLoad(Unit) local hoverload = self:CanHoverLoad(Unit)
--local dooropen = UTILS.IsLoadingDoorOpen(Unit:GetName()) and self.pilotmustopendoors
-- check if we are in LOAD zone -- check if we are in LOAD zone
local inzone, zonename, zone, distance = self:IsUnitInZone(Unit,CTLD.CargoZoneType.LOAD) local inzone, zonename, zone, distance = self:IsUnitInZone(Unit,CTLD.CargoZoneType.LOAD)
if not inzone then if not inzone then
@@ -1447,6 +1452,9 @@ function CTLD:_LoadTroops(Group, Unit, Cargotype)
elseif not grounded and not hoverload then elseif not grounded and not hoverload then
self:_SendMessage("You need to land or hover in position to load!", 10, false, Group) self:_SendMessage("You need to land or hover in position to load!", 10, false, Group)
if not self.debug then return self end if not self.debug then return self end
elseif self.pilotmustopendoors and not UTILS.IsLoadingDoorOpen(Unit:GetName()) then
self:_SendMessage("You need to open the door(s) to load troops!", 10, false, Group)
if not self.debug then return self end
end end
-- load troops into heli -- load troops into heli
local group = Group -- Wrapper.Group#GROUP local group = Group -- Wrapper.Group#GROUP
@@ -1618,6 +1626,10 @@ end
self:_SendMessage("You need to land or hover in position to load!", 10, false, Group) self:_SendMessage("You need to land or hover in position to load!", 10, false, Group)
if not self.debug then return self end if not self.debug then return self end
end end
if self.pilotmustopendoors and not UTILS.IsLoadingDoorOpen(Unit:GetName()) then
self:_SendMessage("You need to open the door(s) to extract troops!", 10, false, Group)
if not self.debug then return self end
end
-- load troops into heli -- load troops into heli
local unit = Unit -- Wrapper.Unit#UNIT local unit = Unit -- Wrapper.Unit#UNIT
local unitname = unit:GetName() local unitname = unit:GetName()
@@ -2360,6 +2372,11 @@ function CTLD:_UnloadTroops(Group, Unit)
self:T(self.lid .. " _UnloadTroops") self:T(self.lid .. " _UnloadTroops")
-- check if we are in LOAD zone -- check if we are in LOAD zone
local droppingatbase = false local droppingatbase = false
local canunload = true
if self.pilotmustopendoors and not UTILS.IsLoadingDoorOpen(Unit:GetName()) then
self:_SendMessage("You need to open the door(s) to unload troops!", 10, false, Group)
if not self.debug then return self end
end
local inzone, zonename, zone, distance = self:IsUnitInZone(Unit,CTLD.CargoZoneType.LOAD) local inzone, zonename, zone, distance = self:IsUnitInZone(Unit,CTLD.CargoZoneType.LOAD)
if not inzone then if not inzone then
inzone, zonename, zone, distance = self:IsUnitInZone(Unit,CTLD.CargoZoneType.SHIP) inzone, zonename, zone, distance = self:IsUnitInZone(Unit,CTLD.CargoZoneType.SHIP)
@@ -3046,7 +3063,7 @@ end
--- User function - Activate Name #CTLD.CargoZone.Type ZoneType for this CTLD instance. --- User function - Activate Name #CTLD.CargoZone.Type ZoneType for this CTLD instance.
-- @param #CTLD self -- @param #CTLD self
-- @param #string Name Name of the zone to change in the ME. -- @param #string Name Name of the zone to change in the ME.
-- @param #CTLD.CargoZoneTyp ZoneType Type of zone this belongs to. -- @param #CTLD.CargoZoneType ZoneType Type of zone this belongs to.
-- @param #boolean NewState (Optional) Set to true to activate, false to switch off. -- @param #boolean NewState (Optional) Set to true to activate, false to switch off.
function CTLD:ActivateZone(Name,ZoneType,NewState) function CTLD:ActivateZone(Name,ZoneType,NewState)
self:T(self.lid .. " AddZone") self:T(self.lid .. " AddZone")
@@ -3082,7 +3099,7 @@ end
--- User function - Deactivate Name #CTLD.CargoZoneType ZoneType for this CTLD instance. --- User function - Deactivate Name #CTLD.CargoZoneType ZoneType for this CTLD instance.
-- @param #CTLD self -- @param #CTLD self
-- @param #string Name Name of the zone to change in the ME. -- @param #string Name Name of the zone to change in the ME.
-- @param #CTLD.CargoZoneTyp ZoneType Type of zone this belongs to. -- @param #CTLD.CargoZoneType ZoneType Type of zone this belongs to.
function CTLD:DeactivateZone(Name,ZoneType) function CTLD:DeactivateZone(Name,ZoneType)
self:T(self.lid .. " AddZone") self:T(self.lid .. " AddZone")
self:ActivateZone(Name,ZoneType,false) self:ActivateZone(Name,ZoneType,false)