forked from FAForever/fa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThreatBuildConditions.lua
More file actions
52 lines (49 loc) · 2.02 KB
/
ThreatBuildConditions.lua
File metadata and controls
52 lines (49 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
-- ****************************************************************************
-- **
-- ** File : /lua/editor/UnitCountBuildConditions.lua
-- ** Author(s): Dru Staltman, John Comes
-- **
-- ** Summary : Generic AI Platoon Build Conditions
-- ** Build conditions always return true or false
-- **
-- ** Copyright © 2005 Gas Powered Games, Inc. All rights reserved.
-- ****************************************************************************
function EnemyThreatGreaterThanValueAtBase(aiBrain, locationType, threatValue, threatType, rings)
local testRings = rings or 10
local FactoryManager = aiBrain.BuilderManagers[locationType].FactoryManager
if not FactoryManager then
return false
end
local position = FactoryManager:GetLocationCoords()
if aiBrain:GetThreatAtPosition( position, testRings, true, threatType or 'Overall' ) > threatValue then
return true
end
return false
end
function EnemyThreatLessThanValueAtBase(aiBrain, locationType, threatValue, threatType, rings)
local testRings = rings or 10
local FactoryManager = aiBrain.BuilderManagers[locationType].FactoryManager
if not FactoryManager then
return false
end
local position = FactoryManager:GetLocationCoords()
if aiBrain:GetThreatAtPosition( position, testRings, true, threatType or 'Overall' ) > threatValue then
return true
end
return false
end
function HaveLessThreatThanNearby( aiBrain, locationType, poolType, enemyType, rings )
local pool = aiBrain:GetPlatoonUniquelyNamed('ArmyPool')
local poolThreat = pool:GetPlatoonThreat( poolType, categories.ALLUNITS )
local testRings = rings or 10
local FactoryManager = aiBrain.BuilderManagers[locationType].FactoryManager
if not FactoryManager then
return false
end
local position = FactoryManager:GetLocationCoords()
local enemyThreat = aiBrain:GetThreatAtPosition( position, testRings, true, enemyType )
if poolThreat < enemyThreat then
return true
end
return false
end