forked from FAForever/fa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMarkerBuildConditions.lua
More file actions
94 lines (89 loc) · 4.72 KB
/
MarkerBuildConditions.lua
File metadata and controls
94 lines (89 loc) · 4.72 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
-- ****************************************************************************
-- **
-- ** File : /lua/editor/MarkerBuildConditions.lua
-- ** Author(s): John Comes, Dru Staltman
-- **
-- ** Summary : Generic AI Platoon Build Conditions
-- ** Build conditions always return true or false
-- **
-- ** Copyright © 2005 Gas Powered Games, Inc. All rights reserved.
-- ****************************************************************************
local AIUtils = import('/lua/ai/aiutilities.lua')
--------------------------------------------------------------------------------------------------------------
-- function: MarkerGreaterThanDistance = BuildCondition doc = "Please work function docs."
--
-- parameter 0: string aiBrain = "default_brain"
-- parameter 1: string markerType = "Defensive_Point" doc = "docs for param1"
-- parameter 2: float distance = 1.0 doc = "docs for param1"
-- parameter 3: float threatMin = 1.0 doc = "docs for param1"
-- parameter 4: float threatMax = 1.0 doc = "docs for param1"
-- parameter 5: int threatRings = 1 doc = "docs for param1"
-- parameter 6: float startX = 1.0 doc = "docs for param1"
-- parameter 7: float startZ = 1.0 doc = "docs for param1"
--
--------------------------------------------------------------------------------------------------------------
function MarkerGreaterThanDistance(aiBrain, markerType, distance, threatMin, threatMax, threatRings, threatType)
if not startX and not startZ then
startX, startZ = aiBrain:GetArmyStartPos()
end
local loc
if threatMin and threatMax and threatRings then
loc = AIUtils.AIGetClosestThreatMarkerLoc(aiBrain, markerType, startX, startZ, threatMin, threatMax, threatRings, threatType)
else
loc = AIUtils.AIGetClosestMarkerLocation(aiBrain, markerType, startX, startZ)
end
if loc and VDist2(startX, startZ, loc[1], loc[3]) > distance then
return true
end
return false
end
--------------------------------------------------------------------------------------------------------------
-- function: MarkerLessThanDistance = BuildCondition doc = "Please work function docs."
--
-- parameter 0: string aiBrain = "default_brain"
-- parameter 1: string markerType = "Defensive_Point" doc = "docs for param1"
-- parameter 2: float distance = 1.0 doc = "docs for param1"
-- parameter 3: float threatMin = 1.0 doc = "docs for param1"
-- parameter 4: float threatMax = 1.0 doc = "docs for param1"
-- parameter 5: int threatRings = 1 doc = "docs for param1"
-- parameter 6: float startX = 1.0 doc = "docs for param1"
-- parameter 7: float startZ = 1.0 doc = "docs for param1"
--
--------------------------------------------------------------------------------------------------------------
function MarkerLessThanDistance(aiBrain, markerType, distance, threatMin, threatMax, threatRings, threatType, startX, startZ)
if not startX and not startZ then
startX, startZ = aiBrain:GetArmyStartPos()
end
local loc
if threatMin and threatMax and threatRings then
loc = AIUtils.AIGetClosestThreatMarkerLoc(aiBrain, markerType, startX, startZ, threatMin, threatMax, threatRings, threatType)
else
loc = AIUtils.AIGetClosestMarkerLocation(aiBrain, markerType, startX, startZ)
end
if loc and loc[1] and loc[3] then
if VDist2(startX, startZ, loc[1], loc[3]) < distance then
return true
end
end
return false
end
function CanBuildOnMassLessThanDistance(aiBrain, locationType, distance, threatMin, threatMax, threatRings, threatType, maxNum )
local engineerManager = aiBrain.BuilderManagers[locationType].EngineerManager
if not engineerManager then
return false
end
local position = engineerManager:GetLocationCoords()
local markerTable = AIUtils.AIGetSortedMassLocations(aiBrain, maxNum, threatMin, threatMax, threatRings, threatType, position)
if markerTable[1] and VDist3( markerTable[1], position ) < distance then
local dist = VDist3( markerTable[1], position )
return true
end
return false
end
function CanBuildFirebase( aiBrain, locationType, radius, markerType, tMin, tMax, tRings, tType, maxUnits, unitCat, markerRadius)
local ref, refName = AIUtils.AIFindFirebaseLocation( aiBrain, locationType, radius, markerType, tMin, tMax, tRings, tType, maxUnits, unitCat, markerRadius)
if not ref then
return false
end
return true
end