Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-implement the Easy AI pt. 1 #4858

Merged
merged 46 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
ab0b921
Remove economy managing of engineer manager
Garanas Apr 4, 2023
f4bb7ff
Move towards separate engineer manager class
Garanas Apr 4, 2023
053c5eb
Remove files introduced accidentally
Garanas Apr 4, 2023
42b768f
Refactor the engineer manager
Garanas Apr 4, 2023
9d03820
Add weak meta tables
Garanas Apr 4, 2023
056dd58
Always return a boolean during creation
Garanas Apr 4, 2023
8b4a604
Fix name of parameter
Garanas Apr 4, 2023
089fa66
More work on the engineer manager
Garanas Apr 8, 2023
23437e4
Create separate brain instance: the easy AI!
Garanas Apr 8, 2023
4edbcc7
Undo various changes
Garanas Apr 8, 2023
fb23817
Undo logging
Garanas Apr 8, 2023
acdab51
Undo logging
Garanas Apr 8, 2023
9fc9eae
Add economy monitor
Garanas Apr 9, 2023
e489bf0
The commander is building again
Garanas Apr 11, 2023
a61b22f
Revert some naming conventions
Garanas Apr 11, 2023
5007610
Add more annotations, introduce custom platoon classes
Garanas Apr 12, 2023
7774b4a
Basic state machine setup
Garanas Apr 14, 2023
c2aeaad
Add basic events to platoon
Garanas Apr 14, 2023
2a3ff73
Add platoon and unit to builder parameters check
Garanas Apr 15, 2023
4ae37c3
Merge branch 'deploy/fafdevelop' into refactor/engineer-manager
Garanas Apr 18, 2023
120eb1e
Remove LOG statements
Garanas Apr 18, 2023
df7ee52
Remove LOG statements
Garanas Apr 18, 2023
e696b0f
Revert changes to default platoon
Garanas Apr 18, 2023
39d75d5
Revert changes made to `lua/system/utils.lua`
Garanas Apr 18, 2023
14639d7
Introduce 'ComputeVectors' navigational mesh function
Garanas Apr 21, 2023
c85e86e
Merge branch 'deploy/fafdevelop' into refactor/engineer-manager
Garanas Apr 21, 2023
e65a4d0
Generate rally point markers
Garanas Apr 22, 2023
28baa3d
Merge branch 'refactor/engineer-manager' of https://github.com/FAFore…
Garanas Apr 22, 2023
7fe4efb
Add basic silo behavior
Garanas Apr 24, 2023
0e0f1d1
Merge branch 'deploy/fafdevelop' into refactor/engineer-manager
Garanas Apr 24, 2023
ffaee63
Support multiple missile launchers
Garanas Apr 24, 2023
01fa0f7
Merge branch 'refactor/engineer-manager' of https://github.com/FAFore…
Garanas Apr 24, 2023
43cf857
Simple raiding platoon
Garanas Apr 25, 2023
64b72f8
Add guards in Start state
Garanas Apr 25, 2023
7a68368
Remove __init
Garanas Apr 25, 2023
7e173c8
Toy around with code style
Garanas Apr 25, 2023
4676bb1
Improve the simple raid platoon
Garanas Apr 28, 2023
70e5886
Finalize retreat state
Garanas Apr 29, 2023
7a67b78
Add hook to `GetPlatoonUnits` to prevent returning destroyed units
Garanas Apr 29, 2023
ddb452e
Introduce formation move for platoons
Garanas Apr 30, 2023
d01a0e9
Improve recon grid
Garanas Apr 30, 2023
a28cb25
Enable debugging of recon grid
Garanas Apr 30, 2023
e63c28f
Merge branch 'deploy/fafdevelop' into refactor/engineer-manager
Garanas Apr 30, 2023
c6f6011
Add recon debug UI
Garanas May 4, 2023
0e594f2
Add `OnBeginSession` event for the brain
Garanas May 4, 2023
ccb018d
Improve comments
Garanas May 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 18 additions & 19 deletions engine/Sim/CAiBrain.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function CAiBrain:AssignThreatAtPosition(position, threat, decay, threatType)
end

