mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
#CTLD
* Added option movecratesbeforebuild * Added option surfacetypes for build-in reloads * Inject function can optionally take surfacetypes * Inject function can use the center of the zone instead of a random position #EVENT * Handle landing event if the place is a SCENERY object (helopad on a map, but not an airbase) #ZONE * docu corrections
This commit is contained in:
parent
1d52e27668
commit
53cff8229b
@ -1280,9 +1280,11 @@ function EVENT:onEvent( Event )
|
|||||||
--local name=Event.place:getName() -- This returns a DCS error "Airbase doesn't exit" :(
|
--local name=Event.place:getName() -- This returns a DCS error "Airbase doesn't exit" :(
|
||||||
-- However, this is not a big thing, as the aircraft the pilot ejected from is usually long crashed before the ejected pilot touches the ground.
|
-- However, this is not a big thing, as the aircraft the pilot ejected from is usually long crashed before the ejected pilot touches the ground.
|
||||||
--Event.Place=UNIT:Find(Event.place)
|
--Event.Place=UNIT:Find(Event.place)
|
||||||
else
|
else
|
||||||
Event.Place=AIRBASE:Find(Event.place)
|
if Event.place:isExist() and Event.place:getCategory() ~= Object.Category.SCENERY then
|
||||||
Event.PlaceName=Event.Place:GetName()
|
Event.Place=AIRBASE:Find(Event.place)
|
||||||
|
Event.PlaceName=Event.Place:GetName()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -1387,7 +1387,7 @@ end
|
|||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param #number inner (Optional) Minimal distance from the center of the zone in meters. Default is 0 m.
|
-- @param #number inner (Optional) Minimal distance from the center of the zone in meters. Default is 0 m.
|
||||||
-- @param #number outer (Optional) Maximal distance from the outer edge of the zone in meters. Default is the radius of the zone.
|
-- @param #number outer (Optional) Maximal distance from the outer edge of the zone in meters. Default is the radius of the zone.
|
||||||
-- @param #table surfacetypes (Optional) Table of surface types. Can also be a single surface type. We will try max 1000 times to find the right type!
|
-- @param #table surfacetypes (Optional) Table of surface types. Can also be a single surface type. We will try max 100 times to find the right type!
|
||||||
-- @return Core.Point#COORDINATE The random coordinate.
|
-- @return Core.Point#COORDINATE The random coordinate.
|
||||||
function ZONE_RADIUS:GetRandomCoordinate(inner, outer, surfacetypes)
|
function ZONE_RADIUS:GetRandomCoordinate(inner, outer, surfacetypes)
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
-- @module Ops.CTLD
|
-- @module Ops.CTLD
|
||||||
-- @image OPS_CTLD.jpg
|
-- @image OPS_CTLD.jpg
|
||||||
|
|
||||||
-- Last Update December 2022
|
-- Last Update Jan 2023
|
||||||
|
|
||||||
do
|
do
|
||||||
|
|
||||||
@ -712,6 +712,8 @@ do
|
|||||||
-- my_ctld.usesubcats = false -- use sub-category names for crates, adds an extra menu layer in "Get Crates", useful if you have > 10 crate types.
|
-- my_ctld.usesubcats = false -- use sub-category names for crates, adds an extra menu layer in "Get Crates", useful if you have > 10 crate types.
|
||||||
-- my_ctld.placeCratesAhead = false -- place crates straight ahead of the helicopter, in a random way. If true, crates are more neatly sorted.
|
-- my_ctld.placeCratesAhead = false -- place crates straight ahead of the helicopter, in a random way. If true, crates are more neatly sorted.
|
||||||
-- my_ctld.nobuildinloadzones = true -- forbid players to build stuff in LOAD zones if set to `true`
|
-- my_ctld.nobuildinloadzones = true -- forbid players to build stuff in LOAD zones if set to `true`
|
||||||
|
-- my_ctld.movecratesbeforebuild = true -- crates must be moved once before they can be build. Set to false for direct builds.
|
||||||
|
-- my_ctld.surfacetypes = {land.SurfaceType.LAND,land.SurfaceType.ROAD,land.SurfaceType.RUNWAY,land.SurfaceType.SHALLOW_WATER} -- surfaces for loading back objects
|
||||||
--
|
--
|
||||||
-- ## 2.1 User functions
|
-- ## 2.1 User functions
|
||||||
--
|
--
|
||||||
@ -1089,7 +1091,7 @@ CTLD.UnitTypes = {
|
|||||||
|
|
||||||
--- CTLD class version.
|
--- CTLD class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
CTLD.version="1.0.26"
|
CTLD.version="1.0.27"
|
||||||
|
|
||||||
--- Instantiate a new CTLD.
|
--- Instantiate a new CTLD.
|
||||||
-- @param #CTLD self
|
-- @param #CTLD self
|
||||||
@ -1257,6 +1259,8 @@ function CTLD:New(Coalition, Prefixes, Alias)
|
|||||||
|
|
||||||
-- disallow building in loadzones
|
-- disallow building in loadzones
|
||||||
self.nobuildinloadzones = true
|
self.nobuildinloadzones = true
|
||||||
|
self.movecratesbeforebuild = true
|
||||||
|
self.surfacetypes = {land.SurfaceType.LAND,land.SurfaceType.ROAD,land.SurfaceType.RUNWAY,land.SurfaceType.SHALLOW_WATER}
|
||||||
|
|
||||||
local AliaS = string.gsub(self.alias," ","_")
|
local AliaS = string.gsub(self.alias," ","_")
|
||||||
self.filename = string.format("CTLD_%s_Persist.csv",AliaS)
|
self.filename = string.format("CTLD_%s_Persist.csv",AliaS)
|
||||||
@ -2901,7 +2905,7 @@ function CTLD:_BuildCrates(Group, Unit,Engineering)
|
|||||||
-- get dropped crates
|
-- get dropped crates
|
||||||
for _,_crate in pairs(crates) do
|
for _,_crate in pairs(crates) do
|
||||||
local Crate = _crate -- #CTLD_CARGO
|
local Crate = _crate -- #CTLD_CARGO
|
||||||
if Crate:WasDropped() and not Crate:IsRepair() and not Crate:IsStatic() then
|
if (Crate:WasDropped() or not self.movecratesbeforebuild) and not Crate:IsRepair() and not Crate:IsStatic() then
|
||||||
-- we can build these - maybe
|
-- we can build these - maybe
|
||||||
local name = Crate:GetName()
|
local name = Crate:GetName()
|
||||||
local required = Crate:GetCratesNeeded()
|
local required = Crate:GetCratesNeeded()
|
||||||
@ -2946,7 +2950,12 @@ function CTLD:_BuildCrates(Group, Unit,Engineering)
|
|||||||
local text = string.format("Type: %s | Required %d | Found %d | Can Build %s", name, needed, found, txtok)
|
local text = string.format("Type: %s | Required %d | Found %d | Can Build %s", name, needed, found, txtok)
|
||||||
report:Add(text)
|
report:Add(text)
|
||||||
end -- end list buildables
|
end -- end list buildables
|
||||||
if not foundbuilds then report:Add(" --- None Found ---") end
|
if not foundbuilds then
|
||||||
|
report:Add(" --- None found! ---")
|
||||||
|
if self.movecratesbeforebuild then
|
||||||
|
report:Add("*** Crates need to be moved before building!")
|
||||||
|
end
|
||||||
|
end
|
||||||
report:Add("------------------------------------------------------------")
|
report:Add("------------------------------------------------------------")
|
||||||
local text = report:Text()
|
local text = report:Text()
|
||||||
if not Engineering then
|
if not Engineering then
|
||||||
@ -4339,6 +4348,8 @@ end
|
|||||||
-- @param #CTLD self
|
-- @param #CTLD self
|
||||||
-- @param Core.Zone#ZONE Zone The zone where to drop the troops.
|
-- @param Core.Zone#ZONE Zone The zone where to drop the troops.
|
||||||
-- @param Ops.CTLD#CTLD_CARGO Cargo The #CTLD_CARGO object to spawn.
|
-- @param Ops.CTLD#CTLD_CARGO Cargo The #CTLD_CARGO object to spawn.
|
||||||
|
-- @param #table Surfacetypes (Optional) Table of surface types. Can also be a single surface type. We will try max 1000 times to find the right type!
|
||||||
|
-- @param #boolean PreciseLocation (Optional) Don't try to get a random position in the zone but use the dead center. Caution not to stack up stuff on another!
|
||||||
-- @return #CTLD self
|
-- @return #CTLD self
|
||||||
-- @usage Use this function to pre-populate the field with Troops or Engineers at a random coordinate in a zone:
|
-- @usage Use this function to pre-populate the field with Troops or Engineers at a random coordinate in a zone:
|
||||||
-- -- create a matching #CTLD_CARGO type
|
-- -- create a matching #CTLD_CARGO type
|
||||||
@ -4346,8 +4357,8 @@ end
|
|||||||
-- -- get a #ZONE object
|
-- -- get a #ZONE object
|
||||||
-- local dropzone = ZONE:New("InjectZone") -- Core.Zone#ZONE
|
-- local dropzone = ZONE:New("InjectZone") -- Core.Zone#ZONE
|
||||||
-- -- and go:
|
-- -- and go:
|
||||||
-- my_ctld:InjectTroops(dropzone,InjectTroopsType)
|
-- my_ctld:InjectTroops(dropzone,InjectTroopsType,{land.SurfaceType.LAND})
|
||||||
function CTLD:InjectTroops(Zone,Cargo)
|
function CTLD:InjectTroops(Zone,Cargo,Surfacetypes,PreciseLocation)
|
||||||
self:T(self.lid.." InjectTroops")
|
self:T(self.lid.." InjectTroops")
|
||||||
local cargo = Cargo -- #CTLD_CARGO
|
local cargo = Cargo -- #CTLD_CARGO
|
||||||
|
|
||||||
@ -4379,8 +4390,10 @@ end
|
|||||||
local temptable = cargo:GetTemplates() or {}
|
local temptable = cargo:GetTemplates() or {}
|
||||||
local factor = 1.5
|
local factor = 1.5
|
||||||
local zone = Zone
|
local zone = Zone
|
||||||
|
local randomcoord = zone:GetRandomCoordinate(10,30*factor,Surfacetypes):GetVec2()
|
||||||
local randomcoord = zone:GetRandomCoordinate(10,30*factor):GetVec2()
|
if PreciseLocation then
|
||||||
|
randomcoord = zone:GetCoordinate():GetVec2()
|
||||||
|
end
|
||||||
for _,_template in pairs(temptable) do
|
for _,_template in pairs(temptable) do
|
||||||
self.TroopCounter = self.TroopCounter + 1
|
self.TroopCounter = self.TroopCounter + 1
|
||||||
local alias = string.format("%s-%d", _template, math.random(1,100000))
|
local alias = string.format("%s-%d", _template, math.random(1,100000))
|
||||||
@ -5082,7 +5095,7 @@ end
|
|||||||
self:InjectVehicles(dropzone,injectvehicle)
|
self:InjectVehicles(dropzone,injectvehicle)
|
||||||
elseif cargotype == CTLD_CARGO.Enum.TROOPS or cargotype == CTLD_CARGO.Enum.ENGINEERS then
|
elseif cargotype == CTLD_CARGO.Enum.TROOPS or cargotype == CTLD_CARGO.Enum.ENGINEERS then
|
||||||
local injecttroops = CTLD_CARGO:New(nil,cargoname,cargotemplates,cargotype,true,true,size,nil,true,mass)
|
local injecttroops = CTLD_CARGO:New(nil,cargoname,cargotemplates,cargotype,true,true,size,nil,true,mass)
|
||||||
self:InjectTroops(dropzone,injecttroops)
|
self:InjectTroops(dropzone,injecttroops,self.surfacetypes)
|
||||||
end
|
end
|
||||||
elseif (type(groupname) == "string" and groupname == "STATIC") or cargotype == CTLD_CARGO.Enum.REPAIR then
|
elseif (type(groupname) == "string" and groupname == "STATIC") or cargotype == CTLD_CARGO.Enum.REPAIR then
|
||||||
local cargotemplates = dataset[6]
|
local cargotemplates = dataset[6]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user