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
@ -1281,10 +1281,12 @@ function EVENT:onEvent( Event )
|
||||
-- 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)
|
||||
else
|
||||
if Event.place:isExist() and Event.place:getCategory() ~= Object.Category.SCENERY then
|
||||
Event.Place=AIRBASE:Find(Event.place)
|
||||
Event.PlaceName=Event.Place:GetName()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Mark points.
|
||||
if Event.idx then
|
||||
|
||||
@ -1387,7 +1387,7 @@ end
|
||||
-- @param #ZONE_RADIUS self
|
||||
-- @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 #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.
|
||||
function ZONE_RADIUS:GetRandomCoordinate(inner, outer, surfacetypes)
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
-- @module Ops.CTLD
|
||||
-- @image OPS_CTLD.jpg
|
||||
|
||||
-- Last Update December 2022
|
||||
-- Last Update Jan 2023
|
||||
|
||||
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.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.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
|
||||
--
|
||||
@ -1089,7 +1091,7 @@ CTLD.UnitTypes = {
|
||||
|
||||
--- CTLD class version.
|
||||
-- @field #string version
|
||||
CTLD.version="1.0.26"
|
||||
CTLD.version="1.0.27"
|
||||
|
||||
--- Instantiate a new CTLD.
|
||||
-- @param #CTLD self
|
||||
@ -1257,6 +1259,8 @@ function CTLD:New(Coalition, Prefixes, Alias)
|
||||
|
||||
-- disallow building in loadzones
|
||||
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," ","_")
|
||||
self.filename = string.format("CTLD_%s_Persist.csv",AliaS)
|
||||
@ -2901,7 +2905,7 @@ function CTLD:_BuildCrates(Group, Unit,Engineering)
|
||||
-- get dropped crates
|
||||
for _,_crate in pairs(crates) do
|
||||
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
|
||||
local name = Crate:GetName()
|
||||
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)
|
||||
report:Add(text)
|
||||
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("------------------------------------------------------------")
|
||||
local text = report:Text()
|
||||
if not Engineering then
|
||||
@ -4339,6 +4348,8 @@ end
|
||||
-- @param #CTLD self
|
||||
-- @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 #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
|
||||
-- @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
|
||||
@ -4346,8 +4357,8 @@ end
|
||||
-- -- get a #ZONE object
|
||||
-- local dropzone = ZONE:New("InjectZone") -- Core.Zone#ZONE
|
||||
-- -- and go:
|
||||
-- my_ctld:InjectTroops(dropzone,InjectTroopsType)
|
||||
function CTLD:InjectTroops(Zone,Cargo)
|
||||
-- my_ctld:InjectTroops(dropzone,InjectTroopsType,{land.SurfaceType.LAND})
|
||||
function CTLD:InjectTroops(Zone,Cargo,Surfacetypes,PreciseLocation)
|
||||
self:T(self.lid.." InjectTroops")
|
||||
local cargo = Cargo -- #CTLD_CARGO
|
||||
|
||||
@ -4379,8 +4390,10 @@ end
|
||||
local temptable = cargo:GetTemplates() or {}
|
||||
local factor = 1.5
|
||||
local zone = Zone
|
||||
|
||||
local randomcoord = zone:GetRandomCoordinate(10,30*factor):GetVec2()
|
||||
local randomcoord = zone:GetRandomCoordinate(10,30*factor,Surfacetypes):GetVec2()
|
||||
if PreciseLocation then
|
||||
randomcoord = zone:GetCoordinate():GetVec2()
|
||||
end
|
||||
for _,_template in pairs(temptable) do
|
||||
self.TroopCounter = self.TroopCounter + 1
|
||||
local alias = string.format("%s-%d", _template, math.random(1,100000))
|
||||
@ -5082,7 +5095,7 @@ end
|
||||
self:InjectVehicles(dropzone,injectvehicle)
|
||||
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)
|
||||
self:InjectTroops(dropzone,injecttroops)
|
||||
self:InjectTroops(dropzone,injecttroops,self.surfacetypes)
|
||||
end
|
||||
elseif (type(groupname) == "string" and groupname == "STATIC") or cargotype == CTLD_CARGO.Enum.REPAIR then
|
||||
local cargotemplates = dataset[6]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user