forked from jzy-chitong56/BUG-MORE-AI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathANCIENT_EXPANSION.eai
More file actions
254 lines (247 loc) · 11.1 KB
/
ANCIENT_EXPANSION.eai
File metadata and controls
254 lines (247 loc) · 11.1 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
#IFDEF GLOBAL
integer ancient_exp_state = 0
integer ancient_exp_count = 0
location ancient_exp_loc = null
unit ancient_exp_wisp = null
unit ancient_exp_unit = null
group ancient_exp_group = CreateGroup()
boolean ancient_attack_running = false
boolean ancient_exp_nobuild = false
#ELSE
function SearchTree takes nothing returns nothing
local integer i = 2
loop
exitwhen i > 3 or ancient_exp_unit != null
set ancient_exp_unit = GetOneOfId(ancient_exp_unit, ai_player, old_id[racial_hall[i]])
set i = i + 1
endloop
endfunction
function AncientExpansionJob takes nothing returns nothing
local group g = null
local unit u = null
local location exp_loc = null
local location wisp_loc = null
local unit temp = null
local boolean isstrong = false
call DisplayToAllJobDebug("ANCIENT_EXPANSION JOB STARTED")
if current_expansion == null then
// set current_expansion = ExpNearestMin()
call ChooseExpansion()
endif
if (ancient_exp_unit != null and GetUnitState(ancient_exp_unit, UNIT_STATE_LIFE) <= 0) or current_expansion == null then
// Found out so no point trying ancient expansion again
set ancient_exp_state = 0
set ancient_exp_unit = null
call SetCaptainHome(BOTH_CAPTAINS,GetLocationX(front_loc[0]),GetLocationY(front_loc[0]))
call GroupRecycleGuardPositionInstant(CopyGroup(ancient_exp_group,g))
set gold_buffer = 0
set wood_buffer = 0
set ancient_exp_nobuild = false
return
endif
set exp_time_count = ai_time
set not_taken_expansion = current_expansion
set u = GetExpFoe(u)
if ancient_exp_state == 0 then
//if current_expansion == null then
//call TQAddJob(5, ANCIENT_EXPANSION, 0)
//set u = null
//return
//endif
call Trace("Expansion Distance: " + Int2Str(R2I(GetExpansionDistance())))
call Trace("Expansion state 0: Get the Wisp and Location")
set gold_buffer = GetUnitGoldCost2(racial_expansion)
set wood_buffer = GetUnitWoodCost2(racial_expansion)
set ancient_exp_count = 0
if GetGold() < GetUnitGoldCost2(racial_expansion) or GetWood() < GetUnitWoodCost2(racial_expansion) then
if (race_manual_loading and TownCount(race_manual_loading_mine) == 0) or GetMinesOwned() == 0 then
set ancient_exp_state = 1 // cannot build , need move tree
call TQAddJob(5, ANCIENT_EXPANSION, 0)
set u = null
set ancient_exp_nobuild = true
return
endif
else
if ancient_exp_wisp == null or not UnitAlive(ancient_exp_wisp) then
set ancient_exp_wisp = GetExpansionPeon()
if ancient_exp_wisp == null then
set ancient_exp_wisp = GetExpansionPeon2(ancient_exp_wisp)
endif
endif
if u != null then
//if ancient_exp_loc != null then
//call RemoveGuardPosition(ancient_exp_wisp)
//set exp_loc = GetUnitLoc(current_expansion)
//call RemoveLocation(ancient_exp_loc)
//set ancient_exp_loc = GetBuildLocationInDistanceFromLoc(old_id[racial_expansion], exp_loc, ver_creeps_attack_buildings_dist + 500)
//call IssuePointOrderByIdLoc(ancient_exp_wisp, old_id[racial_expansion], ancient_exp_loc)
//set ancient_exp_state = 1
//call RemoveLocation(exp_loc)
//set exp_loc = null
//endif
call CreateDebugTag("Expansion State 0 - wait attack creep", 10, ancient_exp_wisp, 3.00, 1.50)
else
call CreateDebugTag("Expansion State 0 - build racial_expansion", 10, ancient_exp_wisp, 3.00, 1.50)
call RemoveGuardPosition(ancient_exp_wisp)
//set exp_loc = GetUnitLoc(current_expansion)
if ancient_exp_loc == null then
set temp = CreateUnit(Player(PLAYERPASSIVE), old_id[racial_expansion], GetUnitX(current_expansion), GetUnitY(current_expansion), 270.0)
set exp_loc = Location(GetUnitX(temp),GetUnitY(temp))
call RemoveUnit(temp)
call IssuePointOrderByIdLoc(ancient_exp_wisp,old_id[racial_expansion], exp_loc)
call RemoveLocation(exp_loc)
set exp_loc = null
set temp = null
else
call IssuePointOrderByIdLoc(ancient_exp_wisp,old_id[racial_expansion], ancient_exp_loc)
endif
set ancient_exp_state = 5
//call RemoveLocation(exp_loc)
//set exp_loc = null
endif
endif
call TQAddJob(5, ANCIENT_EXPANSION, 0)
elseif ancient_exp_state == 1 then
call CreateDebugTag("Expansion State 1 - Ordering wisp", 10, ancient_exp_wisp, 3.00, 1.50)
set wisp_loc = GetUnitLoc(ancient_exp_wisp)
if gold_buffer != 0 and DistanceBetweenPoints(wisp_loc, ancient_exp_loc) <= 400 then
set gold_buffer = 0
set wood_buffer = 0
endif
if wisp_loc != null then
call RemoveLocation(wisp_loc)
set wisp_loc = null
endif
if GetUnitState(ancient_exp_wisp, UNIT_STATE_LIFE) > 0 and not ancient_exp_nobuild then
call IssuePointOrderByIdLoc(ancient_exp_wisp, old_id[racial_expansion], ancient_exp_loc)
call TQAddJob(5, ANCIENT_EXPANSION, 0)
else
set ancient_exp_unit = GetOneOfIdNearLoc(ancient_exp_unit, ai_player, old_id[racial_expansion], ancient_exp_loc, 400)
if ancient_exp_unit == null and TownCount(race_manual_loading_mine) == 0 then // no mine , check all hall
set ancient_exp_unit = GetOneOfId(ancient_exp_unit, ai_player, old_id[racial_expansion])
if ancient_exp_unit == null then
call SearchTree()
endif
endif
if ancient_exp_unit == null then
set ancient_exp_state = 0
set u = null
set ancient_exp_nobuild = false
else
if GetLocationNonCreepStrength(GetUnitX(ancient_exp_unit), GetUnitY(ancient_exp_unit), 1500) <= 0 then
set ancient_exp_state = 2
call RemoveGuardPosition(ancient_exp_unit)
call IssueImmediateOrderById(ancient_exp_unit, OrderIdCancel)
call IssueImmediateOrder(ancient_exp_unit, "unroot")
endif
//set no_attack_allowed = true
endif
call TQAddJob(1, ANCIENT_EXPANSION, 0)
endif
elseif ancient_exp_state == 2 then
if GetUnitMoveSpeed(ancient_exp_unit) == 0 then
call CreateDebugTag("Expansion State 2: Uproot Tree", 10, ancient_exp_unit, 3.00, 1.50)
call IssueImmediateOrderById(ancient_exp_unit, OrderIdCancel)
call IssueImmediateOrder(ancient_exp_unit, "unroot")
else
if hero_built[1] then
set ancient_exp_state = 3
//call RemoveGuardPosition(hero_unit[1])
//call IssuePointOrder(hero_unit[1], "move", GetUnitX(ancient_exp_unit), GetUnitY(ancient_exp_unit))
//call GroupClear(ancient_exp_group)
//call GroupEnumUnitsOfPlayer(ancient_exp_group, ai_player, null)
//set ancient_exp_group = SelectByAlive(ancient_exp_group, true)
//set ancient_exp_group = SelectUnittype(ancient_exp_group, UNIT_TYPE_STRUCTURE, false)
//set ancient_exp_group = SelectUnittype(ancient_exp_group, UNIT_TYPE_PEON, false)
//set ancient_exp_group = SelectByUnitStandard(ancient_exp_group, true)
//call GroupRemoveGuardPositionInstant(ancient_exp_group)
//call GroupPointOrder(ancient_exp_group, "smart", GetUnitX(ancient_exp_unit), GetUnitY(ancient_exp_unit))
endif
endif
call TQAddJob(3, ANCIENT_EXPANSION, 0)
elseif ancient_exp_state == 3 then
call CreateDebugTag("Expansion State 3: Awaiting Hero", 10, ancient_exp_unit, 3.00, 1.50)
set isstrong = GetOwnStrength() > GetExpansionStrength()
call SetCaptainHome(BOTH_CAPTAINS,R2I(GetUnitX(ancient_exp_unit)),R2I(GetUnitY(ancient_exp_unit)))
if DistanceBetweenUnits(ancient_exp_unit, hero_unit[1]) <= 750 or u == null or isstrong then
if ancient_exp_count > 0 then
call GroupClear(ancient_exp_group)
call GroupEnumUnitsInRange(ancient_exp_group, GetUnitX(ancient_exp_unit), GetUnitY(ancient_exp_unit), 1000, null)
set ancient_exp_group = SelectByPlayer(ancient_exp_group, ai_player, true)
set ancient_exp_group = SelectByAlive(ancient_exp_group, true)
set ancient_exp_group = SelectUnittype(ancient_exp_group, UNIT_TYPE_STRUCTURE, false)
set ancient_exp_group = SelectUnittype(ancient_exp_group, UNIT_TYPE_PEON, false)
set ancient_exp_group = SelectByUnitStandard(ancient_exp_group, true)
if not isstrong then
call GroupAddUnit(ancient_exp_group, ancient_exp_unit)
endif
////call GroupAddTypeAndRemoveGuard(ancient_exp_group, race_ancient_expansion_help_id, ai_player)
//call GroupPointOrder(ancient_exp_group, "smart", GetUnitX(u), GetUnitY(u))
set ancient_exp_state = 4
else
set ancient_exp_count = ancient_exp_count + 1
endif
else
if ancient_exp_count > 0 then
set ancient_exp_count = ancient_exp_count - 1
endif
//call GroupEnumUnitsOfPlayer(ancient_exp_group, ai_player, null)
//set ancient_exp_group = SelectByAlive(ancient_exp_group, true)
//set ancient_exp_group = SelectUnittype(ancient_exp_group, UNIT_TYPE_STRUCTURE, false)
//set ancient_exp_group = SelectUnittype(ancient_exp_group, UNIT_TYPE_PEON, false)
//set ancient_exp_group = SelectByUnitStandard(ancient_exp_group, true)
//call GroupRemoveGuardPositionInstant(ancient_exp_group)
//call GroupPointOrder(ancient_exp_group, "smart", GetUnitX(ancient_exp_unit), GetUnitY(ancient_exp_unit))
endif
call TQAddJob(5, ANCIENT_EXPANSION, 0)
elseif ancient_exp_state == 4 then
call CreateDebugTag("Expansion State 4: Attacking and taking expansion", 10, ancient_exp_unit, 3.00, 1.50)
call SetCaptainHome(BOTH_CAPTAINS,R2I(GetUnitX(ancient_exp_unit)),R2I(GetUnitY(ancient_exp_unit)))
if u == null then
call GroupRemoveUnit(ancient_exp_group, ancient_exp_unit)
call IssueTargetOrder(ancient_exp_unit, "entangle", current_expansion)
call TQAddUnitJob(R2I(GetTimeToReachUnit(ancient_exp_unit, current_expansion)*2 + 5), RESET_GUARD_POSITION, 0, ancient_exp_unit)
call GroupRecycleGuardPositionInstant(CopyGroup(ancient_exp_group,g))
//call RemoveLocation(ancient_exp_loc)
set ancient_exp_state = 0
//set no_attack_allowed = false
set not_taken_expansion = null
set ancient_expanding = false
set ancient_attack_running = false
set ancient_exp_nobuild = false
call SetCaptainHome(BOTH_CAPTAINS,GetLocationX(front_loc[0]),GetLocationY(front_loc[0]))
set g = null
return
else
//call GroupAddTypeAndRemoveGuard(ancient_exp_group, race_ancient_expansion_help_id, ai_player)
if GetUnitState(ancient_exp_unit, UNIT_STATE_LIFE) <= GetUnitState(ancient_exp_unit, UNIT_STATE_MAX_LIFE) * 0.40 then
call IssueImmediateOrderById(ancient_exp_unit, OrderId("eattree"))
elseif ancient_attack_running then
if DistanceBetweenUnits(ancient_exp_unit, u) <= 750 then
call GroupTargetOrder(ancient_exp_group, "attack", u)
else
call GroupPointOrder(ancient_exp_group, "attack", GetUnitX(u), GetUnitY(u))
endif
endif
call TQAddJob(2, ANCIENT_EXPANSION, 0)
endif
elseif ancient_exp_state == 5 then
call CreateDebugTag("Expansion State 5: Fast Expand as camp clear", 10, ancient_exp_wisp, 3.00, 1.50)
if GetUnitState(ancient_exp_wisp, UNIT_STATE_LIFE) > 0 and CheckExpansionTaken(current_expansion) == false then
if GetUnitCurrentOrder(ancient_exp_wisp) != old_id[racial_expansion] then
call IssuePointOrderByIdLoc(ancient_exp_wisp, old_id[racial_expansion], ancient_exp_loc)
endif
call TQAddJob(5, ANCIENT_EXPANSION, 0)
else
set gold_buffer = 0
set wood_buffer = 0
//call RemoveLocation(ancient_exp_loc)
set ancient_exp_state = 0
//set no_attack_allowed = false
set not_taken_expansion = null
set ancient_expanding = false
endif
endif
set u = null
endfunction
#ENDIF