--- Assigns a unit to a platoon
---@param platoon Platoon | string Either a reference to a platoon, or the unique name of the platoon
---@param platoon moho.platoon_methods | string Either a reference to a platoon, or the unique name of the platoon
---@param unit Unit
---@param squad PlatoonSquads
---@param formation UnitFormations
Expand Down Expand Up @@ -267,7 +267,9 @@ end
function CAiBrain:GetHighestThreatPosition(ring, restriction, threatType, armyIndex)
end

--- Returns a list of units that match the categories
--- Returns a list of units that match the categories.
---
--- This function does **not** take into account intel.
---@param category EntityCategory
---@param needToBeIdle boolean
---@param requireBuilt boolean Appears to be not functional
Expand Down Expand Up @@ -346,7 +348,7 @@ end
---@param radius number in game units
---@param restriction boolean
---@param threatType BrainThreatType
---@param armyIndex number
---@param armyIndex number?
---@return BrainPositionThreat[]
function CAiBrain:GetThreatsAroundPosition(position, radius, restriction, threatType, armyIndex)
end
Expand All @@ -357,14 +359,9 @@ end
function CAiBrain:GetUnitBlueprint(bpName)
end

--- Return list of units around position.
-- @param category Unit's category, example: categories.TECH2 .
-- @param position Table with position {x, y, z}.
-- @param radius Number in game units.
-- @param alliance Types: 'Ally', 'Enemy', 'Neutral'.
-- @return tblUnits Table containing units.

--- Returns the units around a position that match the categories
--- Returns the units around a position that match the categories.
---
--- This function takes into account intel.
---@param category EntityCategory
---@param position Vector
---@param radius number
Expand All @@ -384,7 +381,9 @@ end
function CAiBrain:GiveStorage(type, amount)
end

--- TODO.
--- Returns true when any engineer is building something of the given category
---@param category EntityCategory
---@return boolean
function CAiBrain:IsAnyEngineerBuilding(category)
end

Expand All @@ -394,16 +393,16 @@ function CAiBrain:IsOpponentAIRunning()
end

--- Creates a new platoon.
-- @param name or '', custom platoon name
-- @param aiPlan Plan to follow for this platoon or '', the function for the plan is in '/lua/platoon.lua'.
-- @return Platoon.
---@param name string # unique name for platoon
---@param aiPlan string # to follow for this platoon or '', the function for the plan is in '/lua/platoon.lua'.
---@return Platoon
function CAiBrain:MakePlatoon(name, aiPlan)
end

--- Return number of unit's categories being built.
-- @param entityCategoryOfBuildee Unit's category that is being built.
-- @param entityCategoryOfBuilder Unit's category of the unit building, example: categories.CONSTRUCTION .
-- @return Number.
--- Returns number of units of a given category building units of another given category
---@param entityCategoryOfBuildee EntityCategory # Category of unit that is being built
---@param entityCategoryOfBuilder EntityCategory # Category of unit that is building
---@return number
function CAiBrain:NumCurrentlyBuilding(entityCategoryOfBuildee, entityCategoryOfBuilder)
end

Expand Down
40 changes: 23 additions & 17 deletions engine/Sim/CPlatoon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ end
--- Orders platoon to attack mote to target position..
-- If squad is specified, attack moves only with the squad.
---@param position Vector Table with position {x, y, z}.
---@param squad PlatoonSquadType
---@param squad PlatoonSquadType?
---@return PlatoonCommand
function CPlatoon:AggressiveMoveToLocation(position, squad)
end
Expand All @@ -31,30 +31,33 @@ end
function CPlatoon:CalculatePlatoonThreat(threatType, category)
end

