FAForever / FAForever/fa

AI - Frigate raid detection utility function request

Aperta
#4,465 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
area: AI
Lingua principale
Lua
Stelle
264
Fork
260
Merge medio
3g 2h
PR unite (30g)
21

Descrizione

**Describe the feature**
I desire a utility function that would allow the AI to understand when it can use frigates to raid mass points from the sea.
The reason this is important is so that the AI can understand a few things.
1. When it is viable to rush a naval expansion early game.
2. What priority frigates should be produced over other things in that early game.
3. Which positions a mass raiding based naval platoon would want to focus on.

**Expected behavior**
A count of mass points that can be hit from frigate positions and the table of mass points should be returned for the AI to use.

**Additional context**
I've included code from my current method of how I do this. But it is not reliable and I would seek smarter people than me to assist in improving it for use with the default AI.

```
function InitialNavalAttackCheck(aiBrain)
-- This function will check if there are mass markers that can be hit by frigates. This can trigger faster naval factory builds initially.
-- points = number of points around the extractor, doesn't need to have too many.
-- radius = the radius that the points will be, be set this a little lower than a frigates max weapon range
-- center = the x,y values for the position of the mass extractor. e.g {x = 0, y = 0}
local function DrawCirclePoints(points, radius, center)
local extractorPoints = {}
local slice = 2 * math.pi / points
for i=1, points do
local angle = slice * i
local newX = center[1] + radius * math.cos(angle)
local newY = center[3] + radius * math.sin(angle)
table.insert(extractorPoints, { newX, 0 , newY})
end
return extractorPoints
end
local frigateRaidMarkers = {}
local markers = GetMarkersRNG()
if markers then
local markerCount = 0
local markerCountNotBlocked = 0
local markerCountBlocked = 0
for _, v in markers do
local checkPoints = DrawCirclePoints(6, 26, v.position)
if checkPoints then
for _, m in checkPoints do
-- check if the position is in water
if RUtils.PositionInWater(m) then
-- the 0.36 is derived from the frigate weapon blueprint height
local pointSurfaceHeight = GetSurfaceHeight(m[1], m[3]) + 0.36
markerCount = markerCount + 1
if not aiBrain:CheckBlockingTerrain({m[1], pointSurfaceHeight, m[3]}, v.position, 'low') then
markerCountNotBlocked = markerCountNotBlocked + 1
table.insert( frigateRaidMarkers, { Position=v.position, Name=v.name } )
else
markerCountBlocked = markerCountBlocked + 1
end
end
end
end
end
if markerCountNotBlocked > 8 then
aiBrain.EnemyIntel.FrigateRaid = true
aiBrain.EnemyIntel.FrigateRaidMarkers = frigateRaidMarkers
end
end
end
```

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.