mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge pull request #1241 from FlightControl-Master/FF/Develop
SPAWN AI_Balancer
This commit is contained in:
commit
cf34ec0905
@ -196,8 +196,12 @@ function AI_BALANCER:onenterDestroying( SetGroup, From, Event, To, ClientName, A
|
|||||||
SetGroup:Flush( self )
|
SetGroup:Flush( self )
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_BALANCER self
|
--- RTB
|
||||||
|
-- @param #AI_BALANCER self
|
||||||
-- @param Core.Set#SET_GROUP SetGroup
|
-- @param Core.Set#SET_GROUP SetGroup
|
||||||
|
-- @param #string From
|
||||||
|
-- @param #string Event
|
||||||
|
-- @param #string To
|
||||||
-- @param Wrapper.Group#GROUP AIGroup
|
-- @param Wrapper.Group#GROUP AIGroup
|
||||||
function AI_BALANCER:onenterReturning( SetGroup, From, Event, To, AIGroup )
|
function AI_BALANCER:onenterReturning( SetGroup, From, Event, To, AIGroup )
|
||||||
|
|
||||||
@ -213,10 +217,13 @@ function AI_BALANCER:onenterReturning( SetGroup, From, Event, To, AIGroup )
|
|||||||
local PointVec2 = POINT_VEC2:New( AIGroup:GetVec2().x, AIGroup:GetVec2().y )
|
local PointVec2 = POINT_VEC2:New( AIGroup:GetVec2().x, AIGroup:GetVec2().y )
|
||||||
local ClosestAirbase = self.ReturnAirbaseSet:FindNearestAirbaseFromPointVec2( PointVec2 )
|
local ClosestAirbase = self.ReturnAirbaseSet:FindNearestAirbaseFromPointVec2( PointVec2 )
|
||||||
self:T( ClosestAirbase.AirbaseName )
|
self:T( ClosestAirbase.AirbaseName )
|
||||||
|
--[[
|
||||||
AIGroup:MessageToRed( "Returning to " .. ClosestAirbase:GetName().. " ...", 30 )
|
AIGroup:MessageToRed( "Returning to " .. ClosestAirbase:GetName().. " ...", 30 )
|
||||||
local RTBRoute = AIGroup:RouteReturnToAirbase( ClosestAirbase )
|
local RTBRoute = AIGroup:RouteReturnToAirbase( ClosestAirbase )
|
||||||
AIGroupTemplate.route = RTBRoute
|
AIGroupTemplate.route = RTBRoute
|
||||||
AIGroup:Respawn( AIGroupTemplate )
|
AIGroup:Respawn( AIGroupTemplate )
|
||||||
|
]]
|
||||||
|
AIGroup:RouteRTB(ClosestAirbase)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -326,6 +326,7 @@ function SPAWN:New( SpawnTemplatePrefix )
|
|||||||
self.SpawnInitModu = nil -- No special modulation.
|
self.SpawnInitModu = nil -- No special modulation.
|
||||||
self.SpawnInitRadio = nil -- No radio comms setting.
|
self.SpawnInitRadio = nil -- No radio comms setting.
|
||||||
self.SpawnInitModex = nil
|
self.SpawnInitModex = nil
|
||||||
|
self.SpawnInitAirbase = nil
|
||||||
|
|
||||||
self.SpawnGroups = {} -- Array containing the descriptions of each Group to be Spawned.
|
self.SpawnGroups = {} -- Array containing the descriptions of each Group to be Spawned.
|
||||||
else
|
else
|
||||||
@ -378,6 +379,7 @@ function SPAWN:NewWithAlias( SpawnTemplatePrefix, SpawnAliasPrefix )
|
|||||||
self.SpawnInitModu = nil -- No special modulation.
|
self.SpawnInitModu = nil -- No special modulation.
|
||||||
self.SpawnInitRadio = nil -- No radio comms setting.
|
self.SpawnInitRadio = nil -- No radio comms setting.
|
||||||
self.SpawnInitModex = nil
|
self.SpawnInitModex = nil
|
||||||
|
self.SpawnInitAirbase = nil
|
||||||
|
|
||||||
self.SpawnGroups = {} -- Array containing the descriptions of each Group to be Spawned.
|
self.SpawnGroups = {} -- Array containing the descriptions of each Group to be Spawned.
|
||||||
else
|
else
|
||||||
@ -433,6 +435,7 @@ function SPAWN:NewFromTemplate( SpawnTemplate, SpawnTemplatePrefix, SpawnAliasPr
|
|||||||
self.SpawnInitModu = nil -- No special modulation.
|
self.SpawnInitModu = nil -- No special modulation.
|
||||||
self.SpawnInitRadio = nil -- No radio comms setting.
|
self.SpawnInitRadio = nil -- No radio comms setting.
|
||||||
self.SpawnInitModex = nil
|
self.SpawnInitModex = nil
|
||||||
|
self.SpawnInitAirbase = nil
|
||||||
|
|
||||||
self.SpawnGroups = {} -- Array containing the descriptions of each Group to be Spawned.
|
self.SpawnGroups = {} -- Array containing the descriptions of each Group to be Spawned.
|
||||||
else
|
else
|
||||||
@ -503,6 +506,21 @@ function SPAWN:InitLateActivated( LateActivated )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set spawns to happen at a particular airbase. Only for aircraft, of course.
|
||||||
|
-- @param #SPAWN self
|
||||||
|
-- @param #string AirbaseName Name of the airbase.
|
||||||
|
-- @param #number Takeoff (Optional) Takeoff type. Can be SPAWN.Takeoff.Hot (default), SPAWN.Takeoff.Cold or SPAWN.Takeoff.Runway.
|
||||||
|
-- @return #SPAWN self
|
||||||
|
function SPAWN:InitAirbase( AirbaseName, Takeoff )
|
||||||
|
self:F( )
|
||||||
|
|
||||||
|
self.SpawnInitAirbase=AIRBASE:FindByName(AirbaseName)
|
||||||
|
|
||||||
|
self.SpawnInitTakeoff=Takeoff or SPAWN.Takeoff.Hot
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Defines the Heading for the new spawned units.
|
--- Defines the Heading for the new spawned units.
|
||||||
-- The heading can be given as one fixed degree, or can be randomized between minimum and maximum degrees.
|
-- The heading can be given as one fixed degree, or can be randomized between minimum and maximum degrees.
|
||||||
@ -1115,9 +1133,14 @@ end -- Delay methods
|
|||||||
function SPAWN:Spawn()
|
function SPAWN:Spawn()
|
||||||
self:F( { self.SpawnTemplatePrefix, self.SpawnIndex, self.AliveUnits } )
|
self:F( { self.SpawnTemplatePrefix, self.SpawnIndex, self.AliveUnits } )
|
||||||
|
|
||||||
|
if self.SpawnInitAirbase then
|
||||||
|
return self:SpawnAtAirbase(self.SpawnInitAirbase, self.SpawnInitTakeoff)
|
||||||
|
else
|
||||||
return self:SpawnWithIndex( self.SpawnIndex + 1 )
|
return self:SpawnWithIndex( self.SpawnIndex + 1 )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
--- Will re-spawn a group based on a given index.
|
--- Will re-spawn a group based on a given index.
|
||||||
-- Note: Uses @{DATABASE} module defined in MOOSE.
|
-- Note: Uses @{DATABASE} module defined in MOOSE.
|
||||||
-- @param #SPAWN self
|
-- @param #SPAWN self
|
||||||
@ -3239,6 +3262,7 @@ end
|
|||||||
|
|
||||||
--- This function is called automatically by the Spawning scheduler.
|
--- This function is called automatically by the Spawning scheduler.
|
||||||
-- It is the internal worker method SPAWNing new Groups on the defined time intervals.
|
-- It is the internal worker method SPAWNing new Groups on the defined time intervals.
|
||||||
|
-- @param #SPAWN self
|
||||||
function SPAWN:_Scheduler()
|
function SPAWN:_Scheduler()
|
||||||
self:F2( { "_Scheduler", self.SpawnTemplatePrefix, self.SpawnAliasPrefix, self.SpawnIndex, self.SpawnMaxGroups, self.SpawnMaxUnitsAlive } )
|
self:F2( { "_Scheduler", self.SpawnTemplatePrefix, self.SpawnAliasPrefix, self.SpawnIndex, self.SpawnMaxGroups, self.SpawnMaxUnitsAlive } )
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user