---@param threatType BrainThreatType Examples: 'AntiSurface', 'AntiAir', 'Overall'.
---@param category EntityCategory Unit's category, example: categories.TECH2 .
---@param position Vector Table with position {x, y, z}.
---@param radius number Radius in game units.
---@param threatType BrainThreatType
---@param category EntityCategory
---@param position Vector
---@param radius number
---@return number
function CPlatoon:CalculatePlatoonThreatAroundPosition(threatType, category, position, radius)
end

--- Returns true if squad can attack target unit.
--- Returns true if squad can attack target unit. As an example: can this platoon attack a bomber?
---@param squad PlatoonSquadType
---@param target Unit Unit to check.
---@param target Unit
---@return boolean
function CPlatoon:CanAttackTarget(squad, target)
end

--- TODO.
---@deprecated
---@return boolean
function CPlatoon:CanConsiderFormingPlatoon()
end

--- TODO.
-- Example: local formIt = poolPlatoon:CanFormPlatoon(template, personality:GetPlatoonSize(), self.Location, radius)
---@return boolean
function CPlatoon:CanFormPlatoon()
---@param template table
---@param size number
---@param location Vector
---@param radius number
function CPlatoon:CanFormPlatoon(template, size, location, radius)
end

--- Destroys the platoon including all its units.
Expand Down Expand Up @@ -84,6 +87,7 @@ end

--- TODO.
-- Needs 4 parametrs.
---@deprecated
function CPlatoon:FindClosestUnitToBase()
end

Expand All @@ -105,6 +109,7 @@ end
--- Finds prioritized unit to attack for squad.
-- Uses priorities set by SetPrioritizedTargetList function.
-- Used for TMLs to find a pick a target in their range
---@see `SetPrioritizedTargetList`
---@param squad PlatoonSquadType
---@param alliance AllianceType
---@param canAttack boolean true/false if the squad has to be able to attack the unit.
Expand All @@ -121,6 +126,7 @@ function CPlatoon:FormPlatoon()
end

--- TODO.
---@return string
function CPlatoon:GetAIPlan()
end

Expand All @@ -147,8 +153,8 @@ end
function CPlatoon:GetPlatoonLifetimeStats()
end

--- Returns platoon position
-- @return Table with position {x, y, z}.
--- Computes the average platoon position, returns {0,0,0} if the platoon has no units
---@return Vector
function CPlatoon:GetPlatoonPosition()
end

Expand All @@ -158,8 +164,8 @@ end
function CPlatoon:GetPlatoonUniqueName()
end

--- Returns list of units in theh platoon.
-- @return Table containing units.
--- Returns list of units in the platoon
---@return Unit[]
function CPlatoon:GetPlatoonUnits()
end

Expand Down Expand Up @@ -229,7 +235,7 @@ end
-- If squad is specified, moves only the squad.
---@param position Vector Table with position {x, y, z}.
---@param useTransports boolean true/false
---@param squad PlatoonSquadType
---@param squad PlatoonSquadType?
---@return PlatoonCommand
function CPlatoon:MoveToLocation(position, useTransports, squad)
end
Expand All @@ -238,7 +244,7 @@ end
-- If squad is specified, move only with the squad.
---@param target Unit Unit to move to.
---@param useTransports boolean true/false
---@param squad PlatoonSquadType
---@param squad PlatoonSquadType?
---@return PlatoonCommand
function CPlatoon:MoveToTarget(target, useTransports, squad)
end
Expand Down Expand Up @@ -279,7 +285,7 @@ end
--- Orders platoon to stop, cancels all commands.
-- If squad is specified, stops only the squad.
-- Cancels all commands.
---@param squad PlatoonSquadType
---@param squad PlatoonSquadType?
function CPlatoon:Stop(squad)
end

Expand Down
2 changes: 1 addition & 1 deletion lua/AI/AIBuilders/AIEconomicBuilders.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2777,4 +2777,4 @@ BuilderGroup {
}
}
},
}
}
2 changes: 1 addition & 1 deletion lua/AI/AIBuilders/AIIntelBuilders.lua
Original file line number Diff line number Diff line change
Expand Up @@ -510,4 +510,4 @@ BuilderGroup {
}
}
}
}
}
Loading