mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
#SPAWN - Fix for KeepUnitNames
This commit is contained in:
parent
2e6957984f
commit
a3805118a0
@ -292,9 +292,10 @@ SPAWN = {
|
||||
|
||||
--- Enumerator for spawns at airbases
|
||||
-- @type SPAWN.Takeoff
|
||||
-- @extends Wrapper.Group#GROUP.Takeoff
|
||||
|
||||
-- @field #SPAWN.Takeoff Takeoff
|
||||
-- @field #number Air Take off happens in air.
|
||||
-- @field #number Runway Spawn on runway. Does not work in MP!
|
||||
-- @field #number Hot Spawn at parking with engines on.
|
||||
-- @field #number Cold Spawn at parking with engines off.
|
||||
SPAWN.Takeoff = {
|
||||
Air = 1,
|
||||
Runway = 2,
|
||||
@ -619,12 +620,14 @@ end
|
||||
-- and any spaces before and after the resulting name are removed.
|
||||
-- IMPORTANT! This method MUST be the first used after :New !!!
|
||||
-- @param #SPAWN self
|
||||
-- @param #boolean KeepUnitNames (optional) If true, the unit names are kept, false or not provided to make new unit names.
|
||||
-- @param #boolean KeepUnitNames (optional) If true, the unit names are kept, false or not provided create new unit names.
|
||||
-- @return #SPAWN self
|
||||
function SPAWN:InitKeepUnitNames( KeepUnitNames )
|
||||
self:F()
|
||||
|
||||
self.SpawnInitKeepUnitNames = KeepUnitNames or true
|
||||
self.SpawnInitKeepUnitNames = false
|
||||
|
||||
if KeepUnitNames == true then self.SpawnInitKeepUnitNames = true end
|
||||
|
||||
return self
|
||||
end
|
||||
@ -1609,8 +1612,8 @@ function SPAWN:SpawnWithIndex( SpawnIndex, NoBirth )
|
||||
RandomVec2 = PointVec3:GetRandomVec2InRadius( self.SpawnOuterRadius, self.SpawnInnerRadius )
|
||||
numTries = numTries + 1
|
||||
inZone = SpawnZone:IsVec2InZone(RandomVec2)
|
||||
self:I("Retrying " .. numTries .. "spawn " .. SpawnTemplate.name .. " in Zone " .. SpawnZone:GetName() .. "!")
|
||||
self:I(SpawnZone)
|
||||
--self:I("Retrying " .. numTries .. "spawn " .. SpawnTemplate.name .. " in Zone " .. SpawnZone:GetName() .. "!")
|
||||
--self:I(SpawnZone)
|
||||
end
|
||||
end
|
||||
if (not inZone) then
|
||||
@ -3276,7 +3279,7 @@ end
|
||||
--- Get the index from a given group.
|
||||
-- The function will search the name of the group for a #, and will return the number behind the #-mark.
|
||||
function SPAWN:GetSpawnIndexFromGroup( SpawnGroup )
|
||||
self:F2( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnGroup } )
|
||||
self:F3( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix, SpawnGroup } )
|
||||
|
||||
local IndexString = string.match( SpawnGroup:GetName(), "#(%d*)$" ):sub( 2 )
|
||||
local Index = tonumber( IndexString )
|
||||
@ -3288,7 +3291,7 @@ end
|
||||
|
||||
--- Return the last maximum index that can be used.
|
||||
function SPAWN:_GetLastIndex()
|
||||
self:F( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix } )
|
||||
self:F3( { self.SpawnTemplatePrefix, self.SpawnAliasPrefix } )
|
||||
|
||||
return self.SpawnMaxGroups
|
||||
end
|
||||
@ -3436,24 +3439,28 @@ function SPAWN:_Prepare( SpawnTemplatePrefix, SpawnIndex ) -- R2.2
|
||||
end
|
||||
|
||||
if self.SpawnInitKeepUnitNames == false then
|
||||
for UnitID = 1, #SpawnTemplate.units do
|
||||
SpawnTemplate.units[UnitID].name = string.format( SpawnTemplate.name .. '-%02d', UnitID )
|
||||
for UnitID = 1, #SpawnTemplate.units do
|
||||
if not string.find(SpawnTemplate.units[UnitID].name,"#IFF_",1,true) then --Razbam IFF hack for F15E etc
|
||||
SpawnTemplate.units[UnitID].name = string.format( SpawnTemplate.name .. '-%02d', UnitID )
|
||||
end
|
||||
SpawnTemplate.units[UnitID].unitId = nil
|
||||
end
|
||||
else
|
||||
for UnitID = 1, #SpawnTemplate.units do
|
||||
local SpawnInitKeepUnitIFF = false
|
||||
if string.find(SpawnTemplate.units[UnitID].name,"#IFF_",1,true) then --Razbam IFF hack for F15E etc
|
||||
SpawnInitKeepUnitIFF = true
|
||||
end
|
||||
local UnitPrefix, Rest
|
||||
if SpawnInitKeepUnitIFF == false then
|
||||
UnitPrefix, Rest = string.match( SpawnTemplate.units[UnitID].name, "^([^#]+)#?" ):gsub( "^%s*(.-)%s*$", "%1" )
|
||||
self:T( { UnitPrefix, Rest } )
|
||||
else
|
||||
UnitPrefix=SpawnTemplate.units[UnitID].name
|
||||
local SpawnInitKeepUnitIFF = false
|
||||
if string.find(SpawnTemplate.units[UnitID].name,"#IFF_",1,true) then --Razbam IFF hack for F15E etc
|
||||
SpawnInitKeepUnitIFF = true
|
||||
end
|
||||
SpawnTemplate.units[UnitID].name = string.format( '%s#%03d-%02d', UnitPrefix, SpawnIndex, UnitID )
|
||||
local UnitPrefix, Rest
|
||||
if SpawnInitKeepUnitIFF == false then
|
||||
UnitPrefix, Rest = string.match( SpawnTemplate.units[UnitID].name, "^([^#]+)#?" ):gsub( "^%s*(.-)%s*$", "%1" )
|
||||
SpawnTemplate.units[UnitID].name = string.format( '%s#%03d-%02d', UnitPrefix, SpawnIndex, UnitID )
|
||||
self:T( { UnitPrefix, Rest } )
|
||||
--else
|
||||
--UnitPrefix=SpawnTemplate.units[UnitID].name
|
||||
end
|
||||
--SpawnTemplate.units[UnitID].name = string.format( '%s#%03d-%02d', UnitPrefix, SpawnIndex, UnitID )
|
||||
|
||||
SpawnTemplate.units[UnitID].unitId = nil
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user