mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
AI_BALANCER fixes and other stuff
This commit is contained in:
parent
fc100716e0
commit
196f85f07b
@ -91,7 +91,7 @@ AI_BALANCER = {
|
||||
function AI_BALANCER:New( SetClient, SpawnAI )
|
||||
|
||||
-- Inherits from BASE
|
||||
local self = BASE:Inherit( self, FSM_SET:New( SET_GROUP:New() ) ) -- Core.Fsm#FSM_SET
|
||||
self = BASE:Inherit( self, FSM_SET:New( SET_GROUP:New() ) ) -- Core.Fsm#FSM_SET
|
||||
|
||||
self:SetStartState( "None" )
|
||||
self:AddTransition( "*", "Start", "Monitoring" )
|
||||
@ -103,14 +103,12 @@ function AI_BALANCER:New( SetClient, SpawnAI )
|
||||
self:AddTransition( "*", "End", "End" )
|
||||
self:AddTransition( "*", "Dead", "End" )
|
||||
|
||||
|
||||
|
||||
self.SetClient = SetClient
|
||||
self.SpawnAI = SpawnAI
|
||||
self.ToNearestAirbase = false
|
||||
self.ToHomeAirbase = false
|
||||
|
||||
self:__Start( 1 )
|
||||
self:__Start( 5 )
|
||||
|
||||
return self
|
||||
end
|
||||
@ -190,6 +188,8 @@ end
|
||||
--- @param #AI_BALANCER self
|
||||
function AI_BALANCER:onenterMonitoring( SetGroup )
|
||||
|
||||
self:E( { self.SetClient:Count() } )
|
||||
|
||||
self.SetClient:ForEachClient(
|
||||
--- @param Wrapper.Client#CLIENT Client
|
||||
function( Client )
|
||||
|
||||
@ -42,14 +42,14 @@
|
||||
-- State transition functions can be set **by the mission designer** customizing or improving the behaviour of the state.
|
||||
-- There are 2 moments when state transition methods will be called by the state machine:
|
||||
--
|
||||
-- * **Before** the state transition.
|
||||
-- The state transition method needs to start with the name **OnBefore + the name of the state**.
|
||||
-- * **Leaving** the state.
|
||||
-- The state transition method needs to start with the name **OnLeave + the name of the state**.
|
||||
-- If the state transition method returns false, then the processing of the state transition will not be done!
|
||||
-- If you want to change the behaviour of the AIControllable at this event, return false,
|
||||
-- but then you'll need to specify your own logic using the AIControllable!
|
||||
--
|
||||
-- * **After** the state transition.
|
||||
-- The state transition method needs to start with the name **OnAfter + the name of the state**.
|
||||
-- * **Entering** the state.
|
||||
-- The state transition method needs to start with the name **OnEnter + the name of the state**.
|
||||
-- These state transition methods need to provide a return value, which is specified at the function description.
|
||||
--
|
||||
-- 2) #AI_CARGO_UNIT class
|
||||
@ -135,45 +135,45 @@
|
||||
|
||||
-- UnLoaded
|
||||
|
||||
--- @function [parent=#AI_CARGO] OnBeforeUnLoaded
|
||||
--- @function [parent=#AI_CARGO] OnLeaveUnLoaded
|
||||
-- @param #AI_CARGO self
|
||||
-- @param Wrapper.Controllable#CONTROLLABLE Controllable
|
||||
-- @return #boolean
|
||||
|
||||
--- @function [parent=#AI_CARGO] OnAfterUnLoaded
|
||||
--- @function [parent=#AI_CARGO] OnEnterUnLoaded
|
||||
-- @param #AI_CARGO self
|
||||
-- @param Wrapper.Controllable#CONTROLLABLE Controllable
|
||||
|
||||
-- Loaded
|
||||
|
||||
--- @function [parent=#AI_CARGO] OnBeforeLoaded
|
||||
--- @function [parent=#AI_CARGO] OnLeaveLoaded
|
||||
-- @param #AI_CARGO self
|
||||
-- @param Wrapper.Controllable#CONTROLLABLE Controllable
|
||||
-- @return #boolean
|
||||
|
||||
--- @function [parent=#AI_CARGO] OnAfterLoaded
|
||||
--- @function [parent=#AI_CARGO] OnEnterLoaded
|
||||
-- @param #AI_CARGO self
|
||||
-- @param Wrapper.Controllable#CONTROLLABLE Controllable
|
||||
|
||||
-- Boarding
|
||||
|
||||
--- @function [parent=#AI_CARGO] OnBeforeBoarding
|
||||
--- @function [parent=#AI_CARGO] OnLeaveBoarding
|
||||
-- @param #AI_CARGO self
|
||||
-- @param Wrapper.Controllable#CONTROLLABLE Controllable
|
||||
-- @return #boolean
|
||||
|
||||
--- @function [parent=#AI_CARGO] OnAfterBoarding
|
||||
--- @function [parent=#AI_CARGO] OnEnterBoarding
|
||||
-- @param #AI_CARGO self
|
||||
-- @param Wrapper.Controllable#CONTROLLABLE Controllable
|
||||
|
||||
-- UnBoarding
|
||||
|
||||
--- @function [parent=#AI_CARGO] OnBeforeUnBoarding
|
||||
--- @function [parent=#AI_CARGO] OnLeaveUnBoarding
|
||||
-- @param #AI_CARGO self
|
||||
-- @param Wrapper.Controllable#CONTROLLABLE Controllable
|
||||
-- @return #boolean
|
||||
|
||||
--- @function [parent=#AI_CARGO] OnAfterUnBoarding
|
||||
--- @function [parent=#AI_CARGO] OnEnterUnBoarding
|
||||
-- @param #AI_CARGO self
|
||||
-- @param Wrapper.Controllable#CONTROLLABLE Controllable
|
||||
|
||||
|
||||
@ -310,7 +310,7 @@ do -- FSM
|
||||
function FSM:New( FsmT )
|
||||
|
||||
-- Inherits from BASE
|
||||
local self = BASE:Inherit( self, BASE:New() )
|
||||
self = BASE:Inherit( self, BASE:New() )
|
||||
|
||||
self.options = options or {}
|
||||
self.options.subs = self.options.subs or {}
|
||||
@ -537,17 +537,17 @@ do -- FSM
|
||||
|
||||
self:E( { EventName, ... } )
|
||||
|
||||
local can, to = self:can( EventName )
|
||||
self:E( { EventName, self.current, can, to } )
|
||||
local Can, to = self:can( EventName )
|
||||
self:E( { From = self.current, Event = EventName, To = to, Can = Can } )
|
||||
|
||||
local ReturnValues = nil
|
||||
|
||||
if can then
|
||||
if Can then
|
||||
local from = self.current
|
||||
local params = { from, EventName, to, ... }
|
||||
|
||||
if self:_call_handler("onbefore" .. EventName, params) == false
|
||||
or self:_call_handler("onleave" .. from, params) == false then
|
||||
or self:_call_handler("OnBefore" .. EventName, params) == false
|
||||
or self:_call_handler("onleave" .. from, params) == false
|
||||
or self:_call_handler("OnLeave" .. from, params) == false then
|
||||
return false
|
||||
end
|
||||
|
||||
@ -572,7 +572,9 @@ do -- FSM
|
||||
if fsmparent and Event then
|
||||
self:F2( { "end state: ", fsmparent, Event } )
|
||||
self:_call_handler("onenter" .. to, params)
|
||||
self:_call_handler("OnEnter" .. to, params)
|
||||
self:_call_handler("onafter" .. EventName, params)
|
||||
self:_call_handler("OnAfter" .. EventName, params)
|
||||
self:_call_handler("onstatechange", params)
|
||||
fsmparent[Event]( fsmparent )
|
||||
execute = false
|
||||
@ -581,24 +583,15 @@ do -- FSM
|
||||
if execute then
|
||||
-- only execute the call if the From state is not equal to the To state! Otherwise this function should never execute!
|
||||
if from ~= to then
|
||||
self:T3( { onenter = "onenter" .. to, callback = self["onenter" .. to] } )
|
||||
self:_call_handler("onenter" .. to, params)
|
||||
self:_call_handler("OnEnter" .. to, params)
|
||||
end
|
||||
|
||||
self:T3( { On = "OnBefore" .. to, callback = self["OnBefore" .. to] } )
|
||||
if ( self:_call_handler("OnBefore" .. to, params ) ~= false ) then
|
||||
|
||||
self:T3( { onafter = "onafter" .. EventName, callback = self["onafter" .. EventName] } )
|
||||
self:_call_handler("onafter" .. EventName, params)
|
||||
|
||||
self:T3( { On = "OnAfter" .. EventName, callback = self["OnAfter" .. EventName] } )
|
||||
ReturnValues = self:_call_handler("OnAfter" .. EventName, params )
|
||||
end
|
||||
self:_call_handler("OnAfter" .. EventName, params)
|
||||
|
||||
self:_call_handler("onstatechange", params)
|
||||
end
|
||||
|
||||
return ReturnValues
|
||||
end
|
||||
|
||||
return nil
|
||||
@ -1007,7 +1000,7 @@ do -- FSM_SET
|
||||
function FSM_SET:New( FSMSet )
|
||||
|
||||
-- Inherits from BASE
|
||||
local self = BASE:Inherit( self, FSM:New() ) -- Core.Fsm#FSM_SET
|
||||
self = BASE:Inherit( self, FSM:New() ) -- Core.Fsm#FSM_SET
|
||||
|
||||
if FSMSet then
|
||||
self:Set( FSMSet )
|
||||
|
||||
@ -68,10 +68,10 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
|
||||
|
||||
if Scheduler.SchedulerObject then
|
||||
self.ObjectSchedulers[self.CallID] = Scheduler
|
||||
self:T3( { self.CallID, self.ObjectSchedulers[self.CallID] } )
|
||||
self:E( { CallID = self.CallID, ObjectScheduler = tostring(self.ObjectSchedulers[self.CallID]), SchedulerObject = tostring(Scheduler.SchedulerObject) } )
|
||||
else
|
||||
self.PersistentSchedulers[self.CallID] = Scheduler
|
||||
self:T3( { self.CallID, self.PersistentSchedulers[self.CallID] } )
|
||||
self:E( { CallID = self.CallID, PersistentScheduler = self.PersistentSchedulers[self.CallID] } )
|
||||
end
|
||||
|
||||
self.Schedule = self.Schedule or setmetatable( {}, { __mode = "k" } )
|
||||
|
||||
@ -96,7 +96,11 @@ function SCHEDULER:Schedule( SchedulerObject, SchedulerFunction, SchedulerArgume
|
||||
self:F2( { Start, Repeat, RandomizeFactor, Stop } )
|
||||
self:T3( { SchedulerArguments } )
|
||||
|
||||
|
||||
local ObjectName = "-"
|
||||
if SchedulerObject and SchedulerObject.ClassName and SchedulerObject.ClassID then
|
||||
ObjectName = SchedulerObject.ClassName .. SchedulerObject.ClassID
|
||||
end
|
||||
self:E( { "Schedule :", ObjectName, tostring( SchedulerObject ), Start, Repeat, RandomizeFactor, Stop } )
|
||||
self.SchedulerObject = SchedulerObject
|
||||
|
||||
local ScheduleID = _SCHEDULEDISPATCHER:AddSchedule(
|
||||
|
||||
@ -233,6 +233,7 @@
|
||||
-- @field #table Filter
|
||||
-- @field #table Set
|
||||
-- @field #table List
|
||||
-- @field Core.Scheduler#SCHEDULER CallScheduler
|
||||
-- @extends Core.Base#BASE
|
||||
SET_BASE = {
|
||||
ClassName = "SET_BASE",
|
||||
@ -250,7 +251,7 @@ SET_BASE = {
|
||||
function SET_BASE:New( Database )
|
||||
|
||||
-- Inherits from BASE
|
||||
local self = BASE:Inherit( self, BASE:New() )
|
||||
local self = BASE:Inherit( self, BASE:New() ) -- Core.Set#SET_BASE
|
||||
|
||||
self.Database = Database
|
||||
|
||||
@ -261,6 +262,8 @@ function SET_BASE:New( Database )
|
||||
self.List.__index = self.List
|
||||
self.List = setmetatable( { Count = 0 }, self.List )
|
||||
|
||||
self.CallScheduler = SCHEDULER:New( self )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@ -647,7 +650,7 @@ function SET_BASE:ForEach( IteratorFunction, arg, Set, Function, FunctionArgumen
|
||||
return false
|
||||
end
|
||||
|
||||
local Scheduler = SCHEDULER:New( self, Schedule, {}, self.TimeInterval, self.TimeInterval, 0 )
|
||||
self.CallScheduler:Schedule( self, Schedule, {}, self.TimeInterval, self.TimeInterval, 0 )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@ -5,4 +5,19 @@ rem Provide as the only parameter the path to the .miz files, which can be embed
|
||||
|
||||
echo Path to Mission Files: %1
|
||||
|
||||
For /R %1 %%G IN (*.miz) do 7z u "%%G" "l10n\DEFAULT\Moose.lua"
|
||||
rem For /R %1 %%G IN (*.miz) do 7z u "%%G" "l10n\DEFAULT\Moose.lua"
|
||||
For /R %1 %%M IN (*.miz) do (
|
||||
echo off
|
||||
cd
|
||||
echo "Mission: %%M"
|
||||
mkdir Temp
|
||||
cd Temp
|
||||
mkdir l10n
|
||||
mkdir l10n\DEFAULT
|
||||
copy ..\..\Moose.lua l10n\DEFAULT
|
||||
copy "%%~pM%%~nM.lua" l10n\DEFAULT\*.*
|
||||
dir l10n\DEFAULT
|
||||
7z -bb0 u "%%M" "l10n\DEFAULT\*.lua"
|
||||
cd ..
|
||||
rmdir /S /Q Temp
|
||||
)
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,16 +1,16 @@
|
||||
RU_PlanesClientSet = SET_CLIENT:New():FilterCountries( "RUSSIA" ):FilterCategories( "plane" ):FilterStart()
|
||||
RU_PlanesSpawn = SPAWN:New( "AI RU" ):InitCleanUp( 20 )
|
||||
RU_AI_Balancer = AI_BALANCER:New( RU_PlanesClientSet, RU_PlanesSpawn )
|
||||
|
||||
local US_PlanesClientSet = SET_CLIENT:New():FilterCountries( "USA" ):FilterCategories( "plane" ):FilterStart()
|
||||
|
||||
local US_PlanesSpawn = SPAWN:New( "AI US" ):InitCleanUp( 20 )
|
||||
local US_AI_Balancer = AI_BALANCER:New( US_PlanesClientSet, US_PlanesSpawn )
|
||||
|
||||
local RU_PlanesClientSet = SET_CLIENT:New():FilterCountries( "RUSSIA" ):FilterCategories( "plane" ):FilterStart()
|
||||
local RU_PlanesSpawn = SPAWN:New( "AI RU" ):InitCleanUp( 20 )
|
||||
local RU_AI_Balancer = AI_BALANCER:New( RU_PlanesClientSet, RU_PlanesSpawn )
|
||||
|
||||
local RU_AirbasesSet = SET_AIRBASE:New():FilterCoalitions("red"):FilterStart()
|
||||
RU_AirbasesSet = SET_AIRBASE:New():FilterCoalitions("red"):FilterStart()
|
||||
RU_AirbasesSet:Flush()
|
||||
RU_AI_Balancer:ReturnToNearestAirbases( 10000, RU_AirbasesSet )
|
||||
|
||||
|
||||
US_PlanesClientSet = SET_CLIENT:New():FilterCountries( "USA" ):FilterCategories( "plane" ):FilterStart()
|
||||
US_PlanesSpawn = SPAWN:New( "AI US" ):InitCleanUp( 20 )
|
||||
US_AI_Balancer = AI_BALANCER:New( US_PlanesClientSet, US_PlanesSpawn )
|
||||
|
||||
--RU_AI_Balancer:ReturnToHomeAirbase( 10000 )
|
||||
|
||||
--local PatrolZoneGroup = GROUP:FindByName( "Patrol Zone Blue" )
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -12,13 +12,13 @@ local CargoCarrierTo = UNIT:FindByName( "CarrierTo" )
|
||||
InfantryCargo:Board( CargoCarrierFrom )
|
||||
|
||||
-- Once the Cargo has been loaded into the Carrier, drive to a point and unload the Cargo.
|
||||
function InfantryCargo:OnAfterLoaded()
|
||||
function InfantryCargo:OnEnterLoaded()
|
||||
self:__UnBoard( 1 )
|
||||
self.OnAfterLoaded = nil
|
||||
self.OnEnterLoaded = nil
|
||||
end
|
||||
|
||||
-- Once the Cargo has been unloaded from the Carrier (the Cargo has arrived to the unload gathering point), OnBoard the Cargo in the other Carrier.
|
||||
function InfantryCargo:OnAfterUnLoaded()
|
||||
function InfantryCargo:OnEnterUnLoaded()
|
||||
self:__Board( 1, CargoCarrierTo )
|
||||
self.OnAfterUnLoaded = nil
|
||||
self.OnEnterUnLoaded = nil
|
||||
end
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -17,13 +17,13 @@ local CargoCarrierTo = UNIT:FindByName( "CarrierTo" )
|
||||
InfantryCargo:Board( CargoCarrierFrom )
|
||||
|
||||
-- Once the Cargo has been loaded into the Carrier, drive to a point and unload the Cargo.
|
||||
function InfantryCargo:OnAfterLoaded()
|
||||
function InfantryCargo:OnEnterLoaded()
|
||||
self:__UnBoard( 1 )
|
||||
self.OnAfterLoaded = nil
|
||||
self.OnEnterLoaded = nil
|
||||
end
|
||||
|
||||
-- Once the Cargo has been unloaded from the Carrier (the Cargo has arrived to the unload gathering point), OnBoard the Cargo in the other Carrier.
|
||||
function InfantryCargo:OnAfterUnLoaded()
|
||||
function InfantryCargo:OnEnterUnLoaded()
|
||||
self:__Board( 1, CargoCarrierTo )
|
||||
self.OnAfterUnLoaded = nil
|
||||
self.OnEnterUnLoaded = nil
|
||||
end
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -35,7 +35,7 @@ Patrol2:ManageFuel( 0.2, 0 )
|
||||
-- @param #AI_PATROLZONE self
|
||||
-- @param Wrapper.Group#GROUP AIGroup
|
||||
-- @return #boolean If false is returned, then the OnAfter state transition function will not be called.
|
||||
function Patrol1:OnBeforeRTB( AIGroup )
|
||||
function Patrol1:OnLeaveRTB( AIGroup )
|
||||
AIGroup:MessageToRed( "Returning to base", 20 )
|
||||
end
|
||||
|
||||
@ -51,14 +51,14 @@ end
|
||||
--- State transition function for the PROCESS\_PATROLZONE **Patrol1** object
|
||||
-- @param Process_PatrolCore.Zone#AI_PATROLZONE self
|
||||
-- @param Wrapper.Group#GROUP AIGroup
|
||||
function Patrol1:OnAfterPatrol( AIGroup )
|
||||
function Patrol1:OnEnterPatrol( AIGroup )
|
||||
AIGroup:MessageToRed( "Patrolling in zone " .. PatrolZone1:GetName() , 20 )
|
||||
end
|
||||
|
||||
--- State transition function for the PROCESS\_PATROLZONE **Patrol2** object
|
||||
-- @param #AI_PATROLZONE self
|
||||
-- @param Wrapper.Group#GROUP AIGroup
|
||||
-- @return #boolean If false is returned, then the OnAfter state transition function will not be called.
|
||||
-- @return #boolean If false is returned, then the OnEnter state transition function will not be called.
|
||||
function Patrol2:OnBeforeRTB( AIGroup )
|
||||
AIGroup:MessageToRed( "Returning to base", 20 )
|
||||
end
|
||||
@ -66,7 +66,7 @@ end
|
||||
--- State transition function for the PROCESS\_PATROLZONE **Patrol2** object
|
||||
-- @param Process_PatrolCore.Zone#AI_PATROLZONE self
|
||||
-- @param Wrapper.Group#GROUP AIGroup
|
||||
function Patrol2:OnAfterRTB( AIGroup )
|
||||
function Patrol2:OnEnterRTB( AIGroup )
|
||||
local NewGroup = PatrolSpawn:Spawn()
|
||||
Patrol1:SetControllable( NewGroup )
|
||||
Patrol1:__Start( 1 )
|
||||
@ -75,6 +75,6 @@ end
|
||||
--- State transition function for the PROCESS\_PATROLZONE **Patrol2** object
|
||||
-- @param Process_PatrolCore.Zone#AI_PATROLZONE self
|
||||
-- @param Wrapper.Group#GROUP AIGroup
|
||||
function Patrol2:OnAfterPatrol( AIGroup )
|
||||
function Patrol2:OnEnterPatrol( AIGroup )
|
||||
AIGroup:MessageToRed( "Patrolling in zone " .. PatrolZone2:GetName() , 20 )
|
||||
end
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -517,7 +517,7 @@ end
|
||||
-- we check if the SEADTask has still AlivePlayers assigned to the Task.
|
||||
-- If not, the Task will Abort.
|
||||
-- And it will be Replanned within 30 seconds.
|
||||
function SEADTask:OnAfterPlayerCrashed( PlayerUnit, PlayerName )
|
||||
function SEADTask:OnEnterPlayerCrashed( PlayerUnit, PlayerName )
|
||||
if not SEADTask:HasAliveUnits() then
|
||||
SEADTask:__Abort()
|
||||
SEADTask:__Replan( 30 )
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user